AT NEW in loops
I have an internal sorted table (itab1) which contains data from table VBAP based on a unique key using VBELN and POSNR. I want to extract the first row for each VBELN into a seperate hashed table (itab2) with a key of VBELN. Two restriction apply:
1. I need to retain the data in POSNR as itab2 will be used to read another internal table later on with a key of VBELN and POSNR
2. I need to keep the contents of itab1 for use later in the program so cannot just do a DELETE ADJACENT...ON VBELN to remove the 'duplicates'.
I have tried the following:
LOOP AT itab1 INTO wa_itab1. AT NEW vbeln. INSERT wa_itab1 INTO TABLE itab2. ENDAT. ENDLOOP.
However, immediately after the AT NEW command has executed the contents of wa_itab1-posnr become '*****'. My question is therefore, why does it do this and is there a way that I can get the work area to retain the value in POSNR? Perhaps my logic is flawed - is there a better way of achieving my goal?