Application Development 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: 

Retrieve fieldname

Former Member
0 Kudos

Hi all,

Hw can i retrieve all the fieldname of a table? Any fm to do that? If have, how to define the internal table to hold all the fieldname? Any code to share.

Thks

10 REPLIES 10

Former Member
0 Kudos

check the std table DD03L and pass the table name in TABNAME field (like MARA).

regards

shib dautta

Former Member
0 Kudos

i hope that u want 2 retrieve the fieldname of standard sap tables and not internal table

use this function module FMRE_GET_TABLEFIELDS_LONGNAMES

and pass the table name of which u want the fields and u will get the fieldnames

Former Member
0 Kudos

hi,

try in DD03L table

data itab type standard table of dd03l with header line.

select TABNAME

fieldname

into table itab

where tabname = 'VBAK'.

Former Member
0 Kudos

Hi,

you can use the fm CEV3_TABLE_READ to get all fields of a table.

To get all tables, read table DD02L.

Regards

Nicole

abdulazeez12
Active Contributor
0 Kudos

Use the function module F4_DD_TABLE_FIELDS

0 Kudos

How to declare the internal table to hold this fieldname.?

0 Kudos

Hi Gary,

Use the function module

DDIF_FIELDINFO_GET

To declare the the internal table with the desired fields.

let us suppose take table T549A. if you want all fields of that table.

declare it as shown below.

<b>Method1:</b>

DATA: Begin of itab occurs 0.

include structure T549A.

DATA: End of itab.

<b>Method2:</b>

data: itab like t549a occurs 0 with header line.

if you want only specific fields from that table

declare it as shown below.

DATA: Begin of itab occurs 0,

abkrs like t549a-abkrs,

permo like t549a-permo,

end of itab.

Hope you understand.

0 Kudos

Below are my code, see whether is there any error. How to display the value out in list form to show my code is working?

REPORT ZGARY_TEST.

DATA: Begin of itab occurs 0.

include structure spfli.

DATA: End of itab.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = itab

  • FIELDNAME = ' '

  • LANGU = SY-LANGU

  • LFIELDNAME = ' '

  • ALL_TYPES = ' '

  • GROUP_NAMES = ' '

  • IMPORTING

  • X030L_WA =

  • DDOBJTYPE =

  • DFIES_WA =

  • LINES_DESCR =

  • TABLES

  • DFIES_TAB =

  • FIXED_VALUES =

  • EXCEPTIONS

  • NOT_FOUND = 1

  • INTERNAL_ERROR = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Former Member
0 Kudos

Hi,

While creating a internal table

u include that table in the definition.

IF u won't get these things.

only copy and paste.

Assign points if useful.

Former Member
0 Kudos

Hi Gary,

The given code is a sample program.

You can also go to transaction code ABAPDOCU where you can find n no. of sample programs.

&----


*& Report ZCLASSICAL_REP2 *

*& *

&----


*& *

*& *

&----


REPORT ZCLASSICAL_REP2 MESSAGE-ID ZHAR LINE-COUNT 60(3).

TABLES SFLIGHT.

DATA: ITAB LIKE SFLIGHT OCCURS 0 WITH HEADER LINE.

PARAMETERS: H_CARRID LIKE SFLIGHT-CARRID.

************************************************************************

  • INITIALIZATION.

************************************************************************

INITIALIZATION.

H_CARRID = 'AA'.

************************************************************************

  • AT SELECTION-SCREEN.

************************************************************************

AT SELECTION-SCREEN.

IF H_CARRID <> 'AA'.

MESSAGE E000.

ENDIF.

************************************************************************

  • START-OF-SELECTION.

************************************************************************

START-OF-SELECTION.

SELECT * FROM SFLIGHT INTO TABLE ITAB.

************************************************************************

  • TOP-OF-PAGE.

************************************************************************

WRITE:/10 'DATE:' , SY-DATUM COLOR 3,

30 'PAGE NO:', SY-PAGNO COLOR 3,

45 'TIME:' , SY-UZEIT COLOR 3,

60 'USERNAME:',SY-UNAME COLOR 3.

ULINE.

WRITE:/10 'CARRID', 20 'CONNID', 35 'FLDATE'.

ULINE.

************************************************************************

  • END-OF-PAGE.

************************************************************************

WRITE:/ SY-PAGNO.

************************************************************************

  • END-OF-SELECTION.

************************************************************************

END-OF-SELECTION.

LOOP AT ITAB.

WRITE:/10 ITAB-CARRID COLOR 4,

20 ITAB-CONNID COLOR 4,

35 ITAB-FLDATE COLOR 4.

ENDLOOP.

WRITE:/ 'THIS REPORT IS CONFIDENTIAL' COLOR 3.

Reward if helpful.

Regards,

Harini.S