09-12-2008 3:49 PM
Hi,
How do you store the internal table fieldnames in a internal table of filedname type?
Ex: My table add 3 fields of name field_1, field_2 et field_3. My another table would be 3 records in the fieldname field : field_1, field_2 et field_3.
Thanks.
09-12-2008 4:01 PM
You can check this example..
using the function you can get the fields present in the internal table. in the components table parameter you can see the Fieldnames.
REPORT zztest_fieldname.
DATA: components TYPE TABLE OF rstrucinfo.
DATA: BEGIN OF it_field OCCURS 0,
filed1(30),
field2(30),
field3(30),
END OF it_field.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = sy-repid
fieldname = 'IT_FIELD'
TABLES
components = components.
break-point.
09-12-2008 3:54 PM
so you want to store the "field names" in one internal table as records into another internal table?
09-12-2008 3:55 PM
09-12-2008 3:57 PM
Well, then go for this function module, BUKU_GET_FIELD_NAMES
some sample code,
TABLES SPFLI.
DATA:
T_SPFLI TYPE STANDARD TABLE
OF SPFLI
INITIAL SIZE 10.
CALL FUNCTION 'BUKU_GET_FIELD_NAMES'
EXPORTING
I_S_STRUCTURE = SPFLI
IMPORTING
E_T_FIELD_NAMES = T_FIELDS.
If you check the entries in T_FIELDS, it will only contain the field names of SPFLI.
Instead of SPFLI you can give your own internal table as export parameter and the other table as importing parameter. But make sure that both the internal tables have exactly the same strucuture.
09-12-2008 3:56 PM
Try to use fm
call function 'GET_COMPONENT_LIST'
exporting
program = v_repid
fieldname = v_fname " Internal table
tables
components = i_components.
Here i_components contains all fields declared in the internal table
a®
09-12-2008 4:01 PM
You can check this example..
using the function you can get the fields present in the internal table. in the components table parameter you can see the Fieldnames.
REPORT zztest_fieldname.
DATA: components TYPE TABLE OF rstrucinfo.
DATA: BEGIN OF it_field OCCURS 0,
filed1(30),
field2(30),
field3(30),
END OF it_field.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = sy-repid
fieldname = 'IT_FIELD'
TABLES
components = components.
break-point.
09-12-2008 4:27 PM
Hi,
I thinks you could use the function GET_GLOBAL_SYMBOLS
TYPES: BEGIN OF st_char30,
fieldname TYPE char30,
END OF st_char30.
DATA: lv_champ1 TYPE char200,
lv_champ2 TYPE char200,
lv_champ3 TYPE char200.
DATA: lv_rfieldlist TYPE TABLE OF rfieldlist WITH HEADER LINE.
DATA: lt_table TYPE TABLE OF st_char30 WITH HEADER LINE.
CALL FUNCTION 'GET_GLOBAL_SYMBOLS'
EXPORTING
program = sy-repid
* NAME_PATTERN = '*'
TABLES
fieldlist = lv_rfieldlist .
LOOP AT lv_rfieldlist.
IF lv_rfieldlist CP 'LV_CHAMP*'.
APPEND lv_rfieldlist-name TO lt_table.
ENDIF.
ENDLOOP.