cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: field names of an Internal table

Former Member
0 Kudos

Hi all,

I'd like to display all the field names of the internal table or a structure.

I want it very urgent.

Use ful answers will be awarded greatly.

Thanks in advance.

Jagan Mohan.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Jagan,

Use the below code.

TYPE-POOLS: SYDES.

DATA: TD TYPE SYDES_DESC.

DATA: BEGIN OF WA OCCURS 0,

CONTINUE TYPE C,

NAME(15) TYPE C,

END OF WA.

TYPES:BEGIN OF STR1,

NUM(3) TYPE N,

NAME(20) TYPE C,

END OF STR1.

*DATA: ITAB LIKE T247 OCCURS 0 WITH HEADER LINE.

*DATA: ITAB TYPE STR1 OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF ITAB OCCURS 0,

NUM(3) TYPE N,

NAME(20) TYPE C,

END OF ITAB.

DESCRIBE FIELD ITAB INTO TD.

WA[] = TD-NAMES[].

LOOP AT WA.

IF WA-NAME = SY-REPID.

DELETE WA.

CONTINUE.

ENDIF.

SEARCH WA-NAME FOR '-'.

IF SY-SUBRC = 0.

DELETE WA.

CONTINUE.

ENDIF.

SEARCH WA-NAME FOR '='.

IF SY-SUBRC = 0.

DELETE WA.

CONTINUE.

ENDIF.

ENDLOOP.

LOOP AT WA.

WRITE: / WA-NAME.

ENDLOOP.

Former Member
0 Kudos

Hi,

Use FM <b>DDIF_FIELDINFO_GET</b> and pass appropriate parameters.

*Always reward points for helpful answers

Regards,

Amit

Former Member
0 Kudos

Hi jagan,

you can the all field name from table DD03L,it is a database table which stores all the fields of the tables in sap.

See the following code.

Parameter : p_tabname like dd03l-TABNAME.

data : beging of tbl_lfa1,

TABNAME like dd03l-TABNAME,

FIELDNAME like dd03l-FIELDNAME,

select TABNAME FIELDNAME

from dd03l

into table tbl_lfa1.

where tabname = p_tabname .

If sy-subrc = 0.

sort tbl_lfa1 by tabname.

endif.

loop at tbl_lfa1.

write 😕 tbl_lfa1-TABNAME,tbl_lfa1-FIELDNAME.

endloop.

<b>REWARD IF HELPFUL</b>

Regards,

Vijay

Former Member
0 Kudos

Hi ,

wat i understood is u have an internal and u want to display the fields in this table.

write a select statement and fetch all the value's from table and store that in internal table.

now use top-of-page statement and write the description of the fields on this event.

put a loop in the internal table.

put a write statement in the loop and end tha loop.

this will display all the fields of table with field lebel.

Former Member
0 Kudos

Hi jagan

jsut go to table DD03L

it is a database table which stores all the fields of the tables in sap.

write a select statement

select * from dd03l where tabname = 'MARA'.

you will get each and every details of the table mara

PLEASE REWARD IF HELPFUL

thanks

vivekanand

0 Kudos

Hi,

Use as follows.

Suppose ITAB is your table. or WA is your tables strcuture.


DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr.
DATA: lt_comp       TYPE cl_abap_structdescr=>component_table.
DATA: ls_comp       LIKE LINE OF lt_comp.

lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa ). " Get the description of the data
lt_comp = lr_rtti_struc->get_components( ). "Get the fields of the structure
LOOP at lt_comp into ls_comp.
    WRITE: /ls_comp-name. " Write the column names
ENDLOOP.

Regards,

Sesh