Cursor - dynamic select statement?
Hello!
I am passing a string into a function, and my string is a sql select statement. Is it possible to create a cursor using the string that is passed to the function?
Ex:
create or replace function "GETCOUNT"
(sqlstring in VARCHAR2)
return NUMBER
is
rec_count NUMBER; --I eventually want to return a count of the rows returned from my sqlstring
cursor c1 is sqlstring <--this is what I'd like to do...but how?
begin
... -- I haven't gotten to this point yet
end;
The error I get says 'Encountered the symbol "sqlstring" when expecting on of the following: ( select '
Thanks in advance!!
Something like this ->
create or replace procedure gen_cur(str in varchar2,rc in out sys_refcursor)
is
str1 varchar2(500);
begin
str1 := 'select empno,ename,hiredate,sal
from emp
where '||str;
open rc for str1;
exception
when others then
dbms_output.put_line(sqlerrm);
end;
variable b refcursor
declare
src varchar2(300);
begin
src:= 'sal between 2000 and 7000';
gen_cur(src,:b);
exception
when others then
dbms_output.put_line(sqlerrm);
end;
print bRegards.
Satyaki De.
Similar Messages
-
Hello Gurus,
We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
SELECT (lt_select_flds)
FROM (lf_tab_name)
INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
FOR ALL ENTRIES IN <lt_source_data>
WHERE (lf_where).
In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
This code was working fine till yesterday when we encountered serious performance problems and the Basis team had to do some changes at the DB level [Oracle]. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS.
Is setting changes at the Oracle level cause issues with how the data is being read at the DB. If yes, can you suggest what can we do to this code to get is working correctly [in case Basis can't revert back their changes]?
Would appreciate any help we can get here.You don't understand - this error comes up when we run specific BEx queries. It was working yesterday, but today it is not. Our support package did not change from yesterday. We did not apply any OSSnotes.
We are however doing pre-prepare on our Prod system.
The temporary table is used to store SIDs for use in the join. the table exists in the dictionary, but not at an Oracle level. -
DYnamic select statement in JDBC adapter?
Hi guys,
Is it possible so send dynamic select statement in jdbc adapter?
XIerAamir,
The poster did not specify whether this was sender or receiver channel, but it would only make sense that a "dynamic query" must be on the receiver communication channel since if it was on the sender channel, the channel would have to intelligently determine how to do dynamic queries.
Also, the poster asked if there was a way to "send a dynamic query" to the channel. This seems to imply that the channel is receiving information from somewhere to determine the query, which could only mean it is a receiver channel.
If you would like more information on the JDBC sender communication channel, please open a new thread. -
Hi,
Please let me know what is the difference between using OPEN CURSOR and SELECT statement WITH PACAKGE additon.
PraneethHi,
http://wiki.sdn.sap.com/wiki/display/ABAP/SELECTStatementsandCURSORstatement-Performance+Analysis.
and also check
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/content.htm
cheers,
Bhavana -
CX_SY_DYNAMIC_OSQL_SEMANTICS error with dynamic SELECT statement
Hello Gurus,
We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
SELECT (lt_select_flds)
FROM (lf_tab_name)
INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
FOR ALL ENTRIES IN <lt_source_data>
WHERE (lf_where).
In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
This code was working fine till we were in BW 3.5 and is causing issues after we moved to BW 7.31 recently. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS. THE ERROR TEXT SAYS 'Unable to interpret '<LT_SOURCE_data>-DOC_NUMBER'.
Can you pleasesuggest what can we do to this code to get is working correctly ? What has changed in ABAP Objects that has been introduced from BI 7.0 that could be causing this issue?
Would appreciate any help we can get here.
Thanks
ArvindHi,
Please try this.
data: lv_where type string.
concatenate 'vbeln' 'in' 'r_vbeln' into lv_where separated by space.
select *from table into itab where (lv_where).
Also please check this sample code.
REPORT ZDYNAMIC_WHERE .
TABLES: VBAK.
DATA: CONDITION TYPE STRING.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
INTO CONDITION SEPARATED BY SPACE.
SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
WHERE (CONDITION).
LOOP AT ITAB.
WRITE 'hello'.
ENDLOOP.
Regards,
Ferry Lianto -
Need to wite pl sql procedure for dynamic select statement
Need pl sql procedure for a Dynamic select statement which will drop tables older than 45 days
select 'Drop table'||' ' ||STG_TBL_NAME||'_DTL_STG;' from IG_SESSION_LOG where substr(DTTM_STAMP, 1, 9) < current_date - 45 and INTF_STATUS=0 order by DTTM_STAMP desc;I used this to subtract any data older than 2 years, adjustments can be made so that it fits for forty five days, you can see how I changed it from the originaln dd-mon-yyyy to a "monyy", this way it doesn't become confused with the Static data in the in Oracle, and call back to the previous year when unnecessary:
TO_NUMBER(TO_CHAR(A.MV_DATE,'YYMM')) >= TO_NUMBER(TO_CHAR(SYSDATE - 365, 'YYMM')) -
Autonumbers through dynamic SELECT statement
Trying to get an autonumber from an order table. The order_id I need from the table is only uniquely identified by the customer_id and the date/time. I've been advised that you cannot get an autonumber back from access without going via a select statement.
I've tried to do a dynamic select statement by getting the date (short i.e.DD/MM/YY) from the server using a JSP custom tag and then putting this value into a hidden form field on the previous web page.
However, when I load the next page the data gets input into the order table okay but the web page displayed is blank i.e. it doesn't display the order_id or the form to input credit card details. There are no error messages
Code below, any ideas?
<%@ page language="java" contentType="text/html"
import="ShoppingBasket,Product,java.util.*"
errorPage="errorpage.jsp"%>
<jsp:useBean id="basket" class="ShoppingBasket" scope="session"/>
<html>
<head>
<title>Your Order Has Been Received</title>
</head>
<body>
<%
String customer_id = request.getParameter("customer_id");
String total_value = request.getParameter("total_value");
String order_date = request.getParameter("order_date");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:odbc:Novbase","","");
java.sql.Statement Stmt = connection.createStatement();
String query = ("INSERT INTO Orders (customer_id, total_value) VALUES ("+customer_id+", "+total_value+")");
Stmt.executeUpdate(query);
java.sql.Statement Stmt2 = connection.createStatement();
java.sql.ResultSet RS = Stmt2.executeQuery("SELECT order_id FROM Orders WHERE customer_id = "+customer_id+" AND time_date LIKE '"+order_date+"%'" );
while(RS.next())
String order_id = RS.getString("order_id");
%>
your order id is <%=order_id %>. Please input your credit card details in the form below:
<form name="form1" method="post" action="shop-postorder4.jsp">
<table width="90%" border="0" cellspacing="1" cellpadding="5">
<tr>
<td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
<td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Credit
Card Type</font></td>
<td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<select name="card_type">
<option value="AMERICAN EXPRESS">American Express</option>
<option value="MASTER CARD">Master Card</option>
<option value="SWITCH">Switch</option>
<option value="VISA">Visa</option>
</select>
*</font></td>
</tr>
<tr>
<td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
<td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Credit
Card No.</font></td>
<td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="card_number" size=18 maxlength="18">
*</font></td>
</tr>
<tr>
<td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
<td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Issue
No. <font size="1"><br>
(Switch card holders<br>
only)</font></font></td>
<td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="issue_no" size="2" maxlength="2">
</font></td>
</tr>
<tr>
<td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
<td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Valid
From</font></td>
<td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="valid_from" size="4" maxlength="4">
e.g. 0502</font></td>
</tr>
<tr>
<td width="5%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></td>
<td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Validy
To</font></td>
<td width="70%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="text" name="valid_to" size="4" maxlength="4">
* e.g. 0105</font></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit">
<input type="hidden" name="order_id" value="<%=order_id %>">
</form>
<a href=" <%= response.encodeURL(shop-products.jsp") %">">
<img src="images\toshop.gif" border="0" alt="Return to the Shop"></a>
<%
RS.close();
Stmt.close();
Stmt2.close();
connection.close();
%>
</body>
</html>
</a>String query = ("INSERT INTO Orders (customer_id, total_value) VALUES ("+customer_id+", "+total_value+")");
the data gets input into the order table okay
java.sql.ResultSet RS = Stmt2.executeQuery("SELECT order_id FROM Orders WHERE customer_id = "+customer_id+" AND time_date LIKE '"+order_date+"%'" );It is a field name as <B>time_date </B>in Orders table? And should you insert some value ?
It seems your select return nothing.
When your RS.next() is false, so you get blank. Add some HTNL code or just <HR> after while {} block so your would see it. -
Cursor - Suggestions for Dynamic select statements
Hey,
Am trying to define a cursor like this -
cursor c1 is
select table_name from dba_tables INTERSECT select table_name from dba_tables@SOME_DBLINKMy need is to pass this dblink as IN parameter to the procedure and use it in the select statement for cursor. How can I do this?
Any suggestion is highly appreciated. Thanks!Well that was meant to be my point. If you had two, you wouldn't (I hope) call the second one "c2" - you would be forced to think about what it represented, and name it "c_order_history" or something. Sticking "1" on the end does not make an extensible naming convention for cursors any more than it does for variables, procedures, tables or anything else, and so the "1" in "c1" is redundant because there will never be a c2.
-
Using Cursor in Select statements? How to do this?
I am getting an error whilt passing a cursor to a select clause:
SELECT dbms_xmlquery.getXML('select deptno, dname, '||
'cursor(select empno, ename, sal from emp e where e.deptno = d.deptno) employees '||
'from dept d where d.deptno in (10, 20)')
FROM dual;
DBMS_XMLQUERY.GETXML('SELECTDEPTNO'||'CURSORIS(SELECTEMPNOFROMEMPEWHEREE.DEPT=D.
<?xml version = '1.0'?>
<ERROR>oracle.xml.sql.OracleXMLSQLException: ORA-00923
: FROM keyword not found where expected
</ERROR
THIS IS DUE TO THE CURSOR AND ITS FROM STATEMENT?
CAN ANY ONE PLEASE GUIDE AS TO HOW TO USE CURSORS IN A SELECT STATEMENT PLEASE?Another duplicate thread. See my response Select CLAUSE error using CURSORS & XSU.Please SEE..
Cheers, APC -
JDBC: Dynamic select statement
Hi,
I am working on a JDBC to SAP integration. I am trying to SELECT data from table for a specific time interval.
In the JDBC configuration i am using the Query SQL Statement
For example: select * from X where time='20080808'
Now is it possible to use for example the system date and time of the server where pi is installed or any other dynamic data?
Maybe like this: select * from X where time =@sysdate
If it is possible how? If not why?
I appreciate your help.
Thanks in advance...Hi,
In case of receiver JDBC you can map todays date to the select statement and make the select statement dynamic, however in the sender it can't be done. The work around may be to call the stored procedure from the sender adapter and using the stored procedure construct the select query dynamically.
Thanks
SaNv... -
Getting result of dynamic select statement into variable
I have a function that builds a dynamic sql statement. I then want to take the result of that statement and insert it into a variable. I have tried this
execute immediate strSQL USING OUT intCounter;but that is giving me an error on that line of code. The SQL is a select count(*) and works fine. It is just how to get it into the variable that is tripping me up.
Thanks,
EvaSure. Version 11g. The complete procedure reads as follows:
CREATE OR REPLACE FUNCTION VALIDATIONQUESTIONRESULT
p_ShortName VARCHAR2,
p_SiteID VARCHAR2
RETURN NUMBER IS
strSQL VARCHAR2(5000);
strTableName VARCHAR2(200);
strPatIDFieldName VARCHAR2(200);
intCounter NUMBER;
BEGIN
select VALIDATIONSQL into strSQL from vwvalidationquestions where upper(shortname) = upper(p_ShortName);
select
case UPPER(DBTABLENAME)
when 'CPTICODES' then 'CPTIPATID'
when 'CPTIICODES' then 'CPTIIPATID'
when 'DEMOGRAPHICS' then 'PATID'
when 'FAMILYHISTORY' then 'FHPATID'
when 'GCODES' then 'GCODEPATID'
when 'HOSPITALIZATION' then 'HPATID'
when 'MEDICALHISTORY' then 'MHPATID'
when 'MEDICATIONS' then 'MPATID'
when 'PROCEDURES' then 'PPATID'
when 'VISITS' then 'VPATID' end into strPatIDFieldName
from DATASPECIFICATIONS where UPPER(SHORTNAME) = UPPER(p_ShortName);
strSQL := strSQL||' and '||strPatIDFieldName||' in (select PATID from DEMOGRAPHICS where PARTICID = '||p_SiteID||');';
execute immediate strSQL into intCounter;
return intCounter;
END VALIDATIONQUESTIONRESULT; strSQL when checked builds perfectly. I get 100% what I expect from it. An example of what I am getting from strSQL is:
select count(*) from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);I am getting the number I would expect from this. I just need to put that number into intCounter. I tried altering strSQL so it looked like this:
select count(*) into intCounter from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);but that gave me an error on the execute immediate line as well.
Sorry, I thought it would be simple so that was why I only put that bit of info. I guess it is more complicated than it at first appeared!
Eva -
Ref cursor in select statement
I am not sure this is the right forum, but I got no reply from the OTN Sample.
How do I call a function from a select
statement ?
The function returns a ref cursor.
Here is the function definition:
FUNCTION get_priority_code_list
(p_language_id IN VARCHAR2)
RETURN RefCur
IS
rcur RefCur;
BEGIN
OPEN rcur FOR SELECT
priority_code "priority_code_menu",
priority_code_desc "priority_code_menu_desc"
FROM
prio_desc
WHERE
language_id = p_language_id;
RETURN rcur;
END;
I would like to wrap a SELECT statement
around the function and have the same result
as running the SELECT statement directly.
Of course it does not seem logical here to
use a function, but in fact I want the
function to do more than just a select....
I tried the syntax
SELECT package.function(param) FROM dual;
but that does not work...
or
SELECT * FROM package.function(param);
but that does not work either....
any idea ?
Tks.
nullI have a stored function that returns a ref cursor and I want to use it in select
I tried the following code
for example if the ref cursor returned rows of varchar2
I will define an object
CREATE TYPE myType as OBJECT( doc_type VARCHAR2(256));
created a type as a table of myType
create or replace type myTable as table of myType;
If I write a select statement like below
select * from TABLE(CAST(function_name() AS myTable))
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected - got CURSER
I get this error
Can anyone give any clue why this does throw an error or if there is a second way to do this, -
Inner Join for Dynamic Select statement
Hi All,
Can some one please help me in rewriting the below select statement where i have to remove the existing table1 by putting a dynamic table name which has the same table structure.
select a~zfield1
a~zfield2
from ztab1 as a
inner join ztab2 as b
on b~ztab1-zfield3 = a~ztab2-zfield3
where a~zfield4 = 'A'.
I am looking something as below. But encountering an error when using the below statement
select a~zfield1
a~zfield2
from (v_ztab1) as a
inner join ztab2 as b
on b~ztab1-zfield3 = a~ztab2-zfield3
where a~zfield4 = 'A'.
No Separate selects please. Please help me in rewriting the same select statement itself.
Regards,
PSKhi,
What error you are getting ?
Also INTO is missing from the statement.
SELECT pcarrid pconnid ffldate bbookid
INTO TABLE itab
FROM ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' .
thanks -
Workarea in dynamic select-statement
Hello !
i hope i can get some help...
it should be possible to do a dynamic select like this:
SELECT * FROM (S_TABLE) INTO WA_TABLE.
but my Problem is:
how can i define (dynamic) the wa_table?
it should be the same structure like the table i selected before (the value is in s_table).
thanks very much...
HelmutHi helmut,
1. we need to construct dynamic internal table
for this purpose.
2. this program
gives a selection screen for entering
the TABLE NAME eg. T001.
3. then it SELECTS * from that table,
dynamically,
and gives the data in
<b> <dyntable></b>
4. Just copy paste in new program.
5.
rEPORT abc.
COMPULSORY
FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
FIELD-SYMBOLS: <dynline> TYPE ANY.
DATA: lt TYPE lvc_t_fcat.
DATA: ls TYPE lvc_s_fcat.
FIELD-SYMBOLS: <fld> TYPE ANY.
DATA : fldname(50) TYPE c.
PARAMETERS : iname LIKE dd02l-tabname obligatory.
START-OF-SELECTION.
GET INFO
DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
EXPORTING
tabname = iname
TABLES
ddfields = ddfields.
CONSTRUCT FIELD LIST
LOOP AT ddfields.
ls-fieldname = ddfields-fieldname.
APPEND ls TO lt.
ENDLOOP.
PERFORM
PERFORM mydyntable USING lt.
select * from (iname)
into table <dyntable>.
BREAK-POINT.
INDEPENDENT FORM
FORM mydyntable USING lt TYPE lvc_t_fcat .
Create Dyn Table From FC
FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
FIELD-SYMBOLS: <fs_1>.
FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
DATA: lt_data TYPE REF TO data.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Assign Dyn Table To Field Sumbol
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <dyntable>.
ENDFORM. "MYDYNTABLE
regards,
amit m. -
Dynamic Select statements (Joins)
Hi friends the following is the Source code in my FUNCTION MODULE and this i have few parameters in my report
MARKET
MEMBER
EFFECTIVE DATE
STATUS
COUNTRY
ADMISSION TYPE
I need the output from Different Select options (PARAMETER OPTIONS) from the User point of view..this is Just one market's (XETRA) selections .. I have 13 markets... Kindly anyone help me with the similar output I need a dynamic selection ...
SAMPLE or EXAMPLE CODE appreciated...
CASE iv_market.
WHEN lc_xtra_market.
lv_table = 'ZTGP_MEMBER_XTRA'.
IF iv_member_id IS INITIAL AND iv_country IS INITIAL AND iv_adm_type IS INITIAL.
SELECT ztgp_member_xtra~xetra_id
ztgp_member_xtra~admission
ztgp_member_xtra~partner
ztgp_member_xtra~status
ztgp_member_xtra~adm_type
ztgp_member_xtra~object_id
ztgp_member_xtra~addrnumber
ztgp_member_xtra~beg_dat
adrc~country
INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber WHERE ztgp_member_xtrastatus EQ iv_status AND ztgp_member_xtrabeg_dat LE iv_date_effective AND
ztgp_member_xtra~end_dat GE iv_date_effective.
APPEND lt_member.
ENDSELECT.
ELSEIF NOT iv_member_id IS INITIAL AND iv_country IS INITIAL AND iv_adm_type IS INITIAL.
SELECT ztgp_member_xtra~xetra_id
ztgp_member_xtra~admission
ztgp_member_xtra~partner
ztgp_member_xtra~status
ztgp_member_xtra~adm_type
ztgp_member_xtra~object_id
ztgp_member_xtra~addrnumber
ztgp_member_xtra~beg_dat
adrc~country
INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
WHERE ztgp_member_xtra~xetra_id EQ iv_member_id AND
ztgp_member_xtra~status EQ iv_status AND
ztgp_member_xtra~beg_dat LE iv_date_effective AND
ztgp_member_xtra~end_dat GE iv_date_effective.
APPEND lt_member.
ENDSELECT.
ELSEIF NOT iv_member_id IS INITIAL AND NOT iv_country IS INITIAL AND iv_adm_type IS INITIAL.
SELECT ztgp_member_xtra~xetra_id
ztgp_member_xtra~admission
ztgp_member_xtra~partner
ztgp_member_xtra~status
ztgp_member_xtra~adm_type
ztgp_member_xtra~object_id
ztgp_member_xtra~addrnumber
ztgp_member_xtra~beg_dat
adrc~country
INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
WHERE ztgp_member_xtra~xetra_id EQ iv_member_id AND
adrc~country EQ iv_country AND
ztgp_member_xtra~status EQ iv_status AND
ztgp_member_xtra~beg_dat LE iv_date_effective AND
ztgp_member_xtra~end_dat GE iv_date_effective.
APPEND lt_member.
ENDSELECT.
ELSEIF iv_member_id IS INITIAL AND NOT iv_country IS INITIAL AND iv_adm_type IS INITIAL.
SELECT ztgp_member_xtra~xetra_id
ztgp_member_xtra~admission
ztgp_member_xtra~partner
ztgp_member_xtra~status
ztgp_member_xtra~adm_type
ztgp_member_xtra~object_id
ztgp_member_xtra~addrnumber
ztgp_member_xtra~beg_dat
adrc~country
INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
WHERE adrc~country EQ iv_country AND
ztgp_member_xtra~status EQ iv_status AND
ztgp_member_xtra~beg_dat LE iv_date_effective AND
ztgp_member_xtra~end_dat GE iv_date_effective.
APPEND lt_member.
ENDSELECT.
ELSEIF iv_member_id IS INITIAL AND iv_country IS INITIAL AND NOT iv_adm_type IS INITIAL.
SELECT ztgp_member_xtra~xetra_id
ztgp_member_xtra~admission
ztgp_member_xtra~partner
ztgp_member_xtra~status
ztgp_member_xtra~adm_type
ztgp_member_xtra~object_id
ztgp_member_xtra~addrnumber
ztgp_member_xtra~beg_dat
adrc~country
INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
WHERE ztgp_member_xtra~adm_type EQ iv_adm_type AND
ztgp_member_xtra~status EQ iv_status AND
ztgp_member_xtra~beg_dat LE iv_date_effective AND
ztgp_member_xtra~end_dat GE iv_date_effective.
APPEND lt_member.
ENDSELECT.
ENDIF.
WHEN lc_repo_market.
WHEN lc_eurex_market.
When lc_fwb_market.
and so on... 13 markets..
ENDIF.
IF sy-subrc NE 0.
ENDIF.
WHEN OTHERS.
EXIT.
ENDCASE.In your case your internal tables seems to have constant and same structure so it can be defined statically.
lv_table & lv_where_cond are variables.
SELECT F1 F2 FROM (lv_table)
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE (lv_where_cond).
Maybe you are looking for
-
IPhone not showing up in iTunes or My Computer
My iPhone 3G is charging when connected to my computer but it's not showing up in the computer or iTunes. Help? I have a Windows Vista and an iPhone 3G with iOS 4.2.1.
-
SAP NetWeaver Application Server ABAP 7.03 64-bit Trial - License
I have recently download the SAP NetWeaver Application Server ABAP 7.03 64-bit Trial version for use on Windows Server 2008R2. I went to get a license key and noticed this was only a 90 day license. Is it possible to extend the licensing out to lon
-
Convert Binary File to ASCI File
Hello, I'm having a little trouble writing a labview program to read a binary file and save it to an ASCI file. The binary file may be large so I've tried to read the file in chunks. I will appreciate any help you could offer. I've attached my .vi be
-
OCCI ERROR: (ORA-24392 ) !!
hello all: After my OCCI connection pool runs a moment. it Crash: Error number: 24392 ORA-24392: 没有与服务器句柄相关的连接池 ORA-24392: no connection pool to associate server handle follow is my occi connection pool source code. help me to find problem. thanks. c
-
How do we get spell check on Beta? It isn't obvious like before
I sent a question before but it asked me to confirm my address and didn't show me how to confirm. My problem is I do not know how to get spell check on an e mail. This has been so time consuming because I also can't get to anything once I click. Alwa