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

System variable for columns in internal table

former_member384574
Active Participant
0 Likes
1,519

Hello Experts,

Does anybody know if there's any system data for know the columns of an internal table? The variable sy-TFILL gives us the number of rows but I'm not sure if there's any other variable for find the columns....can anybody help me please?

Thanks in advance,

Regards.
Rebeca

9 REPLIES 9
Read only

former_member189779
Active Contributor
0 Likes
1,074

Hi,

For cloumns refer Link removed by moderator

Message was edited by: Vinod Kumar

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,074

SY-TLENG woul be the length of the lines. But I doubt for number of fields, if the records are not a flat structure, what would be the number of column of a deep structure ? Would it be a constant or would it depend on the values of each record. Nevertheless you can CL_ABAP_STRUCTDESCR's methods DESCRIB_BY_* which will return a ref to CL_ABAP_TYPEDESCR.

Regards,
Raymond

Read only

Former Member
0 Likes
1,074

Hi,

I also doubt if there is a system field that holds the number of columns in an internal table. But you can get the column count by working around. Take a look at this thread. http://scn.sap.com/thread/135452

Regards,

Jake

Read only

Former Member
0 Likes
1,074

Hi,

assign the structure to a field symbol and use assign-components ... press F1 help on assign components...


if sy-index = 1.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc <> 0.
count = count + 1.
ENDIF.
endif.

Otherwise use the below code,

DO.

  ASSIGN COMPONENT SY-INDEX OF STRUCTURE GWA_ITAB TO <FS>.

  IF SY-SUBRC = 0.

    CONTINUE.

  ELSE.

    G_COLNUMBER = SY-INDEX.

    EXIT.

  ENDIF.

ENDDO.

Now G_COLNUMBER - 1 , will be the no of column.

Regards,

Arun

Read only

0 Likes
1,074

Hi,

Using Type polls Slis you can get index of the internal table..

   WHEN  '&IC1'.

      READ TABLE <T_itpac> ASSIGNING <W_itpac>  INDEX selfield-tabindex.

Read only

Former Member
0 Likes
1,074

This message was moderated.

Read only

0 Likes
1,074

Hi Anoop,

Helping others for point's doesn't make you a professional

Read only

matt
Active Contributor
0 Likes
1,074

kesavadas Thekkillath wrote:

Hi Anoop,

Helping others for point's doesn't make you a professional

Anoops answer removed for that reason. Asking for or offering points it NOT permitted in these forums.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,074
Hi,
I do not think there is a system field to handle this. You can read the reply from Raymond for more details.
Compared to the other solutions suggested, I would like to add the simplest way to get it.

data:lwa_structure type ty,

wa_ltype type c,

itab type table of ty.

DESCRIBE FIELD lwa_structure TYPE  wf_ltype COMPONENTS wi_count.

Write wi_count