FUNCTION zsrm_source_list.
“———————————————————————-
““Local interface:
” TABLES
” INPUT STRUCTURE ZSRM_SOURCE_LIST_INPUT OPTIONAL
” OUTPUT STRUCTURE ZSRM_SOURCE_LIST_OUTPUT OPTIONAL
“———————————————————————-
“批量更改货源清单
DATA:lt_eordu LIKE TABLE OF eordu WITH HEADER LINE.
SORT input BY matnr werks.
DATA:lv_matnr TYPE matnr,
lv_werks TYPE werks_d.
DATA:wa_input TYPE zsrm_source_list_input.
LOOP AT input.
MOVE-CORRESPONDING input TO wa_input.
AT NEW werks.
CLEAR:lt_eordu[].
REFRESH lt_eordu.
ENDAT.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
input = wa_input–matnr
IMPORTING
output = wa_input–matnr
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
input = wa_input–lifnr
IMPORTING
output = wa_input–lifnr
EXCEPTIONS
OTHERS = 1.
lt_eordu–matnr = wa_input–matnr.
lt_eordu–werks = wa_input–werks.
lt_eordu–vdatu = wa_input–vdatu.
lt_eordu–bdatu = wa_input–bdatu.
lt_eordu–lifnr = wa_input–lifnr.
lt_eordu–ekorg = wa_input–ekorg.
lt_eordu–reswk = wa_input–reswk.
lt_eordu–autet = wa_input–autet.
lt_eordu–erdat = sy–datum.
lt_eordu–ernam = sy–uname.
lt_eordu-zeord = record-zeord.
lt_eordu–kz = ‘I’.
APPEND lt_eordu.
lv_matnr = wa_input–matnr.
lv_werks = wa_input–werks.
AT END OF werks.
CALL FUNCTION ‘ME_INITIALIZE_SOURCE_LIST’ .
CALL FUNCTION ‘ME_DIRECT_INPUT_SOURCE_LIST’
EXPORTING
i_matnr = lv_matnr
i_werks = lv_werks
I_MT06E = lt_eordu
I_NO_MATERIAL_READ =
activity = ‘V’
I_VORGA =
I_LOGSY =
TABLES
t_eord = lt_eordu
EXCEPTIONS
plant_missing = 1
material_missing = 2
OTHERS = 3.
IF sy–subrc <> 0.
output–matnr = lv_matnr.
output–werks = lv_werks.
output–flag = ‘E’.
output–message = ‘货源清单创建失败’.
APPEND output.
CLEAR output.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION ‘ME_POST_SOURCE_LIST_NEW’
EXPORTING
i_matnr = wa_input–matnr.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = ‘X’.
output–matnr = lv_matnr.
output–werks = lv_werks.
output–flag = ‘S’.
output–message = ‘货源清单创建成功’.
APPEND output.
CLEAR output.
ENDIF.
ENDAT.
ENDLOOP.
ENDFUNCTION.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19787.html