<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Data transfer using ALE/IDOC into XML. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481298#M836915</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In continuation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example Purchasing &amp;amp; Selling scenario&lt;/P&gt;&lt;P&gt;We will develop a custom IDoc to carry the billing number from the Service Receiver&amp;#146;s system to the Service Provider&amp;#146;s system. We will populate the IDoc in a user exit on the sending side and we will process the transaction on the receiving side using a custom function module and a BDC transaction call.&lt;/P&gt;&lt;P&gt;No rule conversion, segment filtering or version conversion will be implemented in the model as described in Figure 1.&lt;/P&gt;&lt;P&gt;Requirements&lt;/P&gt;&lt;P&gt;&amp;#149; Working ALE environment - See ALE Basis Configuration Guide;&lt;/P&gt;&lt;P&gt;&amp;#149; ALE scenario design together with the business requirement;&lt;/P&gt;&lt;P&gt;&amp;#149; Development access; and&lt;/P&gt;&lt;P&gt;&amp;#149; ALE configuration access.&lt;/P&gt;&lt;P&gt;NOTES:&lt;/P&gt;&lt;P&gt;1. All IMG references to transactions are located in the transaction SALE which is the ALE portion of the IMG&lt;/P&gt;&lt;P&gt;2. This is one way of developing a scenario where no message control exists. If message control exist (EG. On purchase orders) then NAST can be used to call an outbound function module that would create the required IDocs.&lt;/P&gt;&lt;P&gt;3. Extensive knowledge of IDocs and ALE basis configuration is required in order to understand this guide.&lt;/P&gt;&lt;P&gt;2. OUTBOUND PROCESSING&lt;/P&gt;&lt;P&gt;2.1. Create IDoc type (WE30) Client independent&lt;/P&gt;&lt;P&gt;The IDoc type refers to the IDoc structure that you will require for your development. In our case the IDoc type is called ZINVRV01. This IDoc type will have 1 segment called Z1INVRV with 2 fields, LIFNR &amp;amp; XBLNR, in this segment. If you require many segments or nested segments then they are also created using the same procedure.&lt;/P&gt;&lt;P&gt;We will create the IDoc of the following structure:&lt;/P&gt;&lt;P&gt;ZINVRV01&lt;/P&gt;&lt;P&gt;Purchasing and Selling - Invoice receipt reversal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Z1INVRV P&amp;amp;S - Segment 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Segment fields &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LIFNR Vendor account number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XBLNR Reference document number&lt;/P&gt;&lt;P&gt;Figure 3: IDoc type ZINVRV01&lt;/P&gt;&lt;P&gt;To create the IDoc type, follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE30 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain IDoc type)&lt;/P&gt;&lt;P&gt;&amp;#149; Type in ZINVRV01 and click on Basic IDoc type, click the Create icon&lt;/P&gt;&lt;P&gt;&amp;#149; Click on Create new (we are creating an IDoc from scratch but you may want to copy another IDoc if it is similar to your requirements) and enter a description, and press enter&lt;/P&gt;&lt;P&gt;&amp;#149; Click on ZINVRV01 and then on the Create icon&lt;/P&gt;&lt;P&gt;&amp;#149; Enter Z1INVRV as the segment type (must start with Z1), check mandatory if the segment must exist (in this case check it), enter 1 in minimum number and 1 as maximum number. (Make the maximum number 9999999999 if there are going to be many of these segments in each IDoc. IE. When line items are passed via IDocs), click on Segment editor&lt;/P&gt;&lt;P&gt;&amp;#149; Enter a description for your segment type and create&lt;/P&gt;&lt;P&gt;&amp;#149; Enter a description for your segment, enter each field required in your IDoc, in our case type LIFNR across for Field name, DE structure and DE documentation, repeat for XBLNR and press enter to validate.&lt;/P&gt;&lt;P&gt;&amp;#149; Save and generate, press back&lt;/P&gt;&lt;P&gt;&amp;#149; To release the segment choose Goto, Release from the menu&lt;/P&gt;&lt;P&gt;&amp;#149; Check the box on the line of your new segment&lt;/P&gt;&lt;P&gt;&amp;#149; Save, back and enter&lt;/P&gt;&lt;P&gt;&amp;#149; Your IDoc type structure should be displayed with your new segment&lt;/P&gt;&lt;P&gt;&amp;#149; Save and back&lt;/P&gt;&lt;P&gt;&amp;#149; To release the IDoc type choose Extras, Release type from the menu and Yes&lt;/P&gt;&lt;P&gt;Your IDoc is now ready for use. If you need to add fields or segments to your IDoc type, you will need to cancel the release of the IDoc type as well as the segment release using a similar procedure followed above (except now you uncheck the release box for the segment and you choose cancel release for the IDoc type).&lt;/P&gt;&lt;P&gt;2.2. Create message type (WE81) Client independent&lt;/P&gt;&lt;P&gt;To create a new message type, follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE81 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain message type for intermed. Structure -&amp;gt; Create logical message type)&lt;/P&gt;&lt;P&gt;&amp;#149; Choose Create logical message type by double clicking on it&lt;/P&gt;&lt;P&gt;&amp;#149; Click on change icon to enter change mode&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries to add a new type&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the required message type, in our case it is ZINVRV and an appropriate description&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit.&lt;/P&gt;&lt;P&gt;Your message type has now been created. The next step will be to link it to the IDoc.&lt;/P&gt;&lt;P&gt;2.2.1. Link message to IDoc type (WE82 &amp;amp; BD69) Client independent&lt;/P&gt;&lt;P&gt;To link the message type to the IDoc type follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE82 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain message type for intermed. Structure -&amp;gt; EDI: Message Types and Assignment to IDoc Types)&lt;/P&gt;&lt;P&gt;&amp;#149; Click on change icon to enter change mode&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries to create the link&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction BD69 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain message type for intermed. Structure -&amp;gt; Assign message type to IDoc for ALE)&lt;/P&gt;&lt;P&gt;&amp;#149; Click on change icon to enter change mode&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries to create the link&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit&lt;/P&gt;&lt;P&gt;Your IDoc is now linked to your message type. We still need to link object types and add the message to the model before we can use the message.&lt;/P&gt;&lt;P&gt;2.2.2. Maintain object type for message type (BD59) Client independent&lt;/P&gt;&lt;P&gt;The ALE objects are used to create links between IDocs and applications objects, to control the serialisation, to filter messages in the customer model and to use listings.&lt;/P&gt;&lt;P&gt;For our own message type and IDoc you must maintain object types for the links. &lt;/P&gt;&lt;P&gt;If you want to check the serialisation for the message type, then you must maintain object types for the serialisation. If no serialisation object has been maintained for a given message type, then the serialisation will not be checked for this message type.&lt;/P&gt;&lt;P&gt;To add an object type to our message type, follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction BD59 (ALE -&amp;gt; Extensions -&amp;gt; ALE object maintenance -&amp;gt; Maintain object types)&lt;/P&gt;&lt;P&gt;&amp;#149; Type in your message type ZINVRV and press enter&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries&lt;/P&gt;&lt;P&gt;&amp;#149; Enter your object type, LIFNR (We need to use the vendor as a filter object), the segment name where LIFNR resides, Z1INVRV, a number 1 for the sequence followed by the actual field name LIFNR&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit.&lt;/P&gt;&lt;P&gt;You have now created an object that we&amp;#146;ll use as a filter object in the customer model to direct the flow of messages to the various logical systems based on the vendors in the filter of the message type ZINVRV.&lt;/P&gt;&lt;P&gt;We now need to add our new message type to the distribution model.&lt;/P&gt;&lt;P&gt;2.3. Configuring the Distribution Model&lt;/P&gt;&lt;P&gt;This task is performed on your ALE reference client.&lt;/P&gt;&lt;P&gt;2.3.1. Manual Configuration (BD64) Client dependent&lt;/P&gt;&lt;P&gt;To manually configure the customer distribution model, read the ALE configuration procedure, and follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Perform the Maintain customer distribution model directly function. (ALE -&amp;gt; Distribution customer model -&amp;gt; Maintain customer distribution model directly)&lt;/P&gt;&lt;P&gt;&amp;#149; Specify the customer model you want to maintain and the logical system that is to be the sender of the messages OR create a new model. (Create model ALE with logical system ALELS1C400)&lt;/P&gt;&lt;P&gt;&amp;#149; Choose the receiving systems to which the sending system must forward message type ZINVRV to.&lt;/P&gt;&lt;P&gt;&amp;#149; For each receiving logical system allocate the message type necessary for communication to the receiving systems as per ALE configuration procedure.&lt;/P&gt;&lt;P&gt;&amp;#149; Create filter objects (in our case LIFNR as the object type with the associated vendor number, 0000018001 with leading zeros, in the object area) for the message types. &lt;/P&gt;&lt;P&gt;&amp;#149; Save the entries.&lt;/P&gt;&lt;P&gt;NOTES:&lt;/P&gt;&lt;P&gt;You cannot maintain a message type between the same sender and receiver in more than one customer distribution model. &lt;/P&gt;&lt;P&gt;Only the owner is authorised to modify the model. &lt;/P&gt;&lt;P&gt;To change the owner of a model, choose the 'Maintain ownership of customer distribution model' function. Make sure that all changes will be distributed to all systems that know the corresponding model. To do so, you can use the correction and transport system. &lt;/P&gt;&lt;P&gt;To transport the customer distribution model you should use the Distribute customer model function of the IMG as described below.&lt;/P&gt;&lt;P&gt;2.3.2. Distribute customer model (BD71) Client dependent&lt;/P&gt;&lt;P&gt;After the customer model has been created centrally, it must be distributed to the other remote systems. This entails first of all setting up the communication for the distributed systems and then sending the model.&lt;/P&gt;&lt;P&gt;2.3.2.1. Distribute Model (BD71) Client dependent&lt;/P&gt;&lt;P&gt;This task is performed on your ALE reference client. To distribute the customer distribution model, read the ALE configuration procedure and follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Make the settings for the communication with the other decentral systems, you have not set them yet. &lt;/P&gt;&lt;P&gt;&amp;#149; Define the RFC destination for R/3 connections whose names correspond to the name of the corresponding logical system. &lt;/P&gt;&lt;P&gt;&amp;#149; Create the output partner profile. &lt;/P&gt;&lt;P&gt;&amp;#149; Distribute the customer model &lt;/P&gt;&lt;P&gt;&amp;#149; Specify the name of the customer model. &lt;/P&gt;&lt;P&gt;&amp;#149; You must specify the target system to which you want to distribute the customer model. &lt;/P&gt;&lt;P&gt;&amp;#149; You must repeat this function for every distributed logical system. &lt;/P&gt;&lt;P&gt;2.3.2.2. Maintain sending system partner profile (WE20) Client dependent&lt;/P&gt;&lt;P&gt;With this function, you define the partner profiles for all outbound and inbound messages on the basis of the customer distribution model. &lt;/P&gt;&lt;P&gt;After you have defined and distributed the customer model, you will have to maintain the partner profiles locally. To do this read the ALE configuration procedure.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the output mode (background, immediately) and the package size for outbound processing. &lt;/P&gt;&lt;P&gt;Requirements &lt;/P&gt;&lt;P&gt;&amp;#149; The customer model must be maintained.&lt;/P&gt;&lt;P&gt;&amp;#149; RFC destinations must be maintained.&lt;/P&gt;&lt;P&gt;&amp;#149; The customer model must be distributed.&lt;/P&gt;&lt;P&gt;&amp;#149; To ensure that the appropriate persons in charge are informed if a processing error occurs, you must make settings in: Error processing Maintain organisational units.&lt;/P&gt;&lt;P&gt;2.4. Populate &amp;amp; distribute IDoc using ABAP&lt;/P&gt;&lt;P&gt;An IDoc consists of a control record with structure edidc and one or more data records with structure edidd. The control record contains the sender and recipient of the IDoc, as well as information on the type of message.&lt;/P&gt;&lt;P&gt;To be able to pass an IDoc to the ALE layer, you must set up a field string with structure edidc and an internal table with structure edidd. They are used to call function module master_idoc_distribute, which performs the save to the database and triggers the dispatch if necessary.&lt;/P&gt;&lt;P&gt;2.4.1. Example code&lt;/P&gt;&lt;P&gt;The code displayed below does the following:&lt;/P&gt;&lt;P&gt;&amp;#149; populates our IDoc segment Z1INVR with the 2 fields XBLNR and LIFNR, populates the segment name and appends this to an internal table used to store the IDoc data;&lt;/P&gt;&lt;P&gt;&amp;#149; populates the control record info with the message type and IDoc type; and&lt;/P&gt;&lt;P&gt;&amp;#149; calls the MASTER_IDOC_DISTRIBUTE function module which distributes the IDoc as configured in the customer distribution model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data declaration statements &lt;/P&gt;&lt;P&gt;DATA: C_INVREV_SEGNAME(7) TYPE C VALUE 'Z1INVRV',&lt;/P&gt;&lt;P&gt;C_INVREV_MESTYPE(6) TYPE C VALUE 'ZINVRV',&lt;/P&gt;&lt;P&gt;C_INVREV_IDOC_TYPE(8) TYPE C VALUE 'ZINVRV01', &lt;/P&gt;&lt;P&gt;Z1INVRV LIKE Z1INVRV,&lt;/P&gt;&lt;P&gt;C_INVREV_DOCTYPE LIKE BKPF-BLART VALUE 'YY',&lt;/P&gt;&lt;P&gt;IDOC_CONTROL LIKE EDIDC,&lt;/P&gt;&lt;P&gt;T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the document header into a structure &lt;/P&gt;&lt;P&gt;LOOP AT DOC_HEAD_TAB INTO DOC_HEAD.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the document item data into a structure &lt;/P&gt;&lt;P&gt;LOOP AT DOC_ITEM_TAB INTO DOC_ITEM WHERE NOT ( LIFNR IS INITIAL ).&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Populate the IDoc segment&amp;#146;s field with the required data &lt;/P&gt;&lt;P&gt;CLEAR Z1INVRV.&lt;/P&gt;&lt;P&gt;Z1INVRV-LIFNR = DOC_ITEM-LIFNR. &amp;#147;Store vendor number for filter&lt;/P&gt;&lt;P&gt;Z1INVRV-XBLNR = DOC_HEAD-XBLNR. &amp;#147;Billing number&lt;/P&gt;&lt;P&gt;IDOC_DATA-SEGNAM = C_INVREV_SEGNAME. &amp;#147;Segment name&lt;/P&gt;&lt;P&gt;IDOC_DATA-SDATA = Z1INVRV. &amp;#147;Segment data&lt;/P&gt;&lt;P&gt;APPEND IDOC_DATA. &amp;#147;Populate IDoc internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the control data info required for the distribution &lt;/P&gt;&lt;P&gt;IDOC_CONTROL-MESTYP = C_INVREV_MESTYPE.&lt;/P&gt;&lt;P&gt;IDOC_CONTROL-DOCTYP = C_INVREV_IDOC_TYPE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call the distribute function with the required parameters &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' IN UPDATE TASK&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;MASTER_IDOC_CONTROL = IDOC_CONTROL&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;COMMUNICATION_IDOC_CONTROL = T_COMM_CONTROL&lt;/P&gt;&lt;P&gt;MASTER_IDOC_DATA = IDOC_DATA&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;ERROR_IN_IDOC_CONTROL = 1&lt;/P&gt;&lt;P&gt;ERROR_WRITING_IDOC_STATUS = 2&lt;/P&gt;&lt;P&gt;ERROR_IN_IDOC_DATA = 3&lt;/P&gt;&lt;P&gt;SENDING_LOGICAL_SYSTEM_UNKNOWN = 4&lt;/P&gt;&lt;P&gt;OTHERS = 5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Figure 4: Outbound processing example code&lt;/P&gt;&lt;P&gt;NOTE:&lt;/P&gt;&lt;P&gt;For debugging purposes, use transaction WE05 (IDoc overview) to see check your IDoc status, or to see whether an IDoc was created/&lt;/P&gt;&lt;P&gt;3. INBOUND PROCESSING&lt;/P&gt;&lt;P&gt;3.1. Create Function Module&lt;/P&gt;&lt;P&gt;This function module is called when a message type, of type ZINVRV, comes into the receiving system. This needs to be configured and is dealt with later in this section. The function module is passed the IDoc as a parameter.&lt;/P&gt;&lt;P&gt;Example parameters&lt;/P&gt;&lt;P&gt;Import parameters Reference field Opt Y/N&lt;/P&gt;&lt;P&gt;INPUT_METHOD BDWFAP_PAR-INPUTMETHD N&lt;/P&gt;&lt;P&gt;MASS_PROCESSING BDWFAP_PAR-MASS_PROC N&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Export Parameters Reference field Opt Y/N&lt;/P&gt;&lt;P&gt;WORKFLOW_RESULT BDWFAP_PAR-RESULT N&lt;/P&gt;&lt;P&gt;APPLICATION_VARIABLE BDWFAP_PAR-APPL_VAR N&lt;/P&gt;&lt;P&gt;IN_UPDATE_TASK BDWFAP_PAR-UPDATETASK N&lt;/P&gt;&lt;P&gt;CALL_TRANSACTION_DONE BDWFAP_PAR-CALLTRANS N&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Parameters Reference field Optional Y/N&lt;/P&gt;&lt;P&gt;IDOC_CONTRL EDIDC &lt;/P&gt;&lt;P&gt;IDOC_DATA EDIDD &lt;/P&gt;&lt;P&gt;IDOC_STATUS BDIDOCSTAT &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES BDWFRETVAR &lt;/P&gt;&lt;P&gt;SERIALIZATION_INFO BDI_SER &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exceptions&lt;/P&gt;&lt;P&gt;WRONG_FUNCTION_CALLED&lt;/P&gt;&lt;P&gt;Example code&lt;/P&gt;&lt;P&gt;The code displayed below does the following:&lt;/P&gt;&lt;P&gt;&amp;#149; populates a BDC table with the IDoc info;&lt;/P&gt;&lt;P&gt;&amp;#149; calls the transaction via a BDC call; and&lt;/P&gt;&lt;P&gt;&amp;#149; updates the IDoc status according to the BDC error status.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXTRACT FROM: Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Declaration of local variables &lt;/P&gt;&lt;P&gt;DATA: C_SEGNAM(10) TYPE C VALUE 'Z1INVRV'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*-Loop through the IDOCs&lt;/P&gt;&lt;P&gt;LOOP AT IDOC_CONTRL.&lt;/P&gt;&lt;P&gt;*---Loop through the data for the IDOC&lt;/P&gt;&lt;P&gt;LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.&lt;/P&gt;&lt;P&gt;CASE IDOC_DATA-SEGNAM.&lt;/P&gt;&lt;P&gt;WHEN C_SEGNAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here we get the info from the idoc table &lt;/P&gt;&lt;P&gt;IT_Z1INVRV = IDOC_DATA-SDATA.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;PERFORM REV_INV.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;PERFORM UPDATE_IDOC_STATUS.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM REV_INV "Reverse invoice form&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local variables &amp;amp; constants &lt;/P&gt;&lt;P&gt;DATA: C_TCODE LIKE BKPF-TCODE VALUE 'VF11'. "BDC transaction code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we can build the bdc table to call the reversal transaction start of screen 109 &lt;/P&gt;&lt;P&gt;CLEAR BDC_TAB.&lt;/P&gt;&lt;P&gt;BDC_TAB-PROGRAM = 'SAPMV60A'.&lt;/P&gt;&lt;P&gt;BDC_TAB-DYNPRO = '109'.&lt;/P&gt;&lt;P&gt;BDC_TAB-DYNBEGIN = 'X'.&lt;/P&gt;&lt;P&gt;APPEND BDC_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Document number &lt;/P&gt;&lt;P&gt;CLEAR BDC_TAB.&lt;/P&gt;&lt;P&gt;BDC_TAB-FNAM = 'KOMFK-VBELN(01)'.&lt;/P&gt;&lt;P&gt;BDC_TAB-FVAL = IT_Z1INVRV-XBLNR. "Billing document number&lt;/P&gt;&lt;P&gt;APPEND BDC_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK Code for screen 109 &lt;/P&gt;&lt;P&gt;CLEAR BDC_TAB.&lt;/P&gt;&lt;P&gt;BDC_TAB-FNAM = 'BDC_OKCODE'.&lt;/P&gt;&lt;P&gt;BDC_TAB-FVAL = 'SICH'.&lt;/P&gt;&lt;P&gt;APPEND BDC_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we can call transaction 'VF11' with the populated bdc table. The transaction is called inside the idoc-contrl loop, so a transaction will be called for every idoc (journal). the transaction is called in no-display mode ('N') because this code runs in background as it is called by ale. The update is specified to be synchronous ('S') because we have to wait for the result to update the idoc status correctly. &lt;/P&gt;&lt;P&gt;CALL TRANSACTION C_TCODE USING BDC_TAB MODE 'N' UPDATE 'S'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Store the return code for use in another form (status update) &lt;/P&gt;&lt;P&gt;RETURN_CODE = SY-SUBRC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here we check the return code, if there was an error, we put the transaction in a bdc session for the user to review and correct. &lt;/P&gt;&lt;P&gt;IF SY-SUBRC NE 0.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BDC_OPEN_GROUP'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;CLIENT = SY-MANDT&lt;/P&gt;&lt;P&gt;GROUP = 'ZINVRV'&lt;/P&gt;&lt;P&gt;USER = C_ALE_USER&lt;/P&gt;&lt;P&gt;KEEP = 'X'.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BDC_INSERT'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;TCODE = C_TCODE&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;DYNPROTAB = BDC_TAB.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BDC_CLOSE_GROUP'&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;NOT_OPEN = 1&lt;/P&gt;&lt;P&gt;QUEUE_ERROR = 2&lt;/P&gt;&lt;P&gt;OTHERS = 3.&lt;/P&gt;&lt;P&gt;ELSE. "No problems&lt;/P&gt;&lt;P&gt;C_EXISTS = 'N'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select from the billing document table to get sales doc number &lt;/P&gt;&lt;P&gt;SELECT * FROM VBRP WHERE VBELN = IT_Z1INVRV-XBLNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select from the sales document table to get user status number &lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM VBAP WHERE VBELN = VBRP-AUBEL AND&lt;/P&gt;&lt;P&gt;POSNR = VBRP-AUPOS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select from the status table to change the user status to pending &lt;/P&gt;&lt;P&gt;SELECT * FROM JEST WHERE OBJNR = VBAP-OBJNR AND&lt;/P&gt;&lt;P&gt;STAT LIKE C_USER_STATUS.&lt;/P&gt;&lt;P&gt;IF JEST-STAT = C_US_PENDING. "User status is pending&lt;/P&gt;&lt;P&gt;JEST-INACT = C_UNCHECKED. "Make pending the active status&lt;/P&gt;&lt;P&gt;UPDATE JEST.&lt;/P&gt;&lt;P&gt;C_EXISTS = 'Y'. "I.E. An entry is already in table&lt;/P&gt;&lt;P&gt;ELSEIF JEST-INACT = C_UNCHECKED AND JEST-STAT NE C_US_PENDING.&lt;/P&gt;&lt;P&gt;JEST-INACT = C_CHECKED. "Make everything else inactive&lt;/P&gt;&lt;P&gt;UPDATE JEST.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;IF C_EXISTS = 'N'. "I.E. Pending has never been a status before&lt;/P&gt;&lt;P&gt;JEST-OBJNR = VBAP-OBJNR.&lt;/P&gt;&lt;P&gt;JEST-STAT = C_US_PENDING.&lt;/P&gt;&lt;P&gt;JEST-INACT = C_UNCHECKED. "Make pending the active status&lt;/P&gt;&lt;P&gt;INSERT JEST.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDSELECT. "Select from VBRP (Billing document table)&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDFORM. " REV_INV&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM UPDATE_IDOC_STATUS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we check the CALL TRANSACTION return code and set IDOC status &lt;/P&gt;&lt;P&gt;CLEAR IDOC_STATUS. &lt;/P&gt;&lt;P&gt;IF RETURN_CODE = 0. &lt;/P&gt;&lt;P&gt;WORKFLOW_RESULT = '0'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-STATUS = '53'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-UNAME = SY-UNAME. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-REPID = SY-REPID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGTY = SY-MSGTY. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGID = SY-MSGID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGNO = SY-MSGNO. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV1 = SY-MSGV1. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV2 = SY-MSGV2.&lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV3 = SY-MSGV3. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV4 = SY-MSGV4. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;APPEND RETURN_VARIABLES. &lt;/P&gt;&lt;P&gt;ELSE. &lt;/P&gt;&lt;P&gt;WORKFLOW_RESULT = '99999'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-STATUS = '51'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-UNAME = SY-UNAME. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-REPID = SY-REPID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGTY = SY-MSGTY. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGID = SY-MSGID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGNO = SY-MSGNO. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV1 = SY-MSGV1.&lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV2 = SY-MSGV2. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV3 = SY-MSGV3. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV4 = SY-MSGV4. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-WF_PARAM = 'ERROR_IDOCS'. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;APPEND RETURN_VARIABLES. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;APPEND IDOC_STATUS. &lt;/P&gt;&lt;P&gt;ENDFORM. " UPDATE_IDOC_STATUS&lt;/P&gt;&lt;P&gt;Figure 5: Inbound processing example code&lt;/P&gt;&lt;P&gt;3.1.1. Debugging inbound FM&lt;/P&gt;&lt;P&gt;Use transaction WE19 to test inbound function module in debugging mode. Also use WE05 to view the IDocs and their statuses.&lt;/P&gt;&lt;P&gt;3.2. Maintain ALE attributes&lt;/P&gt;&lt;P&gt;The inbound function module needs to be linked to the message type and the message type needs to be linked to the appropriate inbound process code at the partner profile level before the scenario is enabled. These steps are described below in detail.&lt;/P&gt;&lt;P&gt;3.2.1. Link Message Type to Function Module (WE57) Client independent&lt;/P&gt;&lt;P&gt;To link a message (ZINVRV) type to a function module (Z_IDOC_INPUT_ZINVRV) follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE57 (ALE -&amp;gt; Extensions -&amp;gt; Inbound -&amp;gt; Allocate function module to logical message)&lt;/P&gt;&lt;P&gt;&amp;#149; Select an entry (EG. IDOC_INPUT_ORDERS) and copy&lt;/P&gt;&lt;P&gt;&amp;#149; Type in module name Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;&amp;#149; Type in basic IDoc type as ZINVRV01&lt;/P&gt;&lt;P&gt;&amp;#149; Type in message type as ZINVRV&lt;/P&gt;&lt;P&gt;&amp;#149; Type object type as IDOCINVOIC (Invoice document) - Used for workflow&lt;/P&gt;&lt;P&gt;&amp;#149; Direction should be set to 2 for inbound&lt;/P&gt;&lt;P&gt;&amp;#149; Enter and save&lt;/P&gt;&lt;P&gt;3.2.2. Define FM settings (BD51) Client independent&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction BD51 (ALE -&amp;gt; Extensions -&amp;gt; Inbound -&amp;gt; Define settings for input modules)&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries&lt;/P&gt;&lt;P&gt;&amp;#149; Type in the name of the new function module Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;&amp;#149; Enter 0 for mass processing in the output column&lt;/P&gt;&lt;P&gt;&amp;#149; Save and Exit&lt;/P&gt;&lt;P&gt;3.2.3. Maintain process codes (WE42) Client dependent&lt;/P&gt;&lt;P&gt;A process code needs to be maintained on each client. It then needs to be linked to the message via the partner profiles on each client. This allows the various clients to use a unique function module for the same message type.&lt;/P&gt;&lt;P&gt;To maintain the process code follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Log on to the appropriate receiving system client&lt;/P&gt;&lt;P&gt;&amp;#149; Execute WE42 (ALE -&amp;gt; Extensions -&amp;gt; Inbound -&amp;gt; Maintaining process codes inbound)&lt;/P&gt;&lt;P&gt;&amp;#149; Choose Inbound with ALE service&lt;/P&gt;&lt;P&gt;&amp;#149; Choose Processing with function module&lt;/P&gt;&lt;P&gt;&amp;#149; Click on Processing with function module and choose create icon&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New Entries&lt;/P&gt;&lt;P&gt;&amp;#149; Type in process code ZINR and give it a description and save&lt;/P&gt;&lt;P&gt;&amp;#149; Now you are asked to Please maintain codes added in ALE entry methods, enter and choose Z_IDOC_INPUT_FIRVSL and copy it. You should choose a FM similar to your one.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter your process code ZINR&lt;/P&gt;&lt;P&gt;&amp;#149; Enter your function module Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;NOTE: The next 6 steps are used in workflow error handling. &lt;/P&gt;&lt;P&gt;&amp;#149; Enter IDPKFIDCMT in object type&lt;/P&gt;&lt;P&gt;&amp;#149; Enter MASSINPUTFINISHED in End event&lt;/P&gt;&lt;P&gt;&amp;#149; Enter IDOCINVOIC in IDoc object type&lt;/P&gt;&lt;P&gt;&amp;#149; Enter INPUTERROROCCURREDFI in IDoc start event&lt;/P&gt;&lt;P&gt;&amp;#149; Enter INPUTFINISHEDFI in IDoc End event&lt;/P&gt;&lt;P&gt;&amp;#149; Enter IDOCINVOIC in Application object type&lt;/P&gt;&lt;P&gt;You will need to determine the task associated with object IDOCINVOIC, and then assign the appropriate position to it. This position will then receive the application error messages via workflow.&lt;/P&gt;&lt;P&gt;To set up the workflow area please consult the Workflow config guide.&lt;/P&gt;&lt;P&gt;3.3. Create inbound partner profile&lt;/P&gt;&lt;P&gt;For each message type you need to maintain the inbound partner profiles.&lt;/P&gt;&lt;P&gt;3.3.1. Maintain receiving system partner profile (WE20) Client dependent&lt;/P&gt;&lt;P&gt;To maintain inbound partner profiles read the document ALE configuration procedure:&lt;/P&gt;&lt;P&gt;&amp;#149; Add the message type ZINVRV with process code ZINR.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the output mode (background, immediately) for inbound processing and NO message code.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the position S and choose the ALE administrator 50000085. This position will then receive all the technical ALE errors via workflow.&lt;/P&gt;&lt;P&gt;3.4. Test&lt;/P&gt;&lt;P&gt;Once the inbound function module has been debugged the scenario should be ready to test in its entirety. If problems occur, read through the relevant areas of this document to check your configuration or code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you,&lt;/P&gt;&lt;P&gt;If you  want me to explain more, you can give me your email id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward with points incase you are satisfied.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sushama&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Mar 2008 06:01:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-03-07T06:01:02Z</dc:date>
    <item>
      <title>Data transfer using ALE/IDOC into XML.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481294#M836911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to transfer FI document data (FB01) from the sap system ,convert it into XML and dump it in 1 of the file servers.I want to do this using ALE/IDOC.Is it possible to do the same and how.Similarly i want to do the same for Vendor and Customer master i.e sending the data in XML format. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly Suggest how do i go about doin the same..Its very urgent.Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Lailu Philip.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 07:15:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481294#M836911</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T07:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data transfer using ALE/IDOC into XML.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481295#M836912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Please refer this link&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/c1/bab13bb3acd607e10000000a11402f/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/c1/bab13bb3acd607e10000000a11402f/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are working on the Version ECC6.0  create an Enhancement spot  before ending of  function module.and You can  use below function modules  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ISIA_CE_IDOC_TO_XML&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CFG_API_CONVERT_IDOC_TO_XML&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IDX_IDOC_TO_XML.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Sree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sree m on Mar 5, 2008 11:09 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sree m on Mar 7, 2008 9:34 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2008 09:51:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481295#M836912</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-05T09:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Data transfer using ALE/IDOC into XML.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481296#M836913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To transfer the data using ALE/IDOC, you need to create a new custom ALE scenario,which  comprises of  5 steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Design and develop the custom IDoc with it&amp;#146;s segments and a new message type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Configure the ALE environment with the new IDoc and message type (customer model, partner profiles and linking IDoc to message type)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Develop the outbound process which does the following:&lt;/P&gt;&lt;P&gt;&amp;#149; Populates the custom IDoc with control info and functional data&lt;/P&gt;&lt;P&gt;&amp;#149; Sends the IDoc to the ALE layer for distribution&lt;/P&gt;&lt;P&gt;&amp;#149; Updates status and handles errors&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Configure the ALE inbound side (partner profiles with inbound process code)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. Develop the inbound process which does the following:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2008 05:57:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481296#M836913</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-07T05:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data transfer using ALE/IDOC into XML.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481297#M836914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In continuation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149; Reads the IDoc into a BDC table; selects other data that is required&lt;/P&gt;&lt;P&gt;&amp;#149; Runs transaction using call transaction or BDC session&lt;/P&gt;&lt;P&gt;&amp;#149; Updates status and handles errors&lt;/P&gt;&lt;P&gt;Below is a pictorial representation of the flow of a complete ALE scenario from the sending system to the receiving system.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2008 05:58:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481297#M836914</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-07T05:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Data transfer using ALE/IDOC into XML.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481298#M836915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In continuation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example Purchasing &amp;amp; Selling scenario&lt;/P&gt;&lt;P&gt;We will develop a custom IDoc to carry the billing number from the Service Receiver&amp;#146;s system to the Service Provider&amp;#146;s system. We will populate the IDoc in a user exit on the sending side and we will process the transaction on the receiving side using a custom function module and a BDC transaction call.&lt;/P&gt;&lt;P&gt;No rule conversion, segment filtering or version conversion will be implemented in the model as described in Figure 1.&lt;/P&gt;&lt;P&gt;Requirements&lt;/P&gt;&lt;P&gt;&amp;#149; Working ALE environment - See ALE Basis Configuration Guide;&lt;/P&gt;&lt;P&gt;&amp;#149; ALE scenario design together with the business requirement;&lt;/P&gt;&lt;P&gt;&amp;#149; Development access; and&lt;/P&gt;&lt;P&gt;&amp;#149; ALE configuration access.&lt;/P&gt;&lt;P&gt;NOTES:&lt;/P&gt;&lt;P&gt;1. All IMG references to transactions are located in the transaction SALE which is the ALE portion of the IMG&lt;/P&gt;&lt;P&gt;2. This is one way of developing a scenario where no message control exists. If message control exist (EG. On purchase orders) then NAST can be used to call an outbound function module that would create the required IDocs.&lt;/P&gt;&lt;P&gt;3. Extensive knowledge of IDocs and ALE basis configuration is required in order to understand this guide.&lt;/P&gt;&lt;P&gt;2. OUTBOUND PROCESSING&lt;/P&gt;&lt;P&gt;2.1. Create IDoc type (WE30) Client independent&lt;/P&gt;&lt;P&gt;The IDoc type refers to the IDoc structure that you will require for your development. In our case the IDoc type is called ZINVRV01. This IDoc type will have 1 segment called Z1INVRV with 2 fields, LIFNR &amp;amp; XBLNR, in this segment. If you require many segments or nested segments then they are also created using the same procedure.&lt;/P&gt;&lt;P&gt;We will create the IDoc of the following structure:&lt;/P&gt;&lt;P&gt;ZINVRV01&lt;/P&gt;&lt;P&gt;Purchasing and Selling - Invoice receipt reversal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Z1INVRV P&amp;amp;S - Segment 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Segment fields &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LIFNR Vendor account number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XBLNR Reference document number&lt;/P&gt;&lt;P&gt;Figure 3: IDoc type ZINVRV01&lt;/P&gt;&lt;P&gt;To create the IDoc type, follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE30 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain IDoc type)&lt;/P&gt;&lt;P&gt;&amp;#149; Type in ZINVRV01 and click on Basic IDoc type, click the Create icon&lt;/P&gt;&lt;P&gt;&amp;#149; Click on Create new (we are creating an IDoc from scratch but you may want to copy another IDoc if it is similar to your requirements) and enter a description, and press enter&lt;/P&gt;&lt;P&gt;&amp;#149; Click on ZINVRV01 and then on the Create icon&lt;/P&gt;&lt;P&gt;&amp;#149; Enter Z1INVRV as the segment type (must start with Z1), check mandatory if the segment must exist (in this case check it), enter 1 in minimum number and 1 as maximum number. (Make the maximum number 9999999999 if there are going to be many of these segments in each IDoc. IE. When line items are passed via IDocs), click on Segment editor&lt;/P&gt;&lt;P&gt;&amp;#149; Enter a description for your segment type and create&lt;/P&gt;&lt;P&gt;&amp;#149; Enter a description for your segment, enter each field required in your IDoc, in our case type LIFNR across for Field name, DE structure and DE documentation, repeat for XBLNR and press enter to validate.&lt;/P&gt;&lt;P&gt;&amp;#149; Save and generate, press back&lt;/P&gt;&lt;P&gt;&amp;#149; To release the segment choose Goto, Release from the menu&lt;/P&gt;&lt;P&gt;&amp;#149; Check the box on the line of your new segment&lt;/P&gt;&lt;P&gt;&amp;#149; Save, back and enter&lt;/P&gt;&lt;P&gt;&amp;#149; Your IDoc type structure should be displayed with your new segment&lt;/P&gt;&lt;P&gt;&amp;#149; Save and back&lt;/P&gt;&lt;P&gt;&amp;#149; To release the IDoc type choose Extras, Release type from the menu and Yes&lt;/P&gt;&lt;P&gt;Your IDoc is now ready for use. If you need to add fields or segments to your IDoc type, you will need to cancel the release of the IDoc type as well as the segment release using a similar procedure followed above (except now you uncheck the release box for the segment and you choose cancel release for the IDoc type).&lt;/P&gt;&lt;P&gt;2.2. Create message type (WE81) Client independent&lt;/P&gt;&lt;P&gt;To create a new message type, follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE81 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain message type for intermed. Structure -&amp;gt; Create logical message type)&lt;/P&gt;&lt;P&gt;&amp;#149; Choose Create logical message type by double clicking on it&lt;/P&gt;&lt;P&gt;&amp;#149; Click on change icon to enter change mode&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries to add a new type&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the required message type, in our case it is ZINVRV and an appropriate description&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit.&lt;/P&gt;&lt;P&gt;Your message type has now been created. The next step will be to link it to the IDoc.&lt;/P&gt;&lt;P&gt;2.2.1. Link message to IDoc type (WE82 &amp;amp; BD69) Client independent&lt;/P&gt;&lt;P&gt;To link the message type to the IDoc type follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE82 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain message type for intermed. Structure -&amp;gt; EDI: Message Types and Assignment to IDoc Types)&lt;/P&gt;&lt;P&gt;&amp;#149; Click on change icon to enter change mode&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries to create the link&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction BD69 (ALE -&amp;gt; Extensions -&amp;gt; IDoc types -&amp;gt; Maintain message type for intermed. Structure -&amp;gt; Assign message type to IDoc for ALE)&lt;/P&gt;&lt;P&gt;&amp;#149; Click on change icon to enter change mode&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries to create the link&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit&lt;/P&gt;&lt;P&gt;Your IDoc is now linked to your message type. We still need to link object types and add the message to the model before we can use the message.&lt;/P&gt;&lt;P&gt;2.2.2. Maintain object type for message type (BD59) Client independent&lt;/P&gt;&lt;P&gt;The ALE objects are used to create links between IDocs and applications objects, to control the serialisation, to filter messages in the customer model and to use listings.&lt;/P&gt;&lt;P&gt;For our own message type and IDoc you must maintain object types for the links. &lt;/P&gt;&lt;P&gt;If you want to check the serialisation for the message type, then you must maintain object types for the serialisation. If no serialisation object has been maintained for a given message type, then the serialisation will not be checked for this message type.&lt;/P&gt;&lt;P&gt;To add an object type to our message type, follow these next few steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction BD59 (ALE -&amp;gt; Extensions -&amp;gt; ALE object maintenance -&amp;gt; Maintain object types)&lt;/P&gt;&lt;P&gt;&amp;#149; Type in your message type ZINVRV and press enter&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries&lt;/P&gt;&lt;P&gt;&amp;#149; Enter your object type, LIFNR (We need to use the vendor as a filter object), the segment name where LIFNR resides, Z1INVRV, a number 1 for the sequence followed by the actual field name LIFNR&lt;/P&gt;&lt;P&gt;&amp;#149; Save and exit.&lt;/P&gt;&lt;P&gt;You have now created an object that we&amp;#146;ll use as a filter object in the customer model to direct the flow of messages to the various logical systems based on the vendors in the filter of the message type ZINVRV.&lt;/P&gt;&lt;P&gt;We now need to add our new message type to the distribution model.&lt;/P&gt;&lt;P&gt;2.3. Configuring the Distribution Model&lt;/P&gt;&lt;P&gt;This task is performed on your ALE reference client.&lt;/P&gt;&lt;P&gt;2.3.1. Manual Configuration (BD64) Client dependent&lt;/P&gt;&lt;P&gt;To manually configure the customer distribution model, read the ALE configuration procedure, and follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Perform the Maintain customer distribution model directly function. (ALE -&amp;gt; Distribution customer model -&amp;gt; Maintain customer distribution model directly)&lt;/P&gt;&lt;P&gt;&amp;#149; Specify the customer model you want to maintain and the logical system that is to be the sender of the messages OR create a new model. (Create model ALE with logical system ALELS1C400)&lt;/P&gt;&lt;P&gt;&amp;#149; Choose the receiving systems to which the sending system must forward message type ZINVRV to.&lt;/P&gt;&lt;P&gt;&amp;#149; For each receiving logical system allocate the message type necessary for communication to the receiving systems as per ALE configuration procedure.&lt;/P&gt;&lt;P&gt;&amp;#149; Create filter objects (in our case LIFNR as the object type with the associated vendor number, 0000018001 with leading zeros, in the object area) for the message types. &lt;/P&gt;&lt;P&gt;&amp;#149; Save the entries.&lt;/P&gt;&lt;P&gt;NOTES:&lt;/P&gt;&lt;P&gt;You cannot maintain a message type between the same sender and receiver in more than one customer distribution model. &lt;/P&gt;&lt;P&gt;Only the owner is authorised to modify the model. &lt;/P&gt;&lt;P&gt;To change the owner of a model, choose the 'Maintain ownership of customer distribution model' function. Make sure that all changes will be distributed to all systems that know the corresponding model. To do so, you can use the correction and transport system. &lt;/P&gt;&lt;P&gt;To transport the customer distribution model you should use the Distribute customer model function of the IMG as described below.&lt;/P&gt;&lt;P&gt;2.3.2. Distribute customer model (BD71) Client dependent&lt;/P&gt;&lt;P&gt;After the customer model has been created centrally, it must be distributed to the other remote systems. This entails first of all setting up the communication for the distributed systems and then sending the model.&lt;/P&gt;&lt;P&gt;2.3.2.1. Distribute Model (BD71) Client dependent&lt;/P&gt;&lt;P&gt;This task is performed on your ALE reference client. To distribute the customer distribution model, read the ALE configuration procedure and follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Make the settings for the communication with the other decentral systems, you have not set them yet. &lt;/P&gt;&lt;P&gt;&amp;#149; Define the RFC destination for R/3 connections whose names correspond to the name of the corresponding logical system. &lt;/P&gt;&lt;P&gt;&amp;#149; Create the output partner profile. &lt;/P&gt;&lt;P&gt;&amp;#149; Distribute the customer model &lt;/P&gt;&lt;P&gt;&amp;#149; Specify the name of the customer model. &lt;/P&gt;&lt;P&gt;&amp;#149; You must specify the target system to which you want to distribute the customer model. &lt;/P&gt;&lt;P&gt;&amp;#149; You must repeat this function for every distributed logical system. &lt;/P&gt;&lt;P&gt;2.3.2.2. Maintain sending system partner profile (WE20) Client dependent&lt;/P&gt;&lt;P&gt;With this function, you define the partner profiles for all outbound and inbound messages on the basis of the customer distribution model. &lt;/P&gt;&lt;P&gt;After you have defined and distributed the customer model, you will have to maintain the partner profiles locally. To do this read the ALE configuration procedure.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the output mode (background, immediately) and the package size for outbound processing. &lt;/P&gt;&lt;P&gt;Requirements &lt;/P&gt;&lt;P&gt;&amp;#149; The customer model must be maintained.&lt;/P&gt;&lt;P&gt;&amp;#149; RFC destinations must be maintained.&lt;/P&gt;&lt;P&gt;&amp;#149; The customer model must be distributed.&lt;/P&gt;&lt;P&gt;&amp;#149; To ensure that the appropriate persons in charge are informed if a processing error occurs, you must make settings in: Error processing Maintain organisational units.&lt;/P&gt;&lt;P&gt;2.4. Populate &amp;amp; distribute IDoc using ABAP&lt;/P&gt;&lt;P&gt;An IDoc consists of a control record with structure edidc and one or more data records with structure edidd. The control record contains the sender and recipient of the IDoc, as well as information on the type of message.&lt;/P&gt;&lt;P&gt;To be able to pass an IDoc to the ALE layer, you must set up a field string with structure edidc and an internal table with structure edidd. They are used to call function module master_idoc_distribute, which performs the save to the database and triggers the dispatch if necessary.&lt;/P&gt;&lt;P&gt;2.4.1. Example code&lt;/P&gt;&lt;P&gt;The code displayed below does the following:&lt;/P&gt;&lt;P&gt;&amp;#149; populates our IDoc segment Z1INVR with the 2 fields XBLNR and LIFNR, populates the segment name and appends this to an internal table used to store the IDoc data;&lt;/P&gt;&lt;P&gt;&amp;#149; populates the control record info with the message type and IDoc type; and&lt;/P&gt;&lt;P&gt;&amp;#149; calls the MASTER_IDOC_DISTRIBUTE function module which distributes the IDoc as configured in the customer distribution model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data declaration statements &lt;/P&gt;&lt;P&gt;DATA: C_INVREV_SEGNAME(7) TYPE C VALUE 'Z1INVRV',&lt;/P&gt;&lt;P&gt;C_INVREV_MESTYPE(6) TYPE C VALUE 'ZINVRV',&lt;/P&gt;&lt;P&gt;C_INVREV_IDOC_TYPE(8) TYPE C VALUE 'ZINVRV01', &lt;/P&gt;&lt;P&gt;Z1INVRV LIKE Z1INVRV,&lt;/P&gt;&lt;P&gt;C_INVREV_DOCTYPE LIKE BKPF-BLART VALUE 'YY',&lt;/P&gt;&lt;P&gt;IDOC_CONTROL LIKE EDIDC,&lt;/P&gt;&lt;P&gt;T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the document header into a structure &lt;/P&gt;&lt;P&gt;LOOP AT DOC_HEAD_TAB INTO DOC_HEAD.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the document item data into a structure &lt;/P&gt;&lt;P&gt;LOOP AT DOC_ITEM_TAB INTO DOC_ITEM WHERE NOT ( LIFNR IS INITIAL ).&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Populate the IDoc segment&amp;#146;s field with the required data &lt;/P&gt;&lt;P&gt;CLEAR Z1INVRV.&lt;/P&gt;&lt;P&gt;Z1INVRV-LIFNR = DOC_ITEM-LIFNR. &amp;#147;Store vendor number for filter&lt;/P&gt;&lt;P&gt;Z1INVRV-XBLNR = DOC_HEAD-XBLNR. &amp;#147;Billing number&lt;/P&gt;&lt;P&gt;IDOC_DATA-SEGNAM = C_INVREV_SEGNAME. &amp;#147;Segment name&lt;/P&gt;&lt;P&gt;IDOC_DATA-SDATA = Z1INVRV. &amp;#147;Segment data&lt;/P&gt;&lt;P&gt;APPEND IDOC_DATA. &amp;#147;Populate IDoc internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the control data info required for the distribution &lt;/P&gt;&lt;P&gt;IDOC_CONTROL-MESTYP = C_INVREV_MESTYPE.&lt;/P&gt;&lt;P&gt;IDOC_CONTROL-DOCTYP = C_INVREV_IDOC_TYPE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Call the distribute function with the required parameters &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' IN UPDATE TASK&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;MASTER_IDOC_CONTROL = IDOC_CONTROL&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;COMMUNICATION_IDOC_CONTROL = T_COMM_CONTROL&lt;/P&gt;&lt;P&gt;MASTER_IDOC_DATA = IDOC_DATA&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;ERROR_IN_IDOC_CONTROL = 1&lt;/P&gt;&lt;P&gt;ERROR_WRITING_IDOC_STATUS = 2&lt;/P&gt;&lt;P&gt;ERROR_IN_IDOC_DATA = 3&lt;/P&gt;&lt;P&gt;SENDING_LOGICAL_SYSTEM_UNKNOWN = 4&lt;/P&gt;&lt;P&gt;OTHERS = 5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Figure 4: Outbound processing example code&lt;/P&gt;&lt;P&gt;NOTE:&lt;/P&gt;&lt;P&gt;For debugging purposes, use transaction WE05 (IDoc overview) to see check your IDoc status, or to see whether an IDoc was created/&lt;/P&gt;&lt;P&gt;3. INBOUND PROCESSING&lt;/P&gt;&lt;P&gt;3.1. Create Function Module&lt;/P&gt;&lt;P&gt;This function module is called when a message type, of type ZINVRV, comes into the receiving system. This needs to be configured and is dealt with later in this section. The function module is passed the IDoc as a parameter.&lt;/P&gt;&lt;P&gt;Example parameters&lt;/P&gt;&lt;P&gt;Import parameters Reference field Opt Y/N&lt;/P&gt;&lt;P&gt;INPUT_METHOD BDWFAP_PAR-INPUTMETHD N&lt;/P&gt;&lt;P&gt;MASS_PROCESSING BDWFAP_PAR-MASS_PROC N&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Export Parameters Reference field Opt Y/N&lt;/P&gt;&lt;P&gt;WORKFLOW_RESULT BDWFAP_PAR-RESULT N&lt;/P&gt;&lt;P&gt;APPLICATION_VARIABLE BDWFAP_PAR-APPL_VAR N&lt;/P&gt;&lt;P&gt;IN_UPDATE_TASK BDWFAP_PAR-UPDATETASK N&lt;/P&gt;&lt;P&gt;CALL_TRANSACTION_DONE BDWFAP_PAR-CALLTRANS N&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table Parameters Reference field Optional Y/N&lt;/P&gt;&lt;P&gt;IDOC_CONTRL EDIDC &lt;/P&gt;&lt;P&gt;IDOC_DATA EDIDD &lt;/P&gt;&lt;P&gt;IDOC_STATUS BDIDOCSTAT &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES BDWFRETVAR &lt;/P&gt;&lt;P&gt;SERIALIZATION_INFO BDI_SER &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exceptions&lt;/P&gt;&lt;P&gt;WRONG_FUNCTION_CALLED&lt;/P&gt;&lt;P&gt;Example code&lt;/P&gt;&lt;P&gt;The code displayed below does the following:&lt;/P&gt;&lt;P&gt;&amp;#149; populates a BDC table with the IDoc info;&lt;/P&gt;&lt;P&gt;&amp;#149; calls the transaction via a BDC call; and&lt;/P&gt;&lt;P&gt;&amp;#149; updates the IDoc status according to the BDC error status.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXTRACT FROM: Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Declaration of local variables &lt;/P&gt;&lt;P&gt;DATA: C_SEGNAM(10) TYPE C VALUE 'Z1INVRV'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*-Loop through the IDOCs&lt;/P&gt;&lt;P&gt;LOOP AT IDOC_CONTRL.&lt;/P&gt;&lt;P&gt;*---Loop through the data for the IDOC&lt;/P&gt;&lt;P&gt;LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.&lt;/P&gt;&lt;P&gt;CASE IDOC_DATA-SEGNAM.&lt;/P&gt;&lt;P&gt;WHEN C_SEGNAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here we get the info from the idoc table &lt;/P&gt;&lt;P&gt;IT_Z1INVRV = IDOC_DATA-SDATA.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;PERFORM REV_INV.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;PERFORM UPDATE_IDOC_STATUS.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM REV_INV "Reverse invoice form&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Local variables &amp;amp; constants &lt;/P&gt;&lt;P&gt;DATA: C_TCODE LIKE BKPF-TCODE VALUE 'VF11'. "BDC transaction code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we can build the bdc table to call the reversal transaction start of screen 109 &lt;/P&gt;&lt;P&gt;CLEAR BDC_TAB.&lt;/P&gt;&lt;P&gt;BDC_TAB-PROGRAM = 'SAPMV60A'.&lt;/P&gt;&lt;P&gt;BDC_TAB-DYNPRO = '109'.&lt;/P&gt;&lt;P&gt;BDC_TAB-DYNBEGIN = 'X'.&lt;/P&gt;&lt;P&gt;APPEND BDC_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Document number &lt;/P&gt;&lt;P&gt;CLEAR BDC_TAB.&lt;/P&gt;&lt;P&gt;BDC_TAB-FNAM = 'KOMFK-VBELN(01)'.&lt;/P&gt;&lt;P&gt;BDC_TAB-FVAL = IT_Z1INVRV-XBLNR. "Billing document number&lt;/P&gt;&lt;P&gt;APPEND BDC_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK Code for screen 109 &lt;/P&gt;&lt;P&gt;CLEAR BDC_TAB.&lt;/P&gt;&lt;P&gt;BDC_TAB-FNAM = 'BDC_OKCODE'.&lt;/P&gt;&lt;P&gt;BDC_TAB-FVAL = 'SICH'.&lt;/P&gt;&lt;P&gt;APPEND BDC_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we can call transaction 'VF11' with the populated bdc table. The transaction is called inside the idoc-contrl loop, so a transaction will be called for every idoc (journal). the transaction is called in no-display mode ('N') because this code runs in background as it is called by ale. The update is specified to be synchronous ('S') because we have to wait for the result to update the idoc status correctly. &lt;/P&gt;&lt;P&gt;CALL TRANSACTION C_TCODE USING BDC_TAB MODE 'N' UPDATE 'S'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Store the return code for use in another form (status update) &lt;/P&gt;&lt;P&gt;RETURN_CODE = SY-SUBRC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here we check the return code, if there was an error, we put the transaction in a bdc session for the user to review and correct. &lt;/P&gt;&lt;P&gt;IF SY-SUBRC NE 0.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BDC_OPEN_GROUP'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;CLIENT = SY-MANDT&lt;/P&gt;&lt;P&gt;GROUP = 'ZINVRV'&lt;/P&gt;&lt;P&gt;USER = C_ALE_USER&lt;/P&gt;&lt;P&gt;KEEP = 'X'.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BDC_INSERT'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;TCODE = C_TCODE&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;DYNPROTAB = BDC_TAB.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BDC_CLOSE_GROUP'&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;NOT_OPEN = 1&lt;/P&gt;&lt;P&gt;QUEUE_ERROR = 2&lt;/P&gt;&lt;P&gt;OTHERS = 3.&lt;/P&gt;&lt;P&gt;ELSE. "No problems&lt;/P&gt;&lt;P&gt;C_EXISTS = 'N'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select from the billing document table to get sales doc number &lt;/P&gt;&lt;P&gt;SELECT * FROM VBRP WHERE VBELN = IT_Z1INVRV-XBLNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select from the sales document table to get user status number &lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM VBAP WHERE VBELN = VBRP-AUBEL AND&lt;/P&gt;&lt;P&gt;POSNR = VBRP-AUPOS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select from the status table to change the user status to pending &lt;/P&gt;&lt;P&gt;SELECT * FROM JEST WHERE OBJNR = VBAP-OBJNR AND&lt;/P&gt;&lt;P&gt;STAT LIKE C_USER_STATUS.&lt;/P&gt;&lt;P&gt;IF JEST-STAT = C_US_PENDING. "User status is pending&lt;/P&gt;&lt;P&gt;JEST-INACT = C_UNCHECKED. "Make pending the active status&lt;/P&gt;&lt;P&gt;UPDATE JEST.&lt;/P&gt;&lt;P&gt;C_EXISTS = 'Y'. "I.E. An entry is already in table&lt;/P&gt;&lt;P&gt;ELSEIF JEST-INACT = C_UNCHECKED AND JEST-STAT NE C_US_PENDING.&lt;/P&gt;&lt;P&gt;JEST-INACT = C_CHECKED. "Make everything else inactive&lt;/P&gt;&lt;P&gt;UPDATE JEST.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;IF C_EXISTS = 'N'. "I.E. Pending has never been a status before&lt;/P&gt;&lt;P&gt;JEST-OBJNR = VBAP-OBJNR.&lt;/P&gt;&lt;P&gt;JEST-STAT = C_US_PENDING.&lt;/P&gt;&lt;P&gt;JEST-INACT = C_UNCHECKED. "Make pending the active status&lt;/P&gt;&lt;P&gt;INSERT JEST.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDSELECT. "Select from VBRP (Billing document table)&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDFORM. " REV_INV&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM UPDATE_IDOC_STATUS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we check the CALL TRANSACTION return code and set IDOC status &lt;/P&gt;&lt;P&gt;CLEAR IDOC_STATUS. &lt;/P&gt;&lt;P&gt;IF RETURN_CODE = 0. &lt;/P&gt;&lt;P&gt;WORKFLOW_RESULT = '0'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-STATUS = '53'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-UNAME = SY-UNAME. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-REPID = SY-REPID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGTY = SY-MSGTY. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGID = SY-MSGID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGNO = SY-MSGNO. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV1 = SY-MSGV1. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV2 = SY-MSGV2.&lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV3 = SY-MSGV3. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV4 = SY-MSGV4. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;APPEND RETURN_VARIABLES. &lt;/P&gt;&lt;P&gt;ELSE. &lt;/P&gt;&lt;P&gt;WORKFLOW_RESULT = '99999'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-STATUS = '51'. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-UNAME = SY-UNAME. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-REPID = SY-REPID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGTY = SY-MSGTY. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGID = SY-MSGID. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGNO = SY-MSGNO. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV1 = SY-MSGV1.&lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV2 = SY-MSGV2. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV3 = SY-MSGV3. &lt;/P&gt;&lt;P&gt;IDOC_STATUS-MSGV4 = SY-MSGV4. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-WF_PARAM = 'ERROR_IDOCS'. &lt;/P&gt;&lt;P&gt;RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM. &lt;/P&gt;&lt;P&gt;APPEND RETURN_VARIABLES. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;APPEND IDOC_STATUS. &lt;/P&gt;&lt;P&gt;ENDFORM. " UPDATE_IDOC_STATUS&lt;/P&gt;&lt;P&gt;Figure 5: Inbound processing example code&lt;/P&gt;&lt;P&gt;3.1.1. Debugging inbound FM&lt;/P&gt;&lt;P&gt;Use transaction WE19 to test inbound function module in debugging mode. Also use WE05 to view the IDocs and their statuses.&lt;/P&gt;&lt;P&gt;3.2. Maintain ALE attributes&lt;/P&gt;&lt;P&gt;The inbound function module needs to be linked to the message type and the message type needs to be linked to the appropriate inbound process code at the partner profile level before the scenario is enabled. These steps are described below in detail.&lt;/P&gt;&lt;P&gt;3.2.1. Link Message Type to Function Module (WE57) Client independent&lt;/P&gt;&lt;P&gt;To link a message (ZINVRV) type to a function module (Z_IDOC_INPUT_ZINVRV) follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction WE57 (ALE -&amp;gt; Extensions -&amp;gt; Inbound -&amp;gt; Allocate function module to logical message)&lt;/P&gt;&lt;P&gt;&amp;#149; Select an entry (EG. IDOC_INPUT_ORDERS) and copy&lt;/P&gt;&lt;P&gt;&amp;#149; Type in module name Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;&amp;#149; Type in basic IDoc type as ZINVRV01&lt;/P&gt;&lt;P&gt;&amp;#149; Type in message type as ZINVRV&lt;/P&gt;&lt;P&gt;&amp;#149; Type object type as IDOCINVOIC (Invoice document) - Used for workflow&lt;/P&gt;&lt;P&gt;&amp;#149; Direction should be set to 2 for inbound&lt;/P&gt;&lt;P&gt;&amp;#149; Enter and save&lt;/P&gt;&lt;P&gt;3.2.2. Define FM settings (BD51) Client independent&lt;/P&gt;&lt;P&gt;&amp;#149; Enter transaction BD51 (ALE -&amp;gt; Extensions -&amp;gt; Inbound -&amp;gt; Define settings for input modules)&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New entries&lt;/P&gt;&lt;P&gt;&amp;#149; Type in the name of the new function module Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;&amp;#149; Enter 0 for mass processing in the output column&lt;/P&gt;&lt;P&gt;&amp;#149; Save and Exit&lt;/P&gt;&lt;P&gt;3.2.3. Maintain process codes (WE42) Client dependent&lt;/P&gt;&lt;P&gt;A process code needs to be maintained on each client. It then needs to be linked to the message via the partner profiles on each client. This allows the various clients to use a unique function module for the same message type.&lt;/P&gt;&lt;P&gt;To maintain the process code follow these steps:&lt;/P&gt;&lt;P&gt;&amp;#149; Log on to the appropriate receiving system client&lt;/P&gt;&lt;P&gt;&amp;#149; Execute WE42 (ALE -&amp;gt; Extensions -&amp;gt; Inbound -&amp;gt; Maintaining process codes inbound)&lt;/P&gt;&lt;P&gt;&amp;#149; Choose Inbound with ALE service&lt;/P&gt;&lt;P&gt;&amp;#149; Choose Processing with function module&lt;/P&gt;&lt;P&gt;&amp;#149; Click on Processing with function module and choose create icon&lt;/P&gt;&lt;P&gt;&amp;#149; Click on New Entries&lt;/P&gt;&lt;P&gt;&amp;#149; Type in process code ZINR and give it a description and save&lt;/P&gt;&lt;P&gt;&amp;#149; Now you are asked to Please maintain codes added in ALE entry methods, enter and choose Z_IDOC_INPUT_FIRVSL and copy it. You should choose a FM similar to your one.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter your process code ZINR&lt;/P&gt;&lt;P&gt;&amp;#149; Enter your function module Z_IDOC_INPUT_ZINVRV&lt;/P&gt;&lt;P&gt;NOTE: The next 6 steps are used in workflow error handling. &lt;/P&gt;&lt;P&gt;&amp;#149; Enter IDPKFIDCMT in object type&lt;/P&gt;&lt;P&gt;&amp;#149; Enter MASSINPUTFINISHED in End event&lt;/P&gt;&lt;P&gt;&amp;#149; Enter IDOCINVOIC in IDoc object type&lt;/P&gt;&lt;P&gt;&amp;#149; Enter INPUTERROROCCURREDFI in IDoc start event&lt;/P&gt;&lt;P&gt;&amp;#149; Enter INPUTFINISHEDFI in IDoc End event&lt;/P&gt;&lt;P&gt;&amp;#149; Enter IDOCINVOIC in Application object type&lt;/P&gt;&lt;P&gt;You will need to determine the task associated with object IDOCINVOIC, and then assign the appropriate position to it. This position will then receive the application error messages via workflow.&lt;/P&gt;&lt;P&gt;To set up the workflow area please consult the Workflow config guide.&lt;/P&gt;&lt;P&gt;3.3. Create inbound partner profile&lt;/P&gt;&lt;P&gt;For each message type you need to maintain the inbound partner profiles.&lt;/P&gt;&lt;P&gt;3.3.1. Maintain receiving system partner profile (WE20) Client dependent&lt;/P&gt;&lt;P&gt;To maintain inbound partner profiles read the document ALE configuration procedure:&lt;/P&gt;&lt;P&gt;&amp;#149; Add the message type ZINVRV with process code ZINR.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the output mode (background, immediately) for inbound processing and NO message code.&lt;/P&gt;&lt;P&gt;&amp;#149; Enter the position S and choose the ALE administrator 50000085. This position will then receive all the technical ALE errors via workflow.&lt;/P&gt;&lt;P&gt;3.4. Test&lt;/P&gt;&lt;P&gt;Once the inbound function module has been debugged the scenario should be ready to test in its entirety. If problems occur, read through the relevant areas of this document to check your configuration or code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you,&lt;/P&gt;&lt;P&gt;If you  want me to explain more, you can give me your email id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward with points incase you are satisfied.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sushama&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2008 06:01:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-transfer-using-ale-idoc-into-xml/m-p/3481298#M836915</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-07T06:01:02Z</dc:date>
    </item>
  </channel>
</rss>

