cancel
Showing results for 
Search instead for 
Did you mean: 

Number of fields in an internal table

Former Member
0 Kudos

How to find number of fields dynamically in an internal table ?

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member188685
Active Contributor
0 Kudos
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.
former_member181995
Active Contributor
0 Kudos

A

former_member181995
Active Contributor
0 Kudos

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 ',' .

former_member188685
Active Contributor
0 Kudos

>

> Sri/Vijay

> Sorry my above reply just by mistake dont mind.

>

Who is Sri in above posts?.

former_member181995
Active Contributor
0 Kudos

Sorry typo 'Ram'.

Am human Too ) Last night's HangO...;-)

Amit.

former_member188685
Active Contributor
0 Kudos

OOPS:) Take rest.

Former Member
0 Kudos

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

bpawanchand
Active Contributor
0 Kudos

Hi

[Internal Tables|]

[SAP tables|]

Regards

Pavan

Former Member
0 Kudos

describe itab. (itab means internal table)