Skip to Content
avatar image
Former Member

Idoc Travel Management

I was wondering if you could point me in the right direction. I am having a little trouble getting the IDOC created. At what point is the IDOC supposed to be created? Trip "SAVE" or PR05, PRFI or PRRW. What message type and basic type should I be using? Or is this not the correct approach for Trip IDOC setup.

Thanks,

Troy

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jun 16, 2017 at 07:06 PM

    Hello,

    An Idoc is created in the background with transaction PRRW, which is Posting Run Management. In PRRW, you select the particular run you want to process and hit POST. That is when the Idoc kicks the doc to R3 System ( If two systems are maintained).

    At this stage, you can go to transaction BD87 and can view the posted I doc. If you see the green sign on, this is for successfully processing of the idoc where as red suggests the contrary.

    Hope you find the above explanation helpful!

    Regards,

    Sudhakar*

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 13, 2017 at 06:12 PM

    Thanks for the response Sudhakar, since you took the time I figured I would let you know what I ended up doing. We needed the IDOC created to link our two systems on SAVE as this is when the user would be attaching the receipts to the travel expense.

    I had already configured all my document types, repositories, protocols,partner profiles,ports etc for archive link to work with our third party document management tool OnBase.

    What I ended up doing for this specific request was creating my own IDOC and message type and put and enhancement point (ZMP56TF00) "trigger customer IDOC after save" in TRIP program (MP56TF00) on save to call the function module 'MASTER_IDOC_DISTRIBUTE', then called function 'EDI_DOCUMENT_DEQUEUE_LATER'.

    Here is the code in full for your reference.

    * Trigger Custom IDOC after save

    CONSTANTS: C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZTRIP',
    C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZTRIP01',
    C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'ZTVSG01'.
    DATA: LT_EDIDC TYPE EDIDC OCCURS 0,
    LT_EDIDD TYPE EDIDD OCCURS 0,
    LS_EDIDC TYPE EDIDC,
    LS_EDIDD TYPE EDIDD,
    LS_ZTVSG01 TYPE ZTVSG01,
    L_NBSEG TYPE I,
    l_trip_total type ptrv_shdr-trip_total.
    CLEAR LS_ZTVSG01.
    CLEAR LS_EDIDC.
    * Save the message type and the basic IDoc type in the control segment
    MOVE C_MESTYP TO LS_EDIDC-MESTYP.
    MOVE C_DOCTYP TO LS_EDIDC-IDOCTP.

    * Create a data segment for expense record
    LS_ZTVSG01-PERNR = wa_head-pernr.
    LS_ZTVSG01-REINR = wa_head-reinr.
    LS_ZTVSG01-DATV1 = wa_head-datv1.
    LS_ZTVSG01-DATB1 = wa_head-datb1.
    select single bukrs ename btrtl from pa0001 into (LS_ZTVSG01-bukrs, LS_ZTVSG01-ename, LS_ZTVSG01-btrtl)
    where pernr = wa_head-pernr
    and endda >= sy-datum
    and begda <= sy-datum.
    select single TRIP_TOTAL from PTRV_SHDR into L_TRIP_TOTAL
    where pernr = wa_head-pernr
    and REINR >= wa_head-reinr.
    LS_ZTVSG01-trip_total = l_trip_total.
    CLEAR LS_EDIDD.
    MOVE C_SEGNAM TO LS_EDIDD-SEGNAM.
    MOVE LS_ZTVSG01 TO LS_EDIDD-SDATA.
    APPEND LS_EDIDD TO LT_EDIDD.
    break rhouston.
    * Call the IDoc creation function
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
    EXPORTING
    MASTER_IDOC_CONTROL = LS_EDIDC
    TABLES
    COMMUNICATION_IDOC_CONTROL = LT_EDIDC
    MASTER_IDOC_DATA = LT_EDIDD
    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 NE 0.
    break rhouston.
    return.
    ENDIF.
    * commit work.
    CALL FUNCTION 'DB_COMMIT'.
    CALL FUNCTION 'DEQUEUE_ALL'.
    COMMIT WORK AND WAIT.
    READ TABLE LT_EDIDC into LS_EDIDC index 1.
    CALL FUNCTION 'EDI_DOCUMENT_DEQUEUE_LATER'
    EXPORTING
    docnum = LS_EDIDC-DOCNUM
    EXCEPTIONS
    IDOC_IS_NOT_TO_DEQUEUE = 1
    OTHERS = 2
    .
    data: h_logsys type TBDLS-LOGSYS,
    OBJ_ROLEA type BORIDENT,
    OBJ_ROLEB type BORIDENT,
    RELATIONTYPE type BRELTYP-RELTYPE,
    FIRE_EVENTS TYPE XFLAG.

    CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
    own_logical_system = h_logsys
    EXCEPTIONS
    own_logical_system_not_defined = 1
    OTHERS = 2.

    if sy-subrc = 0.

    obj_rolea-objkey = LS_EDIDC-DOCNUM.
    obj_rolea-objtype = 'IDOC'.
    obj_rolea-logsys = h_logsys.
    CONCATENATE wa_head-pernr wa_head-reinr into obj_roleb-objkey." = ev_vbeln.
    obj_roleb-objtype = 'BUS2089'. "h_objtype.
    obj_roleb-logsys = h_logsys.

    relationtype = 'ZDCB'.

    * 3. Create link
    CALL FUNCTION 'BINARY_RELATION_CREATE'
    EXPORTING
    obj_rolea = obj_rolea
    obj_roleb = obj_roleb
    relationtype = relationtype
    * FIRE_EVENTS = 'X'
    * IMPORTING
    * BINREL =
    * TABLES
    * BINREL_ATTRIB =
    EXCEPTIONS
    no_model = 1
    internal_error = 2
    unknown = 3
    OTHERS = 4.
    endif.
    commit work.

    Thanks again,

    Troy

    Add comment
    10|10000 characters needed characters exceeded