‎2008 Jan 10 8:58 PM
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.
‎2008 Jan 10 9:11 PM
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. " getrecsRob
‎2008 Jan 10 9:11 PM
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. " getrecsRob
‎2008 Jan 10 9:21 PM
‎2008 Jan 10 9:26 PM