Populating IDoc

Hi,
I have a custom IDoc with 2 same level segments, No mandatory segments are there. These two segment's max number of repetitions are 99999.
I am filling the IDocs in the following way.
I am filling the first segment in a loop after that I am filling the second segment in a nested loop of the first loop. After filling the second segment it is again going to first segment and it is filling and this process is going on until the loop ends.
I am getting the 26 syntax error in the IDoc.
My IDOC # is in the following way right now.
1st segment
2nd segment
1st segment
2nd segment
1st segment
2nd segment
Can anybody tell me, is this filling of IDoc is wrong or correct.
Thanks,
BSV.

Hi bsv,
If I understood your questino correctly, then...
Usually one header record will be having a set of item records. Lets suppose u r generating IDOC's based on a Z program which extracts some data based on a selection screen entries into (lets suppose) two internal tables (1 - header and 1 - item table).
In this scenario, you have to loop through the 1st internal table, fill header segment and loop through the 2nd internal table (nested loop) for the corresponding header record and after the nested loop, you can call the function module that generates the idoc. Now, this continues for all the header and its corresponding items and generates 'n' number of IDOC's based on entries in header table.
Hope it solves your problem.
Regards,
Phani.

Similar Messages

  • Populating Idoc number in Idoc header data

    Hello everybody,
    I want to know that is there any way exists by which we can fill the Idoc number generated in the IDOC itself i.e. we are generating IDOC from EDIDD and EDIDC tables and I have a requirement to populate IDOC number(which will be generated after the IDOC will be created) in one of the IDOC's segment. From my end I have no clue on this because we are trying to use the value (IDOC number) before it is being generated and hence help needed on this.
    Regards,
    Harsh.

    Hi Harsh,
    you can get your idoc number from the master_idoc_data table genretated by FM 'MASTER_IDOC_DISTRIBUTE'.
    edidc-docnum is your desired thing. you can pass this field in other segment.
    Regards,
    Pranay

  • Plz help on  populating  idoc extention invoic02

    I have extenden the invoic02 idoc with the segmenta zfaktura as a child segmet for E1EDKA1
    The name of the extention is ZINVOIC02_EXTENTION
    I want the segment to apear only once based on the condition of partner function
    , but it appears each time the segment  E1EDKA1 which in this case appears 5 times.
    When I try to populate the new fields .
    Any help would do
    Thanks.
    This is the code I am using in the user exit ‘001’. Enhancement LVEDF001.
    TABLES : KNA1 , MARA , EQUI , E1EDK01 , ZFAKTURA.
    CHECK control_record_out-mestyp EQ 'INVOIC'.
    CHECK int_edidd-segnam EQ 'E1EDKA1'.
    LOOP AT int_edidd.
    CASE int_edidd-segnam.
    WHEN ' E1EDKA1'.
    control_record_out-cimtyp = 'ZINVOIC02_EXTENTION'.
    MOVE int_edidd-SDATA TO E1EDKA1.
    If E1EDKA1- PARVW eq ‘RE’
    clear int_edidd.
    Select from equi.
    ZFAKTURA-equnr = equi-equnr.
    ZFAKTURA-eqart = equi-eqart.
    Select from KNA1
    ZFAKTURA-EAN11 = KNA1-EAN11
    int_edidd-segnam = 'ZFAKTURA'.
    int_edidd-sdata = ZFAKTURA.
    append int_edidd.
    CLEAR  E1EDKA1
    Endif.
    ENDCASE.
    ENDLOOP.

    answered

  • Populating idoc with data

    Hi,
    i am trying to send invoice idoc to destination . Can anyone please tell me how to populate the basic idoc type invoice02 with data ? Is there an sap standard program i need to use ?? I am using ALE to send my idoc .
    Thank you

    Hi Alisha
    where are you trying to trigger the idoc from?if you are triggering it from a transaction,you should define a output type for that transaction.
    there are various other things you need to take care of while sending an idoc from origin to destination.
    1.RFC Destination of receiver-define in SM58
    2.port definition-attaching the rfc destination to the outgoing R/3 port in WE21
    3.partner profiles-outbound parameters for the idoc like the port,type,message type etc. in WE20
    here under the message control u have to specify parameters like application,msg type and process code.this process code will link to a FM..IDOC_OUTPUT_INVOIC which consists of the code to populate the idoc.
    4.attaching the basic idoc type to a message type in WE82
    so as soon as u save the txn...the output control will trigger the FM and the idoc will be generated.if the control data like partner profiles,port definitions are set correctly the idoc will reach the destination as desired.
    hope this helps.

  • XI Outbound IDoc different from SAP R/3 Inbound Idoc

    Hi,
    I am having a problem in processing an IDoc from XI to SAP.
    We have created a custom IDoc, which will be populated in XI and then sent through to SAP R/3, which will then process the information in the IDoc.
    I have imported the IDoc into XI and have been able to do the mappings and populate the IDoc from the XI side of things.  If I check the IDoc adapter, the populated IDoc leaves XI with the correct information and with multiple segments.
    If I now go and check the IDoc that has arrived in SAP R/3, it only contains the first segment.  The other segments that were populated in the IDoc that left XI are now not there.  Also some of the information that was in the IDoc leaving XI is different to the information in the IDoc that has arrived in XI.
    I do not experience the same problem when I populate a standard SAP IDoc.
    Has anyone experienced this problem with a custom IDoc before?
    Thanks,
    Miguel

    Hi Vishnu,
    This is the XML file coming out of XI:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ZOEM01>
    - <IDOC BEGIN="">
    - <ZOEM SEGMENT="1">
      <RCVPRN>TSYSTEM</RCVPRN>
      <VTRNR>5500015146</VTRNR>
      <BSTDK>20050305</BSTDK>
      <LABNK>00038</LABNK>
      <IDNKD>FHA5930-A</IDNKD>
      <VRKME>EA</VRKME>
      <KWERK>4601</KWERK>
      <DFABL />
      <BELNR>80084023</BELNR>
      <VEMNG>0000000090</VEMNG>
    - <ZOEM1 SEGMENT="2">
      <EDATUV>20050305</EDATUV>
      <EDATUB>20050305</EDATUB>
      <WMENG>000000000000000</WMENG>
      <FZABR>0000005270</FZABR>
      </ZOEM1>
    - <ZOEM1 SEGMENT="3">
      <EDATUV>20050307</EDATUV>
      <EDATUB>20050307</EDATUB>
      <WMENG>000000000000260</WMENG>
      <FZABR>0000005530</FZABR>
      </ZOEM1>
      </ZOEM>
      </IDOC>
      </ZOEM01>
    Thanks very much for your help,
    Miguel

  • Adding field in standard IDOC Segment E1EDL24

    Hello Friends,
    I have an urgent requirement that I have to extend IDOC segment E1EDL24 with two fields PABNR and LFSNR.
    When I tries to change the segment in WE31, it shows an error message that you can only modify the segments of customer namespace and cannot modify Standard IDOC Segments.
    Can we modify the standard IDOC segments, and if yes, how can we modify the standard IDOC segments. Please clarify.
    Points will be rewarded generously.
    Regards,
    Navin

    Hi Naveen,
    We cannot Modify the Standard segments. But we have to Create a new Segment and Add these fields.
    Then Create an Extended Idoc type
    Implement User Exits in Outbound And Inbound ..
    This is the Complete Steps and Info on this...with an Example...
    Enhancing ALE
    For example, if in an outbound interface you find that the IDOC type does not contain all the data you need to pass to the other system, you can extend the IDOC to accommodate the additional fields and enhance the ALE function modules to populate the fields. Similarly, if in an inbound interface, there is additional data that needs to be posted to the R/3 application, you can extend the IDOC type to have additional fields populated by the external system or translator or the other R/3 system and then enhance the inbound ALE function modules to post the additional data to the R/3 application.
    let us use the SAP Customer Master application as an example. Specifically, letâs focus on the IDOC extension and ALE function module enhancement of IDOC type DEBMAS02 and message type DEBMAS (Customer Master) and the IDOC reduction of message type MATMAS.
    IDOC EXTENSIONS
    Letâs first look at the concept of IDOC extension. SAP delivers Basic IDOC types such as DEBMAS02, MATMAS02, ORDERS02, and WMMBID01. By extending the Basic IDOC type, you are actually creating a new IDOC type. You create a new segment with the additional fields. This new segment has to be associated with one of the existing Basic IDOC segments. Then you create a new extension type, which is associated with the Basic IDOC type. This results in a new IDOC type. In order for ALE function modules to relate to this new IDOC type, the IDOC type is linked to the corresponding message type.
    Note that you should not add fields to existing segments but should create a new segment and associate it with an existing segment. This, in a nutshell, is the process of creating IDOC extensions.
    In our example, the Basic IDOC type DEBMAS02 is used to communicate Customer Master data to the SAP Customer Master application. Even though the application has a screen to enter and store a contact personâs business address (see Figure 1), DEBMAS02 does not have a segment or fields that communicate the contact personâs business address. If your business requires that this business address be communicated to the other system through the ALE interface for Customer Master, then you have to extend the DEBMAS02 IDOC type, and enhance the corresponding ALE function module.
    In DEBMAS02 the contact person fields are present in segment E1KNVKM and the business address of the contact person is stored on the SADR SAP table. You need to create a new segment, Z1SADRX, that is associated with E1KNVKM. This will be done in the process of creating an extension type ZDEBMASX. This extension type will then be associated with a new IDOC type, ZDEBMASZ. IDOC type ZDEBMASZ will be linked to message type DEBMAS for Customer Master. The final step in the IDOC extension process is to check the new objects. This check also verifies the structural integrity of the IDOC type. Letâs look at each of these steps in more detail.
    1. Create an Extension Type and a New Segment.
    Determine the fields on table SADR that you are going to provide for in the new segment Z1SADRX. You need fields for name, street, city, region, and country to give the business address of the contact person. You also need fields for the address number. ADRNR is a field in SAP tables such as SADR that uniquely identifies the address of an entity. This field is cross-referenced from other tables to the SADR table to obtain the full description of the address. Because this is an IDOC type for master data, the first field of the new segment will be MSGFN. The message function field informs the receiving system of the action to be taken for that particular segment. In the code that you write for populating the new segment, the value of the message function is the same as that of the parent segment E1KNVKM. In all, you will have 12 fields in segment Z1SADRX (see Table 1).
    To create an extension type and new segment:
    • Use transaction WE30 or from WEDI go to Development -> IDOC types.
    • Enter ZDEBMASX for Object Name.
    • Choose Extension Type.
    • Click on Create.
    • You will see a pop-up screen. Choose Create New, and enter a description. For version 4.x, enter DEBMAS02 in the Linked Basic Type field. Enter.
    • You will see a screen with ZDEBMASX and its description in the first line. Click on this line, and press Create. For version 4.x, expand the tree of segments, and place the cursor on E1KNVKM.
    • You will see a pop-up screen. Enter E1KNVKM as the reference segment. Enter.
    • For 4.x, press Create after placing the cursor on segment E1KNVKM.
    • You will see a line appear with E1KNVKM hierarchically below ZDEBMASX, with a description "Customer Master contact person (KNVK)."
    • Click on this line and press Create. You will receive a message indicating that the new segment being created will be a child segment of E1KNVKM. Enter. A pop-up box appears for the new segment.
    • Enter Z1SADRX as the segment type, 1 for Minimum, 1 for Maximum. Leave Mandatory segment unchecked. These entries imply that there is only one Z1SADRX segment for every occurrence of the E1KNVKM segment, and also that this segment is not mandatory. Note that if the parent segment is not mandatory, then the child segment should not be mandatory, because this could result in a syntax error during the creation or processing of the IDOC.
    • For 4.x, you must first create the IDOC segment Z1SADRX (Iâll explain why in a moment) from the menu path WEDI -> IDOC -> Development -> IDOC Segment.
    • Click on Segment Editor.
    • On the next screen, click on Create.
    • Enter a development class for the object. Enter.
    • This will take you to the screen for segment definition. Enter a description for the segment. Enter the field name, data element, and the data element documentation name. In most cases, all three fields may have the same values. If you are using a field in the segment that is not present in the ABAP/4 data dictionary, you must first create the domain, data element, field, and appropriate documentation before using it in the new segment.
    • Enter these three columns for all 12 fields. Save.
    • Click on Generate/Activate, F3 to step back.
    • From screen Maintain Segment, go to Segment Type -> Release. A checkbox now appears beside the segment definition Z1SADRX (see Figure 2). Check this box. Save.
    • Save again to store the descriptions of the segment, F3 to step back.
    • Save the extension type.
    It is possible to have several new segments with relevant Basic IDOC type parent segments in a single extension type. However, you can form only one IDOC type based on a single extension type.
    2. Create an IDOC Type.
    The next step is to create an IDOC type by associating the extension type that you created with the Basic IDOC type. This is a simple process:
    • From transaction WE30 or WEDI go to Development -> IDOC Types.
    • Enter ZDEBMASZ for Object Name.
    • Click on IDOC Type.
    • Click on Create.
    • Enter DEBMAS02 for Basic IDOC type.
    • Enter ZDEBMASX for extension type.
    • Enter a description.
    • Enter.
    • You will see a display of the composite IDOC type with all segments, including Z1SADRX (see Figure 3).
    It is possible to associate only one extension type with a Basic IDOC type for a given IDOC type. However, you can have multiple new segments in an extension type.
    3. Link IDOC Type to Message Type.
    The next step is to link the new IDOC type to its corresponding message type. This is important, because this relationship is referenced in the partner profile parameters where you specify the message type and IDOC type to be used for that particular representative system. To link the message type:
    • Use transaction WE82, or from WE30, go to Environment -> IDOC Type / Message Type, or from WEDI go to Development -> IDOC Type -> Environment Î IDOC Type / Message Type.
    • Click on Display <-> Change.
    • Click on New Entries.
    • Enter DEBMAS for message type.
    • Enter DEBMAS02 for Basic IDOC type.
    • Enter ZDEBMASX for extension type.
    • Enter your SAP R/3 release number for Release.
    • Save.
    This data is stored on the EDIMSG table and is accessed by several ALE processes to relate the message type to the IDOC type.
    4. Check the IDOC Type.
    Before checking the IDOC type for consistency, it is important to perform another step that releases the extension type to the IDOC type:
    • From WEDI go to Development -> IDOC Types -> Extras -> Release Type, or from transaction WE30 go to Extras -> Release Type.
    • For the Object Name ZDEBMASX and radio button Extension Type, click Yes.
    • The extension type has now been "released."
    You canât edit the extension type once itâs released. To cancel the release for further editing or deactivation, go to WE30 Î Extras Î Cancel release. The final step in the IDOC extension process is checking the validity of the IDOC type:
    • From transaction WE30 or WEDI go to Development -> IDOC types.
    • Enter ZDEBMASX for Object name.
    • Click on Extension Type.
    • From the Development Object menu select Check.
    • Repeat the operation for IDOC type ZDEBMASZ.
    • A check log will be generated for each run with details of correctness or errors (see Figure 4).
    In some situations it is possible to receive errors during the check process, especially segment length errors. The incorrect IDOC segment can be repaired and corrected by executing program RSEREPSG. This program checks the formal consistency and repairs incorrect segments. In test mode it will generate a log of formal correctness for the specified segment only. For the program to repair segments in normal mode, the underlying IDOC structures (DDIC structures) must be active. This program rectifies the lengths of the DDIC structures and not the fields themselves. RSEREPSG can also be used to change the person responsible for the object and the release flag.
    Menu paths may vary slightly depending on the release/version of SAP R/3, but the procedures and the principles are the same.
    ALE FUNCTION MODULE ENHANCEMENTS
    Having extended the IDOC type to contain additional fields for an inbound or outbound application, you now want to enhance ALE function modules for populating the additional segment on the outbound or applying the additional segment data on the inbound application.
    The core working code for ALE processes for a given application area is always encapsulated in ABAP/4 function modules. These function modules are associated with such control information as message types and process codes. So the ALE process checks this control information and derives the name of the function module to invoke for that particular IDOC processing from certain database tables. These function modules contain objects known as customer functions, which can be considered SAP Enhanced user exits. A function module is called at a particular point during the processing of the main program or function module, and it can be used to influence data processing at that point by adding code to the customer function. The customer function behaves like a normal function module and has import and export parameters, tables (internal tables) statement, and exception processing. Unlike a conventional user exit, customer functions give you the ability to modify only data available to you by the function moduleâs parameters and internal tables. While most ALE/EDI function modules are supported by customer functions, there are ALE/EDI processes that still use conventional user exits. There are a few ways to determine which function module to enhance for a given message type/process code:
    • For master data distribution, from SALE go to Extensions -> Master data distribution -> Setup additional data for message types. Search for message type DEBMAS in this example. You see an entry for DEBMAS associated with function module MASTERIDOC_CREATE_SMD_DEBMAS. This data is stored on table TBDME. The function module names for all master data message types follow this pattern: MASTERIDOC_CREATE_SMD_messagetype. This function module calls another function module of name MASTERIDOC_CREATE_DEBMAS or MASTERIDOC_CREATE_messagetype. Search for the words customer function, and you find several hits that can be used to add code to the function module.
    • From WEDI got to Control -> Inbound process codes -> Inbound with ALE service -> Processing by function module (transaction WE42), or from WEDI go to Control -> Outbound process codes -> Outbound with ALE service -> With function module (transaction WE41). There will be function modules associated with the process codes. For inbound, the function modules usually follow this pattern: IDOC_INPUT_messagetype: for example, IDOC_INPUT_CHRMAS for inbound characteristics master.
    • Use transaction WE57 or from WEDI go to Development -> Message/Application Object. The entries list the function module, Business Object, message type, and IDOC type that are used for inbound ALE/EDI interfaces.
    Customer functions are not specific only to ALE and EDI but also to all programs/modules in SAP R/3. Customer function is a SAP enhancement component; the other two types are menu and screen enhancements.
    All customer function exits are maintained in SAP enhancements and are found by using transaction SMOD. After executing transaction SMOD, pull down (F4) on the enhancement name field, and execute again. This provides you with a list of all SAP enhancements available. SAP enhancements are grouped by development class pertaining to an application area. Choose Application development R/3 SD master data distribution for development class VSV to lead to a screen that lists VSV00001 as an enhancement (see Figure 5). Press Component +/- to display its function exit components. There are four possible components listed, all of which are function exits (and are function modules) that are called from the ALE function modules in the form Call Customer Function Î001â. This is a special occurrence of the ABAP statement Call. Go to item Exit_SAPLVV01_ 001, which you need to enhance for the Customer Master outbound example of an IDOC extension. In the ALE-function module MASTERIDOC_CREATE_DEBMAS, the statement CALL Customer Function 001 is translated in the background to call component EXIT_SAPLVV01_001. Although this function exit can be edited using transaction SE37, you will use a simpler approach.
    When you use SAP enhancements and their components, you manage them with an SAP object known as a project, which is like an envelope containing the selected enhancements and their components. A project can be used to control the execution of components and to transport them to other clients and instances in SAP. Basically, the process involves creating a project, including enhancements and components that are to be enhanced, editing the components, and then activating the project. The following process creates a project for our example Customer Master IDOC extension:
    • Execute transaction CMOD.
    • Enter name of project, say CSTMAST1.
    • Click on Create.
    • Enter a description of the project.
    • Save.
    • Click on SAP Enhancements.
    • Enter VSV00001 for Enhancement.
    • Save.
    Once youâve created the project, edit the function exit components and activate the project. Remember that the code in the function exit enhancement will execute only if the project is activated. In fact, this is a convenient SAP enhancements feature, whereby the work in progress (developing code in the customer function) will not affect users of that application. When the code is completed, the project can be activated so the enhanced functionality takes effect. It can also be deactivated for maintenance.
    As mentioned earlier, customer functions (function exits) are embedded in ALE function modules and can be used to influence the creation and modification of IDOC data on an outbound application or to post additional or modified IDOC data to an inbound R/3 application. Function exits are similar to regular function modules, with import/export parameters, tables (internal tables), and exceptions.
    The two important factors to consider while developing the customer function are:
    1. The point in the ALE function module where the function exit occurs
    2. The data made available by the customer function that can be modified or posted to the R/3 application, based on the direction.
    Because some function modules have several customer functions, it is critical to choose the function exit best suited for that particular enhancement. Do not attempt to perform activities that the function exit is not designed for. The importance of this point is illustrated by the following description of enhancing function modules for outbound and inbound ALE interfaces.
    Outbound interfaces. In an outbound ALE interface you use function exits (customer functions) to populate additional segments created by an IDOC extension or to modify the existing IDOC data segments as per business requirements. Previously, you identified that enhancement VSV00001 has a component EXIT_SAPLVV01_001 (function exit), which can be used for populating the additional data segment Z1SADRX that you created in the IDOC extension ZDEBMASX (IDOC type ZDEBMASZ, based on Basic IDOC type DEBMAS02). You also learned that the ALE function module that calls this function exit is MASTERIDOC_CREATE_DEBMAS, which has a statement Call Customer Function 001.
    Browse the function module MASTERIDOC_CREATE_DEBMAS using transaction SE37. You will find that this customer function is invoked for every segment of IDOC type DEBMAS02. In fact, the function exit is called soon after the creation of an existing segment has been populated with data and appended to the IDOC data table (internal table). Also, the function exit is exporting the message type, IDOC type, and the segment name and is importing the IDOC extension type. It is also passing the IDOC data internal table. This indicates that the ALE function module is allowing you to populate additional segments for every existing segment and modify the existing segmentâs data.
    Letâs write ABAP/4 code to accomplish the task of populating IDOC segment Z1SADRX with a contact personâs business address:
    • From SE37, display function module MASTERIDOC_CREATE_ DEBMAS.
    • Find Customer Function 001.
    • Double-click on 001.
    • The function EXIT_SAPLVV01_001 will be displayed.
    • Double-click on INCLUDE ZXVSVU01.
    • You will be asked to create a new include object. Proceed as desired.
    • Enter code (as in Listing 1).
    • Be sure to perform a main program check (Function Module -> Check -> main program) and extended program check (Function module -> Check -> Extended check).
    Now that you have extended the IDOC and enhanced the ALE function module based on the requirements for the contact personâs business address on the Customer Master, letâs test the interface. You should create a logical system and define a port for this interface. You should also configure the Customer Distribution Model to indicate that message type DEBMAS is being distributed to this logical system. The only difference in configuration between a regular outbound ALE interface and an enhanced one is the partner profile definition. While maintaining the outbound parameters of the partner profile, make sure the IDOC type is ZDEBMASZ. The fields for Basic IDOC type and extension type are automatically populated with DEBMAS02 and ZDEBMASX, respectively.
    To maintain the contact personâs business address of a customer:
    • Use transaction BD12 or from BALE go to Master Data ->Customer -> Send and send that Customer Master record by executing the transaction after filling in the relevant fields such as customer number, message type, and logical system.
    • Use transaction WE02 or WE05 to verify the IDOC created. You should see the new segment Z1SADRX populated with the correct data.
    With SAP releases below 4.5B, you cannot capture changes to business address through change pointers because a change document object is not available for capturing business address changes, and also earlier releases have not been configured to write change documents for a contact personâs business address. If you would like this functionality, you can either create change document objects, generate function modules to create change documents, and perform ALE configuration to tie it in, or make a cosmetic change to the contact person screen data while changing the contact personâs business address so that it gets captured as a change to the Customer Master. Subsequently, the ALE enhancement that you performed captures the contact personâs business address.
    Inbound interfaces. The process for enhancing inbound ALE interfaces is similar for outbound, with a few exceptions; specifically in the coding of customer functions (function exits) for the ALE/EDI function modules.
    The first step is to create an IDOC extension for the specific Basic IDOC type by adding new segments at the appropriate hierarchy level: that is, associated to the relevant existing segment. Populate the data fields on the new segments with application data by the translator or external system/program before importing them into the R/3 System. Then, find the ALE function module that is invoked by the inbound processing. By browsing through the code or reading the documentation on the function exit enhancements using the SMOD transaction, identify the function exit in which you should place your code. The technique used in the code to post the additional or modified IDOC data to the application can vary based on the application rules and requirements, the data available at that point in processing, and the application function modules available to update the application tables. It is important to search first for application modules that process the data and see if they can be called within the function exit. If the additional data in the extended segments in specific to a custom table or resides in nonkey fields of a single or small set of tables, you may be able to update it directly by SQL statements in the function exit. This approach should be carefully evaluated and is certainly not highly recommended.
    Another option is to use Call Transaction from within the function exit to process the additional data. For example, in the case of message type WMMBXY for inbound goods movements from a warehouse management system, the standard interface creates batches for materials, but does not update its characteristics. In such a case, you can use Call Transaction MSC1 to create the batch and assign characteristic values to it from within the function exit provided.
    Error handling is a very important consideration when making enhancements to inbound ALE/EDI objects. In ALE and EDI inbound processing, workflow is used for handling errors at different levels such as technical and application. If workflow has been configured for the interface, the error messages and workflow items flow to the inbox of the named recipient(s).
    It is also critical to enhance the workflow that handles notifications of the inbound ALE/EDI process. In most scenarios this is not a very difficult task because SAP lets you influence the workflow parameters and messages in function exits (customer functions). You typically do this using flags and message codes to trigger certain workflow actions. If you conform to the status codes and flags stipulated for workflow processing, the enhancement could be error-free and seamless. In the case of an inbound IDOC with an extension, you should populate the EDIDC fields IDOCTYP (new IDOC type) and CIMTYP (extension type) accordingly.
    Reward if Helpful

  • Regarding IDOC Extension

    Hi Experts,
    I need to Extend IDOC <b>COND_A03</b> with 5 Custom feilds. This Idoc will be populating 10 tables like A932,A933,A34,A35,A36,A37....,.I need to extend in
    <b>IDOC_INPUT_COND_A</b> through exit CALL CUSTOMER FUNCTION '002'.
    Here the 3 feilds will be present in A932 table and there will be only 4 feilds in A933 table and 3 feilds will be present in A934 table and so on. I..e all the 5 custom  feilds will not be present in all the tables.
    How i need to build the logic so that when the data comes to that function module i need to populate only 3 feilds into A932 table and 4 feilds into A933 table and so on..
    How do i need to build the logic.., to post the data when the number  of fields differ from one table to the other.

    ALE FUNCTION MODULE ENHANCEMENTS
    Having extended the IDOC type to contain additional fields for an inbound or outbound application, you now want to enhance ALE function modules for populating the additional segment on the outbound or applying the additional segment data on the inbound application.
    The core working code for ALE processes for a given application area is always encapsulated in ABAP/4 function modules. These function modules are associated with such control information as message types and process codes. So the ALE process checks this control information and derives the name of the function module to invoke for that particular IDOC processing from certain database tables. These function modules contain objects known as customer functions, which can be considered SAP Enhanced user exits. A function module is called at a particular point during the processing of the main program or function module, and it can be used to influence data processing at that point by adding code to the customer function. The customer function behaves like a normal function module and has import and export parameters, tables (internal tables) statement, and exception processing. Unlike a conventional user exit, customer functions give you the ability to modify only data available to you by the function moduleâs parameters and internal tables. While most ALE/EDI function modules are supported by customer functions, there are ALE/EDI processes that still use conventional user exits. There are a few ways to determine which function module to enhance for a given message type/process code:
    • For master data distribution, from SALE go to Extensions -> Master data distribution -> Setup additional data for message types. Search for message type DEBMAS in this example. You see an entry for DEBMAS associated with function module MASTERIDOC_CREATE_SMD_DEBMAS. This data is stored on table TBDME. The function module names for all master data message types follow this pattern: MASTERIDOC_CREATE_SMD_messagetype. This function module calls another function module of name MASTERIDOC_CREATE_DEBMAS or MASTERIDOC_CREATE_messagetype. Search for the words customer function, and you find several hits that can be used to add code to the function module.
    • From WEDI got to Control -> Inbound process codes -> Inbound with ALE service -> Processing by function module (transaction WE42), or from WEDI go to Control -> Outbound process codes -> Outbound with ALE service -> With function module (transaction WE41). There will be function modules associated with the process codes. For inbound, the function modules usually follow this pattern: IDOC_INPUT_messagetype: for example, IDOC_INPUT_CHRMAS for inbound characteristics master.
    • Use transaction WE57 or from WEDI go to Development -> Message/Application Object. The entries list the function module, Business Object, message type, and IDOC type that are used for inbound ALE/EDI interfaces.
    Customer functions are not specific only to ALE and EDI but also to all programs/modules in SAP R/3. Customer function is a SAP enhancement component; the other two types are menu and screen enhancements.
    All customer function exits are maintained in SAP enhancements and are found by using transaction SMOD. After executing transaction SMOD, pull down (F4) on the enhancement name field, and execute again. This provides you with a list of all SAP enhancements available. SAP enhancements are grouped by development class pertaining to an application area. Choose Application development R/3 SD master data distribution for development class VSV to lead to a screen that lists VSV00001 as an enhancement (see Figure 5). Press Component +/- to display its function exit components. There are four possible components listed, all of which are function exits (and are function modules) that are called from the ALE function modules in the form Call Customer Function Î001â. This is a special occurrence of the ABAP statement Call. Go to item Exit_SAPLVV01_ 001, which you need to enhance for the Customer Master outbound example of an IDOC extension. In the ALE-function module MASTERIDOC_CREATE_DEBMAS, the statement CALL Customer Function 001 is translated in the background to call component EXIT_SAPLVV01_001. Although this function exit can be edited using transaction SE37, you will use a simpler approach.
    When you use SAP enhancements and their components, you manage them with an SAP object known as a project, which is like an envelope containing the selected enhancements and their components. A project can be used to control the execution of components and to transport them to other clients and instances in SAP. Basically, the process involves creating a project, including enhancements and components that are to be enhanced, editing the components, and then activating the project. The following process creates a project for our example Customer Master IDOC extension:
    • Execute transaction CMOD.
    • Enter name of project, say CSTMAST1.
    • Click on Create.
    • Enter a description of the project.
    • Save.
    • Click on SAP Enhancements.
    • Enter VSV00001 for Enhancement.
    • Save.
    Once youâve created the project, edit the function exit components and activate the project. Remember that the code in the function exit enhancement will execute only if the project is activated. In fact, this is a convenient SAP enhancements feature, whereby the work in progress (developing code in the customer function) will not affect users of that application. When the code is completed, the project can be activated so the enhanced functionality takes effect. It can also be deactivated for maintenance.
    As mentioned earlier, customer functions (function exits) are embedded in ALE function modules and can be used to influence the creation and modification of IDOC data on an outbound application or to post additional or modified IDOC data to an inbound R/3 application. Function exits are similar to regular function modules, with import/export parameters, tables (internal tables), and exceptions.
    The two important factors to consider while developing the customer function are:
    1. The point in the ALE function module where the function exit occurs
    2. The data made available by the customer function that can be modified or posted to the R/3 application, based on the direction.
    Because some function modules have several customer functions, it is critical to choose the function exit best suited for that particular enhancement. Do not attempt to perform activities that the function exit is not designed for. The importance of this point is illustrated by the following description of enhancing function modules for outbound and inbound ALE interfaces.
    Outbound interfaces. In an outbound ALE interface you use function exits (customer functions) to populate additional segments created by an IDOC extension or to modify the existing IDOC data segments as per business requirements. Previously, you identified that enhancement VSV00001 has a component EXIT_SAPLVV01_001 (function exit), which can be used for populating the additional data segment Z1SADRX that you created in the IDOC extension ZDEBMASX (IDOC type ZDEBMASZ, based on Basic IDOC type DEBMAS02). You also learned that the ALE function module that calls this function exit is MASTERIDOC_CREATE_DEBMAS, which has a statement Call Customer Function 001.
    Browse the function module MASTERIDOC_CREATE_DEBMAS using transaction SE37. You will find that this customer function is invoked for every segment of IDOC type DEBMAS02. In fact, the function exit is called soon after the creation of an existing segment has been populated with data and appended to the IDOC data table (internal table). Also, the function exit is exporting the message type, IDOC type, and the segment name and is importing the IDOC extension type. It is also passing the IDOC data internal table. This indicates that the ALE function module is allowing you to populate additional segments for every existing segment and modify the existing segmentâs data.
    Letâs write ABAP/4 code to accomplish the task of populating IDOC segment Z1SADRX with a contact personâs business address:
    • From SE37, display function module MASTERIDOC_CREATE_ DEBMAS.
    • Find Customer Function 001.
    • Double-click on 001.
    • The function EXIT_SAPLVV01_001 will be displayed.
    • Double-click on INCLUDE ZXVSVU01.
    • You will be asked to create a new include object. Proceed as desired.
    • Enter code (as in Listing 1).
    • Be sure to perform a main program check (Function Module -> Check -> main program) and extended program check (Function module -> Check -> Extended check).
    Now that you have extended the IDOC and enhanced the ALE function module based on the requirements for the contact personâs business address on the Customer Master, letâs test the interface. You should create a logical system and define a port for this interface. You should also configure the Customer Distribution Model to indicate that message type DEBMAS is being distributed to this logical system. The only difference in configuration between a regular outbound ALE interface and an enhanced one is the partner profile definition. While maintaining the outbound parameters of the partner profile, make sure the IDOC type is ZDEBMASZ. The fields for Basic IDOC type and extension type are automatically populated with DEBMAS02 and ZDEBMASX, respectively.
    To maintain the contact personâs business address of a customer:
    • Use transaction BD12 or from BALE go to Master Data ->Customer -> Send and send that Customer Master record by executing the transaction after filling in the relevant fields such as customer number, message type, and logical system.
    • Use transaction WE02 or WE05 to verify the IDOC created. You should see the new segment Z1SADRX populated with the correct data.
    With SAP releases below 4.5B, you cannot capture changes to business address through change pointers because a change document object is not available for capturing business address changes, and also earlier releases have not been configured to write change documents for a contact personâs business address. If you would like this functionality, you can either create change document objects, generate function modules to create change documents, and perform ALE configuration to tie it in, or make a cosmetic change to the contact person screen data while changing the contact personâs business address so that it gets captured as a change to the Customer Master. Subsequently, the ALE enhancement that you performed captures the contact personâs business address.
    Inbound interfaces. The process for enhancing inbound ALE interfaces is similar for outbound, with a few exceptions; specifically in the coding of customer functions (function exits) for the ALE/EDI function modules.
    The first step is to create an IDOC extension for the specific Basic IDOC type by adding new segments at the appropriate hierarchy level: that is, associated to the relevant existing segment. Populate the data fields on the new segments with application data by the translator or external system/program before importing them into the R/3 System. Then, find the ALE function module that is invoked by the inbound processing. By browsing through the code or reading the documentation on the function exit enhancements using the SMOD transaction, identify the function exit in which you should place your code. The technique used in the code to post the additional or modified IDOC data to the application can vary based on the application rules and requirements, the data available at that point in processing, and the application function modules available to update the application tables. It is important to search first for application modules that process the data and see if they can be called within the function exit. If the additional data in the extended segments in specific to a custom table or resides in nonkey fields of a single or small set of tables, you may be able to update it directly by SQL statements in the function exit. This approach should be carefully evaluated and is certainly not highly recommended.
    Another option is to use Call Transaction from within the function exit to process the additional data. For example, in the case of message type WMMBXY for inbound goods movements from a warehouse management system, the standard interface creates batches for materials, but does not update its characteristics. In such a case, you can use Call Transaction MSC1 to create the batch and assign characteristic values to it from within the function exit provided.
    regards,
    srinivas
    *reward for useful answers*</b>

  • Provide me some IDOC related docs.

    I want to learn IDoc. Can any boddy sent me material that guide me to create IDocs, and also clear concept related to idocs

    Hi Dilip,
    Just go through this and learn whatever you want....
    <b>
    ALE/ IDOC</b>
    http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b835943d711d1893e0000e8323c4f/content.htm
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/SDEDI/SDEDI.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDISC/CAEDISCAP_STC.pdf
    http://edocs.bea.com/elink/adapter/r3/userhtm/ale.htm#1008419
    http://www.netweaverguru.com/EDI/HTML/IDocBook.htm
    http://www.sapgenie.com/sapedi/index.htm
    http://www.sappoint.com/abap/ale.pdf
    http://www.sappoint.com/abap/ale2.pdf
    http://www.sapgenie.com/sapedi/idoc_abap.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/0b/2a60bb507d11d18ee90000e8366fc2/frameset.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/78/217da751ce11d189570000e829fbbd/frameset.htm
    http://www.allsaplinks.com/idoc_sample.html
    http://www.sappoint.com/abap.html
    http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b835943d711d1893e0000e8323c4f/content.htm
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://edocs.bea.com/elink/adapter/r3/userhtm/ale.htm#1008419
    http://www.netweaverguru.com/EDI/HTML/IDocBook.htm
    http://www.sapgenie.com/sapedi/index.htm
    http://www.allsaplinks.com/idoc_sample.html
    <b>
    ALE/ IDOC/ XML</b>
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://www.thespot4sap.com/Articles/SAP_XML_Business_Integration.asp
    http://help.sap.com/saphelp_srm30/helpdata/en/72/0fe1385bed2815e10000000a114084/content.htm
    <b>EDI</b>
    http://www.netweaverguru.com/EDI/HTML/IDocBook.htm
    http://www.sapgenie.com/sapedi/idoc_abap.htm
    http://www.onestopsap.com/interview-Question/edi/
    http://www.intelligententerprise.com/channels/applications/feature/archive/kasturi2.jhtml
    http://www.sapgenie.com/sapgenie/docs/i830v3020.xls
    http://help.sap.com/saphelp_46c/helpdata/en/0b/2a655d507d11d18ee90000e8366fc2/frameset.htm
    http://www.hud.gov/offices/hsg/comp/edi/0306sec1.cfm
    http://www.sapgenie.com/sapedi/index.htm
    http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b835943d711d1893e0000e8323c4f/content.htm
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://edocs.bea.com/elink/adapter/r3/userhtm/ale.htm#1008419
    http://www.sapgenie.com/sapedi/index.htm
    http://www.allsaplinks.com/idoc_sample.html
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://www.sapgenie.com/sapedi/idoc_abap.htm
    http://help.sap.com/saphelp_erp2004/helpdata/en/0b/2a60bb507d11d18ee90000e8366fc2/frameset.htm
    http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b828943d711d1893e0000e8323c4f/frameset.htm
    http://www.sapgenie.com/ale/whitepaper.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDALEIO/BCMIDALEIO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDALEPRO/BCMIDALEPRO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFAALEQS/CABFAALEQS.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDISC/CAEDISCAP_STC.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDI/CAEDI.pdf
    <b>Check this IDoc online document:</b>
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDISC/CAEDISCAP_STC.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDI/CAEDI.pdf
    <b>Also check this links for additional information:</b>
    http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b835943d711d1893e0000e8323c4f/content.htm
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://edocs.bea.com/elink/adapter/r3/userhtm/ale.htm#1008419
    http://www.netweaverguru.com/EDI/HTML/IDocBook.htm
    http://www.sapgenie.com/sapedi/index.htm
    <b>For IDOC Convertion:</b>
    /people/kevin.wilson2/blog/2005/12/07/changing-fields-in-an-idoc-segment
    <b>For Idoc Processing:</b>
    http://www.sapgenie.com/sapedi/idoc_abap.htm
    The procedure to start configuration, populating idoc and then sending is ....
    1. Define Logical System and Assign Logical System
    TCODE sale
    2. Define RFC
    TCODE sm59
    3. Define Port
    TCODE we21
    4. Define Partner Profile
    TCODE we20
    5. Define Distribution Model
    TCODE bd64
    6. Send Data
    TCODE bd10
    7. Get Data
    TCODE bd11
    8. IDoc List
    TCODE we02
    Hope this will guide you to start working on it..
    Regards,
    Abhy
    PN: Let us know if the information was helpful....
    Message was edited by: Abhy Thomas

  • About Orders05 outbound Idoc.

    Hi,
    I am using an outbound idoc of basic type Orders05 with an extension of the idoc header segment.This outbound idoc will get triggered once a PO is saved and sent through EDI.
    I have to do an enhancement wherein I have to populate the mode of transport field(EXPVZ) and place of loading(LADEL) in the fields of the extended segment selecting them from EIKP depending upon the BELNR value in the header of the idoc(E1EDK01-BELNR).
    I am unable to understand how do I populate the fields.
    Could you please help me.
    Thanks,
    Sandeep.

    HI,
    see the below steps you will completely understand the processing outbound..
    2.1 Outbound Interface
    PROCESS DIAGRAM
    Outbound Interface
    1. Analyse Hierarchy Levels
    2. Create New segment
    3. Create New IDoc Type
    4. Create New Message Type
    5. Link Message with IDoc Type
    6.  Create an entry in EDP13 via transactions WE20 and BD64
    7. Populate the Custom IDoc via ABAP Program
    7b Error Handling
    7c. Send Status Email
    8. Test the Population of the Custom IDoc
    <b>Step 1 – Analyse Hierarchy Levels:</b>
    Analyse the data relationships being processed in the interface.  Define the appropriate hierarchical Parent-to-Child relationships. 
    Navigate to transaction code WEDI
    Transaction WEDI displays the IDOC main menu.  This allows navigation around the various development and control areas to create a customised IDOC.
    <b>Step 2 – Create a new segment:</b>
    via wedi : Development - IDOC Segments or Transaction code WE31.
    •     Enter segment name and click on Create.
    &#61662;     The name of the segment type must start with Z1 , and have a maximum of eight characters.
    •     Enter description and enter the relevant field names and data elements.
    &#61662;     The segment should represent a structure in the program so for each field in the segment a field name and a data element must be defined.
    •     Save the segment and enter Person Responsible and Processing Person .
    •     Go to Edit and Set Release.
    •     Repeat this procedure for each new Segment in the IDOC.
    <b>Step 3 – Create a new IDOC Type</b>
    via wedi Development - IDOC Types or Transaction WE30.
    •     Enter segment name (starting with Z), click on Basic Type and then Create. 
    •     Create as new, enter Person Responsible and Processing Person  and enter description.
    •     On ‘Create Basic Type’ screen decide where segments should be inserted and go to Edit/Create Segment.
    •     Complete relevant fields in the Maintain Attributes screen:
    •     From the relevant segments created in Step 2 enter the Segment type and if mandatory segment.
    •     The Minimum and Maximum number of segments to be allowed in the sequence. (One minimum and one maximum if segment is mandatory).
    •     The Parent Segment and Hierarchy Level will be automatically created depending on where in the IDOC tree you decided to create that particular segment.
    •     Repeat this process for each segment needed in the IDOC type, deciding whether to add the next segments at the same level or as a ‘Child’.
    •     When IDOC created return to initial screen.  Go to Edit and Set Release.
    •     Go to Transaction WE60 to view the IDoc Type you have created.
    <b>Step 4 – Create new Message Type</b>
    via wedi Development - Message Types or Transaction WE81.
    •     Display/Change and click on New Entries
    •     Create a new Message Type and Save.
    Step <b>5 – Link Message Type to IDOC Type</b>
    via wedi Development - IDOC Type/Message or Transaction WE82.
    •     Display/Change and then click on New Entries.
    •     Enter Message Type, Basic Type (IDOC Type) and Release (46C) and Save.
    <b>Step 6 – Create an entry in EDP13 via transactions WE20 and BD64.</b>
    The partner profile for the Idoc must be set up and generated in the transaction BD64 and transaction WE20.
    •     WE20 – Add Message Type to appropriate Partner Type, Enter Message Type, Receiver Port and Idoc Type and Save.
    •     BD64 – Create a Model View, Enter Sender and Receiver Ports, Attach Message Type.  Go to ‘Environment’ on Menu and click on Generate Partner Profiles and generate (not save) profile.
    <b>Step 7 – Populate the custom IDOC via ABAP Program</b>
    See Test Program ZOUTBD_IDOC_TEMPLATE, Appendix IV.
    •     Create an Internal Table for each segment type, this should be exactly the same structure as the segment type.
    •     The control record is filled into a structure like EDIDC.  The message type and the Idoc type for the Idoc must be populated into the eddic structure.
    - PERFORM populate_Control_structure USING  c_mestyp
                                                c_SEGMENT_type1.
    •     The data segments are filled into a structure like edidd-sdata; sdata and the segment name are populated into the edidd structure.
    - PERFORM transfer_Parent_data_to_seg.
    •     The standard SAP function module MASTER_IDOC_DISTRIBUTE is called to pass the populated IDOC to the ALE Layer.
    - PERFORM master_idoc_distribute.
    •     NOTE:  This function module is only called for stand alone programs and Shared Master Data programs (SMD).   It is not called when using extensions or output determination.
    •     The ALE Layer handles the sending of the IDOC to the receiving system.
    •     Error Handling (see  Step 7b).
    •     Commit work.
    Project Specific
    <b>Step 7b – Error Handling</b>•     Analyse which fields in the interface are mandatory for the receiving system and who needs to receive error notification.
    •     Declare a structure of type ‘MCMAILOBJ’ for sending instructions.
    •     Enter values for the internal table based on structure ‘MCMAILOBJ’
    •     For selection processes, on SY-SUBRC checks and where fields are mandatory for the receiving system; insert Function Module  ‘MC_SEND_MAIL’.
    •     Enter values in the following parameters: -
    MS_MAIL_SENDMODE         =  ‘B’ (Batch Mode)
    MS_MAIL_TITLE                    =  'Mail Title'
    MS_MAIL_DESCRIPTION     =  ‘Error description’ (e.g. MATNR not given)
    MS_MAIL_RECEIVER           =  ‘Name of Receiver’ (To be determined)
    MS_MAIL_EXPRESS             =  ‘E’ (Express Delivery)
    MS_MAIL_DLINAME            = Leave Blank
    MS_MAIL_LANGU                =  'E'  (Language)
    MS_MAIL_FUNKOBJ_NAME  = Leave Blank
    TABLES
               MS_MAIL_CONT           =  I_MCMAILOBJ
    Note:
    It has to be determined separately for each interface how these errors and mail notifications are to be grouped – dependant upon the number of errors that are potentially likely. One possible approach is to send an email for each reason for rejection and include all the records that failed for that reason in the mail notification. Another possible approach is to send an email for every failure.
    When error checking for mandatory fields it is common SAP practice to reject a record on its first failure (irrespective of subsequent errors in that record)
    <b>Step 7c – Send status mail</b>
    •     Append to table I_MCMAILOBJ details of the time the interface was processed, how many Idocs were created and how many of these produced a status of 03.
    •     Select the user to receive the mail from ZINT_RECEIVER, using the name of the program as a key (SY-CPROG).
    •     Use function Module ‘MC_SEND_MAIL’ to send a mail to the user containing the contents of I_MCMAILOBJ at the end of the interface processing.
    <b>Step 8 – Test the population of the custom IDOC</b>
    via wedi IDoc - Display IDoc or Transaction WE02.
    •     Enter your message type and execute.
    •     Status should be green, double click on one of the Idocs you have created to view its contents.
    •     If a problem has occurred click on Status which will give you a description of the error.
    •     Drop down Data Records arrow and this should list the data in the IDoc in the correct hierarchical structure.
    •     Click on each individual segment and view the content to check that the correct data has been read.
    •     If you have UNIX access by using AL11 you can view the file that you have created.
    Note:
    For some interfaces it may be valid to send an empty file to SAP.  This empty file is converted to the custom IDOC format expected by SAP.  This custom IDOC will contain dummy information.  In the inbound processing code, if the dummy information is identified then the processing of the IDOC is considered to be complete and the IDOC should then be assigned a successfully processed status of 53, even though it has not been processed at all.
    rewards if useful
    regards,
    nazeer

  • Problem in lsmw idoc method

    Hi all,
    iam uploading material master data(MATMAS) using Idoc method, iam getting the
    I doc status as 51(i.e document is not posted) when i checked the error it is giving the error as material number is not entered ........
    can any one help on this.
    regards,
    rams

    Check the converted data in LSMW. if material no. is not getting populated.. go to conversion program (LSMW--> go to-user menu -- display conversion program) and set a break point while populating IDoc data and check what's going wrong. and rectify the problem...

  • Create Idoc Type under ECC6

    Hi folks,
    I've created a new Idoc segment for an existing idoc (The original idoc doesn't have the fields I need).  I'm now trying to create a new Idoc type taking into consideration the new Idoc Extension I've created.  When I type my new idoc type and select 'basic type', I believe I should get prompted (somewhere) to enter the Basic Idoc type and Extension type, but when I create a new basic type, I don't get the option to add my new extension.  And If I copy the original basic type, I don't get my new segments.
    Can someone please tell me what I'm missing in the create new Idoc Process?
    Cheers,
    Steve

    Hi Stephen..
    According to ur Scenario (Adding  new Segments to a Basic type ) , you should not create  a Basic idoc type . Rather you should create an Extended idoc type in WE30.
    That will ask for the Basic type and the new segments can be added here.
    This is the Complete info:
    1.     
    IDOC Enhancement
    This is the Complete Steps and Info on this...with an Example...
    Enhancing ALE
    For example, if in an outbound interface you find that the IDOC type does not contain all the data you need to pass to the other system, you can extend the IDOC to accommodate the additional fields and enhance the ALE function modules to populate the fields. Similarly, if in an inbound interface, there is additional data that needs to be posted to the R/3 application, you can extend the IDOC type to have additional fields populated by the external system or translator or the other R/3 system and then enhance the inbound ALE function modules to post the additional data to the R/3 application.
    let us use the SAP Customer Master application as an example. Specifically, letâs focus on the IDOC extension and ALE function module enhancement of IDOC type DEBMAS02 and message type DEBMAS (Customer Master) and the IDOC reduction of message type MATMAS.
    IDOC EXTENSIONS
    Letâs first look at the concept of IDOC extension. SAP delivers Basic IDOC types such as DEBMAS02, MATMAS02, ORDERS02, and WMMBID01. By extending the Basic IDOC type, you are actually creating a new IDOC type. You create a new segment with the additional fields. This new segment has to be associated with one of the existing Basic IDOC segments. Then you create a new extension type, which is associated with the Basic IDOC type. This results in a new IDOC type. In order for ALE function modules to relate to this new IDOC type, the IDOC type is linked to the corresponding message type.
    Note that you should not add fields to existing segments but should create a new segment and associate it with an existing segment. This, in a nutshell, is the process of creating IDOC extensions.
    In our example, the Basic IDOC type DEBMAS02 is used to communicate Customer Master data to the SAP Customer Master application. Even though the application has a screen to enter and store a contact personâs business address (see Figure 1), DEBMAS02 does not have a segment or fields that communicate the contact personâs business address. If your business requires that this business address be communicated to the other system through the ALE interface for Customer Master, then you have to extend the DEBMAS02 IDOC type, and enhance the corresponding ALE function module.
    In DEBMAS02 the contact person fields are present in segment E1KNVKM and the business address of the contact person is stored on the SADR SAP table. You need to create a new segment, Z1SADRX, that is associated with E1KNVKM. This will be done in the process of creating an extension type ZDEBMASX. This extension type will then be associated with a new IDOC type, ZDEBMASZ. IDOC type ZDEBMASZ will be linked to message type DEBMAS for Customer Master. The final step in the IDOC extension process is to check the new objects. This check also verifies the structural integrity of the IDOC type. Letâs look at each of these steps in more detail.
    1. Create an Extension Type and a New Segment.
    Determine the fields on table SADR that you are going to provide for in the new segment Z1SADRX. You need fields for name, street, city, region, and country to give the business address of the contact person. You also need fields for the address number. ADRNR is a field in SAP tables such as SADR that uniquely identifies the address of an entity. This field is cross-referenced from other tables to the SADR table to obtain the full description of the address. Because this is an IDOC type for master data, the first field of the new segment will be MSGFN. The message function field informs the receiving system of the action to be taken for that particular segment. In the code that you write for populating the new segment, the value of the message function is the same as that of the parent segment E1KNVKM. In all, you will have 12 fields in segment Z1SADRX (see Table 1).
    To create an extension type and new segment:
    • Use transaction WE30 or from WEDI go to Development -> IDOC types.
    • Enter ZDEBMASX for Object Name.
    • Choose Extension Type.
    • Click on Create.
    • You will see a pop-up screen. Choose Create New, and enter a description. For version 4.x, enter DEBMAS02 in the Linked Basic Type field. Enter.
    • You will see a screen with ZDEBMASX and its description in the first line. Click on this line, and press Create. For version 4.x, expand the tree of segments, and place the cursor on E1KNVKM.
    • You will see a pop-up screen. Enter E1KNVKM as the reference segment. Enter.
    • For 4.x, press Create after placing the cursor on segment E1KNVKM.
    • You will see a line appear with E1KNVKM hierarchically below ZDEBMASX, with a description "Customer Master contact person (KNVK)."
    • Click on this line and press Create. You will receive a message indicating that the new segment being created will be a child segment of E1KNVKM. Enter. A pop-up box appears for the new segment.
    • Enter Z1SADRX as the segment type, 1 for Minimum, 1 for Maximum. Leave Mandatory segment unchecked. These entries imply that there is only one Z1SADRX segment for every occurrence of the E1KNVKM segment, and also that this segment is not mandatory. Note that if the parent segment is not mandatory, then the child segment should not be mandatory, because this could result in a syntax error during the creation or processing of the IDOC.
    • For 4.x, you must first create the IDOC segment Z1SADRX (Iâll explain why in a moment) from the menu path WEDI -> IDOC -> Development -> IDOC Segment.
    • Click on Segment Editor.
    • On the next screen, click on Create.
    • Enter a development class for the object. Enter.
    • This will take you to the screen for segment definition. Enter a description for the segment. Enter the field name, data element, and the data element documentation name. In most cases, all three fields may have the same values. If you are using a field in the segment that is not present in the ABAP/4 data dictionary, you must first create the domain, data element, field, and appropriate documentation before using it in the new segment.
    • Enter these three columns for all 12 fields. Save.
    • Click on Generate/Activate, F3 to step back.
    • From screen Maintain Segment, go to Segment Type -> Release. A checkbox now appears beside the segment definition Z1SADRX (see Figure 2). Check this box. Save.
    • Save again to store the descriptions of the segment, F3 to step back.
    • Save the extension type.
    It is possible to have several new segments with relevant Basic IDOC type parent segments in a single extension type. However, you can form only one IDOC type based on a single extension type.
    2. Create an IDOC Type.
    The next step is to create an IDOC type by associating the extension type that you created with the Basic IDOC type. This is a simple process:
    • From transaction WE30 or WEDI go to Development -> IDOC Types.
    • Enter ZDEBMASZ for Object Name.
    • Click on IDOC Type.
    • Click on Create.
    • Enter DEBMAS02 for Basic IDOC type.
    • Enter ZDEBMASX for extension type.
    • Enter a description.
    • Enter.
    • You will see a display of the composite IDOC type with all segments, including Z1SADRX (see Figure 3).
    It is possible to associate only one extension type with a Basic IDOC type for a given IDOC type. However, you can have multiple new segments in an extension type.
    3. Link IDOC Type to Message Type.
    The next step is to link the new IDOC type to its corresponding message type. This is important, because this relationship is referenced in the partner profile parameters where you specify the message type and IDOC type to be used for that particular representative system. To link the message type:
    • Use transaction WE82, or from WE30, go to Environment -> IDOC Type / Message Type, or from WEDI go to Development -> IDOC Type -> Environment Î IDOC Type / Message Type.
    • Click on Display <-> Change.
    • Click on New Entries.
    • Enter DEBMAS for message type.
    • Enter DEBMAS02 for Basic IDOC type.
    • Enter ZDEBMASX for extension type.
    • Enter your SAP R/3 release number for Release.
    • Save.
    This data is stored on the EDIMSG table and is accessed by several ALE processes to relate the message type to the IDOC type.
    4. Check the IDOC Type.
    Before checking the IDOC type for consistency, it is important to perform another step that releases the extension type to the IDOC type:
    • From WEDI go to Development -> IDOC Types -> Extras -> Release Type, or from transaction WE30 go to Extras -> Release Type.
    • For the Object Name ZDEBMASX and radio button Extension Type, click Yes.
    • The extension type has now been "released."
    You canât edit the extension type once itâs released. To cancel the release for further editing or deactivation, go to WE30 Î Extras Î Cancel release. The final step in the IDOC extension process is checking the validity of the IDOC type:
    • From transaction WE30 or WEDI go to Development -> IDOC types.
    • Enter ZDEBMASX for Object name.
    • Click on Extension Type.
    • From the Development Object menu select Check.
    • Repeat the operation for IDOC type ZDEBMASZ.
    • A check log will be generated for each run with details of correctness or errors (see Figure 4).
    In some situations it is possible to receive errors during the check process, especially segment length errors. The incorrect IDOC segment can be repaired and corrected by executing program RSEREPSG. This program checks the formal consistency and repairs incorrect segments. In test mode it will generate a log of formal correctness for the specified segment only. For the program to repair segments in normal mode, the underlying IDOC structures (DDIC structures) must be active. This program rectifies the lengths of the DDIC structures and not the fields themselves. RSEREPSG can also be used to change the person responsible for the object and the release flag.
    Menu paths may vary slightly depending on the release/version of SAP R/3, but the procedures and the principles are the same.
    ALE FUNCTION MODULE ENHANCEMENTS
    Having extended the IDOC type to contain additional fields for an inbound or outbound application, you now want to enhance ALE function modules for populating the additional segment on the outbound or applying the additional segment data on the inbound application.
    The core working code for ALE processes for a given application area is always encapsulated in ABAP/4 function modules. These function modules are associated with such control information as message types and process codes. So the ALE process checks this control information and derives the name of the function module to invoke for that particular IDOC processing from certain database tables. These function modules contain objects known as customer functions, which can be considered SAP Enhanced user exits. A function module is called at a particular point during the processing of the main program or function module, and it can be used to influence data processing at that point by adding code to the customer function. The customer function behaves like a normal function module and has import and export parameters, tables (internal tables) statement, and exception processing. Unlike a conventional user exit, customer functions give you the ability to modify only data available to you by the function moduleâs parameters and internal tables. While most ALE/EDI function modules are supported by customer functions, there are ALE/EDI processes that still use conventional user exits. There are a few ways to determine which function module to enhance for a given message type/process code:
    • For master data distribution, from SALE go to Extensions -> Master data distribution -> Setup additional data for message types. Search for message type DEBMAS in this example. You see an entry for DEBMAS associated with function module MASTERIDOC_CREATE_SMD_DEBMAS. This data is stored on table TBDME. The function module names for all master data message types follow this pattern: MASTERIDOC_CREATE_SMD_messagetype. This function module calls another function module of name MASTERIDOC_CREATE_DEBMAS or MASTERIDOC_CREATE_messagetype. Search for the words customer function, and you find several hits that can be used to add code to the function module.
    • From WEDI got to Control -> Inbound process codes -> Inbound with ALE service -> Processing by function module (transaction WE42), or from WEDI go to Control -> Outbound process codes -> Outbound with ALE service -> With function module (transaction WE41). There will be function modules associated with the process codes. For inbound, the function modules usually follow this pattern: IDOC_INPUT_messagetype: for example, IDOC_INPUT_CHRMAS for inbound characteristics master.
    • Use transaction WE57 or from WEDI go to Development -> Message/Application Object. The entries list the function module, Business Object, message type, and IDOC type that are used for inbound ALE/EDI interfaces.
    Customer functions are not specific only to ALE and EDI but also to all programs/modules in SAP R/3. Customer function is a SAP enhancement component; the other two types are menu and screen enhancements.
    All customer function exits are maintained in SAP enhancements and are found by using transaction SMOD. After executing transaction SMOD, pull down (F4) on the enhancement name field, and execute again. This provides you with a list of all SAP enhancements available. SAP enhancements are grouped by development class pertaining to an application area. Choose Application development R/3 SD master data distribution for development class VSV to lead to a screen that lists VSV00001 as an enhancement (see Figure 5). Press Component +/- to display its function exit components. There are four possible components listed, all of which are function exits (and are function modules) that are called from the ALE function modules in the form Call Customer Function Î001â. This is a special occurrence of the ABAP statement Call. Go to item Exit_SAPLVV01_ 001, which you need to enhance for the Customer Master outbound example of an IDOC extension. In the ALE-function module MASTERIDOC_CREATE_DEBMAS, the statement CALL Customer Function 001 is translated in the background to call component EXIT_SAPLVV01_001. Although this function exit can be edited using transaction SE37, you will use a simpler approach.
    When you use SAP enhancements and their components, you manage them with an SAP object known as a project, which is like an envelope containing the selected enhancements and their components. A project can be used to control the execution of components and to transport them to other clients and instances in SAP. Basically, the process involves creating a project, including enhancements and components that are to be enhanced, editing the components, and then activating the project. The following process creates a project for our example Customer Master IDOC extension:
    • Execute transaction CMOD.
    • Enter name of project, say CSTMAST1.
    • Click on Create.
    • Enter a description of the project.
    • Save.
    • Click on SAP Enhancements.
    • Enter VSV00001 for Enhancement.
    • Save.
    Once youâve created the project, edit the function exit components and activate the project. Remember that the code in the function exit enhancement will execute only if the project is activated. In fact, this is a convenient SAP enhancements feature, whereby the work in progress (developing code in the customer function) will not affect users of that application. When the code is completed, the project can be activated so the enhanced functionality takes effect. It can also be deactivated for maintenance.
    As mentioned earlier, customer functions (function exits) are embedded in ALE function modules and can be used to influence the creation and modification of IDOC data on an outbound application or to post additional or modified IDOC data to an inbound R/3 application. Function exits are similar to regular function modules, with import/export parameters, tables (internal tables), and exceptions.
    The two important factors to consider while developing the customer function are:
    1. The point in the ALE function module where the function exit occurs
    2. The data made available by the customer function that can be modified or posted to the R/3 application, based on the direction.
    Because some function modules have several customer functions, it is critical to choose the function exit best suited for that particular enhancement. Do not attempt to perform activities that the function exit is not designed for. The importance of this point is illustrated by the following description of enhancing function modules for outbound and inbound ALE interfaces.
    Outbound interfaces. In an outbound ALE interface you use function exits (customer functions) to populate additional segments created by an IDOC extension or to modify the existing IDOC data segments as per business requirements. Previously, you identified that enhancement VSV00001 has a component EXIT_SAPLVV01_001 (function exit), which can be used for populating the additional data segment Z1SADRX that you created in the IDOC extension ZDEBMASX (IDOC type ZDEBMASZ, based on Basic IDOC type DEBMAS02). You also learned that the ALE function module that calls this function exit is MASTERIDOC_CREATE_DEBMAS, which has a statement Call Customer Function 001.
    Browse the function module MASTERIDOC_CREATE_DEBMAS using transaction SE37. You will find that this customer function is invoked for every segment of IDOC type DEBMAS02. In fact, the function exit is called soon after the creation of an existing segment has been populated with data and appended to the IDOC data table (internal table). Also, the function exit is exporting the message type, IDOC type, and the segment name and is importing the IDOC extension type. It is also passing the IDOC data internal table. This indicates that the ALE function module is allowing you to populate additional segments for every existing segment and modify the existing segmentâs data.
    Letâs write ABAP/4 code to accomplish the task of populating IDOC segment Z1SADRX with a contact personâs business address:
    • From SE37, display function module MASTERIDOC_CREATE_ DEBMAS.
    • Find Customer Function 001.
    • Double-click on 001.
    • The function EXIT_SAPLVV01_001 will be displayed.
    • Double-click on INCLUDE ZXVSVU01.
    • You will be asked to create a new include object. Proceed as desired.
    • Enter code (as in Listing 1).
    • Be sure to perform a main program check (Function Module -> Check -> main program) and extended program check (Function module -> Check -> Extended check).
    Now that you have extended the IDOC and enhanced the ALE function module based on the requirements for the contact personâs business address on the Customer Master, letâs test the interface. You should create a logical system and define a port for this interface. You should also configure the Customer Distribution Model to indicate that message type DEBMAS is being distributed to this logical system. The only difference in configuration between a regular outbound ALE interface and an enhanced one is the partner profile definition. While maintaining the outbound parameters of the partner profile, make sure the IDOC type is ZDEBMASZ. The fields for Basic IDOC type and extension type are automatically populated with DEBMAS02 and ZDEBMASX, respectively.
    To maintain the contact personâs business address of a customer:
    • Use transaction BD12 or from BALE go to Master Data ->Customer -> Send and send that Customer Master record by executing the transaction after filling in the relevant fields such as customer number, message type, and logical system.
    • Use transaction WE02 or WE05 to verify the IDOC created. You should see the new segment Z1SADRX populated with the correct data.
    Reward if Helpful.

  • Ale-idoc  steps

    Hi All,
    Can any one please give me the step by step ale-idoc toturial.about the steps to send data from one client to other.
    Regards,
    bunty

    Hi,
    <b>
      It gives, entire idoc documentation.
    http://help.sap.com/saphelp_nw04/helpdata/en/3b/beb13b00ae793be10000000a11402f/frameset.htm
    To develop a new custom ALE scenario, comprises 5 steps:
    1. Design and develop the custom IDoc with it’s segments and a new message type
    2. Configure the ALE environment with the new IDoc and message type (customer model, partner profiles and linking IDoc to message type)
    3. Develop the outbound process which does the following:
    • Populates the custom IDoc with control info and functional data
    • Sends the IDoc to the ALE layer for distribution
    • Updates status and handles errors
    4. Configure the ALE inbound side (partner profiles with inbound process code)
    5. Develop the inbound process which does the following:
    • Reads the IDoc into a BDC table; selects other data that is required
    • Runs transaction using call transaction or BDC session
    • Updates status and handles errors
    Below is a pictorial representation of the flow of a complete ALE scenario from the sending system to the receiving system.
    Figure 1: ALE Scenario model
    1.1. ALE Example
    For the purposes of this example we will develop a small ALE scenario. This scenario is described below.
    “The receiver of an internal service must be able to reverse (cancel) the invoice receipt which will then cancel the applicable billing document automatically on the service provider’s system.”
    Figure 2: Example Purchasing & Selling scenario
    We will develop a custom IDoc to carry the billing number from the Service Receiver’s system to the Service Provider’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.
    No rule conversion, segment filtering or version conversion will be implemented in the model as described in Figure 1.
    Requirements
    • Working ALE environment - See ALE Basis Configuration Guide;
    • ALE scenario design together with the business requirement;
    • Development access; and
    • ALE configuration access.
    NOTES:
    1. All IMG references to transactions are located in the transaction SALE which is the ALE portion of the IMG
    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.
    3. Extensive knowledge of IDocs and ALE basis configuration is required in order to understand this guide.
    2. OUTBOUND PROCESSING
    2.1. Create IDoc type (WE30) Client independent
    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 & XBLNR, in this segment. If you require many segments or nested segments then they are also created using the same procedure.
    We will create the IDoc of the following structure:
    ZINVRV01
    Purchasing and Selling - Invoice receipt reversal
    Z1INVRV P&S - Segment 1
    Segment fields
    LIFNR Vendor account number
    XBLNR Reference document number
    Figure 3: IDoc type ZINVRV01
    To create the IDoc type, follow these next few steps:
    • Enter transaction WE30 (ALE -> Extensions -> IDoc types -> Maintain IDoc type)
    • Type in ZINVRV01 and click on Basic IDoc type, click the Create icon
    • 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
    • Click on ZINVRV01 and then on the Create icon
    • 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
    • Enter a description for your segment type and create
    • 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.
    • Save and generate, press back
    • To release the segment choose Goto, Release from the menu
    • Check the box on the line of your new segment
    • Save, back and enter
    • Your IDoc type structure should be displayed with your new segment
    • Save and back
    • To release the IDoc type choose Extras, Release type from the menu and Yes
    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).
    2.2. Create message type (WE81) Client independent
    To create a new message type, follow these next few steps:
    • Enter transaction WE81 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> Create logical message type)
    • Choose Create logical message type by double clicking on it
    • Click on change icon to enter change mode
    • Click on New entries to add a new type
    • Enter the required message type, in our case it is ZINVRV and an appropriate description
    • Save and exit.
    Your message type has now been created. The next step will be to link it to the IDoc.
    2.2.1. Link message to IDoc type (WE82 & BD69) Client independent
    To link the message type to the IDoc type follow these next few steps:
    • Enter transaction WE82 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> EDI: Message Types and Assignment to IDoc Types)
    • Click on change icon to enter change mode
    • Click on New entries to create the link
    • Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01
    • Save and exit
    • Enter transaction BD69 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> Assign message type to IDoc for ALE)
    • Click on change icon to enter change mode
    • Click on New entries to create the link
    • Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01
    • Save and exit
    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.
    2.2.2. Maintain object type for message type (BD59) Client independent
    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.
    For our own message type and IDoc you must maintain object types for the links.
    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.
    To add an object type to our message type, follow these next few steps:
    • Enter transaction BD59 (ALE -> Extensions -> ALE object maintenance -> Maintain object types)
    • Type in your message type ZINVRV and press enter
    • Click on New entries
    • 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
    • Save and exit.
    You have now created an object that we’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.
    We now need to add our new message type to the distribution model.
    2.3. Configuring the Distribution Model
    This task is performed on your ALE reference client.
    2.3.1. Manual Configuration (BD64) Client dependent
    To manually configure the customer distribution model, read the ALE configuration procedure, and follow these steps:
    • Perform the Maintain customer distribution model directly function. (ALE -> Distribution customer model -> Maintain customer distribution model directly)
    • 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)
    • Choose the receiving systems to which the sending system must forward message type ZINVRV to.
    • For each receiving logical system allocate the message type necessary for communication to the receiving systems as per ALE configuration procedure.
    • 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.
    • Save the entries.
    NOTES:
    You cannot maintain a message type between the same sender and receiver in more than one customer distribution model.
    Only the owner is authorised to modify the model.
    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.
    To transport the customer distribution model you should use the Distribute customer model function of the IMG as described below.
    2.3.2. Distribute customer model (BD71) Client dependent
    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.
    2.3.2.1. Distribute Model (BD71) Client dependent
    This task is performed on your ALE reference client. To distribute the customer distribution model, read the ALE configuration procedure and follow these steps:
    • Make the settings for the communication with the other decentral systems, you have not set them yet.
    • Define the RFC destination for R/3 connections whose names correspond to the name of the corresponding logical system.
    • Create the output partner profile.
    • Distribute the customer model
    • Specify the name of the customer model.
    • You must specify the target system to which you want to distribute the customer model.
    • You must repeat this function for every distributed logical system.
    2.3.2.2. Maintain sending system partner profile (WE20) Client dependent
    With this function, you define the partner profiles for all outbound and inbound messages on the basis of the customer distribution model.
    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.
    • Enter the output mode (background, immediately) and the package size for outbound processing.
    Requirements
    • The customer model must be maintained.
    • RFC destinations must be maintained.
    • The customer model must be distributed.
    • 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.
    2.4. Populate & distribute IDoc using ABAP
    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.
    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.
    2.4.1. Example code
    The code displayed below does the following:
    • 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;
    • populates the control record info with the message type and IDoc type; and
    • calls the MASTER_IDOC_DISTRIBUTE function module which distributes the IDoc as configured in the customer distribution model.
    *--- Data declaration statements
    DATA: C_INVREV_SEGNAME(7) TYPE C VALUE 'Z1INVRV',
    C_INVREV_MESTYPE(6) TYPE C VALUE 'ZINVRV',
    C_INVREV_IDOC_TYPE(8) TYPE C VALUE 'ZINVRV01',
    Z1INVRV LIKE Z1INVRV,
    C_INVREV_DOCTYPE LIKE BKPF-BLART VALUE 'YY',
    IDOC_CONTROL LIKE EDIDC,
    T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,
    IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.
    *--- Move the document header into a structure
    LOOP AT DOC_HEAD_TAB INTO DOC_HEAD.
    ENDLOOP.
    *--- Move the document item data into a structure
    LOOP AT DOC_ITEM_TAB INTO DOC_ITEM WHERE NOT ( LIFNR IS INITIAL ).
    ENDLOOP.
    *--- Populate the IDoc segment’s field with the required data
    CLEAR Z1INVRV.
    Z1INVRV-LIFNR = DOC_ITEM-LIFNR. “Store vendor number for filter
    Z1INVRV-XBLNR = DOC_HEAD-XBLNR. “Billing number
    IDOC_DATA-SEGNAM = C_INVREV_SEGNAME. “Segment name
    IDOC_DATA-SDATA = Z1INVRV. “Segment data
    APPEND IDOC_DATA. “Populate IDoc internal table
    *--- Move the control data info required for the distribution
    IDOC_CONTROL-MESTYP = C_INVREV_MESTYPE.
    IDOC_CONTROL-DOCTYP = C_INVREV_IDOC_TYPE.
    *--- Call the distribute function with the required parameters
    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.
    Figure 4: Outbound processing example code
    NOTE:
    For debugging purposes, use transaction WE05 (IDoc overview) to see check your IDoc status, or to see whether an IDoc was created/
    3. INBOUND PROCESSING
    3.1. Create Function Module
    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.
    Example parameters
    Import parameters Reference field Opt Y/N
    INPUT_METHOD BDWFAP_PAR-INPUTMETHD N
    MASS_PROCESSING BDWFAP_PAR-MASS_PROC N
    Export Parameters Reference field Opt Y/N
    WORKFLOW_RESULT BDWFAP_PAR-RESULT N
    APPLICATION_VARIABLE BDWFAP_PAR-APPL_VAR N
    IN_UPDATE_TASK BDWFAP_PAR-UPDATETASK N
    CALL_TRANSACTION_DONE BDWFAP_PAR-CALLTRANS N
    Table Parameters Reference field Optional Y/N
    IDOC_CONTRL EDIDC
    IDOC_DATA EDIDD
    IDOC_STATUS BDIDOCSTAT
    RETURN_VARIABLES BDWFRETVAR
    SERIALIZATION_INFO BDI_SER
    Exceptions
    WRONG_FUNCTION_CALLED
    Example code
    The code displayed below does the following:
    • populates a BDC table with the IDoc info;
    • calls the transaction via a BDC call; and
    • updates the IDoc status according to the BDC error status.
    EXTRACT FROM: Z_IDOC_INPUT_ZINVRV
    *--- Declaration of local variables
    DATA: C_SEGNAM(10) TYPE C VALUE 'Z1INVRV'.
    *-Loop through the IDOCs
    LOOP AT IDOC_CONTRL.
    *---Loop through the data for the IDOC
    LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
    CASE IDOC_DATA-SEGNAM.
    WHEN C_SEGNAM.
    Here we get the info from the idoc table
    IT_Z1INVRV = IDOC_DATA-SDATA.
    ENDCASE.
    PERFORM REV_INV.
    ENDLOOP.
    PERFORM UPDATE_IDOC_STATUS.
    ENDLOOP.
    FORM REV_INV "Reverse invoice form
    *--- Local variables & constants
    DATA: C_TCODE LIKE BKPF-TCODE VALUE 'VF11'. "BDC transaction code
    *--- Now we can build the bdc table to call the reversal transaction start of screen 109
    CLEAR BDC_TAB.
    BDC_TAB-PROGRAM = 'SAPMV60A'.
    BDC_TAB-DYNPRO = '109'.
    BDC_TAB-DYNBEGIN = 'X'.
    APPEND BDC_TAB.
    *--- Document number
    CLEAR BDC_TAB.
    BDC_TAB-FNAM = 'KOMFK-VBELN(01)'.
    BDC_TAB-FVAL = IT_Z1INVRV-XBLNR. "Billing document number
    APPEND BDC_TAB.
    *--- OK Code for screen 109
    CLEAR BDC_TAB.
    BDC_TAB-FNAM = 'BDC_OKCODE'.
    BDC_TAB-FVAL = 'SICH'.
    APPEND BDC_TAB.
    *--- 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.
    CALL TRANSACTION C_TCODE USING BDC_TAB MODE 'N' UPDATE 'S'.
    *--- Store the return code for use in another form (status update)
    RETURN_CODE = SY-SUBRC.
    *--- 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.
    IF SY-SUBRC NE 0.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = 'ZINVRV'
    USER = C_ALE_USER
    KEEP = 'X'.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = C_TCODE
    TABLES
    DYNPROTAB = BDC_TAB.
    CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
    NOT_OPEN = 1
    QUEUE_ERROR = 2
    OTHERS = 3.
    ELSE. "No problems
    C_EXISTS = 'N'.
    Select from the billing document table to get sales doc number
    SELECT * FROM VBRP WHERE VBELN = IT_Z1INVRV-XBLNR.
    Select from the sales document table to get user status number
    SELECT SINGLE * FROM VBAP WHERE VBELN = VBRP-AUBEL AND
    POSNR = VBRP-AUPOS.
    Select from the status table to change the user status to pending
    SELECT * FROM JEST WHERE OBJNR = VBAP-OBJNR AND
    STAT LIKE C_USER_STATUS.
    IF JEST-STAT = C_US_PENDING. "User status is pending
    JEST-INACT = C_UNCHECKED. "Make pending the active status
    UPDATE JEST.
    C_EXISTS = 'Y'. "I.E. An entry is already in table
    ELSEIF JEST-INACT = C_UNCHECKED AND JEST-STAT NE C_US_PENDING.
    JEST-INACT = C_CHECKED. "Make everything else inactive
    UPDATE JEST.
    ENDIF.
    ENDSELECT.
    IF C_EXISTS = 'N'. "I.E. Pending has never been a status before
    JEST-OBJNR = VBAP-OBJNR.
    JEST-STAT = C_US_PENDING.
    JEST-INACT = C_UNCHECKED. "Make pending the active status
    INSERT JEST.
    ENDIF.
    ENDSELECT. "Select from VBRP (Billing document table)
    ENDIF.
    ENDFORM. " REV_INV
    FORM UPDATE_IDOC_STATUS.
    *--- Now we check the CALL TRANSACTION return code and set IDOC status
    CLEAR IDOC_STATUS.
    IF RETURN_CODE = 0.
    WORKFLOW_RESULT = '0'.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-STATUS = '53'.
    IDOC_STATUS-UNAME = SY-UNAME.
    IDOC_STATUS-REPID = SY-REPID.
    IDOC_STATUS-MSGTY = SY-MSGTY.
    IDOC_STATUS-MSGID = SY-MSGID.
    IDOC_STATUS-MSGNO = SY-MSGNO.
    IDOC_STATUS-MSGV1 = SY-MSGV1.
    IDOC_STATUS-MSGV2 = SY-MSGV2.
    IDOC_STATUS-MSGV3 = SY-MSGV3.
    IDOC_STATUS-MSGV4 = SY-MSGV4.
    RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    ELSE.
    WORKFLOW_RESULT = '99999'.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-STATUS = '51'.
    IDOC_STATUS-UNAME = SY-UNAME.
    IDOC_STATUS-REPID = SY-REPID.
    IDOC_STATUS-MSGTY = SY-MSGTY.
    IDOC_STATUS-MSGID = SY-MSGID.
    IDOC_STATUS-MSGNO = SY-MSGNO.
    IDOC_STATUS-MSGV1 = SY-MSGV1.
    IDOC_STATUS-MSGV2 = SY-MSGV2.
    IDOC_STATUS-MSGV3 = SY-MSGV3.
    IDOC_STATUS-MSGV4 = SY-MSGV4.
    RETURN_VARIABLES-WF_PARAM = 'ERROR_IDOCS'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    ENDIF.
    APPEND IDOC_STATUS.
    ENDFORM. " UPDATE_IDOC_STATUS
    Figure 5: Inbound processing example code
    3.1.1. Debugging inbound FM
    Use transaction WE19 to test inbound function module in debugging mode. Also use WE05 to view the IDocs and their statuses.
    3.2. Maintain ALE attributes
    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.
    3.2.1. Link Message Type to Function Module (WE57) Client independent
    To link a message (ZINVRV) type to a function module (Z_IDOC_INPUT_ZINVRV) follow these steps:
    • Enter transaction WE57 (ALE -> Extensions -> Inbound -> Allocate function module to logical message)
    • Select an entry (EG. IDOC_INPUT_ORDERS) and copy
    • Type in module name Z_IDOC_INPUT_ZINVRV
    • Type in basic IDoc type as ZINVRV01
    • Type in message type as ZINVRV
    • Type object type as IDOCINVOIC (Invoice document) - Used for workflow
    • Direction should be set to 2 for inbound
    • Enter and save
    3.2.2. Define FM settings (BD51) Client independent
    • Enter transaction BD51 (ALE -> Extensions -> Inbound -> Define settings for input modules)
    • Click on New entries
    • Type in the name of the new function module Z_IDOC_INPUT_ZINVRV
    • Enter 0 for mass processing in the output column
    • Save and Exit
    3.2.3. Maintain process codes (WE42) Client dependent
    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.
    To maintain the process code follow these steps:
    • Log on to the appropriate receiving system client
    • Execute WE42 (ALE -> Extensions -> Inbound -> Maintaining process codes inbound)
    • Choose Inbound with ALE service
    • Choose Processing with function module
    • Click on Processing with function module and choose create icon
    • Click on New Entries
    • Type in process code ZINR and give it a description and save
    • 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.
    • Enter your process code ZINR
    • Enter your function module Z_IDOC_INPUT_ZINVRV
    NOTE: The next 6 steps are used in workflow error handling.
    • Enter IDPKFIDCMT in object type
    • Enter MASSINPUTFINISHED in End event
    • Enter IDOCINVOIC in IDoc object type
    • Enter INPUTERROROCCURREDFI in IDoc start event
    • Enter INPUTFINISHEDFI in IDoc End event
    • Enter IDOCINVOIC in Application object type
    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.
    To set up the workflow area please consult the Workflow config guide.
    3.3. Create inbound partner profile
    For each message type you need to maintain the inbound partner profiles.
    3.3.1. Maintain receiving system partner profile (WE20) Client dependent
    To maintain inbound partner profiles read the document ALE configuration procedure:
    • Add the message type ZINVRV with process code ZINR.
    • Enter the output mode (background, immediately) for inbound processing and NO message code.
    • Enter the position S and choose the ALE administrator 50000085. This position will then receive all the technical ALE errors via workflow.
    3.4. Test
    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.
    IDOC Programming
    Index
    Process Steps for IDOC Programming 3
    Interpreting An IDoc Segment Info 3
    IDoc Type – The Structure of The IDoc File 5
    Defining The Message Type 6
    Define Valid Combination Of Message and IDoc Types 6
    Process Steps for Inbound IDOC Programming 7
    Characteristics of Inbound function module 7
    Assigning a processing function 8
    Processing Codes 9
    Workflow Handling 12
    Create Inbound Partner Profile 12
    Sample Code Snippet 14
    Execution Steps for inbound Idoc: 17
    Testing of Inbound Idoc: 19
    Process Steps for Outbound IDOC Programming 21
    Common Steps 21
    Create Outbound Partner Profile 21
    Sample Code Snippet 23
    Execution Steps: 26
    Testing of Outbound Idoc: 26
    Change Pointers & Reduction of IDOCs. 26
                                                                                    What is IDOC
    IDocs are SAP’s file format to exchange data with a foreign system. IDocs is the acronym for Intermediate Document. This indicates a set of (electronic) information, which builds a logical entity. An IDoc is e.g. all the data of a single customer in your customer master data file. Or the Idoc is all the data of a single invoice.
    • IDocs are an ASCII file format to exchange data between computers; the format is chosen arbitrarily
    • IDocs are similar to segmented files; they are not a description language like ANSI X.12, EDIFACT or XML
    • The IDoc contents are processed by function modules, which can be assigned in customizing
    Process Steps for IDOC Programming
    The following steps are required for inbound and outbound IDOC Programming.
    Interpreting An IDoc Segment Info
    All IDoc data records are exchanged in a fixed format, regardless of the segment type. The segment’s true structure is stored in R/3’s repository as a DDIC structure of the same name.
    Go to transaction code WE31. Enter the name of the Segment, which is to be created (fig 2.1).
    E.g. Create the segment ZEMPMASTSEG
    Fig 2.1 WE31- IDOC Segment main screen.
    Fig 2.2 WE31 IDOC Segment definition screen.
    In the above screen user can enter the fields, which are necessary for the segment. Once all the necessary fields will be populated then Save the transaction. After Saving release the version of the Segment by selecting the version and through menu Edit -> Set release.
    Same way create one or more segment.
    Fig 2.3 WE31 – IDOC Segment definition screen for another segment (ZEMPMASTHEADERSEG).
    IDoc Type – The Structure of the IDoc File
    The IDoc type is the name of the data structure used to describe the file format of a specific IDoc.
    An IDoc is a segmented data file. It has typically several segments. The segments are usually structured into fields, however different segments use different fields.
    The IDoc type is defined with transaction WE30, the respective segments are defined with transaction WE31 as per the point 2
    Go to transaction code WE30. Enter the IDOC Type name.
    Fig 3.1 WE30 – IDOC Type main screen.
    Add the segments to the IDOC Type as per the requirement.
    For e.g. in the fig 3.2 it shown that IDOC Type is having only one segment ZEMPMASTHEADERSEG, which is having one child segment ZEMPMASTSEG
    Fig 3.2 WE30 – IDOC Type segment screen
    For each segment developer (double click on the segment) can set the minimum, maximum number of segment in a sequence.
    Fig 3.3 fig 3.4
    Defining the Message Type
    The message type defines the context under which an IDoc is transferred to its destination. It allows using the same IDoc file format to use for several different applications.
    The message type together with the IDoc type determines the processing function.
    The message type defined using transaction code WE81.
    fig 4.1 WE81 – Message Types
    Define Valid Combination Of Message and IDoc Types
    The valid combinations of message type and IDoc type are stored in table EDIMSG, using transaction WE82.
    The declaration of valid combinations is done to allow validation, if the system can handle a certain combination.
    Fig 5.1 WE82 – Message Type Assignment
    Process Step for Inbound IDOC Programming
    Characteristics of Inbound function module
    Before assigning the function module to Inbound process code, its characteristics must be set with the transaction BD51. This step is mandatory before assigning the function module to Inbound process code.
    For inbound processing you need to tell, whether the function will be capable of dialog processing. This is meant for those functions, which process the inbound data via call transaction. Those functions can be replayed in visible batch input mode to check why the processing might have failed.
    Fig 6.1
    Here the main characteristic is Input Type. It means “How are IDoc packages processed?” and having values like
    Input Type Short Text
    0 Mass Processing
    1 Individual input
    2 Individual input with IDOC locked in CALL TRANSACTION
    Also another property Dialog Allowed can be set here. With “Dialog allowed” IDocs can be processed in dialog mode.
    Fig 6.2 – BD51 Characteristics of Inbound Function Module
    Assigning a processing function
    The combination of message type and IDoc type determine the processing algorithm. This is usually a function module with a well-defined interface or a SAP business object and is set up in table EDIFCT.
    The entry made the points to a function module, which will be called when the IDoc is to be processed. The entries for message code and message function are usually left blank. They can be used to derive sub types of messages together with the partner profile used.
    Used transaction code WE57 for assigning function module to IDOC Type.
    Fig 7.1 WE57 – Assign Function Module to Message and IDOC Type
    Fig 7.2 Assign a handler function to a message/message type
    Process Codes
    R/3 uses the method of logical process codes to detach the Idoc processing and the processing function module. They assign a logical name to function instead of specifying the physical function name.
    The combination message type/IDoc will determine the logical processing code, which itself points to a function. If the function changes, only the definition of the processing codes will be changed and the new function will be immediately effective for all IDocs associated with the process code.
    For inbound processing codes you have to specify the method to use for the determination of the inbound function.
    The Inbound processing code can be attach to the function module using transaction code WE42
    Fig 8.1 WE42 – Define Inbound Process Code
    You need to tick, if your function can be used via the ALE engine. This is the option you would usually choose. It allows processing via the ALE scenarios. See fig below
    Fig 8.2 WE42 – Set properties of Inbound Process Code
    See fig 8.4
    Fig 8.3 WE42 – Set the Message type for the Inbound Process Code
    Fig 8.4 WE42 – Fill the details of the Inbound Process Code.
    The properties set in the above fig 8.4 are used for the workflow handling when the IDOC is having any error.
    Properties, which are useful in the workflow processing, are as follows.
    • Object Type – It is a business object created using transaction code SWO1 and used as a handler
    • Starting Event - Will triggered the workflow on occur of Error.
    • Ending Event - Will terminate the workflow after processing the
    Workflow Handling
    Refer: - Workflow Guide
    Create Inbound Partner Profile
    For each message type you need to maintain the inbound partner profiles. Maintain receiving system partner profile using WE20 (See fig. 10.3). Add the message type in the Senders inbound parameter.
    Following steps will be followed for creation of partner profile (Inbound).
    • Add the message type (e.g. ZEMPMSG) into the inbound parameter by clicking .
    Fig. 10.1 WE20 – Addition of message type in Inbound Partner Profile
    • On the next screen enter the message type , process code. In the Processing by function module block select the radio button based on the need. If you clicked on Triggered by background program then the IDOC will be collected and will triggered by another program which will run in background and if the second option Triggered immediately is clicked then the IDOC will be processed by the function module as soon as it is triggered.
    Fig. 10.2 WE20 – Inbound Parameters.
    Fig 10.3 WE20 – Create Partner profile
    Sample Code Snippet
    Important Steps are as follows.
    1) Unpacking of IDOC: - Unpack the IDOC into the respective segments.
    2) Process Data: - Process the unpacked data.
    3) Error Handling.
    4) Workflow triggering.
    FUNCTION Z_IDOC_INPUT_EMPMAST.
    ""Local interface:
    *” IMPORTING
    *" REFERENCE (INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
    *" REFERENCE (MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
    *” EXPORTING
    *" REFERENCE (WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT
    *" REFERENCE (APPLICATION_VARIABLE) LIKE BDWFAP_PAR-APPL_VAR
    *" REFERENCE (IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
    *" REFERENCE (CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
    *” TABLES
    *" IDOC_CONTRL STRUCTURE EDIDC
    *" IDOC_DATA STRUCTURE EDIDD
    *" IDOC_STATUS STRUCTURE BDIDOCSTAT
    *" RETURN_VARIABLES STRUCTURE BDWFRETVAR
    *" SERIALIZATION_INFO STRUCTURE BDI_SER
    *” EXCEPTIONS
    *" WRONG_FUNCTION_CALLED
    DATA: S_EMPMAST LIKE ZEMPMASTHEADERSEG.
    DATA: T_EMPMAST LIKE ZEMPMASTSEG OCCURS 0 WITH HEADER LINE.
    DATA: WA_EMPMAST LIKE ZEMPMAST.
    DATA: L_FLAG VALUE 'Y'.
    CLEAR S_EMPMAST.
    REFRESH T_EMPMAST.
    check if the function is called correctly *
    IF IDOC_CONTRL-MESTYP <> 'ZEMPMSG'.
    RAISE WRONG_FUNCTION_CALLED.
    ENDIF.
    WORKFLOW_RESULT = 0.
    Unpacking the IDoc
    LOOP AT IDOC_DATA.
    CASE IDOC_DATA-SEGNAM.
    WHEN 'ZEMPMASTHEADERSEG'.
    MOVE IDOC_DATA-SDATA TO S_EMPMAST.
    WHEN 'ZEMPMASTSEG'.
    MOVE IDOC_DATA-SDATA TO T_EMPMAST.
    APPEND T_EMPMAST.
    ENDCASE.
    ENDLOOP.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-MSGV1 = IDOC_CONTRL-IDOCTP.
    IDOC_STATUS-MSGID = '00'.
    IDOC_STATUS-MSGNO = '398'.
    Processing Data
    LOOP AT T_EMPMAST.
    MOVE-CORRESPONDING T_EMPMAST TO WA_EMPMAST.
    INSERT INTO ZEMPMAST VALUES WA_EMPMAST.
    G_OKCODE = SY-SUBRC.
    IF G_OKCODE <> 0.
    L_FLAG = 'N'.
    Error Handling
    IDOC_STATUS-STATUS = '51'.
    IDOC_STATUS-MSGTY = 'E'.
    IDOC_STATUS-MSGV2 = 'Employee & already exists'.
    REPLACE '&' WITH WA_EMPMAST-EMPNO INTO IDOC_STATUS-MSGV2.
    IDOC_STATUS-SEGNUM = SY-TABIX + 1.
    APPEND IDOC_STATUS.
    ENDIF.
    AT LAST.
    ENDAT.
    ENDLOOP.
    IF L_FLAG <> 'Y'.
    Workflow Triggering
    CLEAR RETURN_VARIABLES.
    RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    WORKFLOW_RESULT = '99999'.
    ROLLBACK WORK.
    ELSE.
    IDOC_STATUS-STATUS = '53'.
    IDOC_STATUS-MSGTY = 'S'.
    IDOC_STATUS-MSGV2 = 'Employee Info inserted'.
    APPEND IDOC_STATUS.
    ENDIF.
    ENDFUNCTION.
    Execution Steps for inbound Idoc:
    To execute inbound idoc go to Transaction we19 give the Idoc number execute the transaction
    It displays a screen with control, data, and status records. Click Standard inbound OR inbound function module buttons and process the idoc.
    i) Standard inbound:
    If you have selected the standard inbound button it displays a screen with the standard setup:
    II) Inbound function module:
    If you select the in bound function module button displays the below screen you can enter the function module name which you want to execute
    If you select Check box Call in debug mode you can execute the function module in debug mode.
    Call transaction Processing:
    In Background:
    The function module is called in the background
    This setting is only important if the function module to be called reacts accordingly to the importing parameter 'INPUT_METHOD'. This is therefore only valid for function modules which implement the application functionality using the command 'CALL TRANSACTION'.
    In foreground :
    The function module is called in the foreground.
    This setting is only important if the function module to be called reacts accordingly to the importing parameter 'INPUT_METHOD'. This is therefore only true for function modules which implement application functionality using the command 'CALL TRANSACTION'.
    In foreground After error:
    The function module is called in a background session. This becomes a session in the foreground after the first error has occurred.
    This setting is only important if the function module to be called reacts accordingly to the importing parameter 'INPUT_METHOD'. This is therefore only true for function modules which implement application functionality using the command 'CALL TRANSACTION'.
    Now it will post the idoc.
    Testing of Inbound Idoc:
    If you need to check the status of idoc Go to Transaction ZE05 give the idoc number in the idoc number select option execute the transaction.
    Then displays a screen with Out box and Inbox . select the idoc number in the Inbox Shows the control record , data record ,status record .select the status record and check for the idoc status Then you will be known the idoc is successful posted or not.
    The idoc which has been posted into SAP successfully will have the status 53.
    The list of the other valid status for Inbound Idoc are as follows:
    Status Message Description
    50 IDoc added
    51 Error: Application document not posted
    52 Application document posted
    62 IDoc passed to application
    64 IDoc ready to be transferred to application
    74 IDoc was created by test transaction
                                                                                    Process Steps for Outbound IDOC Programming
    The following steps are required for Outbound IDOC Programming.
    Common Steps
    The steps for new segment creation, new Idoc Type, new Message Type and linking between message type and Idoc Type are same as Inbound Idoc Programming. The detail Steps for such activities are mentioned in the Page 2 to Page 5.
    Create Outbound Partner Profile
    Use Transaction WE20 and select the Receiver Partner. Then add message type ZEMPMSG in the outbound parameters. The partner profile needs to be created at the ReceiverLogical System(LS)/Customer(KU)/Vendor(LI)/Bank(B)/Benefits provider(BP)/ User(US) only.
    Then double click on the Message type ZEMPMSG and it navigates to the following screen where user has to set the following attributes:
    • Receiver port as A000000001 for RFC
    • Packet Size field as 1
    • Idoc type Z_EMPMAT_IN in basic type field
    • Set the Syntax check box
    • Set the output mode as Transfer Idoc immediately
    • Save the changes.
    Coding Steps:
    1) Create an Executable Program Based on specification.
    2) All the Important Data should be displayed as Parameters with mandatory.
    i) Message type
    ii) Sender port
    iii) Sender partner
    iv) Sender partner function
    v) Receiver port
    vi) Receiver partner
    vii) Receiver partner function
    3) Select the data based on selection screen into an internal table.
    4) Read the selected internal table and fill the Header segment.
    5) Now Loop the internal table to fill other Segments.
    6) Fill the Control segment data.
    7) Call the proper Function module and pass the data to the function module
    To create the idoc.
    8) Change the status of idoc based on the function module return code.
    9) If FM return code is 0 set status to 03.
    10) See the demo program Z_IDOC_OUTBOUND_EMP for more Clarification.
    Sample Code Snippet
    REPORT Z_IDOC_OUTBOUND_EMP .
    TABLES: ZEMPMAST.
    DATA: F_IDOC_CONTRL LIKE EDIDC,
    T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,
    T_IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.
    Data: Begin of t_zempmast occurs 0.
    include structure zempmast.
    Data: end of t_zempmast.
    data:wa_ZEMPMAST like ZEMPMAST.
    data:wa_ZEMPMASTSEG like ZEMPMASTSEG.
    Data: wa_ZEMPMASTHEADERSEG like ZEMPMASTHEADERSEG.
    CONSTANTS: C_BASIC_IDOC_TYPE LIKE EDIDC-IDOCTP VALUE 'Z_EMPMAT_IN',
    C_Z1CLIPS_SEG_NAME LIKE EDIDD-SEGNAM VALUE 'Z1CLIPS',
    TRUE VALUE 'X',
    FALSE VALUE SPACE.
    “Selection Screen----
    SELECTION-SCREEN BEGIN OF BLOCK EMP WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_EMPNO FOR ZEMPMAST-EMPNO.
    SELECTION-SCREEN END OF BLOCK EMP.
    PARAMETERS: P_MESTYP LIKE EDIDC-MESTYP
    DEFAULT 'ZEMPMSG'
    OBLIGATORY.
    PARAMETERS: P_SNDPRT LIKE EDIDC-SNDPRT,
    P_SNDPRN LIKE EDIDC-SNDPRN,
    P_SNDPFC LIKE EDIDC-SNDPFC.
    PARAMETERS: P_RCVPRT LIKE EDIDC-RCVPRT,
    P_RCVPRN LIKE EDIDC-RCVPRN,
    P_RCVPFC LIKE EDIDC-RCVPFC.
    “Selection of data
    Perform select_data.
    “Create Idoc
    perform creat_idoc.
    CLEAR F_IDOC_CONTRL.
    *& Form select_data
    text
    --> p1 text
    <-- p2 text
    FORM select_data.
    “Selecting the required data based on Selection Screen
    select * into corresponding fields of table t_ZEMPMAST from ZEMPMAST
    where EMPNO in s_EMPNO.
    ENDFORM. " select_data
    *& Form creat_idoc
    text
    --> p1 text
    <-- p2 text
    FORM creat_idoc.
    “Creating Header Segment
    if not t_zempmast[] is initial.
    T_IDOC_DATA-SEGNAM = 'ZEMPMASTHEADERSEG'.
    “Populating Idoc data table with header Segment
    perform prepare_segment using wa_zempmast.
    T_IDOC_DATA-SDATA = wa_ZEMPMASTHEADERSEG.
    APPEND T_IDOC_DATA.
    “Creating other Segments.
    loop at t_zempmast into wa_zempmast.
    CLEAR T_IDOC_DATA.
    “Filling item segment
    T_IDOC_DATA-SEGNAM = 'ZEMPMASTSEG'.
    perform prepare_segment1 using wa_zempmast.
    T_IDOC_DATA-SDATA = wa_ZEMPMASTSEG.
    “Adding the item segments into idoc table
    APPEND T_IDOC_DATA.
    CLEAR T_IDOC_DATA.
    endloop.
    “Filling Control data.
    F_IDOC_CONTRL-MESTYP = P_MESTYP.
    F_IDOC_CONTRL-IDOCTP = C_BASIC_IDOC_TYPE.
    F_IDOC_CONTRL-SNDPRT = P_SNDPRT.
    F_IDOC_CONTRL-SNDPRN = P_SNDPRN.
    F_IDOC_CONTRL-SNDPFC = P_SNDPFC.
    F_IDOC_CONTRL-RCVPRT = P_RCVPRT.
    F_IDOC_CONTRL-RCVPRN = P_RCVPRN.
    F_IDOC_CONTRL-RCVPFC = P_RCVPFC.
    “Creating idoc
    PERFORM DISTRIBUTE_THE_IDOC TABLES T_IDOC_DATA
    T_COMM_CONTROL
    USING F_IDOC_CONTRL.
    endif.
    ENDFORM. " creat_idoc
    *& Form prepare_segment
    text
    -->P_T_ZEMPMAST text
    FORM prepare_segment USING P_T_ZEMPMAST like ZEMPMAST.
    “Filling header Segment
    wa_ZEMPMASTHEADERSEG-REPNAME = sy-repid.
    wa_ZEMPMASTHEADERSEG-DATE = sy-datum.
    wa_ZEMPMASTHEADERSEG-TIME = sy-uzeit.
    ENDFORM. " prepare_segment
    *& Form prepare_segment1
    text
    -->P_WA_ZEMPMAST text
    FORM prepare_segment1 USING P_T_ZEMPMAST like ZEMPMAST.
    “filling item segment
    wa_ZEMPMASTSEG-EMPNO = P_T_ZEMPMAST-EMPNO.
    wa_ZEMPMASTSEG-EMPNAME = P_T_ZEMPMAST-EMPNAME.
    ENDFORM. " prepare_segment1
    *& Form DISTRIBUTE_THE_IDOC
    text
    -->P_T_IDOC_DATA text
    -->P_T_COMM_CONTROL text
    -->P_F_IDOC_CONTRL text
    FORM DISTRIBUTE_THE_IDOC TABLES T_IDOC_DATA STRUCTURE EDIDD
    T_COMM_CONTROL STRUCTURE EDIDC
    USING F_IDOC_CONTRL STRUCTURE EDIDC.
    READ TABLE T_IDOC_DATA INDEX 1.
    IF SY-SUBRC = 0.
    insert and distribute the idoc
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
    EXPORTING
    MASTER_IDOC_CONTROL = F_IDOC_CONTRL
    TABLES
    COMMUNICATION_IDOC_CONTRO

  • Out bound IDOC creation

    Hi experts,
    I am given a task to create an out bound IDOC which would be input to TIBCO, which must be triggered every time Good issue transaction is completed by either VT02N or VL02N transaction up pressing SAVE.
    IDOC is to have fields from Customize tables apart from standard SAP tables, so was asked to create an own IDOC ( eg: Z--Idoc).
    Please tell me how to create the idoc, and also the method to trigger it and how to populate the IDOC ( program etc).
    Use full inputs would be promtly rewarded.
    Regards,
    Ram.

    Hi
    Creation of Custom IDOc type and message Type
    First Create Partner Profile(WE20 Tcode) and Port Definition in WE19 Tcodes.
    take the Basis help to create them.
    1.First create segments in WE31 Tcode with the required dataelements
    2.Create the Basic Idoc Type in WE30
       release the Segments and IDOC type.
    3.Create Message type in We81
    4.Assign the message type to IDOC type in WE82 T code
    5.Create the process code in We41 (for Outbound) WE42 (for Inbound)
    6.Create A fun module in SE37 starting with ZIDOC_OUTPUT_.. by copying some Inbound (for    Inbound) Outbound Fun module
    7.Create  Workflow setting if needed ..
    8. Assign the fun module to Idoc Type, Message Type and WF object (if it is there0
    9.Define setting for fun module in BD51
    10.In BD51 Define the settings for Fun module..
    10.Assign the Processs Code to Fun mod`ule
    Outbound Interface
    PROCESS DIAGRAM for Outbound Interface
    1. Analyse Hierarchy Levels
    2. Create New segment
    3. Create New IDoc Type
    4. Create New Message Type
    5. Link Message with IDoc Type
    6. Create an entry in EDP13 via transactions WE20 and BD64
    7. Populate the Custom IDoc via ABAP Program
    7b Error Handling
    7c. Send Status Email
    8. Test the Population of the Custom IDoc
    Step 1 – Analyse Hierarchy Levels:
    Analyse the data relationships being processed in the interface. Define the appropriate hierarchical Parent-to-Child relationships.
    Navigate to transaction code WEDI
    Transaction WEDI displays the IDOC main menu. This allows navigation around the various development and control areas to create a customised IDOC.
    Step 2 – Create a new segment:
    via wedi : Development - IDOC Segments or Transaction code WE31.
    • Enter segment name and click on Create.
    ? The name of the segment type must start with Z1 , and have a maximum of eight characters.
    • Enter description and enter the relevant field names and data elements.
    ? The segment should represent a structure in the program so for each field in the segment a field name and a data element must be defined.
    • Save the segment and enter Person Responsible and Processing Person .
    • Go to Edit and Set Release.
    • Repeat this procedure for each new Segment in the IDOC.
    Step 3 – Create a new IDOC Type
    via wedi Development - IDOC Types or Transaction WE30.
    • Enter segment name (starting with Z), click on Basic Type and then Create.
    • Create as new, enter Person Responsible and Processing Person and enter description.
    • On ‘Create Basic Type’ screen decide where segments should be inserted and go to Edit/Create Segment.
    • Complete relevant fields in the Maintain Attributes screen:
    • From the relevant segments created in Step 2 enter the Segment type and if mandatory segment.
    • The Minimum and Maximum number of segments to be allowed in the sequence. (One minimum and one maximum if segment is mandatory).
    • The Parent Segment and Hierarchy Level will be automatically created depending on where in the IDOC tree you decided to create that particular segment.
    • Repeat this process for each segment needed in the IDOC type, deciding whether to add the next segments at the same level or as a ‘Child’.
    • When IDOC created return to initial screen. Go to Edit and Set Release.
    • Go to Transaction WE60 to view the IDoc Type you have created.
    Step 4 – Create new Message Type
    via wedi Development - Message Types or Transaction WE81.
    • Display/Change and click on New Entries
    • Create a new Message Type and Save.
    Step 5 – Link Message Type to IDOC Type
    via wedi Development - IDOC Type/Message or Transaction WE82.
    • Display/Change and then click on New Entries.
    • Enter Message Type, Basic Type (IDOC Type) and Release (46C) and Save.
    Step 6 – Create an entry in EDP13 via transactions WE20 and BD64.
    The partner profile for the Idoc must be set up and generated in the transaction BD64 and transaction WE20.
    • WE20 – Add Message Type to appropriate Partner Type, Enter Message Type, Receiver Port and Idoc Type and Save.
    • BD64 – Create a Model View, Enter Sender and Receiver Ports, Attach Message Type. Go to ‘Environment’ on Menu and click on Generate Partner Profiles and generate (not save) profile.
    Step 7 – Populate the custom IDOC via ABAP Program
    See Test Program ZOUTBD_IDOC_TEMPLATE, Appendix IV.
    • Create an Internal Table for each segment type, this should be exactly the same structure as the segment type.
    • The control record is filled into a structure like EDIDC. The message type and the Idoc type for the Idoc must be populated into the eddic structure.
    - PERFORM populate_Control_structure USING c_mestyp
    c_SEGMENT_type1.
    • The data segments are filled into a structure like edidd-sdata; sdata and the segment name are populated into the edidd structure.
    - PERFORM transfer_Parent_data_to_seg.
    • The standard SAP function module MASTER_IDOC_DISTRIBUTE is called to pass the populated IDOC to the ALE Layer.
    - PERFORM master_idoc_distribute.
    • NOTE: This function module is only called for stand alone programs and Shared Master Data programs (SMD). It is not called when using extensions or output determination.
    • The ALE Layer handles the sending of the IDOC to the receiving system.
    • Error Handling (see Step 7b).
    • Commit work.
    Project Specific
    Step 7b – Error Handling• Analyse which fields in the interface are mandatory for the receiving system and who needs to receive error notification.
    • Declare a structure of type ‘MCMAILOBJ’ for sending instructions.
    • Enter values for the internal table based on structure ‘MCMAILOBJ’
    • For selection processes, on SY-SUBRC checks and where fields are mandatory for the receiving system; insert Function Module ‘MC_SEND_MAIL’.
    • Enter values in the following parameters: -
    MS_MAIL_SENDMODE = ‘B’ (Batch Mode)
    MS_MAIL_TITLE = 'Mail Title'
    MS_MAIL_DESCRIPTION = ‘Error description’ (e.g. MATNR not given)
    MS_MAIL_RECEIVER = ‘Name of Receiver’ (To be determined)
    MS_MAIL_EXPRESS = ‘E’ (Express Delivery)
    MS_MAIL_DLINAME = Leave Blank
    MS_MAIL_LANGU = 'E' (Language)
    MS_MAIL_FUNKOBJ_NAME = Leave Blank
    TABLES
    MS_MAIL_CONT = I_MCMAILOBJ
    Note:
    It has to be determined separately for each interface how these errors and mail notifications are to be grouped – dependant upon the number of errors that are potentially likely. One possible approach is to send an email for each reason for rejection and include all the records that failed for that reason in the mail notification. Another possible approach is to send an email for every failure.
    When error checking for mandatory fields it is common SAP practice to reject a record on its first failure (irrespective of subsequent errors in that record)
    Step 7c – Send status mail
    • Append to table I_MCMAILOBJ details of the time the interface was processed, how many Idocs were created and how many of these produced a status of 03.
    • Select the user to receive the mail from ZINT_RECEIVER, using the name of the program as a key (SY-CPROG).
    • Use function Module ‘MC_SEND_MAIL’ to send a mail to the user containing the contents of I_MCMAILOBJ at the end of the interface processing.
    Step 8 – Test the population of the custom IDOC
    via wedi IDoc - Display IDoc or Transaction WE02.
    • Enter your message type and execute.
    • Status should be green, double click on one of the Idocs you have created to view its contents.
    • If a problem has occurred click on Status which will give you a description of the error.
    • Drop down Data Records arrow and this should list the data in the IDoc in the correct hierarchical structure.
    • Click on each individual segment and view the content to check that the correct data has been read.
    • If you have UNIX access by using AL11 you can view the file that you have created.
    Note:
    For some interfaces it may be valid to send an empty file to SAP. This empty file is converted to the custom IDOC format expected by SAP. This custom IDOC will contain dummy information. In the inbound processing code, if the dummy information is identified then the processing of the IDOC is considered to be complete and the IDOC should then be assigned a successfully processed status of 53, even though it has not been processed at all.
    Regards
    Anji

  • IDOC Structure

    Hi..
    How do we know which message type is appropriate for our document type.?
    Can any one give the whole list of message types used in interface.
    Regards
    Sampath

    Hi
    You can go to transaction WE64 to see detail message type including the process code (FM).
    There are different message types for different partners depending on your requirement u have to use that
    Sending data to sap/non sap is same but the it makes some difference in configuration in bd64 ie distribution model, as a abaper our work is same while sending idocs to legas as to be send sap.
    here i am giving entire material for ALE/IDOCS and let me know if u have any doubts.
    It gives, entire idoc documentation.
    http://help.sap.com/saphelp_nw04/helpdata/en/3b/beb13b00ae793be10000000a11402f/frameset.htm
    To develop a new custom ALE scenario, comprises 5 steps:
    1. Design and develop the custom IDoc with it’s segments and a new message type
    2. Configure the ALE environment with the new IDoc and message type (customer model, partner profiles and linking IDoc to message type)
    3. Develop the outbound process which does the following:
    • Populates the custom IDoc with control info and functional data
    • Sends the IDoc to the ALE layer for distribution
    • Updates status and handles errors
    4. Configure the ALE inbound side (partner profiles with inbound process code)
    5. Develop the inbound process which does the following:
    • Reads the IDoc into a BDC table; selects other data that is required
    • Runs transaction using call transaction or BDC session
    • Updates status and handles errors
    Below is a pictorial representation of the flow of a complete ALE scenario from the sending system to the receiving system.
    Figure 1: ALE Scenario model
    1.1. ALE Example
    For the purposes of this example we will develop a small ALE scenario. This scenario is described below.
    “The receiver of an internal service must be able to reverse (cancel) the invoice receipt which will then cancel the applicable billing document automatically on the service provider’s system.”
    Figure 2: Example Purchasing & Selling scenario
    We will develop a custom IDoc to carry the billing number from the Service Receiver’s system to the Service Provider’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.
    No rule conversion, segment filtering or version conversion will be implemented in the model as described in Figure 1.
    Requirements
    • Working ALE environment - See ALE Basis Configuration Guide;
    • ALE scenario design together with the business requirement;
    • Development access; and
    • ALE configuration access.
    NOTES:
    1. All IMG references to transactions are located in the transaction SALE which is the ALE portion of the IMG
    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.
    3. Extensive knowledge of IDocs and ALE basis configuration is required in order to understand this guide.
    2. OUTBOUND PROCESSING
    2.1. Create IDoc type (WE30) Client independent
    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 & XBLNR, in this segment. If you require many segments or nested segments then they are also created using the same procedure.
    We will create the IDoc of the following structure:
    ZINVRV01
    Purchasing and Selling - Invoice receipt reversal
    Z1INVRV P&S - Segment 1
    Segment fields
    LIFNR Vendor account number
    XBLNR Reference document number
    Figure 3: IDoc type ZINVRV01
    To create the IDoc type, follow these next few steps:
    • Enter transaction WE30 (ALE -> Extensions -> IDoc types -> Maintain IDoc type)
    • Type in ZINVRV01 and click on Basic IDoc type, click the Create icon
    • 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
    • Click on ZINVRV01 and then on the Create icon
    • 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
    • Enter a description for your segment type and create
    • 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.
    • Save and generate, press back
    • To release the segment choose Goto, Release from the menu
    • Check the box on the line of your new segment
    • Save, back and enter
    • Your IDoc type structure should be displayed with your new segment
    • Save and back
    • To release the IDoc type choose Extras, Release type from the menu and Yes
    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).
    2.2. Create message type (WE81) Client independent
    To create a new message type, follow these next few steps:
    • Enter transaction WE81 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> Create logical message type)
    • Choose Create logical message type by double clicking on it
    • Click on change icon to enter change mode
    • Click on New entries to add a new type
    • Enter the required message type, in our case it is ZINVRV and an appropriate description
    • Save and exit.
    Your message type has now been created. The next step will be to link it to the IDoc.
    2.2.1. Link message to IDoc type (WE82 & BD69) Client independent
    To link the message type to the IDoc type follow these next few steps:
    • Enter transaction WE82 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> EDI: Message Types and Assignment to IDoc Types)
    • Click on change icon to enter change mode
    • Click on New entries to create the link
    • Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01
    • Save and exit
    • Enter transaction BD69 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> Assign message type to IDoc for ALE)
    • Click on change icon to enter change mode
    • Click on New entries to create the link
    • Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01
    • Save and exit
    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.
    2.2.2. Maintain object type for message type (BD59) Client independent
    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.
    For our own message type and IDoc you must maintain object types for the links.
    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.
    To add an object type to our message type, follow these next few steps:
    • Enter transaction BD59 (ALE -> Extensions -> ALE object maintenance -> Maintain object types)
    • Type in your message type ZINVRV and press enter
    • Click on New entries
    • 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
    • Save and exit.
    You have now created an object that we’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.
    We now need to add our new message type to the distribution model.
    2.3. Configuring the Distribution Model
    This task is performed on your ALE reference client.
    2.3.1. Manual Configuration (BD64) Client dependent
    To manually configure the customer distribution model, read the ALE configuration procedure, and follow these steps:
    • Perform the Maintain customer distribution model directly function. (ALE -> Distribution customer model -> Maintain customer distribution model directly)
    • 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)
    • Choose the receiving systems to which the sending system must forward message type ZINVRV to.
    • For each receiving logical system allocate the message type necessary for communication to the receiving systems as per ALE configuration procedure.
    • 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.
    • Save the entries.
    NOTES:
    You cannot maintain a message type between the same sender and receiver in more than one customer distribution model.
    Only the owner is authorised to modify the model.
    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.
    To transport the customer distribution model you should use the Distribute customer model function of the IMG as described below.
    2.3.2. Distribute customer model (BD71) Client dependent
    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.
    2.3.2.1. Distribute Model (BD71) Client dependent
    This task is performed on your ALE reference client. To distribute the customer distribution model, read the ALE configuration procedure and follow these steps:
    • Make the settings for the communication with the other decentral systems, you have not set them yet.
    • Define the RFC destination for R/3 connections whose names correspond to the name of the corresponding logical system.
    • Create the output partner profile.
    • Distribute the customer model
    • Specify the name of the customer model.
    • You must specify the target system to which you want to distribute the customer model.
    • You must repeat this function for every distributed logical system.
    2.3.2.2. Maintain sending system partner profile (WE20) Client dependent
    With this function, you define the partner profiles for all outbound and inbound messages on the basis of the customer distribution model.
    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.
    • Enter the output mode (background, immediately) and the package size for outbound processing.
    Requirements
    • The customer model must be maintained.
    • RFC destinations must be maintained.
    • The customer model must be distributed.
    • 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.
    2.4. Populate & distribute IDoc using ABAP
    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.
    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.
    2.4.1. Example code
    The code displayed below does the following:
    • 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;
    • populates the control record info with the message type and IDoc type; and
    • calls the MASTER_IDOC_DISTRIBUTE function module which distributes the IDoc as configured in the customer distribution model.
    *--- Data declaration statements
    DATA: C_INVREV_SEGNAME(7) TYPE C VALUE 'Z1INVRV',
    C_INVREV_MESTYPE(6) TYPE C VALUE 'ZINVRV',
    C_INVREV_IDOC_TYPE(8) TYPE C VALUE 'ZINVRV01',
    Z1INVRV LIKE Z1INVRV,
    C_INVREV_DOCTYPE LIKE BKPF-BLART VALUE 'YY',
    IDOC_CONTROL LIKE EDIDC,
    T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,
    IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.
    *--- Move the document header into a structure
    LOOP AT DOC_HEAD_TAB INTO DOC_HEAD.
    ENDLOOP.
    *--- Move the document item data into a structure
    LOOP AT DOC_ITEM_TAB INTO DOC_ITEM WHERE NOT ( LIFNR IS INITIAL ).
    ENDLOOP.
    *--- Populate the IDoc segment’s field with the required data
    CLEAR Z1INVRV.
    Z1INVRV-LIFNR = DOC_ITEM-LIFNR. “Store vendor number for filter
    Z1INVRV-XBLNR = DOC_HEAD-XBLNR. “Billing number
    IDOC_DATA-SEGNAM = C_INVREV_SEGNAME. “Segment name
    IDOC_DATA-SDATA = Z1INVRV. “Segment data
    APPEND IDOC_DATA. “Populate IDoc internal table
    *--- Move the control data info required for the distribution
    IDOC_CONTROL-MESTYP = C_INVREV_MESTYPE.
    IDOC_CONTROL-DOCTYP = C_INVREV_IDOC_TYPE.
    *--- Call the distribute function with the required parameters
    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.
    Figure 4: Outbound processing example code
    NOTE:
    For debugging purposes, use transaction WE05 (IDoc overview) to see check your IDoc status, or to see whether an IDoc was created/
    3. INBOUND PROCESSING
    3.1. Create Function Module
    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.
    Example parameters
    Import parameters Reference field Opt Y/N
    INPUT_METHOD BDWFAP_PAR-INPUTMETHD N
    MASS_PROCESSING BDWFAP_PAR-MASS_PROC N
    Export Parameters Reference field Opt Y/N
    WORKFLOW_RESULT BDWFAP_PAR-RESULT N
    APPLICATION_VARIABLE BDWFAP_PAR-APPL_VAR N
    IN_UPDATE_TASK BDWFAP_PAR-UPDATETASK N
    CALL_TRANSACTION_DONE BDWFAP_PAR-CALLTRANS N
    Table Parameters Reference field Optional Y/N
    IDOC_CONTRL EDIDC
    IDOC_DATA EDIDD
    IDOC_STATUS BDIDOCSTAT
    RETURN_VARIABLES BDWFRETVAR
    SERIALIZATION_INFO BDI_SER
    Exceptions
    WRONG_FUNCTION_CALLED
    Example code
    The code displayed below does the following:
    • populates a BDC table with the IDoc info;
    • calls the transaction via a BDC call; and
    • updates the IDoc status according to the BDC error status.
    EXTRACT FROM: Z_IDOC_INPUT_ZINVRV
    *--- Declaration of local variables
    DATA: C_SEGNAM(10) TYPE C VALUE 'Z1INVRV'.
    *-Loop through the IDOCs
    LOOP AT IDOC_CONTRL.
    *---Loop through the data for the IDOC
    LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
    CASE IDOC_DATA-SEGNAM.
    WHEN C_SEGNAM.
    Here we get the info from the idoc table
    IT_Z1INVRV = IDOC_DATA-SDATA.
    ENDCASE.
    PERFORM REV_INV.
    ENDLOOP.
    PERFORM UPDATE_IDOC_STATUS.
    ENDLOOP.
    FORM REV_INV "Reverse invoice form
    *--- Local variables & constants
    DATA: C_TCODE LIKE BKPF-TCODE VALUE 'VF11'. "BDC transaction code
    *--- Now we can build the bdc table to call the reversal transaction start of screen 109
    CLEAR BDC_TAB.
    BDC_TAB-PROGRAM = 'SAPMV60A'.
    BDC_TAB-DYNPRO = '109'.
    BDC_TAB-DYNBEGIN = 'X'.
    APPEND BDC_TAB.
    *--- Document number
    CLEAR BDC_TAB.
    BDC_TAB-FNAM = 'KOMFK-VBELN(01)'.
    BDC_TAB-FVAL = IT_Z1INVRV-XBLNR. "Billing document number
    APPEND BDC_TAB.
    *--- OK Code for screen 109
    CLEAR BDC_TAB.
    BDC_TAB-FNAM = 'BDC_OKCODE'.
    BDC_TAB-FVAL = 'SICH'.
    APPEND BDC_TAB.
    *--- 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.
    CALL TRANSACTION C_TCODE USING BDC_TAB MODE 'N' UPDATE 'S'.
    *--- Store the return code for use in another form (status update)
    RETURN_CODE = SY-SUBRC.
    *--- 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.
    IF SY-SUBRC NE 0.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = 'ZINVRV'
    USER = C_ALE_USER
    KEEP = 'X'.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = C_TCODE
    TABLES
    DYNPROTAB = BDC_TAB.
    CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
    NOT_OPEN = 1
    QUEUE_ERROR = 2
    OTHERS = 3.
    ELSE. "No problems
    C_EXISTS = 'N'.
    Select from the billing document table to get sales doc number
    SELECT * FROM VBRP WHERE VBELN = IT_Z1INVRV-XBLNR.
    Select from the sales document table to get user status number
    SELECT SINGLE * FROM VBAP WHERE VBELN = VBRP-AUBEL AND
    POSNR = VBRP-AUPOS.
    Select from the status table to change the user status to pending
    SELECT * FROM JEST WHERE OBJNR = VBAP-OBJNR AND
    STAT LIKE C_USER_STATUS.
    IF JEST-STAT = C_US_PENDING. "User status is pending
    JEST-INACT = C_UNCHECKED. "Make pending the active status
    UPDATE JEST.
    C_EXISTS = 'Y'. "I.E. An entry is already in table
    ELSEIF JEST-INACT = C_UNCHECKED AND JEST-STAT NE C_US_PENDING.
    JEST-INACT = C_CHECKED. "Make everything else inactive
    UPDATE JEST.
    ENDIF.
    ENDSELECT.
    IF C_EXISTS = 'N'. "I.E. Pending has never been a status before
    JEST-OBJNR = VBAP-OBJNR.
    JEST-STAT = C_US_PENDING.
    JEST-INACT = C_UNCHECKED. "Make pending the active status
    INSERT JEST.
    ENDIF.
    ENDSELECT. "Select from VBRP (Billing document table)
    ENDIF.
    ENDFORM. " REV_INV
    FORM UPDATE_IDOC_STATUS.
    *--- Now we check the CALL TRANSACTION return code and set IDOC status
    CLEAR IDOC_STATUS.
    IF RETURN_CODE = 0.
    WORKFLOW_RESULT = '0'.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-STATUS = '53'.
    IDOC_STATUS-UNAME = SY-UNAME.
    IDOC_STATUS-REPID = SY-REPID.
    IDOC_STATUS-MSGTY = SY-MSGTY.
    IDOC_STATUS-MSGID = SY-MSGID.
    IDOC_STATUS-MSGNO = SY-MSGNO.
    IDOC_STATUS-MSGV1 = SY-MSGV1.
    IDOC_STATUS-MSGV2 = SY-MSGV2.
    IDOC_STATUS-MSGV3 = SY-MSGV3.
    IDOC_STATUS-MSGV4 = SY-MSGV4.
    RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    ELSE.
    WORKFLOW_RESULT = '99999'.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-STATUS = '51'.
    IDOC_STATUS-UNAME = SY-UNAME.
    IDOC_STATUS-REPID = SY-REPID.
    IDOC_STATUS-MSGTY = SY-MSGTY.
    IDOC_STATUS-MSGID = SY-MSGID.
    IDOC_STATUS-MSGNO = SY-MSGNO.
    IDOC_STATUS-MSGV1 = SY-MSGV1.
    IDOC_STATUS-MSGV2 = SY-MSGV2.
    IDOC_STATUS-MSGV3 = SY-MSGV3.
    IDOC_STATUS-MSGV4 = SY-MSGV4.
    RETURN_VARIABLES-WF_PARAM = 'ERROR_IDOCS'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    ENDIF.
    APPEND IDOC_STATUS.
    ENDFORM. " UPDATE_IDOC_STATUS
    Figure 5: Inbound processing example code
    3.1.1. Debugging inbound FM
    Use transaction WE19 to test inbound function module in debugging mode. Also use WE05 to view the IDocs and their statuses.
    3.2. Maintain ALE attributes
    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.
    3.2.1. Link Message Type to Function Module (WE57) Client independent
    To link a message (ZINVRV) type to a function module (Z_IDOC_INPUT_ZINVRV) follow these steps:
    • Enter transaction WE57 (ALE -> Extensions -> Inbound -> Allocate function module to logical message)
    • Select an entry (EG. IDOC_INPUT_ORDERS) and copy
    • Type in module name Z_IDOC_INPUT_ZINVRV
    • Type in basic IDoc type as ZINVRV01
    • Type in message type as ZINVRV
    • Type object type as IDOCINVOIC (Invoice document) - Used for workflow
    • Direction should be set to 2 for inbound
    • Enter and save
    3.2.2. Define FM settings (BD51) Client independent
    • Enter transaction BD51 (ALE -> Extensions -> Inbound -> Define settings for input modules)
    • Click on New entries
    • Type in the name of the new function module Z_IDOC_INPUT_ZINVRV
    • Enter 0 for mass processing in the output column
    • Save and Exit
    3.2.3. Maintain process codes (WE42) Client dependent
    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.
    To maintain the process code follow these steps:
    • Log on to the appropriate receiving system client
    • Execute WE42 (ALE -> Extensions -> Inbound -> Maintaining process codes inbound)
    • Choose Inbound with ALE service
    • Choose Processing with function module
    • Click on Processing with function module and choose create icon
    • Click on New Entries
    • Type in process code ZINR and give it a description and save
    • 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.
    • Enter your process code ZINR
    • Enter your function module Z_IDOC_INPUT_ZINVRV
    NOTE: The next 6 steps are used in workflow error handling.
    • Enter IDPKFIDCMT in object type
    • Enter MASSINPUTFINISHED in End event
    • Enter IDOCINVOIC in IDoc object type
    • Enter INPUTERROROCCURREDFI in IDoc start event
    • Enter INPUTFINISHEDFI in IDoc End event
    • Enter IDOCINVOIC in Application object type
    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.
    To set up the workflow area please consult the Workflow config guide.
    3.3. Create inbound partner profile
    For each message type you need to maintain the inbound partner profiles.
    3.3.1. Maintain receiving system partner profile (WE20) Client dependent
    To maintain inbound partner profiles read the document ALE configuration procedure:
    • Add the message type ZINVRV with process code ZINR.
    • Enter the output mode (background, immediately) for inbound processing and NO message code.
    • Enter the position S and choose the ALE administrator 50000085. This position will then receive all the technical ALE errors via workflow.
    3.4. Test
    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.
    IDOC Programming
    Index
    Process Steps for IDOC Programming 3
    Interpreting An IDoc Segment Info 3
    IDoc Type – The Structure of The IDoc File 5
    Defining The Message Type 6
    Define Valid Combination Of Message and IDoc Types 6
    Process Steps for Inbound IDOC Programming 7
    Characteristics of Inbound function module 7
    Assigning a processing function 8
    Processing Codes 9
    Workflow Handling 12
    Create Inbound Partner Profile 12
    Sample Code Snippet 14
    Execution Steps for inbound Idoc: 17
    Testing of Inbound Idoc: 19
    Process Steps for Outbound IDOC Programming 21
    Common Steps 21
    Create Outbound Partner Profile 21
    Sample Code Snippet 23
    Execution Steps: 26
    Testing of Outbound Idoc: 26
    Change Pointers & Reduction of IDOCs. 26
    What is IDOC
    IDocs are SAP’s file format to exchange data with a foreign system. IDocs is the acronym for Intermediate Document. This indicates a set of (electronic) information, which builds a logical entity. An IDoc is e.g. all the data of a single customer in your customer master data file. Or the Idoc is all the data of a single invoice.
    • IDocs are an ASCII file format to exchange data between computers; the format is chosen arbitrarily
    • IDocs are similar to segmented files; they are not a description language like ANSI X.12, EDIFACT or XML
    • The IDoc contents are processed by function modules, which can be assigned in customizing
    Process Steps for IDOC Programming
    The following steps are required for inbound and outbound IDOC Programming.
    Interpreting An IDoc Segment Info
    All IDoc data records are exchanged in a fixed format, regardless of the segment type. The segment’s true structure is stored in R/3’s repository as a DDIC structure of the same name.
    Go to transaction code WE31. Enter the name of the Segment, which is to be created (fig 2.1).
    E.g. Create the segment ZEMPMASTSEG
    Fig 2.1 WE31- IDOC Segment main screen.
    Fig 2.2 WE31 IDOC Segment definition screen.
    In the above screen user can enter the fields, which are necessary for the segment. Once all the necessary fields will be populated then Save the transaction. After Saving release the version of the Segment by selecting the version and through menu Edit -> Set release.
    Same way create one or more segment.
    Fig 2.3 WE31 – IDOC Segment definition screen for another segment (ZEMPMASTHEADERSEG).
    IDoc Type – The Structure of the IDoc File
    The IDoc type is the name of the data structure used to describe the file format of a specific IDoc.
    An IDoc is a segmented data file. It has typically several segments. The segments are usually structured into fields, however different segments use different fields.
    The IDoc type is defined with transaction WE30, the respective segments are defined with transaction WE31 as per the point 2
    Go to transaction code WE30. Enter the IDOC Type name.
    Fig 3.1 WE30 – IDOC Type main screen.
    Add the segments to the IDOC Type as per the requirement.
    For e.g. in the fig 3.2 it shown that IDOC Type is having only one segment ZEMPMASTHEADERSEG, which is having one child segment ZEMPMASTSEG
    Fig 3.2 WE30 – IDOC Type segment screen
    For each segment developer (double click on the segment) can set the minimum, maximum number of segment in a sequence.
    Fig 3.3 fig 3.4
    Defining the Message Type
    The message type defines the context under which an IDoc is transferred to its destination. It allows using the same IDoc file format to use for several different applications.
    The message type together with the IDoc type determines the processing function.
    The message type defined using transaction code WE81.
    fig 4.1 WE81 – Message Types
    Define Valid Combination Of Message and IDoc Types
    The valid combinations of message type and IDoc type are stored in table EDIMSG, using transaction WE82.
    The declaration of valid combinations is done to allow validation, if the system can handle a certain combination.
    Fig 5.1 WE82 – Message Type Assignment
    Process Step for Inbound IDOC Programming
    Characteristics of Inbound function module
    Before assigning the function module to Inbound process code, its characteristics must be set with the transaction BD51. This step is mandatory before assigning the function module to Inbound process code.
    For inbound processing you need to tell, whether the function will be capable of dialog processing. This is meant for those functions, which process the inbound data via call transaction. Those functions can be replayed in visible batch input mode to check why the processing might have failed.
    Here the main characteristic is Input Type. It means “How are IDoc packages processed?” and having values like
    Input Type Short Text
    0 Mass Processing
    1 Individual input
    2 Individual input with IDOC locked in CALL TRANSACTION
    Also another property Dialog Allowed can be set here. With “Dialog allowed” IDocs can be processed in dialog mode.
    Fig 6.2 – BD51 Characteristics of Inbound Function Module
    Assigning a processing function
    The combination of message type and IDoc type determine the processing algorithm. This is usually a function module with a well-defined interface or a SAP business object and is set up in table EDIFCT.
    The entry made the points to a function module, which will be called when the IDoc is to be processed. The entries for message code and message function are usually left blank. They can be used to derive sub types of messages together with the partner profile used.
    Used transaction code WE57 for assigning function module to IDOC Type.
    Fig 7.1 WE57 – Assign Function Module to Message and IDOC Type
    Fig 7.2 Assign a handler function to a message/message type
    Process Codes
    R/3 uses the method of logical process codes to detach the Idoc processing and the processing function module. They assign a logical name to function instead of specifying the physical function name.
    The combination message type/IDoc will determine the logical processing code, which itself points to a function. If the function changes, only the definition of the processing codes will be changed and the new function will be immediately effective for all IDocs associated with the process code.
    For inbound processing codes you have to specify the method to use for the determination of the inbound function.
    The Inbound processing code can be attach to the function module using transaction code WE42
    8.1 WE42 – Define Inbound Process Code
    You need to tick, if your function can be used via the ALE engine. This is the option you would usually choose. It allows processing via the ALE scenarios. See fig below
    WE42 – Set properties of Inbound Process Code
    WE42 – Set the Message type for the Inbound Process Code
    Fig 8.4 WE42 – Fill the details of the Inbound Process Code.
    The properties set in the above fig 8.4 are used for the workflow handling when the IDOC is having any error.
    Properties, which are useful in the workflow processing, are as follows.
    • Object Type – It is a business object created using transaction code SWO1 and used as a handler
    • Starting Event - Will triggered the workflow on occur of Error.
    • Ending Event - Will terminate the workflow after processing the
    Workflow Handling
    Refer: - Workflow Guide
    Create Inbound Partner Profile
    For each message type you need to maintain the inbound partner profiles. Maintain receiving system partner profile using WE20 (See fig. 10.3). Add the message type in the Senders inbound parameter.
    Following steps will be followed for creation of partner profile (Inbound).
    • Add the message type (e.g. ZEMPMSG) into the inbound parameter by clicking .
    WE20 – Addition of message type in Inbound Partner Profile
    • On the next screen enter the message type , process code. In the Processing by function module block select the radio button based on the need. If you clicked on Triggered by background program then the IDOC will be collected and will triggered by another program which will run in background and if the second option Triggered immediately is clicked then the IDOC will be processed by the function module as soon as it is triggered.
    WE20 – Inbound Parameters.
    WE20 – Create Partner profile
    Sample Code Snippet
    Important Steps are as follows.
    1) Unpacking of IDOC: - Unpack the IDOC into the respective segments.
    2) Process Data: - Process the unpacked data.
    3) Error Handling.
    4) Workflow triggering.
    FUNCTION Z_IDOC_INPUT_EMPMAST.
    ""Local interface:
    *” IMPORTING
    *" REFERENCE (INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
    *" REFERENCE (MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
    *” EXPORTING
    *" REFERENCE (WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT
    *" REFERENCE (APPLICATION_VARIABLE) LIKE BDWFAP_PAR-APPL_VAR
    *" REFERENCE (IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK
    *" REFERENCE (CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS
    *” TABLES
    *" IDOC_CONTRL STRUCTURE EDIDC
    *" IDOC_DATA STRUCTURE EDIDD
    *" IDOC_STATUS STRUCTURE BDIDOCSTAT
    *" RETURN_VARIABLES STRUCTURE BDWFRETVAR
    *" SERIALIZATION_INFO STRUCTURE BDI_SER
    *” EXCEPTIONS
    *" WRONG_FUNCTION_CALLED
    DATA: S_EMPMAST LIKE ZEMPMASTHEADERSEG.
    DATA: T_EMPMAST LIKE ZEMPMASTSEG OCCURS 0 WITH HEADER LINE.
    DATA: WA_EMPMAST LIKE ZEMPMAST.
    DATA: L_FLAG VALUE 'Y'.
    CLEAR S_EMPMAST.
    REFRESH T_EMPMAST.
    check if the function is called correctly *
    IF IDOC_CONTRL-MESTYP 'ZEMPMSG'.
    RAISE WRONG_FUNCTION_CALLED.
    ENDIF.
    WORKFLOW_RESULT = 0.
    Unpacking the IDoc
    LOOP AT IDOC_DATA.
    CASE IDOC_DATA-SEGNAM.
    WHEN 'ZEMPMASTHEADERSEG'.
    MOVE IDOC_DATA-SDATA TO S_EMPMAST.
    WHEN 'ZEMPMASTSEG'.
    MOVE IDOC_DATA-SDATA TO T_EMPMAST.
    APPEND T_EMPMAST.
    ENDCASE.
    ENDLOOP.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-MSGV1 = IDOC_CONTRL-IDOCTP.
    IDOC_STATUS-MSGID = '00'.
    IDOC_STATUS-MSGNO = '398'.
    Processing Data
    LOOP AT T_EMPMAST.
    MOVE-CORRESPONDING T_EMPMAST TO WA_EMPMAST.
    INSERT INTO ZEMPMAST VALUES WA_EMPMAST.
    G_OKCODE = SY-SUBRC.
    IF G_OKCODE 0.
    L_FLAG = 'N'.
    Error Handling
    IDOC_STATUS-STATUS = '51'.
    IDOC_STATUS-MSGTY = 'E'.
    IDOC_STATUS-MSGV2 = 'Employee & already exists'.
    REPLACE '&' WITH WA_EMPMAST-EMPNO INTO IDOC_STATUS-MSGV2.
    IDOC_STATUS-SEGNUM = SY-TABIX + 1.
    APPEND IDOC_STATUS.
    ENDIF.
    AT LAST.
    ENDAT.
    ENDLOOP.
    IF L_FLAG 'Y'.
    Workflow Triggering
    CLEAR RETURN_VARIABLES.
    RETURN_VARIABLES-WF_PARAM = 'Error_IDOCs'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    WORKFLOW_RESULT = '99999'.
    ROLLBACK WORK.
    ELSE.
    IDOC_STATUS-STATUS = '53'.
    IDOC_STATUS-MSGTY = 'S'.
    IDOC_STATUS-MSGV2 = 'Employee Info inserted'.
    APPEND IDOC_STATUS.
    ENDIF.
    ENDFUNCTION.
    Execution Steps for inbound Idoc:
    To execute inbound idoc go to Transaction we19 give the Idoc number execute the transaction
    It displays a screen with control, data, and status records. Click Standard inbound OR inbound function module buttons and process the idoc.
    i) Standard inbound:
    If you have selected the standard inbound button it displays a screen with the standard setup:
    II) Inbound function module:
    If you select the in bound function module button displays the below screen you can enter the function module name which you want to execute
    If you select Check box Call in debug mode you can execute the function module in debug mode.
    Call transaction Processing:
    In Background:
    The function module is called in the background
    This setting is only important if the function module to be called reacts accordingly to the importing parameter 'INPUT_METHOD'. This is therefore only valid for function modules which implement the application functionality using the command 'CALL TRANSACTION'.
    In foreground :
    The function module is called in the foreground.
    This setting is only important if the function module to be called reacts accordingly to the importing parameter 'INPUT_METHOD'. This is therefore only true for function modules which implement application functionality using the command 'CALL TRANSACTION'.
    In foreground After error:
    The function module is called in a background session. This becomes a session in the foreground after the first error has occurred.
    This setting is only important if the function module to be called reacts accordingly to the importing parameter 'INPUT_METHOD'. This is therefore only true for function modules which implement application functionality using the command 'CALL TRANSACTION'.
    Now it will post the idoc.
    Testing of Inbound Idoc:
    If you need to check the status of idoc Go to Transaction ZE05 give the idoc number in the idoc number select option execute the transaction.
    Then displays a screen with Out box and Inbox . select the idoc number in the Inbox Shows the control record , data record ,status record .select the status record and check for the idoc status Then you will be known the idoc is successful posted or not.
    The idoc which has been posted into SAP successfully will have the status 53.
    The list of the other valid status for Inbound Idoc are as follows:
    Status Message Description
    50 IDoc added
    51 Error: Application document not posted
    52 Application document posted
    62 IDoc passed to application
    64 IDoc ready to be transferred to application
    74 IDoc was created by test transaction
    Process Steps for Outbound IDOC Programming
    The following steps are required for Outbound IDOC Programming.
    Common Steps
    The steps for new segment creation, new Idoc Type, new Message Type and linking between message type and Idoc Type are same as Inbound Idoc Programming. The detail Steps for such activities are mentioned in the Page 2 to Page 5.
    Create Outbound Partner Profile
    Use Transaction WE20 and select the Receiver Partner. Then add message type ZEMPMSG in the outbound parameters. The partner profile needs to be created at the ReceiverLogical System(LS)/Customer(KU)/Vendor(LI)/Bank(B)/Benefits provider(BP)/ User(US) only.
    Then double click on the Message type ZEMPMSG and it navigates to the following screen where user has to set the following attributes:
    • Receiver port as A000000001 for RFC
    • Packet Size field as 1
    • Idoc type Z_EMPMAT_IN in basic type field
    • Set the Syntax check box
    • Set the output mode as Transfer Idoc immediately
    • Save the changes.
    Coding Steps:
    1) Create an Executable Program Based on specification.
    2) All the Important Data should be displayed as Parameters with mandatory.
    i) Message type
    ii) Sender port
    iii) Sender partner
    iv) Sender partner function
    v) Receiver port
    vi) Receiver partner
    vii) Receiver partner function
    3) Select the data based on selection screen into an internal table.
    4) Read the selected internal table and fill the Header segment.
    5) Now Loop the internal table to fill other Segments.
    6) Fill the Control segment data.
    7) Call the proper Function module and pass the data to the function module
    To create the idoc.
    8) Change the status of idoc based on the function module return code.
    9) If FM return code is 0 set status to 03.
    10) See the demo program Z_IDOC_OUTBOUND_EMP for more Clarification.
    Sample Code Snippet
    REPORT Z_IDOC_OUTBOUND_EMP .
    TABLES: ZEMPMAST.
    DATA: F_IDOC_CONTRL LIKE EDIDC,
    T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,
    T_IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.
    Data: Begin of t_zempmast occurs 0.
    include structure zempmast.
    Data: end of t_zempmast.
    data:wa_ZEMPMAST like ZEMPMAST.
    data:wa_ZEMPMASTSEG like ZEMPMASTSEG.
    Data: wa_ZEMPMASTHEADERSEG like ZEMPMASTHEADERSEG.
    CONSTANTS: C_BASIC_IDOC_TYPE LIKE EDIDC-IDOCTP VALUE 'Z_EMPMAT_IN',
    C_Z1CLIPS_SEG_NAME LIKE EDIDD-SEGNAM VALUE 'Z1CLIPS',
    TRUE VALUE 'X',
    FALSE VALUE SPACE.
    “Selection Screen----
    SELECTION-SCREEN BEGIN OF BLOCK EMP WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_EMPNO FOR ZEMPMAST-EMPNO.
    SELECTION-SCREEN END OF BLOCK EMP.
    PARAMETERS: P_MESTYP LIKE EDIDC-MESTYP
    DEFAULT 'ZEMPMSG'
    OBLIGATORY.
    PARAMETERS: P_SNDPRT LIKE EDIDC-SNDPRT,
    P_SNDPRN LIKE EDIDC-SNDPRN,
    P_SNDPFC LIKE EDIDC-SNDPFC.
    PARAMETERS: P_RCVPRT LIKE EDIDC-RCVPRT,
    P_RCVPRN LIKE EDIDC-RCVPRN,
    P_RCVPFC LIKE EDIDC-RCVPFC.
    “Selection of data
    Perform select_data.
    “Create Idoc
    perform creat_idoc.
    CLEAR F_IDOC_CONTRL.
    *& Form select_data
    text
    --> p1 text
    <-- p2 text
    FORM select_data.
    “Selecting the required data based on Selection Screen
    select * into corresponding fields of table t_ZEMPMAST from ZEMPMAST
    where EMPNO in s_EMPNO.
    ENDFORM. " select_data
    *& Form creat_idoc
    text
    --> p1 text
    <-- p2 text
    FORM creat_idoc.
    “Creating Header Segment
    if not t_zempmast[] is initial.
    T_IDOC_DATA-SEGNAM = 'ZEMPMASTHEADERSEG'.
    “Populating Idoc data table with header Segment
    perform prepare_segment using wa_zempmast.
    T_IDOC_DATA-SDATA = wa_ZEMPMASTHEADERSEG.
    APPEND T_IDOC_DATA.
    “Creating other Segments.
    loop at t_zempmast into wa_zempmast.
    CLEAR T_IDOC_DATA.
    “Filling item segment
    T_IDOC_DATA-SEGNAM = 'ZEMPMASTSEG'.
    perform prepare_segment1 using wa_zempmast.
    T_IDOC_DATA-SDATA = wa_ZEMPMASTSEG.
    “Adding the item segments into idoc table
    APPEND T_IDOC_DATA.
    CLEAR T_IDOC_DATA.
    endloop.
    “Filling Control data.
    F_IDOC_CONTRL-MESTYP = P_MESTYP.
    F_IDOC_CONTRL-IDOCTP = C_BASIC_IDOC_TYPE.
    F_IDOC_CONTRL-SNDPRT = P_SNDPRT.
    F_IDOC_CONTRL-SNDPRN = P_SNDPRN.
    F_IDOC_CONTRL-SNDPFC = P_SNDPFC.
    F_IDOC_CONTRL-RCVPRT = P_RCVPRT.
    F_IDOC_CONTRL-RCVPRN = P_RCVPRN.
    F_IDOC_CONTRL-RCVPFC = P_RCVPFC.
    “Creating idoc
    PERFORM DISTRIBUTE_THE_IDOC TABLES T_IDOC_DATA
    T_COMM_CONTROL
    USING F_IDOC_CONTRL.
    endif.
    ENDFORM. " creat_idoc
    *& Form prepare_segment
    text
    -->P_T_ZEMPMAST text
    FORM prepare_segment USING P_T_ZEMPMAST like ZEMPMAST.
    “Filling header Segment
    wa_ZEMPMASTHEADERSEG-REPNAME = sy-repid.
    wa_ZEMPMASTHEADERSEG-DATE = sy-datum.
    wa_ZEMPMASTHEADERSEG-TIME = sy-uzeit.
    ENDFORM. " prepare_segment
    *& Form prepare_segment1
    text
    -->P_WA_ZEMPMAST text
    FORM prepare_segment1 USING P_T_ZEMPMAST like ZEMPMAST.
    “filling item segment
    wa_ZEMPMASTSEG-EMPNO = P_T_ZEMPMAST-EMPNO.
    wa_ZEMPMASTSEG-EMPNAME = P_T_ZEMPMAST-EMPNAME.
    ENDFORM. " prepare_segment1
    *& Form DISTRIBUTE_THE_IDOC
    text
    -->P_T_IDOC_DATA text
    -->P_T_COMM_CONTROL text
    -->P_F_IDOC_CONTRL text
    FORM DISTRIBUTE_THE_IDOC TABLES T_IDOC_DATA STRUCTURE EDIDD
    T_COMM_CONTROL STRUCTURE EDIDC
    USING F_IDOC_CONTRL STRUCTURE EDIDC.
    READ TABLE T_IDOC_DATA INDEX 1.
    IF SY-SUBRC = 0.
    insert and distribute the idoc
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
    EXPORTING
    MASTER_IDOC_CONTROL = F_IDOC_CONTRL
    TABLES
    COMMUNICATION_IDOC_CONTROL = T_COMM_CONTROL
    MASTER_IDOC_DATA = T_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.
    “displays the message if creation of idoc is not sucessfull
    MESSAGE ID 'ZI'
    TYPE 'E'
    NUMBER '017'
    WITH 'MASTER_IDOC_DISTRIBUTE' SY-SUBRC.
    STOP.
    else.
    COMMIT WORK.
    “Displays message with success message
    MESSAGE ID 'ZI'
    TYPE 'I'
    NUMBER '020'
    WITH F_IDOC_CONTRL-IDOCTP SY-SUBRC.
    ENDIF.
    CLEAR: T_IDOC_DATA.
    REFRESH: T_IDOC_DATA.
    ENDIF.
    ENDFORM. " DISTRIBUTE_THE_IDOC
    Execution Steps
    To execute the outbound idoc Go to SE38 screen&#61672;Give the program name and fill the Selection and execute it.
    Testing of Outbound Idoc:
    If you need to check the status of idoc Go to Transaction ZE05 give the idoc number in the idoc number select option execute the transaction.
    Then displays a screen with Out box and Inbox . select the idoc number in the Outbox Shows the control record , data record ,status record .select the status record and check for the idoc status Then you will be known the idoc is successful posted or not.
    The idoc which has been successful will have the status 03.
    The bellow are the some of the Out bound status:
    Status Message Description
    01 IDoc created
    02 Error passing data to port
    03 Data passed to port OK
    29 Error in ALE service
    30 IDoc ready for dispatch (ALE service)
    31 Error - no further processing
    Change Pointers & Reduction of IDOCs.
    Applications, which write change documents, will also try to write change
    pointers for ALE operations. These are log entries to remember all modified
    data records relevant for ALE. The change point is used for extending or reducing the Idoc structure.
    Following Steps must be followed in case of Change Pointer.
    1) Goto Transaction BD60.
    Note down the Details of the Message Type for which change pointer has to activate. Details like Function Module, Classification Object, ALE object Type etc.
    E.g. ZDEBP3
    2) Next step is goto transaction BD53
    Click on change button.
    First select the segment for which the fields has to modified (either remove or
    add ).
    It will show the fields in a pop-up window where the user can select, deselect the respective fields.
    Save the settings for the Message type. Don’t forget to deactivate and activate the change pointers by clicking Deactivate change pointer and Activate Change pointers button on the main screen. It is mandatory to first Deactivate the change pointer and then activate it.
    Do not save the changes in the same transport request. Create separate transport request, which will be not transported. This is because once you transport the changes then it will not allow you to do the changes on the server on which it has transported.
    3) Once the activation is done system will reset the settings for the Message type in Change pointers (BD60). Maintained the old settings for the Message type like Function Module, Classification Object, and ALE object Type etc.
    Check this link
    http://www.intelligententerprise.com/channels/applications/feature/archive/kasturi2.jhtml
    Regards
    Pavan

  • Regarding outbound idoc into xml conversion

    Hello everyone
    can anyone let me kno all the procedure to make our idoc outbound and convert it into XML file,  is there any standard program or any other method if i am using we21 then what thing i have to do. is it neccesary for us to go to tc we60 and change schema of our structure or not, i don't want to use XI, please tell me whole procedure if possible, waiting for your reply.
    plz reply me.
    Thanks & Regards
    vimarsh b
    Edited by: vimarsh b on Jan 8, 2008 5:58 AM

    hai,
    check this.
    Outbound Interface
    PROCESS DIAGRAM for Outbound Interface
    1. Analyse Hierarchy Levels
    2. Create New segment
    3. Create New IDoc Type
    4. Create New Message Type
    5. Link Message with IDoc Type
    6. Create an entry in EDP13 via transactions WE20 and BD64
    7. Populate the Custom IDoc via ABAP Program
    7b Error Handling
    7c. Send Status Email
    8. Test the Population of the Custom IDoc
    Step 1 – Analyse Hierarchy Levels:
    Analyse the data relationships being processed in the interface. Define the appropriate hierarchical Parent-to-Child relationships.
    Navigate to transaction code WEDI
    Transaction WEDI displays the IDOC main menu. This allows navigation around the various development and control areas to create a customised IDOC.
    Step 2 – Create a new segment:
    via wedi : Development - IDOC Segments or Transaction code WE31.
    • Enter segment name and click on Create.
    ? The name of the segment type must start with Z1 , and have a maximum of eight characters.
    • Enter description and enter the relevant field names and data elements.
    ? The segment should represent a structure in the program so for each field in the segment a field name and a data element must be defined.
    • Save the segment and enter Person Responsible and Processing Person .
    • Go to Edit and Set Release.
    • Repeat this procedure for each new Segment in the IDOC.
    Step 3 – Create a new IDOC Type
    via wedi Development - IDOC Types or Transaction WE30.
    • Enter segment name (starting with Z), click on Basic Type and then Create.
    • Create as new, enter Person Responsible and Processing Person and enter description.
    • On ‘Create Basic Type’ screen decide where segments should be inserted and go to Edit/Create Segment.
    • Complete relevant fields in the Maintain Attributes screen:
    • From the relevant segments created in Step 2 enter the Segment type and if mandatory segment.
    • The Minimum and Maximum number of segments to be allowed in the sequence. (One minimum and one maximum if segment is mandatory).
    • The Parent Segment and Hierarchy Level will be automatically created depending on where in the IDOC tree you decided to create that particular segment.
    • Repeat this process for each segment needed in the IDOC type, deciding whether to add the next segments at the same level or as a ‘Child’.
    • When IDOC created return to initial screen. Go to Edit and Set Release.
    • Go to Transaction WE60 to view the IDoc Type you have created.
    Step 4 – Create new Message Type
    via wedi Development - Message Types or Transaction WE81.
    • Display/Change and click on New Entries
    • Create a new Message Type and Save.
    Step 5 – Link Message Type to IDOC Type
    via wedi Development - IDOC Type/Message or Transaction WE82.
    • Display/Change and then click on New Entries.
    • Enter Message Type, Basic Type (IDOC Type) and Release (46C) and Save.
    Step 6 – Create an entry in EDP13 via transactions WE20 and BD64.
    The partner profile for the Idoc must be set up and generated in the transaction BD64 and transaction WE20.
    • WE20 – Add Message Type to appropriate Partner Type, Enter Message Type, Receiver Port and Idoc Type and Save.
    • BD64 – Create a Model View, Enter Sender and Receiver Ports, Attach Message Type. Go to ‘Environment’ on Menu and click on Generate Partner Profiles and generate (not save) profile.
    Step 7 – Populate the custom IDOC via ABAP Program
    See Test Program ZOUTBD_IDOC_TEMPLATE, Appendix IV.
    • Create an Internal Table for each segment type, this should be exactly the same structure as the segment type.
    • The control record is filled into a structure like EDIDC. The message type and the Idoc type for the Idoc must be populated into the eddic structure.
    - PERFORM populate_Control_structure USING c_mestyp
    c_SEGMENT_type1.
    • The data segments are filled into a structure like edidd-sdata; sdata and the segment name are populated into the edidd structure.
    - PERFORM transfer_Parent_data_to_seg.
    • The standard SAP function module MASTER_IDOC_DISTRIBUTE is called to pass the populated IDOC to the ALE Layer.
    - PERFORM master_idoc_distribute.
    • NOTE: This function module is only called for stand alone programs and Shared Master Data programs (SMD). It is not called when using extensions or output determination.
    • The ALE Layer handles the sending of the IDOC to the receiving system.
    • Error Handling (see Step 7b).
    • Commit work.
    Project Specific
    Step 7b – Error Handling• Analyse which fields in the interface are mandatory for the receiving system and who needs to receive error notification.
    • Declare a structure of type ‘MCMAILOBJ’ for sending instructions.
    • Enter values for the internal table based on structure ‘MCMAILOBJ’
    • For selection processes, on SY-SUBRC checks and where fields are mandatory for the receiving system; insert Function Module ‘MC_SEND_MAIL’.
    • Enter values in the following parameters: -
    MS_MAIL_SENDMODE = ‘B’ (Batch Mode)
    MS_MAIL_TITLE = 'Mail Title'
    MS_MAIL_DESCRIPTION = ‘Error description’ (e.g. MATNR not given)
    MS_MAIL_RECEIVER = ‘Name of Receiver’ (To be determined)
    MS_MAIL_EXPRESS = ‘E’ (Express Delivery)
    MS_MAIL_DLINAME = Leave Blank
    MS_MAIL_LANGU = 'E' (Language)
    MS_MAIL_FUNKOBJ_NAME = Leave Blank
    TABLES
    MS_MAIL_CONT = I_MCMAILOBJ
    Note:
    It has to be determined separately for each interface how these errors and mail notifications are to be grouped – dependant upon the number of errors that are potentially likely. One possible approach is to send an email for each reason for rejection and include all the records that failed for that reason in the mail notification. Another possible approach is to send an email for every failure.
    When error checking for mandatory fields it is common SAP practice to reject a record on its first failure (irrespective of subsequent errors in that record)
    Step 7c – Send status mail
    • Append to table I_MCMAILOBJ details of the time the interface was processed, how many Idocs were created and how many of these produced a status of 03.
    • Select the user to receive the mail from ZINT_RECEIVER, using the name of the program as a key (SY-CPROG).
    • Use function Module ‘MC_SEND_MAIL’ to send a mail to the user containing the contents of I_MCMAILOBJ at the end of the interface processing.
    Step 8 – Test the population of the custom IDOC
    via wedi IDoc - Display IDoc or Transaction WE02.
    • Enter your message type and execute.
    • Status should be green, double click on one of the Idocs you have created to view its contents.
    • If a problem has occurred click on Status which will give you a description of the error.
    • Drop down Data Records arrow and this should list the data in the IDoc in the correct hierarchical structure.
    • Click on each individual segment and view the content to check that the correct data has been read.
    • If you have UNIX access by using AL11 you can view the file that you have created.
    Note:
    For some interfaces it may be valid to send an empty file to SAP. This empty file is converted to the custom IDOC format expected by SAP. This custom IDOC will contain dummy information. In the inbound processing code, if the dummy information is identified then the processing of the IDOC is considered to be complete and the IDOC should then be assigned a successfully processed status of 53, even though it has not been processed at all.
    also gothroughthe links,
    http://www.theobald-software.com/download/ERPConnect/ERPConnectDevGuide_EN.pdf.
    http://help.sap.com/saphelp_nw04/helpdata/en/0b/2a611c507d11d18ee90000e8366fc2/frameset.htm
    Check below link. It will give the step by step procedure for IDOC creation.
    http://www.supinfo-projects.com/cn/2005/idocs_en/2/
    With regards,
    Sowjanya.B.

Maybe you are looking for