Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

To Update the IDOC segment values through report program

Former Member
0 Likes
3,569

My requirement is to update the Idoc segment through the report program. Any SAP provided standard function module is available to update the Idoc segment values. Please help needed.

My requirement is to update the Idoc segment through the report program. Any SAP provided standard function module is available to update the Idoc segment values. Please help needed.

4 REPLIES 4
Read only

Former Member
0 Likes
1,570

Hi,

You can use the following steps in succession to change segment data.

1) EDI_DOCUMENT_OPEN_FOR_EDIT. Use this to read the IDoc

data into an internal table(declared of type EDIDD)

2) EDI_CHANGE_DATA_SEGMENTS. Looping at this table make

necessary changes to the segments and pass them to

another internal table (eg: IT_EDIDD) and pass this

table to this fm. This changes only those segements

that you have changed.

3) EDI_DOCUMENT_CLOSE_EDIT. This closes the IDoc.

4) IDOC_STATUS_WRITE_TO_DATABASE. This writes the status

to the IDoc. Use this if you need.

Hope this helps,

Vamsi

Read only

0 Likes
1,570

I need the function module name to release the IDOC lock,

after the Idoc close.

Actually i am using the below function module for update the segment value through report program.

1) EDI_DOCUMENT_OPEN_FOR_EDIT.

2) EDI_CHANGE_DATA_SEGMENTS.

3) EDI_DOCUMENT_CLOSE_EDIT.

4) IDOC_STATUS_WRITE_TO_DATABASE. To update Idoc status.

After using this fn. mod., i can't able to release the IDOC lock.

I was used the fn. mod. EDI_DOCUMENT_DEQUEUE_LATER to release the lock but it is getting released.

I need help to solve this problem.

Read only

Former Member
0 Likes
1,570

Use the FM L_IDOC_SEGMENT_CREATE in the program and do update.

Thanks

Eswar

Read only

Former Member
0 Likes
1,570
 DATA: LT_EDIDD TYPE STANDARD TABLE OF EDIDD."Local Table to Hold EDIDD
    LT_EDIDD = I_EDIDD. "table should have the data
*-- Opening the IDoc for Edit
    CALL FUNCTION 'EDI_DOCUMENT_OPEN_FOR_EDIT'
      EXPORTING
        DOCUMENT_NUMBER               = X_EDIDC-DOCNUM
      TABLES
        IDOC_DATA                     = IT_EDIDD
      EXCEPTIONS
        DOCUMENT_FOREIGN_LOCK         = 1
        DOCUMENT_NOT_EXIST            = 2
        DOCUMENT_NOT_OPEN             = 3
        STATUS_IS_UNABLE_FOR_CHANGING = 4
        OTHERS                        = 5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
*-- Editing the IDoc
    CALL FUNCTION 'EDI_CHANGE_DATA_SEGMENTS'
      TABLES
        IDOC_CHANGED_DATA_RANGE = LT_EDIDD
      EXCEPTIONS
        IDOC_NOT_OPEN           = 1
        DATA_RECORD_NOT_EXIST   = 2
        OTHERS                  = 3.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
*-- Closing the IDoc after Edit
    CALL FUNCTION 'EDI_DOCUMENT_CLOSE_EDIT'
      EXPORTING
        DOCUMENT_NUMBER  = X_EDIDC-DOCNUM
        DO_COMMIT        = 'X'
        DO_UPDATE        = 'X'
        WRITE_ALL_STATUS = 'X'
      EXCEPTIONS
        IDOC_NOT_OPEN    = 1
        DB_ERROR         = 2
        OTHERS           = 3.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

thanks

vijay