Application Development 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: 

Urgent...simple internal table problem

Former Member
0 Kudos

Hi gurus

i am filling a internal table like this

loop at i_0001 into s_0001.

clear out_final.

out_final-pernr = s_0001-pernr.

out_final-parea = s_0001-parea.

loop at i_0021 into s_0021 where pernr = s_0001-pernr and subty ne '7'.

perform rec1.

endloop.

loop at i_0106 into s_0106 where pernr = s_0001-pernr and subty ne '7'.

perform rec2.

append out_final to i_final.

clear out_final.

endloop.

and my performs are

FORM rec1.

read table i_0021 into s_0021 with key pernr = s_0001-pernr.

out_final-fname = s_0021-fname.

out_final-lname = s_0021-lname.

out_final-bdate = s_0021-bdate.

ENDFORM. " rec1

FORM rec2.

read table i_0106 into s_0106 with key pernr = s_0001-pernr.

out_final-ssn = s_0106-ssn.

out_final-add1 = s_0106-add1.

out_final-add2 = s_0106-add2.

out_final-city = s_0106-city.

out_final-state = s_0106-state.

out_final-country = s_0106-country.

out_final-zip = s_0106-zip.

out_final-hphone = s_0106-hphone.

ENDFORM. " rec2

all my declerations and syntax are correct

now i have 2 simple things to ask

1. when i write data i get duplicate records ....is my loop , clear and append are in right place

2. i wan to delimit this data for a condition where bdate is greater than 18. bdate is of type p0021-fgbdt which i have to format using some FM....how do i do that where do i have to add code for that.

thanks in advance

plz help

regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

clear s_0001, s0106, s_0021.

insted of using a loop why dont you use read

and then check the sy-subrc after each read statement.

Regards,

siva chalasani

6 REPLIES 6

Former Member
0 Kudos

Hi,

clear s_0001, s0106, s_0021.

insted of using a loop why dont you use read

and then check the sy-subrc after each read statement.

Regards,

siva chalasani

0 Kudos

thanks for your help siva

even i want to use read table but i have a condition in loope where subty ne '7' which i think cannot use in read table if you have any other option plz suggest.

i am debugging my code still not able to solve it..can you plz also help me with my 2nd question.

thanks

Former Member
0 Kudos

Hi,

Check the below code.

loop at i_0001 into s_0001.

clear out_final.

out_final-pernr = s_0001-pernr.

out_final-parea = s_0001-parea.

<b>*****loop at i_0021 into s_0021 where pernr = s_0001-pernr and subty ne '7'.</b>

perform rec1.

<b>***endloop.

****loop at i_0106 into s_0106 where pernr = s_0001-pernr and subty ne '7'.</b>perform rec2.

<b>if not out_final is initial.</b>

append out_final to i_final.

<b>endif.</b>

clear out_final.

endloop.

and my performs are

FORM rec1.

read table i_0021 into s_0021 with key pernr = s_0001-pernr

<b>subty ne '7'.</b>

<b>if sy-subrc = 0.</b>

out_final-fname = s_0021-fname.

out_final-lname = s_0021-lname.

out_final-bdate = s_0021-bdate.

<b>endif.</b>

ENDFORM. " rec1

FORM rec2.

read table i_0106 into s_0106 with key pernr = s_0001-pernr

<b>subty ne '7'.</b>

<b>if sy-subrc = 0.</b>

out_final-ssn = s_0106-ssn.

out_final-add1 = s_0106-add1.

out_final-add2 = s_0106-add2.

out_final-city = s_0106-city.

out_final-state = s_0106-state.

out_final-country = s_0106-country.

out_final-zip = s_0106-zip.

out_final-hphone = s_0106-hphone.

<b>endif.</b>

ENDFORM. " rec2

<b></b><b></b>

Hope this will solve ur duplication problem

kesavadas_thekkillath
Active Contributor
0 Kudos

loop at i_0001 into s_0001.

clear out_final.

out_final-pernr = s_0001-pernr.

out_final-parea = s_0001-parea.

read table i_0021 into s_0021 with key pernr = s_0001-pernr and subty ne '7'..

if sy-subrc = 0.

if s_0021-bdate+6(2) > 18.

out_final-fname = s_0021-fname.

out_final-lname = s_0021-lname.

out_final-bdate = s_0021-bdate.

read table i_0106 into s_0106 with key pernr = s_0001-pernr and subty ne '7'..

if sy-subrc = 0

out_final-ssn = s_0106-ssn.

out_final-add1 = s_0106-add1.

out_final-add2 = s_0106-add2.

out_final-city = s_0106-city.

out_final-state = s_0106-state.

out_final-country = s_0106-country.

out_final-zip = s_0106-zip.

out_final-hphone = s_0106-hphone.

endif.

endif.

endif.

0 Kudos

guys

thanks for ur time

but as for my knoweledge we cannot use ne is read statement only = is allowed.

though i will try and update you guys

if ther is any other way plz let me know

...plz try to solve my 2nd question as well

thanks

Former Member
0 Kudos

solved thx