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