Skip to Content
avatar image
Former Member

read internal table

Hi expertz,

i have 2 tables with different structures and 1 field in common

iam reading entries in one table using the common field..but the problem is... this field is not unique so im always reading the same entry..but wanted to read next entry..how can i overcome this problem..

thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Sep 22, 2008 at 10:08 AM

    Hi,

    Please use

    LOOP at First Internal table into Workarea1.

    Read Table Second Internal table into work area2 where Workarea2-field = workarea1-field.

    if sy-subrc eq 0.

    endif.

    endloop.

    regards

    jana

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      sort before loop based on branch field.

      Sort gt_output by zbranch.

      LOOP AT gt_output.

      READ TABLE gt_zfitab_payments

      ASSIGNING <fs_payments> WITH KEY zbranch = gt_output-branch BINARY SEARCH .

      endloop.

      Hope helps.

      If not can you provide test data.

      Regards,

      Salini.

  • avatar image
    Former Member
    Sep 22, 2008 at 10:16 AM

    Hi ,

    If u want to read line of an internal table uniquely , u need to have unique key combination .

    U can do like this .

    U can create a counter on the 1st internal table at the every change of common field value , so that u can read using the common field and counter.

    ex:

    sort it2 by <commonfield>.

    loop at it2.

    v = v + 1.

    read table it2 with key <commonfield> = <commnfield> counter = v.

    at end of <commonfield>.

    clear v.

    endat.

    endloop.

    2nd way :

    I dont know wht u want to do after reading , how ever if u want all records with common fields u can loop with respect to common field.

    ex:

    loop at it2.

    loop at it1 where commonfield = it2-commonfield.

    <write ur logic wht ever u want to>

    endloop.

    endloop.

    Hope this helps in solving ur problem.

    Regards,

    Ramesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 22, 2008 at 10:16 AM

    Hi,

    If you are talking about Database Tables, try to use 'Inner join' or 'For all entries'.

    If you are talking about internal tables, try to 'SORT' it and use 'DELETE ADJACENT DUPLICATES'.

    Regard,

    R.Nagarajan.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 22, 2008 at 10:17 AM

    Hi,

    In that case you need to use nested loop. But use it like this

    LOOP AT gt_output.

    LOOP AT gt_zfitab_payments WHERE zbranch = gv_storeno.

    -


    -


    ENDLOOP.

    ENDLOOP.

    Regards,

    Venkat

    Add comment
    10|10000 characters needed characters exceeded