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: 

AT NEW command for two fields

Former Member
0 Kudos

Dear All,

How to use AT NEW command in internal table for two fields.

Warm Regards,

N.Jain

1 ACCEPTED SOLUTION

Former Member

Suppose if there are f1 and f2 fields...

if u use AT NEW F2...it will automatically trigger if there is change in f1 also...

Ensure the order of fields are F1,F2 for the above said instance..

Regards,

PRa

5 REPLIES 5

Former Member

Suppose if there are f1 and f2 fields...

if u use AT NEW F2...it will automatically trigger if there is change in f1 also...

Ensure the order of fields are F1,F2 for the above said instance..

Regards,

PRa

Former Member
0 Kudos

Hi nishu

See the code below.

DATA : BEGIN OF ITAB OCCURS 0,

bukrs like t001-bukrs,

f1(10) type c,

end of itab.

itab-bukrs = '1000'.

itab-f1 = '1111111'.

append itab.

itab-bukrs = '1100'.

itab-f1 = '3333333'.

append itab.

itab-bukrs = '1200'.

itab-f1 = '555555'.

append itab.

*----


AT NEW

loop at itab.

at new bukrs.

write 😕 itab-bukrs , itab-f1.

endat.

endloop.

*----


AT ON CHANGE

loop at itab.

ON CHANGE OF ITAB-BUKRS.

write 😕 itab-bukrs , itab-f1.

ENDON.

Hope this helps.

Britto

Former Member
0 Kudos

Hi!

if there are two consecutive fields(f1 ,f2) ,then write-

AT NEW f2.

This will check for the the combination of both the fields.

but if the fields are not consecutive , you can use

ON CHANGE OF f1 and

ON CHANGE OF f2 ,seperately for both the fields.

Reward points if it helps.

Regards,

Neha Bansal.

Message was edited by:

Neha Bansal

Former Member
0 Kudos

Hi,

LOOP.
  AT FIRST.... ENDAT.
    AT NEW <f1>....... ENDAT. 
      AT NEW <f2>....... ENDAT. 
     ...
          AT <fgi>..... ENDAT. 
          <single line processing without control statement>
...
      AT END OF <f2>.... ENDAT. 
    AT END OF <f1>.... ENDAT. 
  AT LAST..... ENDAT.
ENDLOOP.

Regards

Sudheer

Former Member
0 Kudos

Hi

See the following code. It is useful for u.

DATA: BEGIN OF ty_batest,

designation TYPE zba_test-designation,

salary TYPE zba_test-salary,

empno TYPE zba_test-empno,

empname TYPE zba_test-empname,

address TYPE zba_test-address,

END OF ty_batest,

it_batest LIKE TABLE OF ty_batest,

wa_batest LIKE ty_batest.

SELECT * FROM zba_test INTO CORRESPONDING FIELDS OF TABLE it_batest.

SORT it_batest BY designation salary.

LOOP AT it_batest INTO wa_batest.

AT NEW designation.

WRITE: / 'Designation :', wa_batest-designation,

/(35) sy-uline.

ENDAT.

AT NEW salary.

WRITE: / 'Salary : ', wa_batest-salary,

/ '----


'.

ENDAT.

WRITE: / 'Emp Name : ', wa_batest-empname,

/ 'Emp Number : ', wa_batest-empno,

/ 'Designation : ', wa_batest-designation,

/ 'Address : ', wa_batest-address,

/ 'Salary : ', wa_batest-salary NO-ZERO .

SKIP.

ENDLOOP.

Regards

Bhuvana.