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

Problem with passing itab to program subprogram

Former Member
0 Likes
675

Hi there. I've got a problem with passing itab to subprogram.


DATA: internaltable LIKE dbtable OCCURS 0 .


PERFORM fill_itab USING internaltable .


FORM fill_itab USING itab  LIKE dbtable . 
...  here modify itab ...
ENDFORM.                    " 

I receive an error: In PERFORM "FILL_ITAB", the actual parameter "internaltable" and

formal parameter "itab" are incomapatible.

So ... how should I corretly pass such internaltable itab to the subpprogram?

Greetings. P.

1 ACCEPTED SOLUTION
Read only

former_member435013
Active Participant
0 Likes
654

Hi,

try:

FORM fill_itab TABLES itab STUCTURE dbtable .

best regards

Walter Habich

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
654

In the FORM statement, you are declaring a one line structure, you need to declare a table here. You could do this in two ways, you can use the USING extension or the TABLES extention.

FORM fill_itab USING itab type table of dbtable. 

ENDFORM.

FORM fill_itab tables itab type dbtable . 

ENDFORM.

Regards,

Rich Heilman

Read only

0 Likes
654

Rich Heilman

 FORM fill_itab USING itab type table of dbtab.  

Returns:

Different number of parameters in FORM and PERFORM (routine:

FILL_ITAB, formal parameters: 3, actual parameters: 1).

 FORM fill_itab tables itab type dbtable .  

Returns:

For typing of TABLES parameters, only table types should be used. -

Read only

0 Likes
654

Hello,

You need first to declare a table type:


TYPES: it_type TYPE TABLE OF dbtable.

FORM fill_itab tables itab TYPE it_type.
 
FORM fill_itab USING itab TYPE it_type.

FORM fill_itab CHANGING itab TYPE it_type.

Regards.

Read only

0 Likes
654

My apologies. Its a holiday here, so my brain is not up and running yet. Try this.

Create a Table Type using a TYPE statement, and then use this in the FORM statement.

TYPES: ttab TYPE TABLE OF dbtable.

DATA: internaltable LIKE dbtable OCCURS 0 .

PERFORM fill_itab USING internaltable .

FORM fill_itab USING itab TYPE ttab.

ENDFORM.                    "fill_itab

Regards,

Rich Heilman

Read only

former_member435013
Active Participant
0 Likes
655

Hi,

try:

FORM fill_itab TABLES itab STUCTURE dbtable .

best regards

Walter Habich