SAP-&EWM은 트랜잭션 코드/SCWM/GRPI를 통해 DN을 생성합니다.
FUNCTION zewm_fm_dn_create_grpi.
*"----------------------------------------------------------------------
*"*" :
*" IMPORTING
*" VALUE(IS_DATA) TYPE ZEWM_S_DN_CREATE_FB
*" EXPORTING
*" VALUE(EV_MSG) TYPE BAPI_MSG
*" VALUE(EV_SEVERITY) TYPE BAPI_MTYPE
*" VALUE(EV_DOCID) TYPE /SCDL/DL_DOCID
*" VALUE(EV_ITEMID) TYPE /SCDL/DL_ITEMID
*"----------------------------------------------------------------------
DATA: lo_log TYPE REF TO /scwm/cl_log,
lo_controller TYPE REF TO /scmb/cl_controller,
lo_tm TYPE REF TO object,
lo_gr_sp TYPE REF TO /scwm/cl_gr_sp,
lo_adapter_handler TYPE REF TO /scwm/cl_dlv_handler_adapter,
lt_outrecords TYPE TABLE OF /scwm/s_gr_egr,
lt_inkeys TYPE TABLE OF index,
lt_ibd TYPE TABLE OF /scwm/s_gr_ibd,
lt_selection TYPE /scmb/t_sp_selection,
lt_return_codes TYPE /scdl/t_sp_return_code,
lt_key_egr TYPE /scdl/t_sp_k_item,
lv_message TYPE string,
lv_rejected TYPE boole_d,
lv_failed TYPE boole_d,
lv_pa_execute TYPE /scdl/dl_docid,
lv_inparam TYPE char4.
*
CLEAR: ev_msg, ev_severity, ev_docid, ev_itemid.
*
CREATE OBJECT lo_log.
lo_log->init( ).
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = is_data-matnr
IMPORTING
output = is_data-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
SELECT SINGLE *
FROM /scdl/db_proci_i
INTO @DATA(ls_i)
WHERE productno = @is_data-matnr
AND doccat = 'EGR'.
SELECT SINGLE scuguid
FROM /scwm/t300_md
WHERE lgnum = @is_data-lgnum
INTO @DATA(lv_locationid_wh_h).
* ,Init
TRY.
lo_controller = /scmb/cl_controller=>get_instance( ).
lo_controller->initialize( io_tm = lo_tm iv_classid = '' ).
CREATE OBJECT lo_adapter_handler.
* lo_adapter_handler->mo_msg_handler->set_log_save_data(
* EXPORTING iv_subobject = /scwm/if_gr_c=>sc_tcode_int_prod ).
CREATE OBJECT lo_gr_sp
EXPORTING
io_handler = lo_adapter_handler.
ENDTRY.
CLEAR:lt_selection,lv_failed,lt_outrecords,lt_key_egr.
*
lt_selection = VALUE #( ( fieldname = '/SCWM/PRODIND_PRDI_H' sign = 'I' option = 'EQ' low = 'D')
( fieldname = 'LOCATIONID_WH_H' sign = 'I' option = 'EQ' low = lv_locationid_wh_h )
( fieldname = 'PRODUCTNO_I' sign = 'I' option = 'EQ' low = is_data-matnr ) ).
lo_gr_sp->/scmb/if_sp_query~execute(" Query
EXPORTING
inkeys = lt_inkeys
query = '/SCWM/QUERY_EGR'
inparam = lv_inparam
selections = lt_selection
IMPORTING
outrecords = lt_outrecords
rejected = lv_failed ).
IF lt_outrecords IS INITIAL OR lv_failed IS NOT INITIAL.
ev_msg = ' , '.
ev_severity = 'E'.
RETURN.
ENDIF.
APPEND VALUE #( docid = ls_i-docid itemid = ls_i-itemid ) TO lt_key_egr.
lo_gr_sp->/scmb/if_sp_action~execute( " Query
EXPORTING
aspect = '/SCWM/ASP_GR_EGR'
inkeys = lt_key_egr
action = 'ACT_MARK_SELECTION'
IMPORTING
outrecords = lt_outrecords
rejected = lv_failed
return_codes = lt_return_codes ).
IF lv_failed IS INITIAL. " Execute
lo_gr_sp->/scmb/if_sp_action~execute("('EXECUTE')
EXPORTING
aspect = '/SCWM/ASP_GR_EGR'
inkeys = lt_key_egr
action = 'ACT_COPY_EGR2IBD'
inparam = lv_pa_execute
IMPORTING
outrecords = lt_outrecords
rejected = lv_failed
return_codes = lt_return_codes ).
ENDIF.
IF lv_failed IS INITIAL. " Query DN
lo_gr_sp->/scmb/if_sp_action~execute(
EXPORTING
aspect = '/SCWM/ASP_GRPREP_IBD'
inkeys = lt_key_egr
action = 'ACT_DISPLAY_COPIED_EGR'
inparam = lv_inparam
IMPORTING
outrecords = lt_ibd
rejected = lv_failed
return_codes = lt_return_codes ).
ENDIF.
IF lv_failed IS INITIAL.
lo_gr_sp->/scmb/if_sp_transaction~before_save(
IMPORTING
rejected = lv_rejected ).
IF lv_rejected = abap_true.
lv_failed = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO lv_message.
ev_msg = lv_message.
ev_severity = 'E'.
RETURN.
ENDIF.
ENDIF.
IF lv_failed IS INITIAL.
lo_gr_sp->/scmb/if_sp_transaction~save(" Save-> DN
IMPORTING
rejected = lv_rejected ).
IF lv_rejected = abap_true.
lv_failed = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO lv_message.
ev_msg = lv_message.
ev_severity = 'E'.
RETURN.
ENDIF.
ENDIF.
IF lv_failed IS INITIAL.
COMMIT WORK AND WAIT.
lo_gr_sp->/scmb/if_sp_transaction~cleanup(
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_commit ).
/scwm/cl_tm=>cleanup( iv_reason = /scmb/if_sp_transaction=>sc_cleanup_commit ).
ev_msg = ' '.
ev_severity = 'S'.
READ TABLE lt_ibd INTO DATA(ls_ibd) INDEX 1.
IF sy-subrc = 0.
ev_docid = ls_ibd-docid.
ev_itemid = ls_ibd-itemid.
ENDIF.
ELSE.
ROLLBACK WORK.
lo_gr_sp->/scmb/if_sp_transaction~cleanup(
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_end ).
/scwm/cl_tm=>cleanup( ).
ev_msg = ' '.
ev_severity = 'E'.
RETURN.
ENDIF.
ENDFUNCTION.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[ABAP] ALV GRID를 사용하여 셀에 색상 지정(Indivisual Cell Color Settings For ALV GRID)안녕하세요. 이번은 ALV의 셀에 색을 붙이기 위한 샘플 코드입니다. "Excel의 조건부 서식처럼 조건을 충족하는 경우에만 색상을 변경하고 싶습니다." 「담당자가 일람을 보고, 요 대응・주의의 내용이 있는 개소에 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.