2010 Mar 27 5:29 AM
Hello SAP gurus
I am trying to write a bapi that accepts table name, fields, where to condition dynamically and returns the result
When I use the following statements, I keep getting errors.
In the following staments please note that SELECTCOL, TABNAME, WHERECOL and VALUE ARE ALL DYNAMICALLY SENT VIA BAPI IMPORT TABS.
First I tried
-
STATEMENT 1 and THE ERROR I got were as follows
SELECT (SELECTCOL)
from (TABNAME)
WHERE (WHERECOL) = (VALUE)
into corresponding fields of table <dyn_table>.
ERROR 1
If the name of the database table is not
determined until runtime, you must specify
an out put area with "INTO.."
=========================================================
STATEMENT 2 and the error I got were as follows
SELECT (SELECTCOL)
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
FROM (TABNAME)
WHERE (WHERECOL) = (VALUE).
incorrect expression "=" in logical condition.
-
THe select statement works with '*" which gets everything, but I want only the columns that meets the condtion
specified with WHERE Clause.
Any feedback or suggestions will be highly appreciated.
Thanks
Ram
Edited by: Prasad Ram on Mar 27, 2010 6:31 AM
2010 Mar 27 6:49 AM
Hi, Prasad
Please check the following Sample Code hope this will help you to solve out your problem,
DATA: itab_ref TYPE REF TO data,
tabname like RSRD1-TBMA_VAL VALUE 'pa0001',
fields TYPE string,
where TYPE string.
CREATE DATA itab_ref TYPE STANDARD TABLE OF (tabname).
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE.
ASSIGN itab_ref->* TO <itab>.
DEFINE dselect.
SELECT (&1) FROM (&2) INTO CORRESPONDING FIELDS OF TABLE &3 WHERE (&4).
END-OF-DEFINITION.
START-OF-SELECTION.
fields = 'pernr begda endda'.
where = 'pernr = ''1000'''.
dselect fields tabname <itab> where.Please Reply in case of any Issue,
Best Regards,
Faisal
Hello SAP gurus
I am trying to write a bapi that accepts table name, fields, where to condition dynamically and returns the result
When I use the following statements, I keep getting errors.
In the following staments please note that SELECTCOL, TABNAME, WHERECOL and VALUE ARE ALL DYNAMICALLY SENT VIA BAPI IMPORT TABS.
First I tried
-
STATEMENT 1 and THE ERROR I got were as follows
SELECT (SELECTCOL)
from (TABNAME)
WHERE (WHERECOL) = (VALUE)
into corresponding fields of table <dyn_table>.
ERROR 1
If the name of the database table is not
determined until runtime, you must specify
an out put area with "INTO.."
=========================================================
STATEMENT 2 and the error I got were as follows
SELECT (SELECTCOL)
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
FROM (TABNAME)
WHERE (WHERECOL) = (VALUE).
incorrect expression "=" in logical condition.
-
THe select statement works with '*" which gets everything, but I want only the columns that meets the condtion
specified with WHERE Clause.
Any feedback or suggestions will be highly appreciated.
Thanks
Ram
Edited by: Prasad Ram on Mar 27, 2010 6:31 AM
2010 Mar 27 6:49 AM
Hi, Prasad
Please check the following Sample Code hope this will help you to solve out your problem,
DATA: itab_ref TYPE REF TO data,
tabname like RSRD1-TBMA_VAL VALUE 'pa0001',
fields TYPE string,
where TYPE string.
CREATE DATA itab_ref TYPE STANDARD TABLE OF (tabname).
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE.
ASSIGN itab_ref->* TO <itab>.
DEFINE dselect.
SELECT (&1) FROM (&2) INTO CORRESPONDING FIELDS OF TABLE &3 WHERE (&4).
END-OF-DEFINITION.
START-OF-SELECTION.
fields = 'pernr begda endda'.
where = 'pernr = ''1000'''.
dselect fields tabname <itab> where.Please Reply in case of any Issue,
Best Regards,
Faisal
2010 Mar 29 1:50 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |