on 08-02-2008 6:49 AM
How to find number of fields dynamically in an internal table ?
Report ztest.
type-pools: slis.
data: T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
data: v_lines type i.
" Internal table should be declated in this way..
data: begin of it_itab occurs 0,
matnr like vbap-matnr, <---use LIKE
vbeln like vbap-vbeln,
posnr like vbap-posnr,
end of it_itab.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'IT_ITAB'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = T_FIELDCAT[].
describe table t_fiedcat lines v_lines.
write v_lines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sri/Vijay
Sorry my above reply just by mistake dont mind.
concatenate all the fields and move them to final internal table , call the function module "GET_COMPONENT_LIST" and pass the work area of the final internal table in the parameter fieldname
***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.
********end of getting no of fields**********
TRANSFER wa_mat_out_head TO P_FNAME.
LOOP AT GT_PAYR.
MOVE: GT_payr-LIFNR TO T_payr-lifnr,
GT_payr-ZBUKR TO T_payr-zbukr,
GT_payr-LAUFD TO T_payr-LAUFD,
GT_payr-CHECT TO T_payr-CHECT,
GT_payr-RWBTR TO T_payr-RWBTR.
Concatenate T_payr-lifnr t_payr-zbukr T_payr-laufd T_payr-chect
T_payr-rwbtr into wa_mat_out-rec SEPARATED by ',' .
Hi,
If you are talking about Number of Records in an internal table then you can use
Describe table itab lines w_line.
You can get the number of records in w_line variable.
But if you want ot get number of Column or fields dynamically then you have to use field-symbol concept-
Refer this link for hints-
Regards,
Sujit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.