Reg:ALE/IDOCS

Hi Experts,
I have one doubt in ale/idocs that is , some idocs are accidently posted, how to solve this issue. at the same time how to avoid duplication of idocs. please send the answers.
Thanks & Regards,
N.Narasimha Rao.

I understand what you mean by "Duplicates", but the question that I have to ask is what do you mean by "accidentily posted".
The key thing to the ALE framework is the proper use of DB transactions.  The updateing of the ALE status and message tables are combined in the same DB transaction as the actual buisness logic updates that are happening in your IDoc processing function.  So what does this mean to you you're asking?  It means that the implimentation of your update logic can sometimes cause the possibility of duplicates.
Certain types of updates are ones that cause issues, and these would be updates that are beyond your control when it comes to the DB transaction:
- BDC/Call Transaction - On these they have their own seperate DB transaction, so it is possible that the BDC can sucsesfully post a transaction and then when the logic returns to the IDoc processing function if something causes it to terminate before completing then it is possible that the buisness transaction is complete and your IDoc status has never been updated.  Because the IDoc status has never been updated the same IDoc will get picked up for processing again.
- Calls to API functions where they contain a commit inside them or an option to include a commit and you don't supress it - Similiar to Call Transaction issues on this one that the buisness transaction can be commited before the framework commits its final status.
- Multiple transactions - Sometimes it is nesasary to call multiple APIs inside your processing function but they require commits in between them in order to work properly.  An example of this could be first creating a customer master record and then creating a sales order for that customer.  In this case a commit is required inbetween the two calls.  In a case like this it is possible that half of your buisness logic has been executed and commited, the second part hasn't been commited and the framework hasn't commited the status.  The requriment for the commit would be that the customer master API doing the update uses an update task and therefore the actual updates to the DB aren't executed until an explicit commit statement is executed (note also that the ALE framework sets update tasks to local mode so that it doesn't require the use of asynch update processes).
So, with these above things being issues when it comes to the DB transactions for ALE processing, what can you do to prevent them:
- For Call transaction issues there isn't much that you can do, becuase the DB transactions is out of your hands.  The only solution I would recommend here is to not use Call Transactions.  It is an old technology anyways and there are much better ways to do it usually by calling APIs.
- If the API you are calling contains a commit, you should look to see if there is an option for you to turn it off via an input parameter.  If not then you will end up with some of the same issues as Call transaction but there is a technique that you can use to supress duplicates from posting since the DB transaction (unlike in Call Transaction) is actaully the same transaction that was started by the ALE framework, the technique is what I refer to as ALE Stages.
- If you require multiple API calls which require commits in between them then the solution that I have used many times is what I refer to as ALE Stages.
So how do you do ALE stages?  The following is an overview of what you'll need to do:
- Create a new custom table as a copy of the INDX table (data cluster table).  This table is going to be used for two purposes, one is to store information about what has been processed so far and secondly is to handle the passing of transient data if processing is restarted.
- In your processing function consider it as a number of stages (one for each transaction) and perform the following logic for each stage:
1) Use the import statement to read in data from the cluster table (Keyed off of the IDoc number).  This contains information about what stages have been completed and also any transient data that has been generated by one stage and needs to be passed to another.  You can use a complex data structre to store all of this information.
2) If the current stage has already been executed then skip this section of your processing logic.  Otherwise execute it:
2a) Execute the API call
2b) Used an export statement to write an updated status to the data cluster table including any transient data that will be required for the next stage.
2c) Execute a commit
- After all stages are complete, do a delete on the record in the data cluster table.  Important point though is to not do a commit.  The reason that you don't do a commit is if there is a failure prior to commit inside the ALE framework that update the final IDoc status then you will have lost your stage status information and the entire IDoc would be duplicated again.
- By doing stages of this type you are creating sub-transactions that if the IDoc fails at any point then when it is reexecuted it will skip the parts that have already been done.
- The secret to this is that each stage is it's own DB transaction and includes the API call and the update to the stage status table together.  The final deleting of the stage status is linked in with the overall DB transaction done by the ALE framework.
- In the case where you are using an API that has a commit embbeded inside it that you don't have control over, you can still use stages.  The secret is that you need to update the stage status table prior to the API call.  Even though it is done first it isn't commited until the API executes it's embeded commit.  The only issue with this is that you can't depend on return values from the API as transient data to support the next stage becuase you have no way of writing it to the stage status table as part of the same transaction as the API update.
This is a failry high-level description of some of the things to look out for and how to handle them.  The use of stages is something I've done a lot and is nice because if implimented properly it will provide a bullet-proof way to ensure that no part of your transaction will be updated twice.  The main issue I find when I see developers try to implimnet this though is that they don't understand completly how DB transactions work and they end up with holes in their logic.
Hope this helps.  If I've got some time at some point I'll post some specific pieces of code as an example of stages.
~Ian
Edited by: Ian Maxwell on Aug 3, 2008 5:43 PM

