adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management
MASTER IDOC DISTRIBUTE
Aus SAP Wiki ツ
Deklaration
e1mbgmcr TYPE e1mbgmcr, e1bp2017_gm_head_01 TYPE e1bp2017_gm_head_01, e1bp2017_gm_code TYPE e1bp2017_gm_code, e1bp2017_gm_item_create TYPE e1bp2017_gm_item_create, /spe/e1bp2017_servicepart_d TYPE /spe/e1bp2017_servicepart_d, ls_idoc_data TYPE edidd, lt_idoc_data TYPE TABLE OF edidd, lt_comm_control TYPE TABLE OF edidc, ls_idoc_control_master TYPE edidc, lt_messages TYPE bal_t_msg, ls_message TYPE bal_s_msg.
Codeschnipsel
* control data CLEAR ls_idoc_control_master. ls_idoc_control_master-mestyp = 'MBGMCR'. ls_idoc_control_master-idoctp = 'MBGMCR03'. ls_idoc_control_master-rcvprt = 'LI'. "Partnerart Empfänger ls_idoc_control_master-rcvpfc = 'ZW'. "Partnerrolle Empfänger zcl_ldl_functions=>get_partner( EXPORTING iv_code = p_ldlco IMPORTING ev_partner = ls_idoc_control_master-rcvprn ). ls_idoc_control_master-rcvpor = 'A000000005'. "Empfängerport ls_idoc_control_master-sndprt = 'LS'. "Partnerart Empfänger ls_idoc_control_master-sndprn = 'XX'. CONCATENATE 'SAP' sy-sysid INTO ls_idoc_control_master-sndpor. * for segment 'E1MBGMCR' * CLEAR: e1mbgmcr, ls_idoc_data, lt_idoc_data. ls_idoc_data-sdata = e1mbgmcr. ls_idoc_data-segnam = 'E1MBGMCR'. APPEND ls_idoc_data TO lt_idoc_data. * for segment 'E1BP2017_GM_HEAD_01' * CLEAR: e1bp2017_gm_head_01, ls_idoc_data. MOVE-CORRESPONDING is_goodsmvtheader TO e1bp2017_gm_head_01. "#EC ENHOK IF NOT e1bp2017_gm_head_01 IS INITIAL. ls_idoc_data-sdata = e1bp2017_gm_head_01. ls_idoc_data-segnam = 'E1BP2017_GM_HEAD_01'. APPEND ls_idoc_data TO lt_idoc_data. ENDIF. * for segment 'E1BP2017_GM_CODE' * CLEAR: e1bp2017_gm_code, ls_idoc_data. MOVE-CORRESPONDING is_goodsmvtcode TO e1bp2017_gm_code. "#EC ENHOK IF NOT e1bp2017_gm_code IS INITIAL. ls_idoc_data-sdata = e1bp2017_gm_code. ls_idoc_data-segnam = 'E1BP2017_GM_CODE'. APPEND ls_idoc_data TO lt_idoc_data. ENDIF. * for segment 'E1BP2017_GM_ITEM_CREATE' LOOP AT it_goodsmvtitem INTO DATA(ls_goodsmvtitem). CLEAR: e1bp2017_gm_item_create, ls_idoc_data. "Für Items muss eine Konvertierung stattfinden. "XYZ braucht für Paletten, Palettenmenge "Es muss aus Gründen die Konvertierung auf führende Nullen stattfinden DATA: lv_matnr_mit_nullen TYPE matnr. DATA: lv_mhd_int_date TYPE char08. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = ls_goodsmvtitem-material IMPORTING output = lv_matnr_mit_nullen. zcl_ldl_functions=>calc_quant( EXPORTING iv_matnr = lv_matnr_mit_nullen iv_menge = ls_goodsmvtitem-entry_qnt iv_out = 'X' IMPORTING ev_menge = ls_goodsmvtitem-entry_qnt ). zcl_ldl_functions=>get_partner( EXPORTING iv_code = p_ldlco IMPORTING ev_partner = ls_goodsmvtitem-vendor ). SHIFT ls_goodsmvtitem-vendor LEFT DELETING LEADING '0'. "MHD wird wie folgt gebraucht -> YYYYMMDD READ TABLE it_servicepart_data INTO DATA(ls_need_hu_for_mhd) INDEX 1. SELECT SINGLE mhd FROM zbestand_ldl INTO lv_mhd_int_date WHERE code = p_ldlco AND sscc = ls_need_hu_for_mhd-hu_number. ls_goodsmvtitem-expirydate = lv_mhd_int_date. "Mapping MOVE_TYPE in LDL Bewegungsart zcl_ldl_functions=>map_mmt( EXPORTING iv_bwa = ls_goodsmvtitem-move_type iv_out = 'X' IMPORTING ev_bwa = ls_goodsmvtitem-move_type ). MOVE-CORRESPONDING ls_goodsmvtitem TO e1bp2017_gm_item_create. "#EC ENHOK CONDENSE e1bp2017_gm_item_create-entry_qnt. CONDENSE e1bp2017_gm_item_create-po_pr_qnt. CONDENSE e1bp2017_gm_item_create-amount_lc. CONDENSE e1bp2017_gm_item_create-amount_sv. CONDENSE e1bp2017_gm_item_create-su_pl_stck_1. CONDENSE e1bp2017_gm_item_create-st_un_qtyy_1. CONDENSE e1bp2017_gm_item_create-su_pl_stck_2. CONDENSE e1bp2017_gm_item_create-st_un_qtyy_2. e1bp2017_gm_item_create-material = zcl_ldl_functions=>convert_matnr_external( iv_matnr = e1bp2017_gm_item_create-material ). ls_idoc_data-sdata = e1bp2017_gm_item_create. ls_idoc_data-segnam = 'E1BP2017_GM_ITEM_CREATE'. APPEND ls_idoc_data TO lt_idoc_data. ** for segment 'E1BP2017_GM_ITEM_CREATE1' * * CLEAR: e1bp2017_gm_item_create1, ls_idoc_data, lt_idoc_data. * MOVE-CORRESPONDING goodsmvtitem * TO e1bp2017_gm_item_create1. "#EC ENHOK * CONDENSE e1bp2017_gm_item_create1-quantity. * idoc_data-sdata = e1bp2017_gm_item_create1. * idoc_data-segnam = 'E1BP2017_GM_ITEM_CREATE1'. * APPEND ls_idoc_data TO lt_idoc_data. ENDLOOP. CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' EXPORTING master_idoc_control = ls_idoc_control_master * OBJ_TYPE = * CHNUM = TABLES communication_idoc_control = lt_comm_control master_idoc_data = lt_idoc_data EXCEPTIONS error_in_idoc_control = 1 error_writing_idoc_status = 2 error_in_idoc_data = 3 sending_logical_system_unknown = 4 OTHERS = 5. IF sy-subrc <> 0. READ TABLE lt_comm_control INTO DATA(ls_comm_doc) INDEX 1. ls_message-msgty = 'E'. ls_message-msgid = 'ZLDL_BESTMONI'. ls_message-msgno = '021'. ls_message-msgv1 = ls_comm_doc-docnum. APPEND ls_message TO et_results. ENDIF.