10-09-2007 7:08 AM
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-09-2007 7:12 AM
check the std table DD03L and pass the table name in TABNAME field (like MARA).
regards
shib dautta
10-09-2007 7:12 AM
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
10-09-2007 7:12 AM
hi,
try in DD03L table
data itab type standard table of dd03l with header line.
select TABNAME
fieldname
into table itab
where tabname = 'VBAK'.
10-09-2007 7:13 AM
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
10-09-2007 7:13 AM
10-09-2007 7:15 AM
10-09-2007 7:23 AM
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.
10-09-2007 7:29 AM
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.
10-09-2007 7:13 AM
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.
10-09-2007 7:16 AM
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