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: 

control statement

Former Member
0 Kudos
98

i m using at new field statement inside the loop.

whenever the data in first field changes i want to append tht whole line in another internal table.

loop at it.

at new field1.

it1 = it.

append it1.

endat.

endloop.

except first field all other fields r displaying * .

why..

how to get the data.

based on tht data i have to do some calculation.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
76

Hi Vinothini,

Code as follows.

loop at it.

at new field1.

<b>read table it index sy-tabix.</b>

it1 = it.

append it1.

endat.

endloop.

Thanks,

Vinay

9 REPLIES 9

Former Member
0 Kudos
76

sdo like this

data : wa like it.

loop at it.

move-corresponding it to wa.

at new field1.

it1 = wa.

append it1.

endat.

endloop.

regards

shiba dutta

0 Kudos
76

i tried wat u specified but not able to reach my requirement.

my table has.

it.

field1 field2

1 a

1 b

1 c

2 d

2 e

2 f

3 g

3 h

3 i

4 j

4 k

4 l

my output must be it1.

field1 field2

1 a

2 d

3 g

4 j

how to get this.

Thanks in advance.

0 Kudos
76

data : wa like it.

sort it by field1 field2.

loop at it.

move-corresponding it to wa.

at new field1.

append wa to it1.

endat.

clear : wa,it1.

endloop.

regards

shiba dutta

0 Kudos
76

while using at new the respective field must be in the first column.

Check this...

ield1 field2

1 a

1 b

1 c

2 d

2 e

2 f

3 g

3 h

3 i

4 j

4 k

4 l

loop at it.

wk_field1 = it_field1.

wk_field2 = it_field2.

at new field1.

move- corresponding it to it2.

append it2.

endat.

cleart it2,it1.

endloop.

Former Member
0 Kudos
77

Hi Vinothini,

Code as follows.

loop at it.

at new field1.

<b>read table it index sy-tabix.</b>

it1 = it.

append it1.

endat.

endloop.

Thanks,

Vinay

Former Member
0 Kudos
76

Hi,

<b>Reason</b>

At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:

All character type fields (on the right) are filled with "*" after the current control level key.

All other fields (on the right) are set to their initial values after the current control level key.

<b>Solution to avoid</b>

Declare a work area similar to it and use it for appending.

loop at it.

<b>it2 = it.</b>

at new field1.

<b>it1 = it2.</b>

append it1.

endat.

endloop.

Reward if helpful.

kesavadas_thekkillath
Active Contributor
0 Kudos
76

try this...may b helpful...

data:begin of itab occurs 0,

matnr like mara-matnr,

maktx like makt-maktx,

end of itab .

data:begin of itab2 occurs 0,

matnr like mara-matnr,

maktx like makt-maktx,

end of itab2.

select maramatnr maktmaktx appending table itab

from mara inner join makt on maramatnr = maktmatnr.

data:wk_maktx like makt-maktx.

loop at itab.

wk_maktx = itab-maktx.

at new matnr.

clear itab2.

endat.

at end of matnr.

move:itab-matnr to itab2-matnr,

wk_maktx to itab2-maktx.

append itab2.

endat.

endloop.

kesavadas_thekkillath
Active Contributor
0 Kudos
76

Sorry its not like that...

here it is

hile using at new the respective field must be in the first column.

Check this...

ield1 field2

1 a

1 b

1 c

2 d

2 e

2 f

3 g

3 h

3 i

4 j

4 k

4 l

loop at it.

wk_field1 = it_field1.

wk_field2 = it_field2.

at new field1.

move wk_field1 to it2-field1.

move wk_field2 to it2-field2.

append it2.

clear : wk_field1,wk_field2.

endat.

cleart it2,it1.

endloop.

kesavadas_thekkillath
Active Contributor
0 Kudos
76

in case of at new u must use local variables to store data...

other wise u can do the same with

on change of it_field-field1.

move the necessary fields to itab2

append itab2.

clear itab2.

endon.

here local variables are not required.....