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
  • 1.  SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Fri October 04, 2002 02:56 AM

    Hi webMethodists,

    I have noticed users looking for a way to get

    a) idoc number via transaction id
    b) idoc status via idoc number

    Here is what I do:

    a1) create a new remote-enabled function module in SE37:

    FUNCTION Z_GET_RELATIONS.
    *“----------------------------------------------------------------------
    "“Local interface:
    *” IMPORTING
    *” VALUE(OBJKEY) TYPE SWO_TYPEID
    *" VALUE(OBJTYPE) TYPE SWO_OBJTYP
    *" VALUE(RELATIONTYPE) LIKE BRELTYP-RELTYPE OPTIONAL
    *" EXPORTING
    *" VALUE(RETURN_CODE) TYPE FUNKTION
    *" TABLES
    *" LINKS STRUCTURE RELGRAPHLK
    *"----------------------------------------------------------------------

    data: object1 like borident,
    S_OWN_LOGSYSTEM LIKE TBDLS-LOGSYS.

    CALL FUNCTION ‘OWN_LOGICAL_SYSTEM_GET’
    IMPORTING
    OWN_LOGICAL_SYSTEM = S_OWN_LOGSYSTEM
    EXCEPTIONS
    OWN_LOGICAL_SYSTEM_NOT_DEFINED = 1
    OTHERS = 2.
    RETURN_CODE = SY-SUBRC.
    CHECK RETURN_CODE = 0.

    clear object1.
    object1-objkey = objkey.
    object1-objtype = objtype.
    object1-logsys = s_own_logsystem.

    CALL FUNCTION ‘SREL_GET_NEXT_RELATIONS’
    EXPORTING
    OBJECT = object1

    • ROLETYPE =
      RELATIONTYPE = relationtype
    • MAX_HOPS = 1
    • INCL_APPLRELS = ’ ’
    • EXCL_ROLES =
    • EXCL_RELATIONS =
      TABLES
      LINKS = links
    • ROLES =
    • APPLLINKS =
      EXCEPTIONS
      OTHERS = 4.
      RETURN_CODE = SY-SUBRC.

    ENDFUNCTION.

    a2) Create a flow service z_get_relations via the RFC lookup function in the browser Administration tool

    a3) Use the new service in your own flows, OBJKEY = transaction id, OBJTYPE = “TRANSID”, RELATIONTYPE = “IDC8”.
    The IDoc number is returned in LINKS-OBJKEY_A.

    For other purposes you might want to try running the service with OBJKEY = idoc number (must have all 16 digits), OBJTYPE = “IDOC” and for starters no RELATIONTYPE. Look at the records returned in LINKS. You might find other interesting relation types. To use a specific relation type in your flows set RELATIONTYPE to the LINKS-RELTYPE of the record (relation) you are looking for.

    b) To get current IDoc status and message create this remote-enabled function module in SE37:

    FUNCTION Z_GET_IDOC_STATUS_TEXT.
    *“----------------------------------------------------------------------
    "“Local interface:
    *” IMPORTING
    *” VALUE(IDOC_NUMBER) LIKE EDIDC-DOCNUM
    *" EXPORTING
    *" VALUE(IDOC_STATUS) LIKE EDIDC-STATUS
    *" VALUE(IDOC_MESSAGE) LIKE BDIDOCATTR-MESSAGE
    *"----------------------------------------------------------------------

    • This function module returns last (current) status and corresponding

    • message of an IDoc.

    • The following select also exists as func.mod GET_STATUS_FROM_IDOCNR,

    • but here we just do a direct select.
      SELECT SINGLE STATUS FROM EDIDC INTO IDOC_STATUS
      WHERE DOCNUM = IDOC_NUMBER.

    • If IDOC_GET_MESSAGE_ATTRIBUTE had been RFC enabled it would not be

    • necessary to create Z_IDOC_STATUS_TEXT. An other option is to find the

    • status message via IDOC_READ_COMPLETELY, but this would generate a lot

    • more RFC


    #Integration-Server-and-ESB
    #webMethods
    #Adapters-and-E-Standards


  • 2.  RE: SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Fri October 04, 2002 03:22 AM

    I forgot to mention two things:

    1. Only newer SAP systems (4.5+ I think…) have the function module SREL_GET_NEXT_RELATIONS that I use in z_get_relations. In 4.0b you can use SWW_WI_READ_CONTAINERS_OF_OBJ ( no need for a z_get_relations ) which is somewhat similar to SREL_GET_NEXT_RELATIONS in 4.6. It (SWW_…) also exists in 4.6, but I am not sure if it still works. For 3.1 systems I do not know.

    2. Be sure to drop $tid from the pipeline before calling any RFCs. I have experienced that the calls are simply ignored ( no error message ) if $tid is present.

    Regards

    Mikael


    #Integration-Server-and-ESB
    #webMethods
    #Adapters-and-E-Standards


  • 3.  RE: SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Wed November 06, 2002 04:27 PM

    Mikael,

    I too have noted the same thing! I thought I was crazy… and I can’t believe that the $tid is coming into play and causing the calls to be ignored. Anyone know why this is the case?

    Now, as a rule, I drop the $tid when calling a RFC.

    BTW, thanks for posting this IDOC Status check.

    Thanks,

    ajandja


    #webMethods
    #Integration-Server-and-ESB
    #Adapters-and-E-Standards


  • 4.  RE: SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Mon December 13, 2004 02:29 PM

    hi Mikael,

    Using this function Z_GET_RELATIONS im getting this error:

    2004-12-13 09:20:45 BRST com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: Time limit exceeded

    can ya help me?

    srry about my english, im from Brazil, and im learning it


    #Integration-Server-and-ESB
    #webMethods
    #Adapters-and-E-Standards


  • 5.  RE: SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Sun April 06, 2008 03:04 AM

    Hi Mikael,

    Thank you for the program.

    I have implemented this in our dev system.

    This is actually not returning desired results. I suspect something missing on the SAP side. Not able to see any relations except IDC0.

    I am testing this against an outbound idoc (SAP to wM).

    I tested with OBJKEY= IDOC number
    OBJTYPE=IDOC.

    Thank you
    Sridhar


    #Adapters-and-E-Standards
    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Sun April 06, 2008 03:04 AM

    Hi Mikael,

    Thank you for the program.

    I have implemented this in our dev system.

    This is actually not returning desired results. I suspect something missing on the SAP side. Not able to see any relations except IDC0.

    I am testing this against an outbound idoc (SAP to wM).

    I tested with OBJKEY= IDOC number
    OBJTYPE=IDOC.

    Thank you
    Sridhar


    #Adapters-and-E-Standards
    #webMethods
    #Integration-Server-and-ESB


  • 7.  RE: SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Thu August 20, 2009 05:01 PM

    As some of you were puzzled by this: if you leave $tid in the pipeline before calling an RFC, then the SAP Adapter calls this function module via tRFC (transactional RFC) instead of via synchronous RFC… And as a tRFC has no response, it “appears” as if it is simply ignored without error…
    But in fact it has been executed successfully in the SAP system. Only the SAP system doesn’t send any response back, cause it’s an asynchronous call… :slight_smile:

    Solution: either drop $tid, or use the Service “pub.sap.client:invoke” (instead of RFC:OutboundProcess or sap.map: outbound, etc.). The “invoke” Service always makes a “synchronous” RFC call.


    #Adapters-and-E-Standards
    #webMethods
    #Integration-Server-and-ESB


  • 8.  RE: SAP Get IDoc number via transid and get IDoc status via IDoc number

    Posted Thu October 22, 2009 05:38 PM

    Here another update on this topic:

    the mechanism and sample code provided by mikael works only up to (and including) SAP_BASIS 6.20. Starting with SAP_BASIS 6.40 the ALE team changed the way the TID and the IDoc DOCNUM are linked: the “SREL” relations are no longer used.
    This is probably what sridharrt observed above… :frowning:

    Starting with SAP_BASIS 7.00 ALE offers a different API for linking the TID and the DOCNUM:

    INBOUND_IDOCS_FOR_TID
    OUTBOUND_IDOCS_FOR_TID

    Both of them are remoted enabled, so can be called from wM.

    Now what do we do, if we are on SAP_BASIS 6.40?! (I think SAP ERP 4.7 is using that Basis release. ECC 6.0 should already be on Basis 7.00.) Well, the answer is: there is no solution…

    You could download a free 7.00 MiniSAP system from SDN, install it somewhere, look at the source code of the above two function modules and create similar function modules in 6.40. This would work.

    Lanzelot

    OK, I did it for your convenience:

    function inbound_idocs_for_tid.
    *“----------------------------------------------------------------------
    "“Lokale Schnittstelle:
    *” IMPORTING
    *” VALUE(TID) TYPE EDIDS-TID
    *" CHANGING
    *" VALUE(I_DOCNUM) TYPE IDOC_TT
    *" EXCEPTIONS
    *" NO_IDOC_FOUND
    *"----------------------------------------------------------------------

    data: wa_docnum like edidc-docnum.
    select docnum from edids into wa_docnum
    where ( status eq ‘50’
    or status eq ‘56’ )
    and tid eq tid.
    append wa_docnum to i_docnum.
    endselect.
    if sy-subrc ne 0.
    raise no_idoc_found.
    endif.

    endfunction.

    function outbound_idocs_for_tid.
    *“----------------------------------------------------------------------
    "“Lokale Schnittstelle:
    *” IMPORTING
    *” VALUE(TID) TYPE EDIDS-TID
    *" CHANGING
    *" VALUE(I_DOCNUM) TYPE IDOC_TT
    *" EXCEPTIONS
    *" NO_IDOC_FOUND
    *"----------------------------------------------------------------------
    data: wa_docnum like edidc-docnum.
    select docnum from edids into wa_docnum
    where status eq ‘03’ and tid eq tid.
    append wa_docnum to i_docnum.
    endselect.
    if sy-subrc ne 0.
    raise no_idoc_found.
    endif.

    endfunction.


    #Adapters-and-E-Standards
    #Integration-Server-and-ESB
    #webMethods