‎2008 Jun 05 9:13 AM
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.
‎2008 Jun 05 9:23 AM
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.
‎2008 Jun 05 9:23 AM
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.
‎2008 Jun 05 9:40 AM
Hi Victor,
this is my structure :
MANDT MANDT
COUNTER NUMC15
PERNR PERNR_D
EMP_NAme PAD_VORNA
PERIOD SPBUPRegards
‎2008 Jun 05 9:43 AM
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.
‎2008 Jun 05 9:28 AM
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