‎2008 May 14 11:47 AM
Hi Experts,
here am trying to read 2 internal tables, by loping one table.
but the problem am using READ stat for 2 tables, for these case i ve proper data in all internal tables before looping tables.
while reading first( it_aufk ) is ok, but 2nd table ( it_afvc ) is not reading, for this while debugging i found correct data in internal tables. even though it_afvc is not reading ( i.e data is nt coming to header ) at all.
my peace of code is:
LOOP AT it_tab2.
it_dummy-psphi = it_tab2-psphi.
it_dummy-posid = it_tab2-posid.
it_dummy-pspid = it_tab2-pspid.
it_dummy-pspnr = it_tab2-pspnr.
it_dummy-post1 = it_tab2-post1.
READ TABLE it_aufk WITH KEY pspel = it_tab2-pspnr BINARY SEARCH.
IF SY-SUBRC EQ 0.
it_dummy-pspel = it_aufk-pspel.
it_dummy-objnr = it_aufk-objnr.
it_dummy-bukrs = it_aufk-bukrs.
it_dummy-aufnr = it_aufk-aufnr.
it_dummy-ktext = it_aufk-ktext.
ENDIF.
problem is below table
READ TABLE it_afvc WITH KEY PROJN = it_tab2-pspnr
BINARY SEARCH.
IF SY-SUBRC EQ 0.
it_dummy-projn = it_afvc-projn.
it_dummy-vornr = it_afvc-vornr.
ENDIF.
APPEND it_dummy.
CLEAR it_dummy.
ENDLOOP.
Could anyone tell where i ve gone wrong.
Thanks in advance.
kumar.
‎2008 May 14 11:51 AM
check if the internal table it_afvc is sorted properly ...
or remove the BINARY SEARCH ... from read
READ TABLE it_afvc WITH KEY PROJN = it_tab2-pspnr
BINARY SEARCH.
‎2008 May 14 11:51 AM
check if the internal table it_afvc is sorted properly ...
or remove the BINARY SEARCH ... from read
READ TABLE it_afvc WITH KEY PROJN = it_tab2-pspnr
BINARY SEARCH.
‎2008 May 14 11:57 AM
Hi Srinivas,
the table it_afvc is storing data properly.
actually according to tables data the 2 read statments will execute same time.
i.e as per data the, it_aufk and it_afvc both will execute at a time, but it_aufk is ok, but it_afvc is not executing.
Rgds,
kumar.
‎2008 May 14 11:55 AM
Hi,
I think you didnt use proper sort statement for internal table.
or because leading zero's the value is not coming to workarea.
use sort stmts before loop.
sort it_afvc by PROJN.
sort it_aufk by pspel.
Please reward points if helpful.
Thanks
Parvathi
‎2008 May 14 11:56 AM
well binary search works ONLY for sorted tables.
Even they muist be sorted by the field you are searching for.
i dont see any sort in your program so i dont wonder too much.
‎2008 May 14 11:58 AM
Hi,
As you are useing Binary serch
Make sure that table it_aufk is sorted on pspel
and table it_afvc is sorted on PROJN
other then that I don't find any error on your code
if data is maintained properly it is bound to come
Reward if helpful
Regards
Bikas
‎2008 May 14 12:12 PM
hi friends, u people r right, i forgot to sort.
now its working.
i ve rewarded.
‎2008 May 14 12:35 PM
Hi,
sort the internal table it_afvc is sorted properly ...
Reward points
‎2008 May 14 12:42 PM
READ TABLE it_afvc WITH KEY PROJN = it_tab2-pspnr.
Try it now.
Regards,
Madan.