0% found this document useful (0 votes)
45 views

Sample Code ALE IDOC

The document clears global variables and parameters. It then loops through IDoc data records where the document number matches a control record. PO data is appended to a local work area and table for header and detail segments. A single IDoc is then created by calling a function, passing the PO data table. If successful, status messages are set and the IDoc number is assigned to a parameter.

Uploaded by

Rap Ferr
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Sample Code ALE IDOC

The document clears global variables and parameters. It then loops through IDoc data records where the document number matches a control record. PO data is appended to a local work area and table for header and detail segments. A single IDoc is then created by calling a function, passing the PO data table. If successful, status messages are set and the IDoc number is assigned to a parameter.

Uploaded by

Rap Ferr
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

*Clear global variables, export parameters

CLEAR: workflow_result,
application_variable,
in_update_task,
call_transaction_done.

in_update_task = cx_on.

LOOP AT idoc_data ASSIGNING <ls_data_rec>


WHERE docnum = <ls_control_rec>-docnum.

**Append PO data for Header & Details segment type***

*Local Work Area


DATA ls_po_data TYPE edi_dd40.
CLEAR ls_po_data.
*Fill PO Data
MOVE-CORRESPONDING is_po_data TO ls_po_data.
APPEND ls_po_data TO ct_po_data.

****Create single IDOC***********

Local Work area


DATA: ls_control_rec TYPE edi_dc40. " IDoc Control Record
* Initialize exporting par error flag, idoc no
CLEAR: e_error_flag, e_idoc_small.
* Fill Control record Data for IDoc
ls_control_rec-idoctyp = is_control-idoctp. "'ZEND_PO_RO'.
ls_control_rec-mestyp = i_msg_type. "Transaction IDOC message type
ls_control_rec-direct = c_inbound. "Inbound IDOC '2'
ls_control_rec-mescod = i_msg_cod. "RAM or PMI
ls_control_rec-sndprt = is_control-sndprt.
ls_control_rec-sndpor = is_control-sndpor.
ls_control_rec-sndprn = is_control-sndprn.
ls_control_rec-rcvpor = is_control-rcvpor.
ls_control_rec-rcvprt = is_control-rcvprt.
ls_control_rec-rcvprn = is_control-rcvprn.
*Create transaction IDOC
CALL FUNCTION 'IDOC_INBOUND_SINGLE'
EXPORTING
pi_idoc_control_rec_40 = ls_control_rec
pi_do_commit = 'X'
IMPORTING
pe_idoc_number = e_idoc_small
TABLES
pt_idoc_data_records_40 = it_po_data
EXCEPTIONS
idoc_not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Fill IDoc Status table with warning message '62'
* IDOC not saved to DB
me->set_status_msg(
EXPORTING i_status = c_warn_status
i_idoc_no = is_control-docnum
i_msgid = c_zend_air
i_msgno = c_idoc_nsave_no "'008'
i_msgv1 = is_control-docnum
i_msgv2 = space
i_msgv3 = space
CHANGING ct_status_rec = ct_status_rec[] ).
e_error_flag = cx_on.
ELSE.
* IDoc no. & was processed successfully '53'
me->set_status_msg(
EXPORTING i_status = c_succ_status
i_idoc_no = is_control-docnum
i_msgid = c_zend_air
i_msgno = c_idoc_succ_no "'003'
i_msgv1 = e_idoc_small "Transaction IDOC
i_msgv2 = space
i_msgv3 = space
CHANGING ct_status_rec = ct_status_rec[] ).

* Assign IDOCs processed succesfully to method parameter

me->assign_idoc_to_param(
EXPORTING i_idocs = c_success_idocs
i_idoc_no = e_idoc_small "Transaction IDOC
CHANGING ct_idocs = ct_idocs[] ).
ENDIF. " IF sy-subrc <> 0

endloop.

You might also like