01-10-2007 11:56 PM
Experts,
I can create a custom idoc in SAP , my question is how can i post these idoc,
for example , for standard idoc type you can trigger and post these idoc with
function module IDOC_WRITE_AND_START_INBOUND OR some tcode, but
if i create a custom IDOC ,how i will be able to post these using above function
module IDOC_WRITE_AND_START_INBOUND
01-10-2007 11:59 PM
Hi,
Populate the Control records and the data records and call the FM
IDOC_INBOUND_ASYNCHRONOUS which will create the IDOC and post..
Thanks,
Naren
01-11-2007 12:14 AM
where will you assign a function module to your idoc type ,which transcation
01-11-2007 12:50 AM
Hi Sanju,
if you cannot use a standard idoc then you´ll need to create a custom one starting from the segment (WE31) where you can create an Idoc segment starting from your own Z table structure using the wizard.
Then you´ll need to also create the idoc type (WE30) and link the segment to the IDoc.
Then you´ll need to create a message type and link the message type to the Idoc type (WE81, WE82).
Then you´´ll use RFC "MASTER_IDOC_DISTRIBUTE" to populate the IDOC and send the data.
This is a sample code just to give you an idea:
DATA:
Z_SEGNAME(7) TYPE C VALUE 'SEGMENT',
Z_MESTYPE(9) TYPE C VALUE 'MESSAGE',
Z_IDOC_TYPE(8) TYPE C VALUE 'IDOC'.
DATA:
IDOC_CONTROL LIKE EDIDC,
T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,
IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.
*Reads data from Z table
SELECT *
FROM ZTABLE
INTO TABLE L_ZTABLE.
*Set the control data info required for the distribution
IDOC_CONTROL-MESTYP = Z_MESTYPE.
IDOC_CONTROL-DOCTYP = Z_IDOC_TYPE.
*Populate the IDoc
LOOP AT L_ZTABLE.
CLEAR IDOC_DATA.
IDOC_DATA-SEGNAM = Z_SEGNAME.
IDOC_DATA-SDATA = ZTABLE.
APPEND IDOC_DATA.
ENDLOOP.
*Deliver the IDOC as defined in distribution model/partner profile
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' IN UPDATE TASK
EXPORTING
MASTER_IDOC_CONTROL = IDOC_CONTROL
TABLES
COMMUNICATION_IDOC_CONTROL = T_COMM_CONTROL
MASTER_IDOC_DATA = 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.
COMMIT WORK.
ENDIF.
Then you can insert this code in your FM.
Hope it helps,
Kind Regards,
Sergio
01-11-2007 3:22 AM
Hi sanju,
These are 2 types 1. Through message control 2.Stand alone.
1. You have to add this FM to process code .Process will attached to apllication .
Ex : Purchase order
Whenever you create PO automatically process code will get trigger and IDOC will created.
2.You have schedule your program.
Pls. reward if useful
01-11-2007 6:02 AM