T-code: ZMMAP
Release (Approve) Purchasing Documents
PROCESS BEFORE OUTPUT.
MODULE status_0100.
*
PROCESS AFTER INPUT.
MODULE user_command_0100.
report zmm_rm06ef00 no standard page heading message-id me.
************************************************************************
* Anzeigen Einkaufsbelege zur Belegnummer *
************************************************************************
* 125229, 10.11.199 MW : To calculate the correct 'open value'
* change Standard date : 2012.9.17
* greate date: 2012.9.17
* by greate : yayun
*----------------------------------------------------------------------*
* Tabellen
* Micah Qin Jan 10 2013 Select Pur Group by User ID.
* M1 Jimmy Mar 28 2013 SU3: M3 Approved send excel to G3
*----------------------------------------------------------------------*
include zmm_fm06lto1.
include zmm_fm06lcfr.
include zmm_selopt_cnt_call.
tables: t16fg, t16fs, t16fv, t16fe, rm06b, t160b,zekpo,mara,zbuyer.
data: begin of xekpo occurs 100.
include structure ekpo.
data : eindt type eket-eindt.
*DATA: zdiff TYPE p DECIMALS 2,
* zvmi TYPE c,
* zitem(20) TYPE c. "若PO价大于last PO价,approve时必须要输入remark. (PO item -> item text)
data: end of xekpo.
*- Interne Tabelle der Zustände ---------------------------------------*
data: begin of zus occurs 10.
include structure t16fv.
data: end of zus.
data: begin of zuskey,
mandt like ekko-mandt,
frggr like ekko-frggr,
frgsx like ekko-frgsx,
end of zuskey.
*****************************************************************************
types:begin of ts_ekko ,
zcbox type c,
ebeln like ekko-ebeln,
bsart like ekko-bsart,
lifnr like ekko-lifnr,
name1 like lfa1-name1, "Lfa1 --- NAME1
ekgrp like ekko-ekgrp,
bedat like ekko-bedat,
frggr like ekko-frggr,
frgsx like ekko-frgsx,
frgxt like t16ft-frgxt,"------------T16FT
frgke like ekko-frgke,
*增加总金额
zjine type p decimals 4,
*ANZFM “Release options
" zreje(10) TYPE c," Can be reject function and Reject Reason (Field 1) (PO header text). 拒绝描述
zbuye(50) type c,"Buyer can check the reject PO in the PO approve screen. Buyer
" Remark (Field 2) (PO header text).自己的描述
end of ts_ekko.
types:begin of ts_ekpo,
ebeln type ekko-ebeln,
ebelp type ekpo-ebelp,
ematn type ekpo-ematn,
txz01 type ekpo-txz01,
matkl type ekpo-matkl,
werks type ekpo-werks,
menge type ekpo-menge,
meins type ekpo-meins,
netpr type ekpo-netpr,
waers type ekko-waers,"-----ekko
peinh type ekpo-peinh,
bprme type ekpo-bprme,
zdiff type p decimals 2,
*增加总价
netwr type ekpo-netwr,
zvmi type c,
zitem(20) type c, "若PO价大于last PO价,approve时必须要输入remark. (PO item -> item text)
end of ts_ekpo.
*vmi
types:begin of ts_vmi,
matnr like zmmt_info_rec-matnr,
lifnr like zmmt_info_rec-lifnr,
zzvmi like zmmt_info_rec-zzvmi,
end of ts_vmi.
data: t_ekko type standard table of ztsekko with header line,
t_ekpo type standard table of ztsekpo with header line,
t_t16ft type standard table of t16ft with header line,
t_lfa1 type standard table of lfa1 with header line,
t_vmi type standard table of ts_vmi with header line.
*****************************************************************************
*add zekpo items data---------greate version number v1 -----------save events.
data:t_zekpo type standard table of zekpo with header line,
wa_zekpo type zekpo .
*Checking the PO price VS last PO Price
data:l_ekpo type standard table of ztsekpo with header line,
lv_ekpo type standard table of ekpo with header line,
lv_ekko type standard table of ekko with header line,
l_ekko type standard table of ekko with header line,
t_ausp type standard table of ausp with header line.
*** call alv
data: ls_fieldcat type slis_fieldcat_alv,
e01_lt_fieldcat type slis_t_fieldcat_alv,
g_tabname_header type slis_tabname,
g_tabname_item type slis_tabname.
data: gt_fieldcat type slis_t_fieldcat_alv,
gs_layout type slis_layout_alv,
gs_keyinfo type slis_keyinfo_alv,
gt_sort type slis_t_sortinfo_alv,
gt_sp_group type slis_t_sp_group_alv,
gt_events type slis_t_event.
data: gt_list_top_of_page type slis_t_listheader.
constants:
gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.
constants:
user_command type slis_formname value 'USER_COMMAND'.
constants:
set_pf_status type slis_formname value 'SET_PF_STATUS'.
data: g_repid like sy-repid.
data: g_boxnam type slis_fieldname value 'BOX',
g_expandname type slis_fieldname value 'EXPAND',
p_f2code like sy-ucomm value '&ETA',
p_lignam type slis_fieldname value 'LIGHTS',
g_save(1) type c,
* g_default(1) type c,
g_exit(1) type c,
gx_variant like disvariant,
g_variant like disvariant.
**********************************************************************
*------- Hilfsfelder Berechtigungsprüfung ------------------
data: xactvt like tact-actvt, "Hilfsfeld Aktivität
xactxt(10), "Hilfsfeld Aktivitätstext
xobjekt(10), "Hilfsfeld Objekt
xobjtxt(15), "Hilfsfeld Objekttext
xfldtxt(15). "Hilfsfeld Feldtext
*M1 add
data: xls_content type solix_tab,
xls_size type so_obj_len.
constants: gc_crlf type c value cl_bcs_convert=>gc_crlf. " ┐ New Line In XLS
data: begin of i_reclist occurs 0,
receiver like somlreci1-receiver ,
end of i_reclist .
data: lv_subrc like sy-subrc.
data:it_zpoemail like standard table of zpoemail with header line .
*M1 End
*ENHANCEMENT-POINT RM06EF00_02 SPOTS ES_RM06EF00 STATIC .
*----------------------------------------------------------------------*
* Parameter und Select-Options *
*----------------------------------------------------------------------*
parameters: p_frgco like t16fc-frgco obligatory memory id fab.
*PARAMETER : P_EKGRP LIKE EKKO-EKGRP. "add Jimmy --- Del by Micah
select-options: s_frggr for ekko-frggr no-display,
s_ekgrp for ekko-ekgrp. "Jimmy add no-display --- Reuse by Micah
parameters: p_frgse like rm06a-p_frgse default 'X' no-display,
p_frgrs like rm06a-p_frgrs no-display,
p_frgvo like rm06a-p_frgvo default 'X' no-display,
p_mitpos like rm06a-p_mitpos default 'X' no-display.
" listu LIKE t160o-listu.
select-options: s_bstyp for ekko-bstyp,
s_ekorg for ekko-ekorg ,
s_ebeln for ekko-ebeln matchcode object mekk,
* MEMORY ID BES,
s_bsart for ekko-bsart,
s_lifnr for ekko-lifnr matchcode object kred,
s_reswk for ekko-reswk no-display,
s_bedat for ekko-bedat,
s_procst for ekko-procstat no-display. "676504
*----------------------------------------------------------------------*
* Hilfsfelder *
*----------------------------------------------------------------------*
include fm06lcek.
include zmm_events.
include zmm_from.
**********************************************************************
data: xfrg1 like ekko-frgzu,
xfrg2 like ekko-frgzu.
data: xselkb like ekko-bstyp,
xselkk like ekko-bstyp,
xselkl like ekko-bstyp,
xselka like ekko-bstyp.
field-symbols: <f1>.
data: hfdpos like sy-fdpos.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Intitialisierung *
*----------------------------------------------------------------------*
initialization.
g_repid = sy-repid.
g_tabname_header = 'T_EKKO'.
g_tabname_item = 'T_EKPO'.
* define keyinfo
clear gs_keyinfo.
gs_keyinfo-header01 = 'EBELN'.
gs_keyinfo-item01 = 'EBELN'.
perform e01_fieldcat_init using gt_fieldcat[].
perform e03_eventtab_build using gt_events[].
perform e06_t_sort_build using gt_sort[].
perform e07_sp_group_build using gt_sp_group[].
perform e05_layout_build using gs_layout. "wg. Parameters
g_save = 'A'.
perform variant_init.
* Get default variant
gx_variant = g_variant.
"* Get default variant
" gx_variant = g_variant.
" CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
" EXPORTING
" i_save = g_save
" CHANGING
" cs_variant = gx_variant
" EXCEPTIONS
" not_found = 2.
" IF sy-subrc = 0.
" p_vari = gx_variant-variant.
" ENDIF.
"**************************************************************************
* PERFORM anforderungsbild(sapfm06l) USING xselkb xselkk
* xselkl xselka.
"listu = t160b-listu.
s_bstyp-sign = 'I'.
s_bstyp-option = 'EQ'.
if xselkb ne space.
s_bstyp-low = 'F'.
append s_bstyp.
endif.
if xselkk ne space.
s_bstyp-low = 'K'.
append s_bstyp.
endif.
if xselkl ne space.
s_bstyp-low = 'L'.
append s_bstyp.
endif.
if xselka ne space.
s_bstyp-low = 'A'.
append s_bstyp.
endif.
if sy-calld ne space. "330331
read table s_bstyp index 1.
case s_bstyp-low.
when 'F'.
get parameter id 'BES' field s_ebeln-low.
when 'K'.
get parameter id 'CTR' field s_ebeln-low.
if s_ebeln-low is initial.
get parameter id 'VRT' field s_ebeln-low.
endif.
when 'L'.
get parameter id 'SAG' field s_ebeln-low.
if s_ebeln-low is initial.
get parameter id 'VRT' field s_ebeln-low.
endif.
when 'A'.
get parameter id 'ANF' field s_ebeln-low.
endcase.
if not s_ebeln-low is initial.
s_ebeln-sign = 'I'.
s_ebeln-option = 'EQ'.
append s_ebeln.
endif.
endif. "330331
get parameter id 'FAB' field p_frgco.
* release just possible for one of the following status (same as ME29N):
s_procst-sign = 'I'. "707850
s_procst-option = 'EQ'. "707850
s_procst-low = space. "707850
append s_procst. "707850
s_procst-low = '02'. "707850
append s_procst. "707850
s_procst-low = '03'. "707850
append s_procst. "707850
s_procst-low = '05'. "707850
append s_procst. "707850
*----------------------------------------------------------------------*
* Selektionsbild *
*----------------------------------------------------------------------*
*AT SELECTION-SCREEN ON listu.
* PERFORM listumfang(sapfm06l) USING listu. "change data 选择模式
at selection-screen on value-request for p_frgco.
call function 'HELP_VALUES_FRGAB'
exporting
i_frgot = '2'
importing
e_frgab = p_frgco
exceptions
others = 1.
at selection-screen.
call function 'ME_REL_CHECK_MANY'
exporting
i_frgot = '2'
i_frgco = p_frgco
tables
t_frggr = s_frggr
t_t16fv = zus.
*----------------------------------------------------------------------*
* Beginn der Selektion *
*----------------------------------------------------------------------*
start-of-selection.
"Add Check by Jimmy
* refresh :S_EKGRP.
* IF P_EKGRP IS NOT INITIAL.
* S_EKGRP-SIGN = 'I'.
* S_EKGRP-OPTION = 'EQ'.
* S_EKGRP-LOW = P_EKGRP.
* APPEND S_EKGRP.
* ENDIF.
if p_frgco+0(1) <> 'B'.
* SELECT * FROM ZBUYER
* WHERE ZUSER = SY-UNAME
* AND ZRGCO = P_FRGCO
* AND ZPGRP IN S_EKGRP.
* ENDSELECT.
* ELSE.
select * from zbuyer
where zuser = sy-uname
and zrgco = p_frgco.
endselect.
endif.
if sy-subrc ne 0.
message i000(oo) with 'You have not authority for this Release Code.'.
exit.
endif.
" Add End
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
percentage = 1
text = 'Data processing, please wait ...'.
perform get_data.
if not xekko[] is initial and xekpo[] is not initial.
perform last_po_data.
perform call_alv.
else.
message i000(oo) with 'No suitable purchasing documents found'.
endif.
at user-command.
case sy-ucomm.
when 'BACK' or 'CANC' or 'EXIT'.
leave to screen 0.
endcase.
end-of-selection.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form get_data.
*- Lesen Belegköpfe --------------------------------------------------*
if p_frgco+0(1) = 'B'.
select * from ekko inner join zbuyer on ekko~ekgrp = zbuyer~zpgrp "Add by Micah - 01/10/2013
into corresponding fields of table xekko
for all entries in zus
where frgrl eq 'X'
and frggr eq zus-frggr
and frgsx eq zus-frgsx
and ebeln in s_ebeln
and bstyp in s_bstyp
and ekorg in s_ekorg
and lifnr in s_lifnr
and reswk in s_reswk
and bedat in s_bedat
and bsart in s_bsart
and ekgrp in s_ekgrp
and loekz eq space
and ( procstat in s_procst "707850
or procstat is null ) "707850
and zbuyer~zuser = sy-uname "Add by Micah - 01/10/2013
and zbuyer~zrgco = p_frgco. "Add by Micah - 01/10/2013
if p_frgrs ne space.
select * from ekko inner join zbuyer on ekko~ekgrp = zbuyer~zpgrp "Add by Micah - 01/10/2013
into corresponding fields of table xekko
for all entries in zus
where frgrl eq space
and frggr eq zus-frggr
and frgsx eq zus-frgsx
and ebeln in s_ebeln
and bstyp in s_bstyp
and ekorg in s_ekorg
and lifnr in s_lifnr
and reswk in s_reswk
and bedat in s_bedat
and bsart in s_bsart
and ekgrp in s_ekgrp
and loekz eq space
and ( procstat in s_procst "707850
or procstat is null ) "707850
and zbuyer~zuser = sy-uname "Add by Micah - 01/10/2013
and zbuyer~zrgco = p_frgco. "Add by Micah - 01/10/2013
endif.
else.
select * from ekko into corresponding fields of table xekko
for all entries in zus
where frgrl eq 'X'
and frggr eq zus-frggr
and frgsx eq zus-frgsx
and ebeln in s_ebeln
and bstyp in s_bstyp
and ekorg in s_ekorg
and lifnr in s_lifnr
and reswk in s_reswk
and bedat in s_bedat
and bsart in s_bsart
and ekgrp in s_ekgrp
and loekz eq space
and ( procstat in s_procst "707850
or procstat is null ). "707850
if p_frgrs ne space.
select * from ekko into corresponding fields of table xekko
for all entries in zus
where frgrl eq space
and frggr eq zus-frggr
and frgsx eq zus-frgsx
and ebeln in s_ebeln
and bstyp in s_bstyp
and ekorg in s_ekorg
and lifnr in s_lifnr
and reswk in s_reswk
and bedat in s_bedat
and bsart in s_bsart
and ekgrp in s_ekgrp
and loekz eq space
and ( procstat in s_procst "707850
or procstat is null ). "707850
endif.
endif.
sort xekko.
*- Check for EhP4-Switch and Central Contract
if cl_ops_switch_check=>mm_sfws_p2pse( ) = 'X'.
delete xekko where bstyp eq 'K'
and statu eq 'K'.
endif.
*- Prüfen Freigabevoraussetzungen ------------------------------------*
loop at xekko.
move-corresponding xekko to zuskey.
read table zus with key zuskey ."BINARY SEARCH.
check sy-subrc eq 0.
xfrg1 = zus+9(8).
xfrg2 = xekko-frgzu.
translate xfrg2 using 'X +'.
overlay xfrg1 with xfrg2 only '+'.
search xfrg1 for 'X'.
*---- Keine Freigabezuständigkeit -------------------------------------*
if sy-subrc ne 0.
delete xekko.
continue.
else.
*---- Freigabestelle merken -------------------------------------------*
hfdpos = sy-fdpos.
assign xfrg2+sy-fdpos(1) to <f1>.
*---- Freigabe bereits erfolgt ----------------------------------------*
if p_frgrs eq space and
<f1> eq space.
delete xekko.
continue.
else.
*---- Freigabe noch nicht erfolgt -------------------------------------*
if p_frgse eq space