‎2008 Nov 19 2:29 PM
I have used the bapi_salesorder_createfromdat1 function module to create sales orders. Now how can i generate an idoc of the sales orders created and send it to other system. Please give a solution.
Edited by: Shakti on Nov 19, 2008 3:30 PM
‎2008 Nov 20 1:34 PM
after your bapi do the following
wa_edidc-rcvprt = gc_ls. "Partner Type of Receiver
wa_edidc-direct = 1. "Outbound
Port is with simialr name of logical system
IF sy-sysid EQ gc_ert.
CONCATENATE: gc_xit gc_clt gc_200 INTO wa_edidc-rcvpor.
ELSEIF sy-sysid EQ gc_erq.
CONCATENATE: gc_xiq gc_clt gc_300 INTO wa_edidc-rcvpor.
ELSEIF sy-sysid EQ gc_erp.
CONCATENATE: gc_xip gc_clt gc_400 INTO wa_edidc-rcvpor.
ENDIF.
XIT only 200 client No, XIQ always only 300 and XIP always only 400 - Confirmed by Markus/ Erik
IF sy-sysid EQ gc_ert.
CONCATENATE: gc_xit gc_clt gc_200 INTO wa_edidc-rcvprn.
ELSEIF sy-sysid EQ gc_erq.
CONCATENATE: gc_xiq gc_clt gc_300 INTO wa_edidc-rcvprn.
ELSEIF sy-sysid EQ gc_erp.
CONCATENATE: gc_xip gc_clt gc_400 INTO wa_edidc-rcvprn.
ENDIF.
wa_edidc-mestyp = gc_ymtspa01. "Message Type
wa_edidc-idoctp = gc_ywhspa01. "IDoc Type
Move data records from internal table to the edidd structure.
Check Whether Invoice is already sent or not to AGCONet
IF NOT gt_final_sp2[] IS INITIAL.
SELECT *
FROM ysmk_invoice01
INTO TABLE gt_invoice01
FOR ALL ENTRIES IN gt_final_sp2
WHERE vbeln EQ gt_final_sp2-vbeln_vf.
IF sy-subrc EQ 0 .
ENDIF.
LOOP AT gt_final_sp2 INTO wa_final_sp2.
CLEAR : wa_invoice01,gv_index.
gv_index = sy-tabix.
READ TABLE gt_invoice01 INTO wa_invoice01 WITH KEY vbeln = wa_final_sp2-vbeln_vf.
IF sy-subrc EQ 0.
IF wa_invoice01-process EQ 'X'.
IF p_check NE 'X'. " To Ignore previously processed Orders
DELETE gt_final_sp2 INDEX gv_index.
ENDIF.
ENDIF.
ENDIF.
CLEAR : wa_final_sp2.
ENDLOOP.
ENDIF.
IF gt_final_sp2[] IS INITIAL.
MESSAGE s222.
LEAVE TO LIST-PROCESSING.
ENDIF.
LOOP AT gt_final_sp2 INTO wa_final_sp2.
wa_sdata_sp2-chas_ser_num = wa_final_sp2-qausp.
wa_sdata_sp2-mat_num = wa_final_sp2-matnr.
wa_sdata_sp2-bill_doc = wa_final_sp2-vbeln_vf.
wa_sdata_sp2-bill_type = wa_final_sp2-fkart.
wa_sdata_sp2-cust_num = wa_final_sp2-kunnr.
wa_sdata_sp2-fkdat = wa_final_sp2-fkdat.
wa_sdata_sp2-kzwi5 = wa_final_sp2-kzwi5.
wa_sdata_sp2-netwr = wa_final_sp2-netwr.
wa_sdata_sp2-aedat = wa_final_sp2-aedat.
wa_edidd-segnam = gc_z1whspf2."Segment Name.
wa_edidd-sdata = wa_sdata_sp2.
APPEND wa_edidd TO gt_edidd.
CLEAR wa_edidd.
wa_invoice01-vbeln = wa_final_sp2-vbeln_vf.
wa_invoice01-process = 'X'.
MODIFY ysmk_invoice01 FROM wa_invoice01.
ENDLOOP.
IF NOT gt_edidd[] IS INITIAL.
*---Function module to trigger the IDOC explicitly
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
master_idoc_control = wa_edidc
TABLES
communication_idoc_control = gt_edidc
master_idoc_data = gt_edidd
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 NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
*Commit work used if the Function module is executed successfully
COMMIT WORK.
READ TABLE gt_edidc INTO wa_edidc INDEX 1.
IF sy-subrc EQ 0.
WRITE:/ wa_edidc-docnum, text-003.
ENDIF.
ENDIF.
ENDIF.
*---Clearing the internal table and work area for Data structures
IF sy-subrc EQ 0.
r_mestyp-low = gc_ymtspa01.
r_mestyp-sign = gc_i.
r_mestyp-option = gc_eq.
APPEND r_mestyp TO r_mestyp.
CLEAR: r_mestyp.
r_docnum-low = wa_edidc-docnum.
r_docnum-sign = gc_i.
r_docnum-option = gc_eq.
APPEND r_docnum TO r_docnum.
CLEAR: r_docnum.
SUBMIT rbdmoind WITH p_credat = sy-datum
WITH p_step = 100 AND RETURN.
SUBMIT rseout00 WITH docnum IN r_docnum
WITH mestyp IN r_mestyp
WITH p_compl = 'Y'
WITH p_rcvpor = 'XITCLT200'
WITH p_rcvprt = 'LS' AND RETURN.
CLEAR: wa_edidc,wa_edidd.
REFRESH: gt_edidc,gt_edidd.
‎2008 Nov 20 4:13 PM
Hello sir.
Thank you for replying me.
So do we need to create message type and idoc type is it??? and wat is this (ysmk_invoice01). Is it a ztable?Sir if you dnt mind please be a bit more clear. Im not that gud in idocs. Can u please explain...
I would be very thankful.
Edited by: Shakti on Nov 20, 2008 5:14 PM
‎2008 Nov 20 8:30 PM
Hello Shakti
Display the sales order (transaction VA02) and choose menu Extras -> Output -> Header -> Edit.
Here you can define an ORDRSP (order response) as EDI output (mode = '6'). If you have created appropriate partner profiles (WE20) and ALE/IDoc ports (WE21) the IDoc will be automatically forwarded to another SAP system or e.g. SAP-XI (for EDI conversion).
Regards
Uwe
‎2008 Nov 21 4:21 PM
Hi...
Here i need to explicitly goto va02 and issue the output. That is not my requirement. In se38 i have written a program by calling a bapi function module. Thru bapi inserted all data. In the same program once the sales orders are created and saved thru bapi and idoc shud be generated. Code shud be return in the same se38 program. So for this do i need to to create Custom idoc???
plz ans me...