Code: Alles auswählen.
CONSTANTS: c_idctyp_epos LIKE edbas-idoctyp VALUE 'Z_EPOS',
c_msgtyp_epos LIKE edmsg-msgtyp VALUE 'ZEPOS',
c_segnam_header LIKE edidd-segnam VALUE 'ZEPOS_HEAD',
c_segnam_link LIKE edidd-segnam VALUE 'ZEPOS_ITEM'.
DATA: fl_zepos_head TYPE zepos_head,
fl_zepos_item TYPE zepos_item.
TYPES: table_segment TYPE TABLE OF edidd.
DATA: i_segment TYPE table_segment.
DATA: f_control_record TYPE edidc,
f_segment TYPE edidd.
DATA: il_edidc TYPE TABLE OF edidc.
* Create control record
CLEAR f_control_record.
f_control_record-idoctp = c_idctyp_epos.
f_control_record-mestyp = c_msgtyp_epos.
* IF NOT recvr IS INITIAL.
* f_control_record-rcvprt = c_rcvprt_ls.
* f_control_record-rcvprn = recvr.
* ENDIF.
LOOP AT gt_output INTO gs_out.
CASE gs_out-comid.
WHEN 'Head'.
* Create header segment
fl_zepos_head-z_matnr = gs_out-compn.
fl_zepos_head-z_maktx = gs_out-compp.
fl_zepos_head-z_werk = gs_werks-werks.
f_segment-sdata = fl_zepos_head.
APPEND f_segment TO i_segment.
WHEN 'Position'.
* Create item segment
fl_zepos_item-z_rohstoff = gs_out-compn..
fl_zepos_item-z_prozent = gs_out-compp..
f_segment-sdata = fl_zepos_item.
APPEND f_segment TO i_segment.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = f_control_record
TABLES
communication_idoc_control = il_edidc
master_idoc_data = i_segment
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.
EXIT.
ENDIF.
** Dequeue idoc
* LOOP AT il_edidc INTO f_control_record.
* APPEND f_control_record TO i_edidc.
* CALL FUNCTION 'EDI_DOCUMENT_DEQUEUE_LATER'
* EXPORTING
* docnum = f_control_record-docnum
* EXCEPTIONS
* idoc_is_not_to_dequeue = 0.
* ENDLOOP.
*
* IF no_commit IS INITIAL.
* ADD 1 TO commit_count.
* IF commit_count >= c_commit_size.
* COMMIT WORK.
* CLEAR commit_count.
* ENDIF.
* ENDIF.
Code: Alles auswählen.
f_control_record-rcvprt = c_rcvprt_ls.
f_control_record-rcvprn = recvr.
....