Similar Messages

  • REG:ALE,IDoc , RFC

    HI,
    PLEASE SEND ANY GOOD MTERIAL FOR ALE IDOC , RFC.
    THANK YOU
    ASHOK KUMAR

    hi,
    <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://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
    ALE/ IDOC/ XML
    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
    IDOC Convertion
    /people/kevin.wilson2/blog/2005/12/07/changing-fields-in-an-idoc-segment
    http://www.sappoint.com/abap/ale.pdf
    http://www.sappoint.com/abap/ale2.pdf
    http://www.sapgenie.com/ale/configuration.htm
    http://www.sappoint.com/abap/ale.pdf
    http://www.sappoint.com/abap/ale2.pdf
    http://www.sapdevelopment.co.uk/training
    http://www.sapgenie.com/ale/why_ale.htm
    http://www.sapdevelopment.co.uk/training
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    ALE/ IDOC
    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.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
    ALE/ IDOC/ XML
    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
    You need to create idocs for the same. Have a look at below link.It will heip you surely.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDI/CAEDI.pdf
    To Create Idoc we need to follow these steps:
    Create Segment ( WE31)
    Create Idoc Type ( WE30 )
    Create Message Type ( WE81 )
    Assign Idoc Type to Message Type ( WE82 )
    Creating a Segment
    Go to transaction code WE31
    Enter the name for your segment type and click on the Create icon
    Type the short text
    Enter the variable names and data elements
    Save it and go back
    Go to Edit -> Set Release
    Follow steps to create more number of segments
    Create IDOC Type
    Go to transaction code WE30
    Enter the Object Name, select Basic type and click Create icon
    Select the create new option and enter a description for your basic IDOC type and press enter
    Select the IDOC Name and click Create icon
    The system prompts us to enter a segment type and its attributes
    Choose the appropriate values and press Enter
    The system transfers the name of the segment type to the IDOC editor.
    Follow these steps to add more number of segments to Parent or as Parent-child relation
    Save it and go back
    Go to Edit -> Set release
    Create Message Type
    Go to transaction code WE81
    Change the details from Display mode to Change mode
    After selection, the system will give this message “The table is cross-client (see Help for further info)”. Press Enter
    Click New Entries to create new Message Type
    Fill details
    Save it and go back
    Assign Message Type to IDoc Type
    Go to transaction code WE82
    Change the details from Display mode to Change mode
    After selection, the system will give this message “The table is cross-client (see Help for further info)”. Press Enter.
    Click New Entries to create new Message Type.
    Fill details
    Save it and go back
    Go thro' thesre links:-
    http://help.sap.com/saphelp_46c/helpdata/en/dc/6b835943d711d1893e0000e8323c4f/content.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/0b/2a6620507d11d18ee90000e8366fc2/frameset.htm
    http://www.sappoint.com/presentation.html
    http://www.allsaplinks.com/idoc_search.html
    http://www.sapgenie.com/sapedi/idoc_abap.htm
    http://www.thespot4sap.com/Articles/SAP_ALE_IDOCS.asp
    <b>RFC</b>
    Remote Function Call:
    RFCs are requests that an SAP component sends to invoke functions on remote systems, or calls that remote systems initiate to invoke functions on an SAP component.A process that can accept RFCs from SAP components. This allows SAP components to access functions in external systems. In SAP BC terminology, the process is called a Listener. Listeners are one or more threads on SAP Business Connector that wait for incoming requests from SAP components. Listeners are named and register with an SAP gateway to indicate that they are ready to accept requests. Listeners can accept RFC or tRFC requests.
    Transactional RFC (tRFC) and Queued RFC (qRFC). tRFC is used mainly to transfer ALE Intermediate Documents (IDocs).
    Transactional RFC:
    If an error occurs during a synchronous remote function call, the system cannot tell at what point the error occurred (most crucially, whether the function module was actually processed in R/3 before the operation failed). Restarting a failed call is therefore a dangerous thing to do, since you risk duplicating a completed function call.
    To alleviate this problem, you can use transactional RFC, which guarantees that each function call you issue will only be executed once, even if you submit it repeatedly to the R/3 System. The system implements this safeguard by assigning a unique transaction ID (TID) to each transaction that you submit. When you attempt to process the transaction, the system checks whether that TID has already been processed. If it has, the transaction is ignored.
    Queued RFC:
    When you use transactional RFC, you cannot guarantee the order in which the function calls will be processed in the system (it is quite possible that one call might overtake another). For cases where you need to specify a particular processing order, you can use queued RFC, which is an extension of transactional RFC. In qRFC, you place each function call in a logical queue. A function call cannot be executed until all of its predecessors in the queue have been processed. Queued RFC calls are processed asynchronously.
    RFC is an SAP interface protocol. Based on CPI-C, it considerably simplifies the programming of communication processes between systems.
    RFCs enable you to call and execute predefined functions in a remote system - or even in the same system.
    RFCs manage the communication process, parameter transfer and error handling.
    Have a look at this link.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE2/BCFESDE2.pdf
    http://help.sap.com/saphelp_47x200/helpdata/en/22/042860488911d189490000e829fbbd/frameset.htm.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f078394a-4469-2910-c4bf-853c75674694
    Regards
    Ashu

  • Reg ALE-IDOC------- rush for points :)

    Hi all,
    I m trying ALE from client 800 to 810 of IDES. I completed the outbound process and i m seeing the IDOC with status 03 in WE02 with green signal.
    Now wht i need to do to see my iDOC....help me futher.
    Regards,
    [email protected]

    Hi
    See the tarnsaction WE05
    or in the tables EDIDS,EDIDC and EDID4
    see the other related tcodes of the IDOC's
    Important Transaction Codes:
    SALE - IMG ALE Configuration root
    WE20 - Manually maintain partner profiles
    BD64 - Maintain customer distribution model
    BD71 - Distribute customer distribution model
    SM59 - Create RFC Destinations
    BDM5 - Consistency check (Transaction scenarios)
    BD82 - Generate Partner Profiles
    BD61 - Activate Change Pointers - Globally
    BD50 - Activate Change Pointer for Msg Type
    BD52 - Activate change pointer per change.doc object
    BD59 - Allocation object type -> IDOC type
    BD56 - Maintain IDOC Segment Filters
    BD53 - Reduction of Message Types
    BD21 - Select Change Pointer
    BD87 - Status Monitor for ALE Messages
    BDM5 - Consistency check (Transaction scenarios)
    BD62 - Define rules
    BD79 - Maintain rules
    BD55 - Defining settings for IDoc conversion
    WEDI - ALE IDoc Administration
    WE21 - Ports in Idoc processing
    WE60 - IDoc documentation
    SARA - IDoc archiving (Object type IDOC)
    WE47 - IDoc status maintenance
    WE07 - IDoc statistics
    BALE - ALE Distribution Administration
    WE05 - IDoc overview
    BD87 - Inbound IDoc reprocessing
    BD88 - Outbound IDoc reprocessing
    BDM2 - IDoc Trace
    BDM7 - IDoc Audit Analysis
    BD21 - Create IDocs from change pointers
    SM58 - Schedule RFC Failures
    Basic config for Distributed data:
    BD64: Maintain a Distributed Model
    BD82: Generate Partner Profile
    BD64: Distribute the distribution Model
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Reg :How can we debug in ale/idoc

    in ale/idoc  where can we put the break points , and how can we know is it received correctly with out we05.

    Hi,
                  WE19 tcode is the Test tool for IDOC. You can put a break-point in the correspond inboound or outbound function module for that IDOC and debug it.
    Regards,
    Vishnu Priya

  • ALE-IDOCS posting

    Hi,
    How to do the inbound data transfer using ale-idocs..
    In hr i am getting errors  plz help me.

    Hi ,
    the thing is ,  data will transfer either outbound and inbound by using the idocs. outbound means sending some information to another system it may be version to version and client to client.
    inbound means receving the data.
    Basically we have some procedure to send an idoc.
    Phase 1 : ALE settings
    Phase 2 : Idoc Creation
    Phase 3 : Code develpment
    Now i am going to first phase..
       Process :
        SALE is the tranx code where we defined the logical systems and assign them.
       here we defined both inbound and outbound system.
       then define RFC destination by using Tranx code : SM59
       define the partner profiles and port using tranx WE21 and WE20
       define the CDM ,Customer distribution model , BD64 , enter the message type and logical system for both (inbound and outbound )
        Note " in distributin model we can defined the filtering and field conversions ..
    Once we finished these settings sucessfully then moves to phase 2.
      Idoc creation :
       creation of segments using tranx code : WE31
       creation of idoc   using tranx code : WE30
        creation of message type : we80 and we81.
    Phase 3 :
    we can use in three ways to develp the code, 
    standard alone program and message control and change control..
    Reg,
    Rupa

  • Logical systems in ALE iDoc

    Hi,
    For exchanging data between two systems(not between two clients of the same system) using ALE iDoc , logical systems should be maintained in both the systems?
    For eg: there are two systems, system A and system B.
    i have maintained the logical systems as SYSA (for system A)  and SYSB ( for system B) in the system A using the transaction 'SALE'. Should this need to be maintained in system B also?
    Thanks & Regards,
    Soumya.

    Hi,
    In both the systems you have to Define the Logical systems,
    but in you assign only one to the client,
    i.e. in system A you assign the Logical Sytem of of A to the Client in SALE
    transaction the same goes for B.
    and you don't need to create a distribution model for both the systems,
    you can create it in one system and send it to the other system.
    Regards,
    Samson Rodrigues.

  • Upload data from legacy system to SAP through ALE IDOC

    Hello All,
    I have a requirement where i need to upload the data from legacy system to SAP. So i am using ALE IDOC.
    In my requirement i need to extend the Standard IDOC. I have extended the IDOC and even found the exit for the updation of the extended fields to SAP. My data would be be placed in the application server.
    Can anybody tell me how to retrieve the data and update in the tables for the extended fields.
    Could you please provide a sample program for retrieving data for IDOC.
    Thanks

    Hi,
    You can find the sample code in the following link.
    Re: calling idoc_input_creditor
    Regards
    Sajid

  • Error in ALE-IDOC related to HR data posting in ECC 6.0

    Hello People,
    Upgradation done from 4.6B to ECC 6.0.
    Here the data comes from the 3rd part s/w and then gets posted through a Z program which in tern calls SAP standard program " RSEINB00" and FM "IDOC_INBOUND_FROM_FILE" is used in this std program to post the data to the corresponding HR tables through IDOC postings.
    ALE-IDOC Z program works fine in 4.6B but gives error in ECC 6.0.
    Error in subroutine read_namtb for structure of infotype Message no. 5-109 Diagnosis An error has occurred in subroutine read_namtb for structure of infotype .
    Procedure
    Check the entry for infotype in table T777D (structure, IDoc segment, expanded structure) and the corresponding structures.
    As per the error message it seems that some table () needs to be maintained with some values, but this was working fine with the 4.6 B with current settings.
    Is this error due to version change to ECC 6.0? What extra settings need to be done with respect to IDOC so that the posting program works fine without giving the stated error. Kindly let me know.
    Thanks and regards,
    Gaurav Joshi.

    Please keep in mind ECC 6.0 is an UniCode based system.
    as 4.6C was not,
    did the Z-program have been tested before in the current environment?
    Some special functions (keywords hints ...) are no longer supported after the upgrade.,
    this was shown during the upgrade in the unicode migration tools
    For sure all the own programms needs to be verfied, after an upgrade.
    commonly this should be done
    in the quality assurance test to avoid touble in production.

  • Error while crating Sales Order using ALE-IDoc?

    Hi all,
    I have developed an ALE-Idoc interface to create Sales Order automatically When the user created a purchase order. It is working fine since past two months.
    But now one  SO is not created and the error message in Inound idoc is 'Sales Area not defined'  message no V1316.
    The material used in Po creation is created recently and using first time .  i am expecting the problem is with in this material  because the PO's created based on other materials is still creating the SO successfully.
    Please help me in solving this problem?
    Thanks,
    Vamshi.

    Hi shan ,
    Thanks for you reply. The sales area for customer and vendor  is maintained in VOE2 and taking correctly for other materials except for the new material.
    Also in Inbound IDoc which contains the error is having correct sales area in it's segment  . But showing that in the error message as 'sales area & & & is not defined' here the sales area is wrong one it is dispalying.
    so please help me on identifying the problem?
    Thanks,
    vamshi.

  • How to create a sales order using PO ALE Idoc

    Hi,
    I  have a purchase order in my ECC6 system, and output for this PO is ALE idoc.
    Now I want to create a Sales order using that Idoc in the same system,
    can anbody please tell the procedure
    sreeram

    Do NOT USE BAPI_SALESORDER_CREATEFROMDATA, that FM is obsolete!
    Use BAPI_SALESORDER_CREATEFROMDAT1 .
    To build a reference to your contract you have to supply ORDER_HEADER_IN.
    Here´s a sample:
    MOVE:
    gs_vbak-vbeln TO ls_bapisdhd1-refobjkey,
    gs_vbak-vbeln TO ls_bapisdhd1-ref_doc,
    gs_vbak-vbtyp TO ls_bapisdhd1-refdoc_cat,
    gs_vbak-auart TO ls_bapisdhd1-refdoctype.
    also gothrouh the links
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2b-%2bsimple%2bprogram%2bto%2bcreate%2bsales%2border%2busing%2bbapi

  • How to use ale/idocs in sap crm to transfer master and transactional data

    hi all,
    I am working on sap crm7.0 ehp1. I want to transfer my master and transactional data from crm development system to crm quality system here through idocs. I am aware of basic ale settings and successfully transfe the ztable data through idocs. But i am not able to find any proper step by step procedure for maste and transactional data in sap crm. Also sap ecc tcode NACE is not available here.
    pls help..
    regards,
    kavita chaudhary

    Kavita,
    In CRM, Exchange Interface (XIF) ALE/IDOC is available to transfer master and transaction data. You can go through the following link for set up.
    Basic Data exchange set up for ALE IDocs - Wiki - SCN Wiki
    You can extend the standard XIF IDOCs using Transaction BDFg as well.
    Thanks,
    Ravi

  • Passing Changed  extended fields using ALE-IDOC to receiving system

    Hi all,
    Please tell me how passing changed  extended fields using ALE-IDOC to receiving system can be achieved. Is it possible by Chnage pointer concept.Do i need to do some coading after data enters into receiving system as it is required while creating the entries in database table.
    For ex. in matmas05 extended for classification and inspection view and then created using 'CREATION'
    related bapi.Do i also need to incorporate the changes by change related bapi or ir can be handled by change pointer concept.
    Thanks.

    Hi Sanu
    1) Please tell me how passing changed extended fields using ALE-IDOC to receiving system can be achieved. Is it possible by Chnage pointer concept.
    => Looks like you have extended standard IDOC here. so you need to find User Exit or BADI for the Push program to populate the additional fields. Yes, it is possible thru change pointers as well.
    1) Do i need to do some coading after data enters into receiving system as it is required while creating the entries in database table.
    => Yes, as suggested in 1 try finding User Exits/BADIs.
    Regards
    Shital

  • Data transfer using ALE/IDOC into XML.

    Dear All,
    I have to transfer FI document data (FB01) from the sap system ,convert it into XML and dump it in 1 of the file servers.I want to do this using ALE/IDOC.Is it possible to do the same and how.Similarly i want to do the same for Vendor and Customer master i.e sending the data in XML format.
    Kindly Suggest how do i go about doin the same..Its very urgent.Please help.
    Thanks & Regards,
    Lailu Philip.

    In continuation:
    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.
    Hope this will help you,
    If you  want me to explain more, you can give me your email id.
    Reward with points incase you are satisfied.
    Regards,
    Sushama

  • How many types of ports are there which we use for data transfe in ale/idoc

    friends let me know how many types of ports  are there which we use for transfering
    data in ale/idocs?

    Hello,
    you can use file port,trnasactional RFC port.FI you are using IDOC-XML conversion combination,then you can XML port also.
    Thanks

  • Any  having the Experiance with message type UTILMD and REQDOC in ALE Idoc

    Hi experts ,
    I am working with SAP ISU ,in ALE Idoc message types UTILMD and REQDOC,
    ver 3.0 and 4.0 ,I got the  almost all necessary details of UTILMD MESSAGE TYPE..but REQDOC is pending.If any one having the format of REQDOC segments and objectypes in SAP ISU please send it to me it will be very helpful to me .
    Regards
    Sarath

    Thak you for the responce,
    Hai Naveen,But i dont have message type or structure for REQDOC ver 3 or 4 .in SAP .do you have that structure for  REQDOC in the  transaction we30 .if so please send me its mainly used for SAP ISU .
    regards
    sarath

