Thursday, June 14, 2007

Passing itabs to subroutines

The aim of the program is to take select-option from the main program and pass the same to a subroutine.

I was able to achieve the same with FORM <> TABLES <>

In order to pass itabs to your subroutine use tables instead of USING in both the
FORM and PERFORM statement.

My pgm was of the form.

FORM sub1 TABLES itab
.
select * from mara into <> where matnr in itab.
END FORM


declare an itab itab1

PERFORM sub1 TABLES itab1.


In my program i obtained select options in my main program and passed it using PERFORM TABLES.
The documention of FORM specifies that TABLES is obsolete , the same functionality can be obtained with USING. When i tried the same the
select * from mara into <> where matnr in itab.

in my program failed in syntax check.
Quiet obvious as SAP does not understand what type i am passing.

I also tried adding like statement in FORM.
It failed too.

Right now TABLES is the working way i know of to pass itabs to subs.

No comments: