08-31-2007 7:36 AM
Hi,
I have written a method which will ask the values in the runtime and it will work as per the values..
For example :
If a query is there like---
SELECT * from ekko into table itab where ebeln = 3000000004.
Now I will give the table name ,internal table name and the value in the selectiuon screen..
How to put the that values in the query like]
SELECT * from <Tablename> into <Int table> where ebeln = <Value name>
08-31-2007 7:45 AM
Hi
You have to use a dynamic select in this case:
Try the Code below.. you will get the Solution
REPORT ZSEL_BGJOB.
DATA: L_TABNAME TYPE DD02L-TABNAME VALUE 'EKPO'.
DATA : REF_TAB TYPE REF TO DATA.
FIELD-SYMBOLS: <FTAB> TYPE TABLE.
**Create the ITAB dynamically and Assign to Field symbol
CREATE DATA REF_TAB TYPE TABLE OF (L_TABNAME).
ASSIGN REF_TAB->* TO <FTAB>.
**Construct the Select statement dynamically..
SELECT * FROM (L_TABNAME) INTO TABLE <FTAB>.
DESCRIBE TABLE <FTAB>.
WRITE:/ SY-TFILL.
<b>Reward if Helpful</b>
08-31-2007 7:45 AM
Hi
You have to use a dynamic select in this case:
Try the Code below.. you will get the Solution
REPORT ZSEL_BGJOB.
DATA: L_TABNAME TYPE DD02L-TABNAME VALUE 'EKPO'.
DATA : REF_TAB TYPE REF TO DATA.
FIELD-SYMBOLS: <FTAB> TYPE TABLE.
**Create the ITAB dynamically and Assign to Field symbol
CREATE DATA REF_TAB TYPE TABLE OF (L_TABNAME).
ASSIGN REF_TAB->* TO <FTAB>.
**Construct the Select statement dynamically..
SELECT * FROM (L_TABNAME) INTO TABLE <FTAB>.
DESCRIBE TABLE <FTAB>.
WRITE:/ SY-TFILL.
<b>Reward if Helpful</b>
08-31-2007 8:56 AM
If we give an internal table of only having two fields of the table means how we cn procees to it
08-31-2007 7:49 AM
Hello Mahesh,
Its not at all possible. Why because, control will consider the word after <b>from</b> as a table name. and with that table name it will search in datadictionary. So you have to pass only valid table names.
You can not give table name dynamically for select statement.
Reward If Useful.
Regards
--
Sasidhar Reddy Matli.
08-31-2007 11:03 AM
Hi,
Just one idea:
Why don't u create 2 reports? The first one (the one that collects information from selection screen) creates another report that selects and outputs the selection, and then call the new report (with submit statement)?
You can allways delete (on the first report) the new report (2nd one)...
It works, but is it worth the effort?
Regards,
Carlos Constantino
08-31-2007 11:37 AM
try the following code:
*&---------------------------------------------------------------------*
*& Report ZCAC_TRETA_DYN_SELECT *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZCAC_TRETA_DYN_SELECT .
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETER P_TABLE TYPE CHAR32 DEFAULT 'SFLIGHT'.
SELECTION-SCREEN END OF BLOCK B1.
DATA: G_LINE TYPE CHAR255,
GT_REPORT TYPE STANDARD TABLE OF CHAR255,
G_FIELD TYPE STRING.
CONCATENATE 'gt_' P_TABLE INTO G_FIELD.
*create new report:
MOVE 'REPORT TRETA.' TO G_LINE.
APPEND G_LINE TO GT_REPORT.
CLEAR G_LINE.
CONCATENATE 'Data:' G_FIELD
' type standard table of ' P_TABLE
' with header line.' INTO G_LINE SEPARATED BY SPACE.
APPEND G_LINE TO GT_REPORT.
CLEAR G_LINE.
CONCATENATE 'select * from ' P_TABLE ' into table' G_FIELD '.'
INTO G_LINE SEPARATED BY SPACE.
APPEND G_LINE TO GT_REPORT.
CLEAR G_LINE.
CONCATENATE 'loop at' G_FIELD '.' INTO G_LINE SEPARATED BY SPACE.
APPEND G_LINE TO GT_REPORT.
CLEAR G_LINE.
CONCATENATE 'write:/,' G_FIELD'.' INTO G_LINE SEPARATED BY SPACE.
APPEND G_LINE TO GT_REPORT.
CLEAR G_LINE.
MOVE 'endloop.' TO G_LINE.
APPEND G_LINE TO GT_REPORT.
INSERT REPORT 'ZCAC_TRETA_DYN_TRETA' FROM GT_REPORT.
SUBMIT ZCAC_TRETA_DYN_TRETA.