How to use where clause with get statement in LDB programs
Hi All,
I am using logical databse in my report program.I am not getting how to use the where clause in the get statement is it possible to use?or if not possible only option is we should filter it after get statment is right?Can you please some body throw some idea on this?
Regards
Mahesh
Hi,
Reffer these links
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
reward if helpful
Thanks,
Suma.
Similar Messages
-
How to use "where" clause in modify statement
Hi
can any1 telll me is it possible to use a where clause in a modify statemetn. I want to use modify statemetn to insert a new recoed in a database table.
Regards
Sabahuddin AhmedMODIFY itab - itab_lines
Syntax :
... itab FROM wa TRANSPORTING comp1 comp2 ... WHERE log_exp.
With these additions the MODIFY statement assigns the content of the comp1 comp2 ... components of the wa work area specified after TRANSPORTING to all lines in the itab table that meet the logical condition log_exp. The wa work area must be compatible with the line type of the internal table.
The TRANSPORTING addition has the same effect as changing individual lines. The WHERE addition can only be specified together with the TRANSPORTING addition. After WHERE, any logical expression can be specified in which the first operand of each individual comparison is a component of the internal table. All logical expressions are therefore possible, with the exception of IS ASSIGNED, , and IS SUPPLIED. It is not possible to dynamically specify a component using bracketed character-type data objects.
While for standard tables and hashed tables all lines in the internal table are checked for the logical expression of the WHERE statement, for sorted tables, optimized access can be achieved by checking at least one opening part of the table key for parity using AND linked queries in the logical expression.
Example
Change the contents of the planetype component for all lines in the sflight_tab internal table in which this component contains the value p_plane1 to the value p_plane2.
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid,
p_plane1 TYPE sflight-planetype,
p_plane2 TYPE sflight-planetype.
DATA sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.
DATA sflight_wa TYPE sflight.
SELECT *
FROM sflight
INTO TABLE sflight_tab
WHERE carrid = p_carrid AND
connid = p_connid.
sflight_wa-planetype = p_plane2.
MODIFY sflight_tab FROM sflight_wa
TRANSPORTING planetype WHERE planetype = p_plane1.
reward if useful -
How to use WHERE Clause in BPEL
Hi ,
i am trying to use where clause in DB adapter but its not working.
my query is "select empname from employee where empid = &a"
can any body tell me what is the reason its npt working?
and how can i retrive data form DB?Hi,
You are thinking perfectly fine. The solution what I suggested was
select ename from emp where empno=?
And the solution provided by you was
SELECT first_name, last_name FROM per_all_people_f WHERE person_id = #p_person_id
There is no problem with the above mentioned select statements.
I just want to say that if you see closely, internal logic changes #parameter name to ?. So both the logics are right.
Cheers,
Abhi... -
Dynamic where clause with loop statement
Hi all,
is it possible to use a dynamic where clause with a loop statement?
Can you please advise me, how the syntax needs to be?
Thanks for your suggestions,
kind regards, Kathrin!Hi Kathrin,
If u are in ECC 6.0, please go through the code...
REPORT zdynamic_select.
TYPES:
BEGIN OF ty_sales,
vbeln TYPE vbak-vbeln, " Sales document
posnr TYPE vbap-posnr, " Sales document item
matnr TYPE vbap-matnr, " Material number
arktx TYPE vbap-arktx, " Short text for sales order item
kwmeng TYPE vbap-kwmeng, " Order quantity
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
netwr TYPE vbak-netwr, " Net Value of the Sales Order
END OF ty_sales.
DATA :
gt_sales TYPE STANDARD TABLE OF ty_sales,
wa_sales TYPE ty_sales.
DATA: ob_select TYPE REF TO cl_rs_where.
DATA: ob_from TYPE REF TO cl_rs_where.
DATA: ob_where TYPE REF TO cl_rs_where,
gv_source TYPE abapsource.
START-OF-SELECTION.
*Step 1 : Prepare the select fields.
PERFORM zf_build_select.
*Step 2 : Build the from clause for the select
PERFORM zf_build_from.
*Step 3 : Build the where clause for the select
PERFORM zf_build_where.
*Step 4 : Execute the dynamic select
SELECT (ob_select->n_t_where)
FROM (ob_from->n_t_where)
INTO CORRESPONDING FIELDS OF TABLE gt_sales
WHERE (ob_where->n_t_where).
LOOP AT gt_sales INTO wa_sales.
WRITE : /5 wa_sales-vbeln,
15 wa_sales-vkorg,
20 wa_sales-kunnr,
40 wa_sales-netwr,
50 wa_sales-posnr,
60 wa_sales-matnr,
70 wa_sales-arktx,
90 wa_sales-kwmeng.
ENDLOOP.
*& Form zf_build_select
FORM zf_build_select .
CREATE OBJECT ob_select.
*Build the table name/field name combination
*Add Sales order header fields
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'VBELN'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'VKORG'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'KUNNR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'NETWR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
*Add Sales order item fields
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'POSNR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'MATNR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'ARKTX'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'KWMENG'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
ENDFORM. " zf_build_select
*& Form zf_build_from
FORM zf_build_from .
CREATE OBJECT ob_from.
*Add opening bracket
CALL METHOD ob_from->add_opening_bracket
CLEAR gv_source.
*Add the join condition.This can be made
*fully dynamic as per your requirement
gv_source = 'VBAK AS VBAK INNER JOIN VBAP AS VBAP'.
*Add the where line
CALL METHOD ob_from->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
*Add the join condition.This can be made
*fully dynamic as per your requirement
gv_source = 'ON VBAKVBELN = VBAPVBELN'.
*Add the where line
CALL METHOD ob_from->add_line
EXPORTING
i_line = gv_source.
*Add the closing bracket
CALL METHOD ob_from->add_closing_bracket
ENDFORM. " zf_build_from
*& Form zf_build_where
FORM zf_build_where .
DATA :
lv_field TYPE REF TO data,
lv_field_low TYPE REF TO data,
lv_field_high TYPE REF TO data.
CREATE OBJECT ob_where.
*Add the field VBELN : Sales Document
*Use this method if you want to assign a single value to a field
*Set the value for VBELN : Sales Document Number
CALL METHOD ob_where->add_field
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_operator = '='
i_intlen = 10
i_datatp = 'CHAR'
IMPORTING
e_r_field = lv_field.
CALL METHOD ob_where->set_value_for_field
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_value = '0000120020'.
*Use this method if you want to assign a range of values
*Set a range for the Sales Document number
CALL METHOD ob_where->add_field_between_2values
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_intlen = 10
i_datatp = 'CHAR'
IMPORTING
e_r_field_low = lv_field_low
e_r_field_high = lv_field_high.
CALL METHOD ob_where->set_2values_for_field
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_value_low = '0000120020'
i_value_high = '0000120067'.
*Set the 'AND' Clause
CALL METHOD ob_where->add_and.
*Add the field MATNR : Material
CALL METHOD ob_where->add_field
EXPORTING
i_fieldnm = 'MATNR'
i_operator = '='
i_intlen = 18
i_datatp = 'CHAR'
IMPORTING
e_r_field = lv_field.
*Set the value for the Material field
CALL METHOD ob_where->set_value_for_field
EXPORTING
i_fieldnm = 'MATNR'
i_value = '000000000050111000'.
*Set the 'AND' Clause
CALL METHOD ob_where->add_and
*Add the field VKORG
CALL METHOD ob_where->add_field
EXPORTING
i_fieldnm = 'VKORG'
i_operator = '='
i_intlen = 4
i_datatp = 'CHAR'
IMPORTING
e_r_field = lv_field.
*Set the value for VKORG : Sales Organization
CALL METHOD ob_where->set_value_for_field
EXPORTING
i_fieldnm = 'VKORG'
i_value = 'GMUS'.
ENDFORM. " zf_build_where -
How to use in clause with variable elements with a prepared statement?
Is there any way to use a prepared statement for a query which incorporates an in clause with unknown number of elements in the list?
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Iraj ():
Is there any way to use a prepared statement for a query which incorporates an in clause with unknown number of elements in the list?<HR></BLOCKQUOTE>
Sorry, can't be done. The PreparedStatement is precomplied, so you can't have variable number of params or unknown number of elements in a list. -
Using where clause with hardcode value in execute immediate
Dear Experts, I am using below in stored procedure getting exception,
EXECUTE IMMEDIATE 'DELETE FROM CC.TB WHERE COL='HG'';
where col is varchar2(30) in CC.TB
Please guide how can i use above statement in stored procedure
Thanks,DBA wrote:
Dear Experts, I am using below in stored procedure getting exception,
EXECUTE IMMEDIATE 'DELETE FROM CC.TB WHERE COL='HG'';
where col is varchar2(30) in CC.TB
Please guide how can i use above statement in stored procedure
Thanks,Why are you using Dynamic SQL? DELETE statement is a DML statement and its valid inside a PL/SQL block.
So you can remove the execute immediate and write your DELETE statement directly.
begin
delete from cc.tb where col = 'HG';
end; -
Hi all,
im trying to set a block default where clause in the pre-query trigger of my block "customer_settlement" , to query the records that exist in a customers table like this, where the customer_name is variable based on the value entered by the user in enter-query mode before hitting the F8 key , the statement is :
set_block_property( 'customer_settlement' , default_where ,
' fk_cust_code in ( select customer_code from customers where customer_name like %' || :customer_settlement.customer_name ||'% )' );
the query doesnt work and giving me an error " unable to perform query" , notice that :customer_settlement.customer_name is an item in the block , the user change it and would like to query upon it , and its not a base table item on customer_settlement block its on customers table only . I tried all combinations of '%' and || but it seems that oracle can't see the value In the customer_name field.
any help is highly thanked.
im using Oracle form 9.0.4 and Oracle 10g Db.
Regards,
IKQHi,
does this work ?
set_block_property( 'customer_settlement' , default_where ,
' fk_cust_code in ( select customer_code from customers where customer_name like '''%' || :customer_settlement.customer_name ||'%''' )' );
Frank -
Hello,
I am using sapnwrfc for perl to get few information about SAP system. To get the Applications pruning on SAP system i need to use two tables DF14AVD and DF14T to get Application Name and Description. table DF14T contains description of the application.
I want to know using QUERY_TABLE how i can combined it and get desired result.
For ex. FCTR_ID is present in both the table. FCTR_ID which are present in DF14AVD table, i want to retrieve short description from DF14T .
Any idea how i can do this?
AmitHi,
You can refer to the following link.
http://help.sap.com/erp2005_ehp_04/helpdata/EN/4b/38b618068911d295300000e8353423/frameset.htm
Thank You.
Regards,
Dhanalakshmi L -
How to use Substring function with Case statement.
Hello Everyone,
I have one requirement where I have to use substring function on the field for report criteria.
E.G.
I have Branch Name Field where I have all branch names information, Now some of the branch names are too big with some extension after the name .
now i want to substing it but the character length varies for each branch.
so is there any way where we can use case statement where we can define that if branch name character are exceeding some value then substing it with this length.Try something like this:
CASE WHEN LENGTH(tablename.Branch_Name) > n THEN SUBSTRING(...) ELSE tablename.Branch_Name END
where n is the number of characters you want to start the break. -
How to use where exists with a subquery
Hi,
Below is my query
select DISTINCT
-1,
vODS_GLBalance.PageNum,
vODS_GLBalance.FiscalYearId,
vODS_GLBalance.FiscalMonthOfYearId,
GLAmount
From ODS.Staging.vODS_GLBalance
where EXISTS
select *
From ODS.Common.tODS_Date
where dateid not in (-1,99991231)
AND convert(date,convert(varchar,FiscalYearId)+'-'+convert(varchar,FiscalMonthOfYearID)+'-01') between dateadd(month,-2,getdate()) and dateadd(month,-1,getdate())
Order BY FiscalYearId ASC,
FiscalMonthOfYearId ASC
My subquery inside the where exists just brings the date for current month,so i want to limit my whole data only for current month,but if i run the whole query it returns me all the data i have in my staging table.
Any suggestions please?
ThanksYou need to correlate the subquery with the outer query, like in this example:
SELECT *
FROM Customers C
WHERE EXISTS (SELECT *
FROM Orders O
WHERE C.CustomerID = O.CustomerID)
That is, show me all customers who have placed at least one order.
I can't give an example with your queries, because I don't know how they are structured.
Erland Sommarskog, SQL Server MVP, [email protected] -
Using where clause with cast multiset
version
oracle 10g
how to select values based on values in the object.
CREATE OR REPLACE TYPE init_queue AS OBJECT (
seq_num_q NUMBER,
source_system_name VARCHAR2 (50 BYTE),
milestone_id NUMBER,
milestone_date DATE,
downstream_order_number VARCHAR2 (175 BYTE),
leg_id VARCHAR2 (175 BYTE),
statuspro_captured_date DATE,
pon VARCHAR2 (26 BYTE),
milestone_source VARCHAR2 (26 BYTE),
session_id NUMBER,
reconfirmation_flag CHAR (1 BYTE),
vec_flag CHAR (1 BYTE)
CREATE OR REPLACE TYPE tab_init_queue AS TABLE OF init_queue;
SET serveroutput on;
DECLARE
v_list tab_init_queue := tab_init_queue ();
v_arr_sort tab_init_queue := tab_init_queue ();
BEGIN
SELECT init_queue (seq_num_q,
source_system_name,
milestone_id,
milestone_date,
downstream_order_number,
leg_id,
statuspro_captured_date,
pon,
milestone_source,
session_id,
reconfirmation_flag,
vec_flag
BULK COLLECT INTO v_list
FROM r_cust_status_init_queue;
SELECT CAST (MULTISET (SELECT *
FROM TABLE (v_list)
WHERE v_list.milestone_id = 11 -- * How to select values based on milestone.*
) AS tab_init_queue)
INTO v_arr_sort
FROM DUAL;
DBMS_OUTPUT.put_line (v_arr_sort.COUNT);
END;
/Edited by: new learner on Aug 23, 2010 7:35 PMnew learner wrote:
version
oracle 10g
how to select values based on values in the object.
CREATE OR REPLACE TYPE init_queue AS OBJECT (
seq_num_q NUMBER,
source_system_name VARCHAR2 (50 BYTE),
milestone_id NUMBER,
milestone_date DATE,
downstream_order_number VARCHAR2 (175 BYTE),
leg_id VARCHAR2 (175 BYTE),
statuspro_captured_date DATE,
pon VARCHAR2 (26 BYTE),
milestone_source VARCHAR2 (26 BYTE),
session_id NUMBER,
reconfirmation_flag CHAR (1 BYTE),
vec_flag CHAR (1 BYTE)
CREATE OR REPLACE TYPE tab_init_queue AS TABLE OF init_queue;
SET serveroutput on;
DECLARE
v_list tab_init_queue := tab_init_queue ();
v_arr_sort tab_init_queue := tab_init_queue ();
BEGIN
SELECT init_queue (seq_num_q,
source_system_name,
milestone_id,
milestone_date,
downstream_order_number,
leg_id,
statuspro_captured_date,
pon,
milestone_source,
session_id,
reconfirmation_flag,
vec_flag
BULK COLLECT INTO v_list
FROM r_cust_status_init_queue;
SELECT CAST (MULTISET (SELECT *
FROM TABLE (v_list)
WHERE v_list.milestone_id = 11 -- * How to select values based on milestone.*
) AS tab_init_queue)
INTO v_arr_sort
FROM DUAL;
DBMS_OUTPUT.put_line (v_arr_sort.COUNT);
END;
/Edited by: new learner on Aug 23, 2010 7:35 PMLike this.
DECLARE
v_list tab_init_queue := tab_init_queue ();
v_arr_sort tab_init_queue := tab_init_queue ();
BEGIN
v_list.extend;
v_list(v_list.count) := init_queue(1, '1', 11, sysdate, '1', '1', sysdate, '1', '1', 1, '1', '1');
8
SELECT CAST (MULTISET (SELECT *
FROM TABLE (v_list)
WHERE milestone_id = 11 -- * How to select values based on milestone.*
) AS tab_init_queue)
INTO v_arr_sort
FROM DUAL;
DBMS_OUTPUT.put_line (v_arr_sort.COUNT);
END;
1
PL/SQL procedure successfully completed.
ME_XE?ME_XE?
ME_XE?select * from v$version;
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
5 rows selected.
ME_XE?It would have been easier if you'd made a simple example so i didn't have to type out the example record (since your original code referenced a table you didn't provide DDL and INSERTS for).
Something to keep in mind for the future (the easier you make it for us, the more likely we are to help). -
How to use 'is null' in select statement of ABAP program
hi,
I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data.
SELECT * FROM mara INTO TABLE it_mara
WHERE volum IS NULL .
Can anyone resolve this.Hi PKB,
Check the below thread for NULL and Space value in ABAP . It will help you
NULL and Space value in ABAP
Regards,
Pawan -
How to use SET BIT and GET BIT in ABAP Programming
Hi,
Our team is currently working for an Upgrade project which is using a tool automatically upgrades when we supplly the code. fine, But now the requirement is , we need to write different test cases for the available key words in ABAP. Now we r looking for the usage of " BIT ", keyword. so , kindly provide any program or code using this key word.
Please find the description Provided and give some relative ABAP code to satisfy the given description.
The data object byte_string must be byte-type. The statement reads the bit at the bit position BITPOS of the variable byte_string and assigns its value to the variable val. A default mode can be specified if required *
Thanks & Regards,
P.N.Kumar.What on earth are you testing? That ABAP still works? I think SAP might have run that through rigourous testing themselves.
If you want sample code, why not read the ABAP help, and work some out for yourself?
matt -
Hii,
I have an issue with using where clause with time stamp. My requirement is to
select * from driver_on_policy
where last_change_datetime = '2001-03-06 19:00:06'
date is in this form 6/3/2001 7:00:06 PM
thnks
samIf you want to use '6/3/2001 7:00:06 PM', then
where last_change_datetime = to_timestamp('6/3/2001 7:00:06 PM','DD/MM/YYYY HH:MI:SS PM')If you can use a literal string in ANSI standard YYYY-MM-DD HH24:MI:SS format, then just
where last_change_datetime = timestamp '2001-03-06 19:00:06' (That 'DD/MM' might need to be switched around to 'MM/DD' if you are in America.)
Message was edited by:
William Robertson -
Using where condition with dynamic internal table
Hi Friends.
How to use where condition with dynamic internal table ?
Regards,
Amit RautHai Amit
REPORT ZDYNAMIC_SELECT .
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.
Thanks & Regards
Sreenivasulu P
Maybe you are looking for
-
Flash Player install app craches
Whenever I try to install Flash Player, the install application crashes. The HW is a mid-2013 MacBook Pro with all the latests software updates. Any hints?
-
Dear All, I have the following requirement and I am not able to find a solution. I have four jsp files called one.jsp, two.jsp, three.jsp, four.jsp. On clicking the submit button in one.jsp, the request goes to two.jsp. two.jsp will do some processin
-
Lookup tables columns as a measure?
Hi Everyone, I am using ver 11.1.1.1.5 I am working on the lookup tables. My lookup table is as below: Param1 Param2 Param3 target 123 A B 100 123 A <NULL> 90 123 <NULL> <NULL> 80 Param 1, 2 and 3 come from 3 different dimension tables. Based on the
-
How to download : Directory Server Resource Kit ???
following this instrustion, but i can't find the download link of DSRK: http://docs.sun.com/source/816-6400-10/install.html this link error?: http://wwws.sun.com/software/download/products/3eef9a29.html help me plz! thanks!
-
Printer Setup Utility not working and autostopping jobs for an HP
I have both an Epson Stylus R200 and an HP Photosmart 2570 series all-in-one. the epson prints fine, but the HP doesn't at all. it keeps stopping the jobs i send to the HP. The HP is also a scanner and i can do scans so i know its not a problem with