Skip to Content
avatar image
Former Member

Logic for IDOC_DATA table updation in a loop

Hi All,

Can any body give me the logic for modification of IDOC_DATA table in a loop.

LOOP AT IDOC_DATA.

CASE IDOC_DATA-SEGNAM.

WHEN SEGMENT1.

............................. Some Code

WHEN SEGMENT2.

SEGMENT2 = IDOC_DATA-SDATA.

SEGMENT2-akont = c_akont.

move c_e1 to SEGMENT2-akont+6(2).

  • Here SEGMENT2 is modified

  • Now i want to write a code to modify IDOC_DATA here

  • Can anybody tell me the logic to update IDOC_DATA table for that particular

  • segment

ENDCASE.

ENDLOOP.

Can anybody provide the statements for the same.

I want to write below code in that place:

<b>MOVE SEGMENT2 TO idoc_data-sdata.

MODIFY idoc_data TRANSPORTING sdata.</b>

Can anybody clarify whether above statements are correct (or) any changes required?

Thanks in advance.

Thanks,

Deep.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 11, 2007 at 04:14 AM

    Hi,

    Please try this.

    DATA: ZSEGMENT2 LIKE SEGMENT2.
    
    LOOP AT IDOC_DATA.
      CASE IDOC_DATA-SEGNAM.
         WHEN SEGMENT1.
            ...
     
         WHEN SEGMENT2.
           MOVE IDOC_DATA-SDATA TO ZSEGMENT2.
           MOVE C_AKONT TO ZSEGMENT2-AKONT.
           MOVE C_E1 TO ZSEGMENT2-AKONT+6(2).
           MOVE ZSEGMENT2 TO IDOC_DATA-SDATA.
           MODIFY IDOC_DATA.
     
      ENDCASE.
    ENDLOOP.
    

    Regards,

    Ferry Lianto

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 11, 2007 at 03:52 AM

    hi,

    Yes u r correct as per the existing code u provided.

    revrt back if any issues,

    Regards,

    Naveen

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 11, 2007 at 04:02 AM

    Hi,

    Store the index in a temporary variable and modify the internal table using the index..

    LOOP AT IDOC_DATA.

    V_TABIX = SY-TABIX. " Naren changes

    CASE IDOC_DATA-SEGNAM.

    WHEN SEGMENT1.

    ............................. Some Code

    WHEN SEGMENT2.

    SEGMENT2 = IDOC_DATA-SDATA.

    SEGMENT2-akont = c_akont.

    move c_e1 to SEGMENT2-akont+6(2).

    • Here SEGMENT2 is modified

    • Now i want to write a code to modify IDOC_DATA here

    • Can anybody tell me the logic to update IDOC_DATA table for that particular

    • segment

    MODIFY IDOC_DATA INDEX V_TABIX TRANSPORTING SDATA. " Naren changes

    ENDCASE.

    ENDLOOP.

    Thanks

    Naren

    Add comment
    10|10000 characters needed characters exceeded