webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Business Connector - excuting BAPI

  • 1.  Business Connector - excuting BAPI

    Posted Wed October 14, 2009 02:44 PM

    Hi,
    I am new to Business Connector, and I think I am missing something basic.
    My scenarion is as follow:
    I am holding an idoc key and type, and I need to get from SAP ERP the full idoc.
    I was told the best way to do it is by running 3 BAPIs one after the other:
    EDI_DOCUMENT_OPEN_FOR_READ
    EDI_SEGMENTS_GET_ALL
    EDI_DOCUMENT_CLOSE_READ

    I am using sap.pub.sap.client.invoke which reqwires only server name and rfcName.
    I fill out:
    servname: myserver
    rfcName:EDI_DOCUMENT_OPEN_FOR_READ

    when I run it, I get
    com.sap.conn.jco.AbapException: DOCUMENT_NUMBER_INVALID
    and this is making sense bacaue I didn’t provide the idoc key…
    But, I can’t understand how should I pass it? is there a hidden way to pass parameters? how should I know what parametrs should I pass?

    Thanks
    Gideon


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 2.  RE: Business Connector - excuting BAPI

    Posted Thu October 22, 2009 05:56 PM

    Hello Gideon,
    you have two options:

    a) Just put a variable of name DOCUMENT_NUMBER into the pipeline, before you invoke
    pub.sap.client:invoke. This Service will pick it up automatically from the pipeline.

    b) A more convenient way is: go to Adapters → SAP → Lookup and create an “RFC Outbound Map” for EDI_DOCUMENT_OPEN_FOR_READ (and the other ones as well).
    Then instead of pub.sap.client:invoke use this generated Outbound Map. It will display the inputs/outputs of that function module in the pipeline neatly.

    One more tip: these three EDI_** function modules will probably use SAP internal user session memory. Therefore you will need to use lockSession/releaseSession as follows:

    • invoke pub.sap.client:lockSession
      (reserves an RFC connection from the pool for your exclusive usage)
    • invoke EDI_DOCUMENT_OPEN_FOR_READ
    • invoke EDI_SEGMENTS_GET_ALL
    • invoke EDI_DOCUMENT_CLOSE_READ
    • invoke pub.sap.client:releaseSession
      (releases the connection back to the pool and resets the user session inside SAP)

    If you are using Java, do the “releaseSession” in a finally block! That way you can be sure that it will always be executed (avoiding ugly connection leaks).

    Lanzelot


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB