08-26-2008 5:49 AM
Hi,
In a normal report program, i ahve an requirement to get all the field names of a database table into an internal table.
Could ypu please tell me how to get only the field names ( like MANDT. PERNR, BEGDA, ENDDA...) of the database table into an internal table.
Please help me,
Thanks in advance,
Arunsri
08-26-2008 6:01 AM
Hi Arunsri....
Check this program....
data: itab like dd03l occurs 0 with header line.
parameters: p_table like dd03l-tabname.
select * from dd03l into corresponding fields of table itab where tabname = p_table.
loop at itab.
write:/ itab-fieldname.
endloop.
You can get the all field names of given table.
Thanks,
Naveen.I
08-26-2008 5:51 AM
Hi
Use
FM HR_READ_INFOTYPE
Regards
Pavan
Edited by: Pavan Bhamidipati on Aug 26, 2008 6:54 AM
08-26-2008 5:53 AM
hi,
Thanks for the timely reply,.but..
I need only the field names of the database table and not the contents...
08-26-2008 5:53 AM
Hi,
Go for the follwoing link>>
[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1456] [original link is broken] [original link is broken] [original link is broken];
thnks
Anurodh
08-26-2008 5:59 AM
Hi,
Try like this:
TYPES: BEGIN OF TY_TAB,
FLD1 TYPE I,
FLD2 TYPE CHAR10,
FLD3 TYPE I,
FLD4 TYPE I,
END OF TY_TAB.
DATA: ITAB TYPE STANDARD TABLE OF TY_TAB, "Dynamic table
WA_ITAB TYPE TY_TAB.
DATA: L_CNT TYPE I.
FIELD-SYMBOLS: <FS> TYPE ANY.
WA_ITAB-FLD1 = 1.
WA_ITAB-FLD2 = 'test'.
WA_ITAB-FLD3 = 3.
APPEND WA_ITAB TO ITAB.
WA_ITAB-FLD1 = 1.
WA_ITAB-FLD2 = 'test'.
WA_ITAB-FLD3 = 3.
APPEND WA_ITAB TO ITAB.
LOOP AT ITAB INTO WA_ITAB.
DO.
L_CNT = L_CNT + 1.
ASSIGN COMPONENT L_CNT OF STRUCTURE WA_ITAB TO <FS>.
IF SY-SUBRC 0.
EXIT.
ENDIF.
IF <FS> IS INITIAL.
* processing for initial.
ENDIF.
ENDDO.
CLEAR L_CNT.
ENDLOOP.
Regards,
Kunjal
08-26-2008 6:00 AM
hi,
The same scenario is given in this link..Foolow it .realy helpful..
http://sap-img.com/abap/how-to-get-the-field-descriptions-of-a-table.htm
Thanks
Mudit
08-26-2008 6:01 AM
Hi Arunsri....
Check this program....
data: itab like dd03l occurs 0 with header line.
parameters: p_table like dd03l-tabname.
select * from dd03l into corresponding fields of table itab where tabname = p_table.
loop at itab.
write:/ itab-fieldname.
endloop.
You can get the all field names of given table.
Thanks,
Naveen.I
08-26-2008 6:05 AM
data:TAB_NAME LIKE DD03L-TABNAME.
data:tbl type standard table of DD03L.
tab_name = 'MARA'.
CALL FUNCTION 'ISB_TABLE_READ_FIELDS'
EXPORTING
TAB_NAME = TAB_NAME
TABLES
TABLE_FIELDS = tbl[]
EXCEPTIONS
NO_ENTRIES_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
08-26-2008 6:08 AM
Hi Arun.,
DATA : begin of itab occurs 0 ,
TABNAME like DD03L-TABNAME ,
FIELDNAME like DD03L-FIELDNAME ,
end of itab .
select TABNAME FIELDNAME from DD03L into table itab .
thanks
Sreenivas Reddy
08-26-2008 6:12 AM
Hi anusri,
TABLES:
pa0000.
DATA:
fs_pa0000 LIKE
pa0000.
DATA:
t_pa0000 LIKE
TABLE OF pa0000.
DATA:
t_hrp1001 LIKE
STANDARD TABLE OF p1001,
t_hrp LIKE
STANDARD TABLE OF p1001.
SELECT-OPTIONS:
s_pernr FOR pa0000-pernr.
SELECT *
FROM pa0000
INTO TABLE t_pa0000
WHERE pernr IN s_pernr
AND endda GE sy-datum
AND begda LE sy-datum
AND stat2 EQ '3'.
LOOP AT t_pa0000 INTO fs_pa0000.
CALL FUNCTION 'RH_READ_INFTY_1000'
EXPORTING
* AUTHORITY = 'DISP'
* WITH_STRU_AUTH = 'X'
plvar = '01'
otype = 'P'
objid = fs_pa0000-pernr
* ISTAT = ' '
* EXTEND = 'X'
begda = fs_pa0000-begda
endda = fs_pa0000-endda
* CONDITION = '00000'
* SORT = 'X'
TABLES
i1000 = t_hrp1001
* OBJECTS =
* EXCEPTIONS
* NOTHING_FOUND = 1
* WRONG_CONDITION = 2
* WRONG_PARAMETERS = 3
* OTHERS = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
Regards,
Sravanthi