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

Regarding internal table

Former Member
0 Likes
790

Hi,

How to know number of columns in an internal table at run-time.

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
772

just do this.

DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
END OF it_mara.

DATA : p(5) TYPE c.
FIELD-SYMBOLS: <fs_record> TYPE ANY.
FIELD-SYMBOLS: <fs_comp> TYPE ANY.

ASSIGN it_mara TO <fs_record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc EQ 0.
p = p + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.

WRITE : / p.

Regards,

Anversha

7 REPLIES 7
Read only

bpawanchand
Active Contributor
0 Likes
772

Hi

To find out the attributes of an internal table at runtime that were not available statically, use the statement:

DESCRIBE TABLE <itab> LINES <l> OCCURS <n> KIND <k>.

Regards

Pavan

Read only

Former Member
0 Likes
772

Use 'describe' command.

Read only

anversha_s
Active Contributor
0 Likes
773

just do this.

DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
ersda LIKE mara-ersda,
END OF it_mara.

DATA : p(5) TYPE c.
FIELD-SYMBOLS: <fs_record> TYPE ANY.
FIELD-SYMBOLS: <fs_comp> TYPE ANY.

ASSIGN it_mara TO <fs_record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc EQ 0.
p = p + 1.
ELSE.
EXIT.
ENDIF.
ENDDO.

WRITE : / p.

Regards,

Anversha

Read only

Former Member
0 Likes
772

Hi Arun,

Use DESCRIBE statement.

Please check this link

[DESCRIDE statement|http://www.sapdb.org/7.4/htmhelp/f6/c3e002e200884292a3e629b6c41b96/content.htm]

Best regards,

raam

Read only

Former Member
0 Likes
772

Hi,

you can use the Describe lines itab into a variable.

if you are in a loop and find the index of the itab you can use the sy-tabix system field.

Read only

Former Member
0 Likes
772

Check the link

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
772

see this below links