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 Internal Table as Subroutine Formal Parameter

Former Member
0 Likes
2,012

Hi,

I have question for specifying internal table type of the subroutine parameter.

The following code could not compile due to the parameter definition problem. I wonder the cause of the problem in the following code:

FORM checkinfoobject

USING value(l_it_subareaid) TYPE STANDARD TABLE OF zpld_nmck.

.....

.....

ENDFORM.

"TYPE STANDARD TABLE OF" cannot be used in specifying parameter for subroutine.

Why is this so?

Thanks in advance.

Regards,

Joon Meng

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,152

Hi,

only for a structure or a Variable we use USING parameters, if you wnt to pass a Table in subroutine u should use TABLES parameter...

eg:

PERFORM checkinfoobject TABLES it_subareaid.

FORM checkinfoobject TABLES it_subareaid STRUCTURE zpld_nmck.

ENDFORM.

Hope it helps!!

Rgds,

Pavan

6 REPLIES 6
Read only

Former Member
0 Likes
1,152
form abcd USING abc type STANDARD TABLE vbak. 
  
endform.
Read only

Former Member
0 Likes
1,153

Hi,

only for a structure or a Variable we use USING parameters, if you wnt to pass a Table in subroutine u should use TABLES parameter...

eg:

PERFORM checkinfoobject TABLES it_subareaid.

FORM checkinfoobject TABLES it_subareaid STRUCTURE zpld_nmck.

ENDFORM.

Hope it helps!!

Rgds,

Pavan

Read only

Former Member
0 Likes
1,152

Hi,

Try like this,



DATA: l_it_subareaid TYPE STANDARD TABLE OF zpld_nmck .
FORM checkinfoobject TABLES l_it_subareaid
USING value(l_it_subareaid) 



ENDFORM.

Regards,

Vikranth

Read only

Former Member
0 Likes
1,152

Hi,

You cannot pass tables like that.

It needs to be passed using the TABLES options.

But that is obsolete now.

So do as follows:-

Declare a table type of zpld_nmck in your global declaration and then use the same in your exporting or importing parameter of the subroutine.

TYPES: TT_ zpld_nmck type standard table of  zpld_nmck.


FORM checkinfoobject
USING value(l_it_subareaid) TYPE TT_ zpld_nmck 
.....
.....
ENDFORM.

Regards,

Ankur Parab

Read only

0 Likes
1,152

Hi,

Thanks for the quick reply!

@Soumyaprakash: I have problem with this declaration. Although I have passed "zpld_nmck" (a structure), but I got the error message stating that it is not a structure.

@Vishnu: Thanks for the solution. It worked! The only drawback one is that this is considered obsolete.

@Vikranth: Sorry for the imprecise description from my side. I need to use subroutines in a function module. So, l_it_subareaid cannot be used in this case.

@Ankur: Thanks for the information. But the problem is that I have 10 subroutines need to be called in a function module. It would inconvenient to declare all these table types. Do you have any other suggestion?

Thanks once again!

Regards,

Joon Meng

Read only

0 Likes
1,152

Hi,

Using TABLES within a SUBROUTINE is OBSOLETE practise.

If you do the extended program check and run the code inspector you will find that it is an obsolete practise.

Currently only USING and CHANGING options are allowed for a subroutine and in case you need to pass tables you have to pass them using table types only.

Regards,

Ankur Parab