09-22-2008 11:06 AM
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
09-22-2008 11: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
09-22-2008 11:11 AM
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
09-22-2008 11:15 AM
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
09-22-2008 11:16 AM
Try this
LOOP AT gt_output.
LOOP AT gt_zfitab_payments
ASSIGNING <fs_payments>
WHERE zbranch = gv_storeno.
endloop.
09-22-2008 11:24 AM
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.
09-22-2008 11: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
09-22-2008 11: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.
09-22-2008 11: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