Skip to Content
avatar image
Former Member

how to populate the data in custom table through an inbound idoc?

i have made the code according to that but it is populating the duplicate data .

idoc struct 1 header (A) with 2 child segments (B and C)

while populate one entry in each segment, it is making one entry in table as per the requirement.

but when i am giving 2 entries in child segment B it should populate 2 entries in Ztable

instead of that 2 entries it is populating 3 entries which the 3rd entry has no data.

LOOP AT idoc_contrl ASSIGNING FIELD-SYMBOL(<ls_idoc_contrl>).

    IF <ls_idoc_contrl>-mestyp NE 'mestyp'.

      RAISE wrong_function_called.

    ENDIF.

* Before reading a new entry, clear application buffer.

    LOOP AT idoc_data[] ASSIGNING FIELD-SYMBOL(<ls_idoc_data>)

                      WHERE docnum EQ idoc_contrl-docnum.

case segmname

when segA

ls_tablefield1 = ls_idocsegfield1,

ls_tablefield2 = ls_idocsegfield2,

ls_tablefield3 = ls_idocsegfield3,

ls_tablefield4 = ls_idocsegfield4,

when segB

ls_tablefield5 = ls_idocsegfield5,

ls_tablefield6 = ls_idocsegfield6,

when segC

ls_tablefield7 = ls_idocsegfield7,

ls_tablefield8 = ls_idocsegfield8,

endcase.

modify  Ztable from ls_idocsegfiled

commit work.

      IF sy-subrc EQ 0.

        lv_edi_status = '53'.

      ELSE.

        lv_edi_status = '51'.

      ENDIF.

endloop.

endloop.

can any one tell what wrong in this code.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 06, 2015 at 04:48 AM

    Hi Akky,

    I found issues in the coding, kindly do not add modify statement inside the Loop.  Create the internal table for the Z-table. Update the internal table inside the Loop.

    After the Outer loop statement, update Z-table using Internal table instead of Work area.

    Before updating the table, you can check with condition, whether we have the entry(IS NOT INITIAL) in Table/work area.

    As per the above code, I think the work area LS_DOCSEGFILED is not updating.

    Kindly check the same in debugger

    ls_tablefield8 = ls_idocsegfield8,

    endcase.

    modify  Ztable from ls_idocsegfiled

    Regards

    Rajkumar Narasimman

    Add comment
    10|10000 characters needed characters exceeded