Application Development and Automation 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 only

problem with Read stat..

Former Member
0 Likes
930

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
908

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.

8 REPLIES 8
Read only

Former Member
0 Likes
909

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.

Read only

0 Likes
908

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.

Read only

Former Member
0 Likes
908

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

Read only

Former Member
0 Likes
908

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.

Read only

Former Member
0 Likes
908

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

Read only

0 Likes
908

hi friends, u people r right, i forgot to sort.

now its working.

i ve rewarded.

Read only

Former Member
0 Likes
908

Hi,

sort the internal table it_afvc is sorted properly ...

Reward points

Read only

Former Member
0 Likes
908

READ TABLE it_afvc WITH KEY PROJN = it_tab2-pspnr.

Try it now.

Regards,

Madan.