on 01-19-2009 3:24 PM
Hello Friends,
Is there a function module,where i give the structure name and get all the feild names within that structure.
regards
kaushik
Use FM NAMETAB_GET and pass structure name in parameter for tabname
You will get the complete list of fields with all their attributes.
Revert if u need more.
Edited by: Ankesh on Jan 19, 2009 8:59 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use the for run time type descriptor classes to do this :
Here is a simple example :
REPORT z_assign_comp.
TYPE-POOLS : slis.
include <icon>.
"& Dynamic Programming ! Using Structure Descriptior Class. *
DATA: BEGIN OF line OCCURS 0,
col1 TYPE i,
col2(10) TYPE c,
col3 TYPE i,
END OF line.
FIELD-SYMBOLS : <fs> TYPE ANY.
FIELD-SYMBOLS : <itab_line> TYPE ANY.
DATA : BEGIN OF t_comp OCCURS 0,
comp(5) TYPE c,
END OF t_comp.
DATA : l_struc TYPE REF TO cl_abap_structdescr.
DATA : l_typedesc TYPE REF TO cl_abap_typedescr.
DATA : lt_comp TYPE abap_compdescr_tab,
w_comp LIKE LINE OF lt_comp.
line-col1 = 11.line-col2 = 'SAP'.line-col3 = 33.
APPEND line.
line-col1 = 44.line-col2 = 'P.I.'.line-col3 = 66.
APPEND line.
ASSIGN line TO <itab_line>.
"Call the static method of the structure descriptor describe_by_data
CALL METHOD cl_abap_structdescr=>describe_by_data
EXPORTING
p_data = <itab_line>
RECEIVING
p_descr_ref = l_typedesc.
"The method returns a reference of a type descriptor class therefore we
"need to Cast the type descriptor to a more specific class i.e
"Structure Descriptor.
l_struc ?= l_typedesc.
"Use the Attribute COMPONENTS of the structure Descriptor class to get
"the field names of the structure
lt_comp = l_struc->components.
LOOP AT line.
WRITE 😕 'Row : ', sy-tabix.
LOOP AT lt_comp INTO w_comp.
" Using the ASSIGN component ,assigns a data object to a field symbol.
ASSIGN COMPONENT w_comp-name OF STRUCTURE line TO <fs>.
WRITE 😕 w_comp-name, ' ', <fs>.
ENDLOOP.
ENDLOOP.
Hope this helps.
regards,
Advait
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use this FM 'DDIF_FIELDINFO_GET'.
Regards,
Jyothi CH.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
FM for that..
DB_GET_TABLE_FIELDS
DDIF_NAMETAB_GET
NAMETAB_GET
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Kaushik,
FM "NAMETAB_GET " is obselete now,so better use any of the below mentioned options:
1. Table DD03L that stores the field of the structure of Data Dictionary(Put Structure name in the TABNAME field).
OR
2.you can use fm DDIF_FIELDINFO_GET.
OR
3. A link that will be a great help to your query: read the last post in this link...that give you the sample code as well
Pooja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kaushik,
Use FM NAMETAB_GET and pass the structure name for TABNAME parameter. Return internal table NAMETAB will contain all the fields with attributes.
Regards
Anki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kaushik,
Use function module KL_TABLE_INFO_GET to get the fields names of a structure/table. Please provide structure name to I_TABNAME import parametes and you will all field details into E_IT_TABFIELDS export parameter.
Thanks,
Vinay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Check the table DD03L. Here you give the table / structure name & get the fieldnames.
Search SDN for further details.
BR,
Suhas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.