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: 

Report

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

naveen_inuganti2
Active Contributor
0 Kudos

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

9 REPLIES 9

bpawanchand
Active Contributor
0 Kudos

Hi

Use

FM HR_READ_INFOTYPE

Regards

Pavan

Edited by: Pavan Bhamidipati on Aug 26, 2008 6:54 AM

Former Member
0 Kudos

hi,

Thanks for the timely reply,.but..

I need only the field names of the database table and not the contents...

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

naveen_inuganti2
Active Contributor
0 Kudos

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

kesavadas_thekkillath
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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