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

at new...

Former Member
0 Likes
1,081

Hi all,

I have problem with at new stell,

I have table p0001 with several records with different stell values, when I do AT NEW program is moving all record but I wont only new different record.

CLEAR p0001.

SORT p0001 BY stell.

LOOP AT p0001 .

AT NEW stell.

MOVE-CORRESPONDING p0001 TO dat.

APPEND dat.

ENDAT.

ENDLOOP.

SORT dat DESCENDING BY pernr begda.

READ TABLE dat INDEX 1.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,029

Hello,

If I understood correctly, please follow

1.Decalare another internal table with same fields as P0001but the stell field should be the first field.

2.Move the complete data into the new internal table.

3.Sort the internal by stell field and rest follow the same procedure as you are following.

Hope it would help you.

Regards,

Ravi

6 REPLIES 6
Read only

Former Member
0 Likes
1,030

Hello,

If I understood correctly, please follow

1.Decalare another internal table with same fields as P0001but the stell field should be the first field.

2.Move the complete data into the new internal table.

3.Sort the internal by stell field and rest follow the same procedure as you are following.

Hope it would help you.

Regards,

Ravi

Read only

Former Member
Read only

former_member212005
Active Contributor
0 Likes
1,029

I think...what you are doing is right...

As suggested, Just try to declare another internal table and pass data into the internal table and make sure that you have STELL as the first column...

And...try to debug and identify...whether the at new event is triggered always...i.e for each record...

Read only

former_member229729
Active Participant
0 Likes
1,029

Hi,

The Sorting field must be a First Field of your Internal table.

Otherwise, it wont work as desired.

Suppose your Field (STELL) is not in the first Column, you can use " ON CHANGE OF ......" event .

Thanks and regards,

Ramani N

Read only

Former Member
0 Likes
1,029

Hi Nick,

Here I do not understand how you get records.

In this below case you will only get Astericks (*****) in your table.

anyhow for this you can follow either of this method:

1) You can sort p0001 BY stell and use 'DELETE ADJACENT DUPLICATES'

2) Use different work area X_P0001 like p0001 and use this before AT NEW.

X_P0001 = P0001.

AT NEW stell

do with X_P0001.

ENDAT.

Left side fields of stell should not be numeric in this case.

Regards,

Subba

Read only

former_member189420
Active Participant
0 Likes
1,029

Hi,

AT NEW works as below:

Loop at itab.
...
AT NEW field3. 
...
END AT.
...
Endloop.

Consider itab contains field1, field2, field3 and so on...

The AT NEW block will be executed only when there is change in the value of field3 or change in the values of it's previous fields i.e. field1 and field2. and other fields are * so copy the itab to workarea and again back to where you want to copy.

That is the reason the field stell should be at the first column. Hope you understand what to do now.

Thanks & Regards,

Anand Patil