用ME_CONFIRMATION_UPDATE處理採購訂單行專案確認檢視
阿新 • • 發佈:2019-01-11
REPORT ZTEST0.
data: lt_xuekes type table of UEKES,
ls_xuekes type UEKES.
data: lt_ekes type table of ekes,
ls_ekes type ekes.
data op type c.
op = 'U'. "修改
*op = 'D'. "新增
*op = 'I'. "刪除
case op.
when 'U'.
*讀取確認
CALL FUNCTION 'ZPP142_GET_EKES'
EXPORTING
I_EBELN = '4900177648'
I_EBELP = '00010'
TABLES
T_ekes = lt_ekes.
.
*準備修改現有條目
loop at lt_ekes into ls_ekes.
MOVE-CORRESPONDING ls_ekes to ls_xuekes.
ls_xuekes-eindt = '20180303'.
ls_xuekes-kz = 'U'.
append ls_xuekes to lt_xuekes.
clear: ls_ekes.
endloop.
if lt_xuekes is
CALL FUNCTION 'ME_CONFIRMATION_UPDATE'
EXPORTING
I_EBELN = '4900177648'
TABLES
XEKES = lt_xuekes
* YEKES =
.
if sy-subrc = 0.
commit WORK AND WAIT.
write 'update ok'.
else.
write
endif.
endif.
when 'I'.
*準備新增新條目
clear:ls_xuekes,lt_xuekes.
ls_xuekes-ebeln = '4900177648'.
ls_xuekes-ebelp = '00010'.
sort lt_ekes DESCENDING by ebeln ebelp etens.
read table lt_ekes into ls_ekes index 1.
if sy-subrc = 0.
ls_xuekes-etens = ls_ekes-etens + 1.
else.
ls_xuekes-etens = '0001'.
endif.
ls_xuekes-ebtyp = 'LA'.
ls_xuekes-eindt = '20160707'.
ls_xuekes-lpein = '1'.
ls_xuekes-erdat = sy-datum.
ls_xuekes-ezeit = sy-uzeit.
ls_xuekes-menge = '22.222'.
ls_xuekes-estkz = '1'.
ls_xuekes-kzdis = 'X'.
ls_xuekes-xblnr = 'A-LJC-SB'.
ls_xuekes-kz = 'I'.
append ls_xuekes to lt_xuekes.
BREAK-POINT.
if lt_xuekes is not INITIAL.
CALL FUNCTION 'ME_CONFIRMATION_UPDATE'
EXPORTING
I_EBELN = '4900177648'
TABLES
XEKES = lt_xuekes
* YEKES =
.
if sy-subrc = 0.
commit WORK AND WAIT.
write 'insert ok'.
else.
write 'insert not ok'.
endif.
endif.
when 'D'.
clear:ls_xuekes,lt_xuekes.
data: lt_yuekes type table of UEKES,
ls_yuekes type UEKES.
*讀取確認
CALL FUNCTION 'ZPP142_GET_EKES'
EXPORTING
I_EBELN = '4900177648'
I_EBELP = '00010'
TABLES
T_ekes = lt_ekes.
.
*準備刪除現有條目
loop at lt_ekes into ls_ekes.
MOVE-CORRESPONDING ls_ekes to ls_yuekes.
ls_yuekes-kz = 'D'.
append ls_yuekes to lt_yuekes.
clear: ls_ekes.
endloop.
if lt_yuekes is not INITIAL.
CALL FUNCTION 'ME_CONFIRMATION_UPDATE'
EXPORTING
I_EBELN = '4900177648'
TABLES
XEKES = lt_xuekes
YEKES = lt_yuekes.
if sy-subrc = 0.
commit WORK AND WAIT.
write 'Delete ok'.
else.
write 'Delete not ok'.
endif.
endif.
endcase.