‎2007 Sep 07 1:03 PM
Hi all,
Can anyone please tell me the name of a Function Module to get the fields of a table .
Kindly reply as fast as possible.
Regards,
Vijay
‎2007 Sep 07 1:06 PM
HI,
Here is the function module
DB_GET_TABLE_FIELDS
Regards
Sudheer
‎2007 Sep 07 1:08 PM
Hi,
You can use
DATA: struc_ref type ref to CL_ABAP_STRUCTDESCR.
DATA: lt_comp TYPE cl_abap_structdescr=>component_table.
struc_ref = CL_ABAP_TYPEDESCR=>describe_by_name ( 'TABLE_NAME' ).
lt_comp = struct_ref->get_components().
Regards,
Sesh
‎2007 Sep 07 1:08 PM
Hi Bala,
you can also chk this
Sometimes you may have only a table name and want to retrieve the name of each field of the corresponding table. For example, when you want to use ASSIGN COMPONENT fieldname OF TABLE table.
An ABAPer's first reaction is to read the standard ABAP basis tables DD02L, DD03L, etc
This way of reading fields is very slow. Use methods from the class CL_ABAP_TYPEDESCR instead.
Example:
data: descr_struc_ref TYPE REF TO cl_abap_structdescr.
descr_struc_ref ?= cl_abap_typedescr=>describe_by_name('SFLIGHT' ).
Here is the result of descr_struct_ref after the execution of this piece of code
ABSOLUTE_NAME C 200 \TYPE=SFLIGHT
TYPE_KIND C 1 u
LENGTH I 4 80
DECIMALS I 4 0
KIND C 1 S
STRUCT_KIND C 1 F
COMPONENTS h 8 Table[14x40]
HAS_INCLUDE C 1
The table COMPONENTS is filled with :
LENGTH DECIMALS TYPE_KIND NAME
3 | 0 |C |MANDT
3 | 0 |C |CARRID
4 | 0 |N |CONNID
8 | 0 |D |FLDATE
etc.
‎2007 Sep 07 1:08 PM
Hi Vijay,
Use the function module
AMDP_TABLE_CONTROL_GET_FIELDS
tabname = table name
vorgid = X
Regards,
Ravi G
‎2007 Sep 07 1:12 PM
Hi,
You can use NAMETAB_GET to get the fields of table with there datelements and length also.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
only = ' '
tabname = 'MARA'
IMPORTING
HEADER =
RC =
TABLES
nametab = gt_table
EXCEPTIONS
internal_error = 1
table_has_no_fields = 2
table_not_activ = 3
no_texts_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Sriram Ponna.
Message was edited by:
Sriram Ponna
‎2007 Sep 07 1:13 PM
‎2007 Sep 07 1:13 PM
Hi ,
Try FM <b>F4_DD_TABLE_FIELDS</b>
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo
‎2007 Sep 07 1:14 PM
‎2007 Sep 07 1:19 PM
Hi all,
Thanks a lot for all your replies . Could you please tell me whether these Function Modules also pick up the Custom fields that have been added to the Table.
Kindly reply as fast as possible.
Regards,
Vijay
‎2007 Sep 07 1:21 PM
Yup....they will show you all fields even from include CI_INCLUDES....