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

db Table as a parameter

Former Member
0 Likes
632

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
Read only

Former Member
0 Likes
608

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
Read only

Former Member
0 Likes
609

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

Read only

0 Likes
608

Thanks Rob. Points assigned.

Read only

0 Likes
608

Glad it worked out for you.

Rob