Application Development and Automation 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: 
Read only

fields in internal table

Former Member
0 Likes
1,163

Hi,

How to get number of fields in an internal table?

Please send a solution.

Thanks & Regards,

Vani.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,104

Hi,

***For getting no of FIELDS in an internal table ********

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

PROGRAM = syrepid

FIELDNAME = 't_payr'

TABLES

COMPONENTS = fieldlist.

describe table fieldlist lines pyr_no_fields.

rgds,

Latheesh.

10 REPLIES 10
Read only

Former Member
0 Likes
1,104
use REUSE_ALV_FIELDCATALOG_MERGE and after u get it_fieldcatalog

describe table it_fieldcatalog lines_v_lines


Message was edited by: Sekhar

Message was edited by: Sekhar

Read only

Former Member
0 Likes
1,104

Vani,

Use the function GET_COMPONENT_LIST and pass the work area of the table to this. It will return a table which will have the list of fields.

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" PROGRAM LIKE SY-REPID

*" FIELDNAME

*" TABLES

*" COMPONENTS STRUCTURE RSTRUCINFO

*"----


Now describe the table COMPONENTS and that will be the number of fields in the internal table.

Regards,

Ravi

Note : Please close the thread if the issue is resolved.

Read only

Former Member
0 Likes
1,104

Hi Vani,

OH SORRY I posted for Table.

Please use the function module

<b>DB_GET_TABLE_FIELDS</b>. It will return the

field details. No of entries of the DBFIELDS

table will give you no of fields in the table.

and also you will get this from the table DD03L.

For itab use <b>GET_COMPONENT_LIST</b>.

Thanks&Regards,

Siri.

Message was edited by: Srilatha T

Read only

Former Member
0 Likes
1,104

Hi,

you can find the number of columns and their order using

the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>

 call function 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   I_PROGRAM_NAME               = sy-repid
   I_INTERNAL_TABNAME           = 'ITAB'
   I_INCLNAME                   = sy-repid
  changing
    ct_fieldcat                  = IT_FIELDCAT
 EXCEPTIONS
   INCONSISTENT_INTERFACE       = 1
   PROGRAM_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

now describe your fieldcat . and find no of columns.

and their order also..

Regards

vijay

Read only

Former Member
0 Likes
1,104

HI

GOOD

SY-DBNAM

The name of the logical database linked to an executable program.

SY-DYNGR

Screen group to which the current screen belongs.

SY-DYNNR

Number of the current screen.

SY-LDBPG

In executable programs, the database program of the associated logical database.

THANKS

MRUTYUN

Read only

Former Member
0 Likes
1,105

Hi,

***For getting no of FIELDS in an internal table ********

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

PROGRAM = syrepid

FIELDNAME = 't_payr'

TABLES

COMPONENTS = fieldlist.

describe table fieldlist lines pyr_no_fields.

rgds,

Latheesh.

Read only

0 Likes
1,104

HI,

Srilatha,Sekhar,Ravi,Vijay,Tripathy,Latheesh.

THANK YOU ALL.

I have written the following test code but not getting the result.

please tell where i am wrong.

REPORT YTEST .

data:

Fields type i,

begin of fieldlist occurs 0,

no like RSTRUCINFO,

end of fieldlist,

begin of itab occurs 0,

f1 TYPE C,

f2,

f3,

end of itab.

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = 'YTEST'

fieldname = itab

tables

components = fieldlist

.

describe table fieldlist lines fields.

write fields.

Read only

0 Likes
1,104

Do like this:

REPORT YRT_TEST1 line-size 500.

data:

Fields type i,

begin of fieldlist occurs 0,

no like RSTRUCINFO,

end of fieldlist,

begin of itab occurs 0,

f1 TYPE C,

f2,

f3,

end of itab.

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = 'YRT_TEST1'

<b>fieldname = 'ITAB'</b>

tables

components = fieldlist

.

describe table fieldlist lines fields.

write:/ fields.

It will surely work.

Regards,

Ravi

PLease award points to helpful posts.

Read only

0 Likes
1,104

Hi Ravi,

It did not work.

Thanks & Regards,

Vani.

Read only

0 Likes
1,104

Thank you Ravi.

It is solved.

Thanks,

Vani.