Application Development 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: 

db Table as a parameter

Former Member
0 Kudos

Hi SDN,

I have two tables with identical structure. How can I write a FORM/ENDFORM such that I pass the name of the table as a variable. Please note I am not talking about internal tables but actual db tables like MARA, etc.

Please give an example.

I want to accomplish the following:

TABLES A, B, C, D

FORM GETRECS

SELECT X, Y, Z

FROM ?

ENDFORM

How can use a variable to replace ? after FROM?

Thanks.

Saf.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Are you looking for something like this:

REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.

TABLES: bsik, bsak.

PERFORM getrecs USING 'BSIK'.
PERFORM getrecs USING 'BSAK'.

DATA: itab TYPE TABLE OF bsik.

*&---------------------------------------------------------------------*
*&      Form  getrecs
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM getrecs  USING    table.

  SELECT * FROM (table)
    APPENDING TABLE itab.

ENDFORM.                    " getrecs

Rob

3 REPLIES 3

Former Member
0 Kudos

Are you looking for something like this:

REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.

TABLES: bsik, bsak.

PERFORM getrecs USING 'BSIK'.
PERFORM getrecs USING 'BSAK'.

DATA: itab TYPE TABLE OF bsik.

*&---------------------------------------------------------------------*
*&      Form  getrecs
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM getrecs  USING    table.

  SELECT * FROM (table)
    APPENDING TABLE itab.

ENDFORM.                    " getrecs

Rob

0 Kudos

Thanks Rob. Points assigned.

0 Kudos

Glad it worked out for you.

Rob