Maybe you are looking for

  • My HP ENVY 4502 won't print more than a few pages at a time

    I'm having real trouble printing from my HP ENVY 4502. Over the last couple of months whenever I have tried to use double sided printing, when the printer comes to printing on the reverse side of the page an on screen message appears saying "Error pr

  • External Monitoring with MXO2 Mini not working

    OK, I chose the Matrox 1080i60 Sequence Preset.  And then I import and use AVCINTRA P2 footage.  When I put it into the sequence...I see the clips on the timeline, but nothing in the Program monitor, nor my external monitor.  I press play...nothing h

  • My InDesign file will not open! URGENT!

    Hi all, One of my InDesign files will not open, when I attempt to open it, I get a message saying "Cannot open file, Adobe may not support the file format, a plug-in that supports the format may be missing or the file may be open in another applicati

  • Should I or shouldn't I? buy I mean

    Ok I've got a imac from 2007 which came with Leopard on it, was new to Mac, and love it. Havent used everything on it yet! I bought iLife 09 as it came with iLife 08, and I liked the look of the new features of iLife 09;faces/places etc My iMac is "o

  • Multiple writes of a DBL 2D array to binary file

    Hello. Does anyone have an example of writing a 2D array to a binary file multiple times? Specifically, I need to write a 2D array of DBL to a binary file mulitple times and then (later) be able to read it back (reconvert to DBL). All of the examples