cancel
Showing results for 
Search instead for 
Did you mean: 

What is the fastest way to fill the same internal table with messages?

sh4il3sh
Participant

I have below table in which some records have field MSTYP and MESSAGE empty. while most records already have MSGTYP and MESSAGE filled.
I need to fill those empty records in a single go(if possible) with MSTYP = 'E' and MESSAGE = "Error".

Of Course I can do LOOP AT table ASSIGNING(<fs>), and also maybe FOR loop but then each field needs to be written/mapped in code in for loop.

Please suggest fastest way to do this.

TYPES: BEGIN OF TY_MARA,
MATNR TYPE MATNR,
MTART TYPE MTART, "...85 more fields
MSGTYP TYPE MSGTYP,
MESSAGE TYPE CHAR128,
END OF TY_MARA.

DATA: lt_mara TYPE TABLE OF TY_MARA.
View Entire Topic
sergei-u-niq
Active Contributor

Hi Shailesh, can't you just

LOOP AT lt_mara ASSIGNING FIELD-SYMBL(<fs_mara>) WHERE mstyp IS INITIAL.
  <fs_mara>-mstyp = 'E'.
  <fs_mara>-message = 'Error'.
ENDLOOP.

HTH,

Sergei

sh4il3sh
Participant
0 Kudos

I am just curious, I already mentioned what you wrote. Just looking for Non-Loop alternative.

sergei-u-niq
Active Contributor

you also wrote "but then each field needs to be written/mapped in code in for loop" - you dont need to map all 85 fields - just the two fields you want to change. but maybe I misunderstood you.