Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function Module Name Required

Former Member
0 Likes
1,196

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

10 REPLIES 10
Read only

Former Member
0 Likes
1,156

HI,

Here is the function module

DB_GET_TABLE_FIELDS

Regards

Sudheer

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,156

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

Read only

Former Member
0 Likes
1,156

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.

Read only

Former Member
0 Likes
1,156

Hi Vijay,

Use the function module

AMDP_TABLE_CONTROL_GET_FIELDS

tabname = table name

vorgid = X

Regards,

Ravi G

Read only

Former Member
0 Likes
1,156

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

Read only

former_member480923
Active Contributor
0 Likes
1,156

check out : F4_DD_TABLE_FIELDS

Anirban M.

Read only

Former Member
0 Likes
1,156

Hi ,

Try FM <b>F4_DD_TABLE_FIELDS</b>

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
1,156

Hi,

Use the function module

DDIF_FIELDINFO_GET

Read only

0 Likes
1,156

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

Read only

0 Likes
1,156

Yup....they will show you all fields even from include CI_INCLUDES....