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

problemin read staement

Former Member
0 Likes
901

hi guriji,

i have writeen one query .

loop at itab.

read table itab2 with key kostl = itab-fictr

hkont = itab-acc_code .

kostl1 = itab2-kostl+6(4).

hkont1 = itab2-hkont+4(6).

if kostl1 = itab-fictr and hkont1 = itab-acc_code.

itab-dmbtr = itab2-dmbtr.

modify itab transporting dmbtr .

clear itab-fictr.

clear itab-acc_code.

clear itab2-dmbtr.

clear itab-dmbtr.

clear kostl1.

clear hkont1.

endif.

when the read statement execute it reads only 2nd line value of itab2. but according to read statement reads whole internal table value.

plz tell me .

thanks.

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
866

>

> loop at itab. "" dont use header line table,,use work area..

> read table itab2 with key kostl = itab-fictr

> hkont = itab-acc_code .

>check sy-subrc eq 0. ""<< add this

> kostl1 = itab2-kostl+6(4).

> hkont1 = itab2-hkont+4(6).

> if kostl1 = itab-fictr and hkont1 = itab-acc_code.

> itab-dmbtr = itab2-dmbtr.

> modify itab transporting dmbtr .

> clear itab-fictr.

> clear itab-acc_code.

> clear itab2-dmbtr.

> clear itab-dmbtr.

> clear kostl1.

> clear hkont1.

> endif.

> thanks.

hi guriji,

i have writeen one query .

loop at itab.

read table itab2 with key kostl = itab-fictr

hkont = itab-acc_code .

kostl1 = itab2-kostl+6(4).

hkont1 = itab2-hkont+4(6).

if kostl1 = itab-fictr and hkont1 = itab-acc_code.

itab-dmbtr = itab2-dmbtr.

modify itab transporting dmbtr .

clear itab-fictr.

clear itab-acc_code.

clear itab2-dmbtr.

clear itab-dmbtr.

clear kostl1.

clear hkont1.

endif.

when the read statement execute it reads only 2nd line value of itab2. but according to read statement reads whole internal table value.

plz tell me .

thanks.

5 REPLIES 5
Read only

Former Member
0 Likes
866

Debugging the code will answer your question.

pk

Read only

Former Member
0 Likes
866

Hi Sachin,

The READ statement reads based on whatever you have given in the KEY statement.

It means it reads only thos records which satisfies the values of ITAB-FICTR.

Dont know what your requirement is.

Regards

Abhii

Read only

former_member156446
Active Contributor
0 Likes
867

>

> loop at itab. "" dont use header line table,,use work area..

> read table itab2 with key kostl = itab-fictr

> hkont = itab-acc_code .

>check sy-subrc eq 0. ""<< add this

> kostl1 = itab2-kostl+6(4).

> hkont1 = itab2-hkont+4(6).

> if kostl1 = itab-fictr and hkont1 = itab-acc_code.

> itab-dmbtr = itab2-dmbtr.

> modify itab transporting dmbtr .

> clear itab-fictr.

> clear itab-acc_code.

> clear itab2-dmbtr.

> clear itab-dmbtr.

> clear kostl1.

> clear hkont1.

> endif.

> thanks.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
866

Hello Sachin,

When in doubt use the philanthropic F1 key. It offers a much faster & more reliable answers than us mortals on SDN.

Cheers,

Suhas

Read only

former_member217544
Active Contributor
0 Likes
866

Hi,

From F1 help of read statement:



If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows. 

Regards,

Swarna Munukoti