SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Sending sales orders in R/3 via ALE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Thu Feb 19, 2009 3:03 pm    Post subject: Sending sales orders in R/3 via ALE Reply with quote

Sending sales orders in R/3 via ALE

QUESTION:
Can you give me a detailed step-by-step guide on how to transfer sales orders from one R/3 system to the next via RFC?


EXPERT RESPONSE FROM: Axel Angeli

There are mainly two ways to transfer sales orders via RFC to another R/3 system.
* Calling the BAPI_SALESORDER_CREATEFROMDAT2 via RFC in the destination system
* Preparing an IDoc and sending the IDoc to the destination

The BAPI has several disadvantages. Mainly you need to collect all your data tediously in a program and then map it to the BAPI parameter structure. Unfortunately, the BAPI paramaters are not very compatible with the SAP R/3 database structure like VBAK and VBAP, namely the names of the fields differ heavily. In addition, all control of errors has to be handled by the sending program and a protocol is not written by the BAPI.

There is no standard way to send the data via ALE, but a simple trick helps us to distribute the order via ALE. SAP R/3 sends out order confirmations to a target system. The data in a sales order confirmation IDoc (ORDRSP) is the same as in an incoming sales order both sharing an ORDERS01 ... ORDERS05 IDoc type. What we have to do is to prepare an ORDRSP order confoirmation and send it to the target with an ORDERS message type.

The following shows a simple program that creates an IDoc and sends the IDoc via RFC to the destination system. For this example the only IDoc specific customizing would be to define an input partner profile in the target system.

Code:
report Z_LOGOS_ALE_ORDERS_DISTR_TEST.
*
parameters: VBELN type VBELN default '84'.
*
data: OBJECT like NAST.
data: CONTROL_RECORD like EDIDC.
data: INT_EDIDD type table of EDIDD with header line.
data: OWN_LOGICAL_SYSTEM type TBDLS-LOGSYS.
*
data: INT_EDI_DC type EDI_DC.
data: INT_EDI_DD type table of EDI_DD with header line.
*
CONTROL_RECORD-MESTYP = 'ORDERS'.
CONTROL_RECORD-IDOCTP = 'ORDERS05'.
*
call function 'OWN_LOGICAL_SYSTEM_GET'
importing
OWN_LOGICAL_SYSTEM = OWN_LOGICAL_SYSTEM
exceptions
OWN_LOGICAL_SYSTEM_NOT_DEFINED = 1
others = 0.
if SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*
CONTROL_RECORD-SNDPRT = 'LS'.
CONTROL_RECORD-SNDPRN = OWN_LOGICAL_SYSTEM.
CONTROL_RECORD-SNDPOR = OWN_LOGICAL_SYSTEM.
*
CONTROL_RECORD-RCVPRT = 'LS'.
CONTROL_RECORD-RCVPRN = OWN_LOGICAL_SYSTEM.
CONTROL_RECORD-RCVPOR = SPACE.
*
OBJECT-OBJKY = VBELN.
*
*call function 'Z_OSCOL_ALE_IDOC_OUTPUT_ORDERS'
call function 'IDOC_OUTPUT_ORDRSP'
exporting
OBJECT = OBJECT
CONTROL_RECORD_IN = CONTROL_RECORD
importing
* OBJECT_TYPE =
CONTROL_RECORD_OUT = CONTROL_RECORD
tables
INT_EDIDD = INT_EDIDD
exceptions
ERROR_MESSAGE_RECEIVED = 1
DATA_NOT_RELEVANT_FOR_SENDING = 2
others = 3.
if SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*
* --Clean up the IDoc from unwanted data
delete INT_EDIDD where SEGNAM eq 'E1EDK18'.
*
* --- Must be filled after func call
CONTROL_RECORD-OUTMOD = '2'.
CONTROL_RECORD-DIRECT = '2'.
*
move-corresponding CONTROL_RECORD to INT_EDI_DC.
INT_EDI_DC-IDOCTYP = CONTROL_RECORD-IDOCTP.
*
loop at INT_EDIDD.
move-corresponding INT_EDIDD to INT_EDI_DD.
append INT_EDI_DD.
endloop.
*
call function 'IDOC_INBOUND_SYNCHRONOUS'
destination 'NONE'
exporting
INT_EDIDC = INT_EDI_DC
ONLINE = 'O'
importing
DOCNUM = CONTROL_RECORD-DOCNUM
* ERROR_BEFORE_CALL_APPLICATION =
tables
INT_EDIDD = INT_EDI_DD
exceptions
IDOC_NOT_SAVED = 1
others = 2
.
if SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
write: / SY-SUBRC color col_normal,
CONTROL_RECORD-DOCNUM color col_normal hotspot.
hide: CONTROL_RECORD.
*
at line-selection.
if not CONTROL_RECORD-DOCNUM is initial.
call function 'EDI_DOCUMENT_TREE_DISPLAY'
exporting
DOCNUM = CONTROL_RECORD-DOCNUM
* OPEN =
exceptions
NO_IDOC_FOUND = 1
others = 2
.
if SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

endif.
*
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.