‎2006 Apr 27 10:46 AM
Hi,
How to get number of fields in an internal table?
Please send a solution.
Thanks & Regards,
Vani.
‎2006 Apr 27 11:09 AM
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.
‎2006 Apr 27 10:50 AM
use REUSE_ALV_FIELDCATALOG_MERGE and after u get it_fieldcatalog
describe table it_fieldcatalog lines_v_lines
Message was edited by: SekharMessage was edited by: Sekhar
‎2006 Apr 27 10:51 AM
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.
‎2006 Apr 27 10:51 AM
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
‎2006 Apr 27 11:01 AM
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.
endifnow describe your fieldcat . and find no of columns.
and their order also..
Regards
vijay
‎2006 Apr 27 11:02 AM
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
‎2006 Apr 27 11:09 AM
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.
‎2006 Apr 27 11:56 AM
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.
‎2006 Apr 27 12:01 PM
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.
‎2006 Apr 27 12:11 PM
‎2006 Apr 27 12:17 PM