Program To Create IDOC in Sap
Program To Create IDOC in Sap
I am developing a function module in ECC that will be used to post inbound IDOC for customer creation
DEBMAS07
The logic is as follows -
The function receives an IDOC structure
It then invokes function module 'IDOC_INPUT_DEBITOR'
IDOC_INPUT_DEBITOR takes care of creating a new customer in table KNA1. But I was
expecting IDOC_INPUT_DEBITOR to also handle the IDOC posting. This way I can go to WE02 and see a
new IDOC record. What am I missing? Is there some more code I need to write after the function module
call?
Solution2:
have a flat file(Which i have attached) below and it contains control and data record. I get this file in my application
server and i have to read this file and create a sales order(Inbound process).
Step 1: Create a file port (Inbound file tab: Maintain Directory, Function module in inbound file if required but not
mandatory)
Step 2: Maintain partner profiles as per control record in file.(message type: ORDERS, IDoc type: ORDERS05 and
process code - ORDE)
Step 3: Run the program RSEINB00 (or schedule periodically); IDocs will be created and processed. (Testing can
be done with tcode WE16)
After crating the sales order i need to send an order confirmation, Delivery and Invoice(outbound process) to a folder in
application server. the flat files have idoc segments and data. I have to create an IDOC for SO pragmatically and also
need to send the outbound file in text format to application server once delivery and invoice is created.
Order confirmation, Delivery and Invoice files can be sent by triggering Output types for each document and to
application server by maintaining file port for the respective message types in Partner profiles.
Order confirmation:
Message type: ORDRSP, IDoc type: ORDERS05, process code: SD10;
Delivery:
Message type: DELVRY; IDoc type: DELVRY**; Process code: DELV
Invoice:
Message type: INVOIC; IDoc type: INVOIC**; Process code:SD09
For the above 3 message types, File port have to be maintained with Directory and function module(WE54) that
determines the naming convention of output file in 'Outbound file' tab.
program RSEINB00
Solution3:
you can use master_ale_distribute function module to create the idoc.but before that you need to populate two
internal table to pass in to this function module.
1.it_edidc = this internal table tells the port,partner profile etc.this internal table having the same structure of edidc
table
2,second you create the internal table conatains the data records.this table got the the structure of edid4.
3.populate these two internal table and pass this to this function module
4.you can populate the second internal table from your flat file by writing some upload program
Copy Code
1. FORM master_ale_distribute .
2.
3. *PERFORM get_mestype.
4. wa_edidc-mestyp = wrk_mestyp.
5. wa_edidc-idoctp = wrk_idoctyp.
6.
7.
8. CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
9.
10. EXPORTING
11. master_idoc_control = wa_edidc
12. * OBJ_TYPE = ''
13. * CHNUM = ''
14. TABLES
15. communication_idoc_control = it_edidc
16. master_idoc_data = it_idoc_data
17. EXCEPTIONS
18. error_in_idoc_control = 1
19. error_writing_idoc_status = 2
20. error_in_idoc_data = 3
21. sending_logical_system_unknown = 4
22. OTHERS = 5.
23.
24. IF sy-subrc <> 0.
25. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
26. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
27. ELSE.
28.
29. COMMIT WORK.
30.
31. READ TABLE it_edidc INTO wa_edidc INDEX 1.
32.
33. IF sy-subrc = 0.
34. MESSAGE s006(msg) WITH wa_edidc-docnum.
35. PERFORM modify_idocnum.
36. ENDIF.
37. ENDIF.
38.
39. ENDFORM.