‎2008 Jun 30 8:24 AM
hi,
i have a report which uses a Field-groups.
it has used field-string, insert- into, and extract syntaxes.
is it possible to replace this field-groups by an internal table?
if yes, how?
‎2008 Jun 30 8:30 AM
Hi Chinmay,
You can do it. Actually field groups comes under the concept of Extracts. In extract each line came have different struture. Where as in internal table each line has same structure. So in the field group which you are using see from how many tables you are extracting the data. Now if you have to use internal table instead of that just declare so many internal tables which you are using in the field group.
This solves the issue.
Regards,
Swapna.
‎2008 Jun 30 9:03 AM
Hi Chinmay,
To replace field-groups with internal tables, First of all create a structure having the same fields, which are used in INSERT ... INTO command.
Now use the following code to populate internal table:
TABLES: mara.
TYPES : BEGIN OF str_mara,
matnr TYPE matnr,
mtart TYPE mtart,
meins TYPE meins,
matkl TYPE matkl,
ernam TYPE ernam,
mbrsh TYPE mbrsh,
bstme TYPE bstme,
END OF str_mara.
DATA: wa_mara TYPE str_mara,
it_mara TYPE STANDARD TABLE OF str_mara.
FIELD-GROUPS: header,fld_grp.
START-OF-SELECTION.
INSERT mara-matnr mara-mtart mara-meins
mara-matkl mara-ernam mara-mbrsh mara-bstme INTO fld_grp.
SELECT matnr mtart meins ernam mbrsh matkl FROM mara INTO CORRESPONDING FIELDS OF mara.
EXTRACT fld_grp.
ENDSELECT.
SORT ASCENDING .
CLEAR mara.
LOOP.
AT fld_grp .
wa_mara-matnr = mara-matnr.
wa_mara-mtart = mara-mtart.
wa_mara-meins = mara-meins.
wa_mara-matkl = mara-matkl.
wa_mara-ernam = mara-ernam.
wa_mara-mbrsh = mara-mbrsh.
wa_mara-bstme = mara-bstme.
APPEND wa_mara TO it_mara.
ENDAT.
ENDLOOP.
SORT it_mara BY matnr.
In this way, you can populate the internal table and use it in place of field-groups....
I hope this will resolve your issue..
Reward point, if useful.
Regards,
Nitin