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

Using At New Problem

Former Member
0 Likes
584

hi,

i use this code and in the at new commend when the loop

move to the second place in table for employee it do the same process instead 1 for every employee so i have duplicates record ,it have to do the process for one employee just one time,i sort the table before for pernr .

what it can be?

Regards

LOOP AT e_table INTO  wa_e_table.
    t_zero[] = e_table[].
   AT NEW pernr..
      DELETE  t_zero[] WHERE pernr NE wa_e_table-pernr.
      LOOP AT all_period INTO wa_all_period.
        CLEAR:wa_t_zero.
        READ TABLE t_zero INTO wa_t_zero WITH KEY period = wa_all_period-period.
        IF sy-subrc <> 0.
          CLEAR: wa_t_zero,wa_t_zero1.
          READ TABLE t_zero INTO wa_t_zero WITH KEY pernr = wa_e_table-pernr.
          MOVE wa_t_zero TO wa_t_zero1.
          wa_t_zero1-period = wa_all_period-period.
          APPEND wa_t_zero1 TO t_zero1.
        ENDIF.
      ENDLOOP.
    ENDAT.
  ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
567

Hi Cosmo,

What is the your e_table structure?

It is important since SAP will use all the fields BEFORE your at new field to differentiate whether it is the same record or not.

So for your case,

AT NEW PERNR.

--> It will execute if any of the fields BEFORE PERNR, different for each records.

So if you only want to execute if PERNR is different then you have to move your PERNR field in your e_table structure to the first.

Hope this help,

Victor.

4 REPLIES 4
Read only

Former Member
0 Likes
568

Hi Cosmo,

What is the your e_table structure?

It is important since SAP will use all the fields BEFORE your at new field to differentiate whether it is the same record or not.

So for your case,

AT NEW PERNR.

--> It will execute if any of the fields BEFORE PERNR, different for each records.

So if you only want to execute if PERNR is different then you have to move your PERNR field in your e_table structure to the first.

Hope this help,

Victor.

Read only

0 Likes
567

Hi Victor,

this is my structure :

MANDT	       MANDT
COUNTER	      NUMC15
PERNR	      PERNR_D
EMP_NAme      PAD_VORNA
PERIOD	         SPBUP

Regards

Read only

0 Likes
567

Hi Cosmo,

Change your structure to:

MANDT MANDT

PERNR PERNR_D

COUNTER NUMC15

EMP_NAme PAD_VORNA

PERIOD SPBUP

It should work now.

Thanks,

Victor.

Read only

Former Member
0 Likes
567

Hi,

If there is any field exist before PERNR in your internal table and change happen in that field also cause to trigger At new. If not so, then you must SORT that internal table with they key PERNR. Did you do that? Check your code once...

Rgds,

Bujji