Application Development 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 internal table

Former Member
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

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

0 Kudos

Hi,

this is how i used...but branch is not key ..so it always reading the same

LOOP AT gt_output.

READ TABLE gt_zfitab_payments

ASSIGNING <fs_payments> WITH KEY zbranch = gv_storeno

BINARY SEARCH .

endloop.

reg

0 Kudos

Hi ,

So whenever you read the record check its values with existing records in the table by comparing some fields which you have considered as unique keys while declaring the table and only if the record is different then only use the record or else go for next records.

Thanks

Sudharshan

0 Kudos

Try this


LOOP AT gt_output.

LOOP AT gt_zfitab_payments
ASSIGNING <fs_payments> 
WHERE zbranch = gv_storeno.

endloop.

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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