‎2010 Jan 18 10:11 AM
Hi,
I would like to seek advice on this.
I have 2 internal table as below. The problem is although i have the same set of data in both internal table but
why sy-subrc still returns 4. I found out anln2 map to different ones. Why read table not able to pick the same anln2 even though it has the same value of anln2 in itab2.
LOOP AT it_itab1 INTO wa_itab1.
READ TABLE it_itab2 INTO wa_itab2
WITH KEY glla = wa_itab2-glia
cctrla = wa_itab2-cctria
anln1 = wa_itab2-anln1
anln2 = wa_itab2-anln2.
IF sy-subrc = 0.
Thanks
‎2010 Jan 18 10:14 AM
Dear Please check the below code
same as urs but small mofications
>
> Hi,
> I would like to seek advice on this.
> I have 2 internal table as below. The problem is although i have the same set of data in both internal table but
> why sy-subrc still returns 4. I found out anln2 map to different ones. Why read table not able to pick the same anln2 even though it has the same value of anln2 in itab2.
>
> LOOP AT it_itab1 INTO wa_itab1.
> READ TABLE it_itab2 INTO wa_itab2
> WITH KEY glla = wa_itab1-glia
> cctrla = wa_itab2-cctria
> anln1 = wa_itab2-anln1
> anln2 = wa_itab2-anln2.
> IF sy-subrc = 0.
>
>
> Thanks
LOOP AT it_itab1 INTO wa_itab1.
READ TABLE it_itab2 INTO wa_itab2
WITH KEY glla = wa_itab1-glia
IF sy-subrc = 0.
cctrla = wa_itab1-cctria
anln1 = wa_itab1-anln1
anln2 = wa_itab1-anln2.
ENDIF.
ENDLOOP.Thanks
Surendra P
‎2010 Jan 18 10:14 AM
Dear Please check the below code
same as urs but small mofications
>
> Hi,
> I would like to seek advice on this.
> I have 2 internal table as below. The problem is although i have the same set of data in both internal table but
> why sy-subrc still returns 4. I found out anln2 map to different ones. Why read table not able to pick the same anln2 even though it has the same value of anln2 in itab2.
>
> LOOP AT it_itab1 INTO wa_itab1.
> READ TABLE it_itab2 INTO wa_itab2
> WITH KEY glla = wa_itab1-glia
> cctrla = wa_itab2-cctria
> anln1 = wa_itab2-anln1
> anln2 = wa_itab2-anln2.
> IF sy-subrc = 0.
>
>
> Thanks
LOOP AT it_itab1 INTO wa_itab1.
READ TABLE it_itab2 INTO wa_itab2
WITH KEY glla = wa_itab1-glia
IF sy-subrc = 0.
cctrla = wa_itab1-cctria
anln1 = wa_itab1-anln1
anln2 = wa_itab1-anln2.
ENDIF.
ENDLOOP.Thanks
Surendra P
‎2010 Jan 18 10:14 AM
Hello
READ TABLE it_itab2 INTO wa_itab2
WITH KEY glla = wa_itab1-glia " wa_itab1 instead of wa_itab2
cctrla = wa_itab1-cctria
anln1 = wa_itab1-anln1
anln2 = wa_itab1-anln2.
‎2010 Jan 18 10:16 AM
hi,
cctrla = wa_itab2-cctria-
and most importantly it must be wa_tab1 in the compare fields...
not wa_tab2
Regards,
Abhijit G. Borkar
‎2010 Jan 18 10:18 AM
Hi ,
The reason behind the unsucessful READ is that you are having a loop in ITAB1. So in that loop for any READ statement you should use work area of ITAB1 in KEY addition.
Here you are looping in ITAB1 but using the work area of ITAB2 (which is not yet populated) . Hence SY-SUBRC always return the valu 4.
Hope this will help you.
Regards,
Nikhil
‎2010 Jan 18 10:18 AM
WITH KEY glla = wa_itab2-glia
cctrla = wa_itab2-cctria
anln1 = wa_itab2-anln1
anln2 = wa_itab2-anln2.change this itab2 in with key to itab1.. how can you read a work area data which is not yet filled??
WITH KEY glla = wa_itab1-glia " i am just making it as itab1 inplace of itab2
cctrla = wa_itab1-cctria
anln1 = wa_itab1-anln1
anln2 = wa_itab1-anln2.
‎2010 Jan 18 10:19 AM
Hi,
please replace
WITH KEY glla = wa_itab2-glia
cctrla = wa_itab2-cctria
anln1 = wa_itab2-anln1
anln2 = wa_itab2-anln2.
BY
WITH KEY glla = wa_itab1-glia
cctrla = wa_itab1-cctria
anln1 = wa_itab1-anln1
anln2 = wa_itab1-anln2.
The values in wa_itab2 are intial before read. You need to use wa_itab1 which have the values after looping.
Hope it will help you...
‎2010 Jan 18 10:21 AM
hi,
please see this ..
LOOP AT it_itab1 INTO wa_itab1.
READ TABLE it_itab2 INTO wa_itab2
WITH KEY glla = wa_itab1-glia
cctrla = wa_itab1-cctria
anln1 = wa_itab1-anln1
anln2 = wa_itab1-anln2.
IF sy-subrc = 0.
---
--
endif.
endloop.thanks
‎2010 Jan 18 10:30 AM