Regarding dynamically assigning the where clause to select query
hi,
Please send the code regarding how to dynamically assign the where clause to select query.
thanks in advance
SELECT <fileds>
INTO TABLE itab
FROM dbase
WHERE condition.
Similar Messages
-
Pass values dynamically to the WHERE clause in SFAPI
Hi there
We have a requirement to pass values dynamically (in the run-time of the interface) to the WHERE condition to our SFAPI query.
Eg -
SELECT person, personal_information, address_information, phone_information, email_information, employment_information, job_information, compensation_information, paycompensation_recurring, paycompensation_non_recurring, job_relation, accompanying_dependent, global_assignment_information, direct_deposit, national_id_card, person_relation
FROM CompoundEmployee
WHERE last_modified_on >= to_date('LAST_RUN_DATE') AND
last_modified_on <= to_date('CURRENT_RUN_TIME')
LAST_RUN_DATE is stored in a custom entity for which we execute another OData query. The custom entity is updated with the CURRENT_RUN_TIME once the interface has been executed successfully. So the next time the interface is run it picks up the LAST_RUN_DATE from the custom OData entity.
SAP PO has the functionality to run a dynamic query for OData adapters. Refer to Note 2051137 - PI Successfactors adapter : Dynamic odata query and single synchronous sfapi query
Eg - select fields from position (this is what you state in OData query path in the comms channel; this is static); and you have an advanced tab in comms channel where you mention dynamicquery and set it to true (this points to a XSD which has the keyword TOP, SKIP & FILTER in it).
This gets the filter values passed from the BPM from another query (from a OData cust_table).
So the whole query is - select fields from position filter field a = x field b = y etc. Field a field b are fields in position that are you passing values x and y in run time of the interface.
SAP PO also has the advanced tab feature for SFAPI for dynamic query.
Question is -
how to use it?
has anyone implemented this before?
What does XSD will look like?
How do we pass values to the fields to the Where clause for SFAPI.
Any ideas are welcome!
Regards
Arijit DasAfter you have added a new where clause on the detail VO, try re-executing VO's query by DetailVO.executeQuery()
If it doesn't work try re-executing the MasterVO's query after you have added the where clause on the detail -
How to dynamically add field name in where clause of select query in web dynpro?
Hello,
Can any body tell me how i can use select query with dynamic wheere condition.
i have a requirement like there are multiple input fields and i want to select data from two database
and condition may vary .Hi
In the where clause you need to write like
WHERE NAME LIKE 'DE%'
Regards
Sudheer -
JSP, DataWebBean: How to dynamically set the where clause of query and display record
Hi,
I am reposting this question as per suggestions made by Mr. Dwight.
I have used ViewCurrentRecord web bean to display records from EMP table. I have to use the Dept_Id_FK from the current
record of the EMP table to display corresponding records of Dept table. I have a view object called DeptView in my Business
Components which selects all the records from the Dept table.
How do I get the value of Dept_Id_FK and use it to display the required records of the Dept table?
I tried to declare a variable and get the value of Dept_Id_FK but it did not work. My code is as follows:
<%! String m_DeptId = null; %>
<jsp:useBean id="RowViewer" class="oracle.jbo.html.databeans.ViewCurrentRecord" scope="request">
<%
RowViewer.initialize(pageContext, "EMPApp_EMP_EMPAppModule.EMPView1");
RowViewer.setReleaseApplicationResources(false);
RowViewer.getRowSet().next();
m_DeptId = (String)RowViewer.getRowSet().getCurrentRow().getAttribute("DeptIdFk");
%>
</jsp:useBean>
Thanks.
nullFirst of all, Thank you very much for making use of the new topic format. It is very much appreciated.
As for your question, I think there are several different ways to accomplish what I think you want to do.
1. Create a view object that includes both Emp and Dept entities and join them there. In this case, your query would look something like this:
Select e.empno,e.name,...,d.dname,d.loc from emp e, dept d
where e.deptno = d.deptno
You should be able to create a JSP off of this view object that contains both the employee and department information. In this case, BC4J takes care of the foreign key to primary key coordination.
2. In order to set a dynamic where clause for a view, you need to do the following in your usebean tag:
rsn.initialize(application,session, request,response,out,"DeptView");
rsn.getRowSet().getViewObject().setWhereClause("deptno=" | | m_DeptId);
rsn.getRowSet().getViewObject().executeQuery();
rsn.getRowSet().first();
You will need to do this in a separate usebean tag from the EmpView, since the usebean can only initialize one view object.
In other words, you would have your ViewCurrentRecord bean tag for the EmpView, then a separate one for the DeptView where you use the above code to set the where clause to display just the information for the department you want.
Another option, but one I'm not sure would work as well, is to create a master-detail JSP to do this for you. Usually a master-detail is a one-to-many (one department to many employees). Your request appears to be the reverse, but might still be doable using the same mechanism.
You set up relationships between views in your BC4J project using View Links. If you used the BC4J project wizard and created default views, some of these links may have been created for you. They are created when BC4J detects a foreign key to primary key relationship in the database.
You can create your own View Links using the View Link wizard. Select your BC4J project node and choose Create View Link... from the context menu. You will be asked to select a source view (Emp), and a target view (Dept), then select the attribute in each view that related the two of them (deptno).
Next, you need to reflect this new relationship setting in your application module. Select your app module and choose Edit from the context menu. On the data model page, select the EmpView node in the Selected list. Now select the DeptView node in the available list and shuttle it over. You should see DeptView1 via yourlink appear indented under the EmpView node. Save and rebuild your BC4J project to reflect the changes.
In your JSP project, you can now have the wizard create a master-detail form for you based on DeptView1.
Let me know if the above answers your question, or if I have misunderstood what it is you wanted to do.
null -
Dynamically changing the WHERE clause in detail VO in Master Detail
Hi, I want to develop a search functionality, results will be in a table, which will have an inline table displaying the details per row found.
I have a MD defined trough viewlink. I do change the master VO at runtime (set the entire SQL), based on the criteria entered by the user.
Is there a way to change the VO at the detail end of the link at runtime - that is what I haven't been able to do.
I have read that the ADF framework creates internal VO for each master row, whenever accessed trough accessor (which is not I am trying to do). I haven't been able to find a way to get a hold of the REAL VO at the detail end and have its WHERE clause changed.
Changes to the "VO instance in AM" (same one used as a definition in the detail end in the ViewLink def) does not seem to reflect the detail VO.
I have a MasterView, DetailView, MasterDetailLink (MasterView->DetailView).
MasterDetailLink is used to create a table with inline detail table. At runtime:
1.get MasterView (from AM), change query trough setQuesry() - works.
2.get DetailView (from AM), change query trough addWhereClause() - does not work (no exceptions) - the results I am getting DO NOT reflect the conditions of the where clause, I mean the clause have not been addedd.
I 've looked at the logs (debug enabled) and it seems to me that there no "activities" related to the detail VO, even after the where clause of the VO from step 2 is changed.
Looks like there is a separate VO which I would like to get a hold of :)
Thanks, and sorry for the long explanationAfter you have added a new where clause on the detail VO, try re-executing VO's query by DetailVO.executeQuery()
If it doesn't work try re-executing the MasterVO's query after you have added the where clause on the detail -
How to use string operation in where clause of select query
Hello All,
I just want to know how can i write a restriction in select query saying retrive data only begins with name "DE*".
Explaination: If my table has records and names starts with character then i want to write a query to fetch all the records in which names starts with DE*.
Thanks in advance for your quick reply...
Dev.Hi
In the where clause you need to write like
WHERE NAME LIKE 'DE%'
Regards
Sudheer -
Dynamic where clause in select query
Hi
I'm trying for a dynamic query and in the dynamic where clause i'm checking a field for constant.....for instance if i wanna to use WERKS EQ '0478' how to declare it in dync where clause. i tried for the following:
SELECT (TAB_FIELD) INTO TABLE DITAB UP TO 10 ROWS FROM (TAB_NAME) WHERE (CONDI).
heree CONDI = 'werks eq 0287' . in this case the query fails as the werks shud be equal to '0287' and not just 0287. How to handle this? i tried for the following
CONDI = 'werks eq " '0287' " ' but no luck as it is not a valid stmt as i knew.hi prabhu,
this is how u select dynamically...
DATA: COND(72) TYPE C,
ITAB LIKE TABLE OF COND.
PARAMETERS: CITY1(10) TYPE C, CITY2(10) TYPE C.
DATA WA TYPE SPFLI-CITYFROM.
CONCATENATE 'CITYFROM = ''' CITY1 '''' INTO COND.
APPEND COND TO ITAB.
CONCATENATE 'OR CITYFROM = ''' CITY2 '''' INTO COND.
APPEND COND TO ITAB.
CONCATENATE 'OR CITYFROM = ''' 'BERLIN' '''' INTO COND.
APPEND COND TO ITAB.
LOOP AT ITAB INTO COND.
WRITE COND.
ENDLOOP.
SKIP.
SELECT CITYFROM
INTO WA
FROM SPFLI
WHERE (ITAB).
WRITE / WA.
ENDSELECT.
regards,
sohi -
VPD - How to make the where clause a correlated query
Hi,
My VPD function has the following where clause:
where_clause:= ' project_id in (select object_id from pa_project_classes p'||
' where p.class_category='||''''||l_cat||''''||
' and p.CLASS_CODE='||''''||l_class||''''||
' and p.OBJECT_TYPE=''PA_PROJECTS'''||
The problem is that the subquery is not using the unique key defined on the table pa_project_classes. What I need is something as follows:
where_clause:= ' project_id in (select object_id from pa_project_classes p'||
' where p.class_category='||''''||l_cat||''''||
' and p.CLASS_CODE='||''''||l_class||''''||
' and p.OBJECT_TYPE=''PA_PROJECTS'''||
' and p.object_id=mainquery.project_id ||
The problem is that since the table pa_project_classes also has a column project_id, I have to prefix the column name by the alias of the main query like 'mainquery.project_id'. However this seems impossible as main query is not unknown .
I would be grateful if you could suggest any workaround or solution.
ThanksJust have a look over these two statements if it solves your problem
one time where clause
Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
dynamic where clause
set_block_property('BLOCK_NAME'default_where, your form itme)
you can where clause at run time from any procedure or some triggers -
URGENT: To change the where condition in select query at runtime ?
Hi,
I have to develop a report, 4 which I have created a selection screen with 7 Input Parameters whose value is to be filled by the user while executing the report.
On the basis of this I do the desired selection of output.
But the problem is that how do I write my select Query(where condition) if the user enetrs only 2 Input parameters or 3 or whatever he feels like.
Pls help me out...hi,
check this sample code.
Here i am populating where condition at runtime.
DATA: V_WHERE TYPE STRING.
SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN,
S_ERDAT FOR VBAK-ERDAT.
SELECTION-SCREEN END OF BLOCK INPUT.
START-OF-SELECTION.
PERFORM POPULATE_WHERE.
PERFORM GET_VBAK_DATA.
*& Form POPULATE_WHERE
* Populate Where
FORM POPULATE_WHERE .
IF NOT S_ERDAT[] IS INITIAL.
CONCATENATE 'VBELN IN S_VBELN'
'AND'
'ERDAT IN S_ERDAT'
INTO V_WHERE
SEPARATED BY SPACE.
ELSE.
V_WHERE = 'VBELN IN S_VBELN'.
ENDIF.
ENDFORM. " POPULATE_WHERE
*& Form GET_VBAK_DATA
* GET VBAK DATA
FORM GET_VBAK_DATA .
SELECT VBELN
ERDAT
VBTYP
NETWR
WAERK
VKORG
VTWEG
SPART
INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
FROM VBAK
WHERE VBELN IN S_VBELN
AND ERDAT IN S_ERDAT.
WHERE (V_WHERE).
endform.
Regards
Sailaja. -
How to formulate where clause in select query at runtime..??
I am facing a problem..
I have to generate a select query during runtime..For Ex: when user selects a row in an alv report, particular date field is to be read and another report is to be opened for that data..
I know how to make drill down report but my problem is concatenating date field...
Plz tell a solution....Hi,
Try like this....
refresh : gt_tvarvc_temp[].
gt_tvarvc_temp[] = lt_tvarvc[].
loop at gt_tvarvc_temp into gs_tvarvc_temp
where name = 'CREDIT_MEMO_DOC_TYPE'.
r_blart-sign = gs_tvarvc_temp-sign.
r_blart-option = gs_tvarvc_temp-opti.
r_blart-low = gs_tvarvc_temp-low.
append r_blart.
clear r_blart.
endloop.
concatenate 'BLART IN ' 'r_blart' into lv_condition
separated by space.
if not lv_customer_cond is initial.
if lv_condition is initial.
concatenate lv_customer_cond lv_condition
into lv_condition separated by space.
else.
concatenate lv_condition 'AND' lv_customer_cond
into lv_condition separated by space.
endif.
endif.
select bukrs belnr gjahr appending corresponding fields
of table lt_potential_credits
from bsid
where (lv_condition).
Hope its helps -
Hi Experts,
I want to fetch data from PAYR table where ZALDT date falls in the date range(s_date) or VOIDD date falls in the date range.
Which one is correct?
SELECT ZBUKR
CHECT
ZALDT
VOIDD
into table T_PAYR
from PAYR
where CHECT in s_chect
and ZALDT in s_date
or VOIDD in s_date.
OR
SELECT ZBUKR
CHECT
ZALDT
VOIDD
into table T_PAYR
from PAYR
where CHECT in s_chect
and ( ZALDT in s_date or VOIDD in s_date ).
Regards,
Sangeeta.hi,
Second one is correct
Issue resolved,please close the thread.
Thnks
Sahil -
What value we need to pass as parameter in where clause in select query
Hi ALL,
I have written following query, it was executing fine and returning me all the rows with search criteria.
SELECT *
FROM
PRTY_RQST PR
JOIN BUSN_APPLC BIAP ON BIAP.BUSN_APPLC_ID = PR.BUSN_APPLC_ID
JOIN INTN_STATS INSTS ON INSTS.INTN_STATS_ID = PR.INTN_STATS_ID
JOIN INTN_PROCES_TYP INTPTY ON INTPTY.INTN_PROCES_TYP_ID = PR.INTN_PROCES_TYP_ID
LEFT JOIN RQST_TYP RQSTYP ON RQSTYP.RQST_TYP_ID = PR.RQST_TYP_ID
JOIN ADDTN_RQST_INFO ADTINF ON PR.PRTY_RQST_ID = ADTINF.PRTY_RQST_ID
JOIN ADDTN_INFO_KEY_TYP ADDKEY ON ADTINF.ADDTN_INFO_KEY_TYP_ID = ADDKEY.ADDTN_INFO_KEY_TYP_ID
JOIN PRTY_KEY PRTKEY ON PR.PRTY_RQST_ID = PRTKEY.PRTY_RQST_ID
JOIN PRTY_KEY_TYP PRKYTP ON PRTKEY.PRTY_KEY_TYP_ID = PRKYTP.PRTY_KEY_TYP_ID
WHERE (BIAP.BUSN_APPLC_NM = 'bpel')
AND (INTPTY.INTN_PROCES_TYP_NM = 'FulfillmentOrder')
AND (PR.UPDT_BY = 'update3')
AND (INSTS.INTN_STATS_NM = 'Submitted')
AND (PR.CHLD_RQST_IND = 'N')
AND (PR.TRACK_RQST_IND = 'Y')
AND (RQSTYP.RQST_TYP_NM = 'PensionPortfolioRebalance')
AND (RQSTYP.RQST_CLASS_NM = 'Composite')
AND (PRKYTP.PRTY_KEY_TYP_NM = 'NPIN')
AND (PRTKEY.PRTY_TYP_VAL = '101101' )
AND (ADDKEY.ADDTN_INFO_KEY_TYP_NM = 'PlanNumber')
AND (ADTINF.ADDTN_RQST_TYP_VALUE = 'TBMBUpdated');
My question here is i don't want pass the value for BIAP.BUSN_APPLC_NM, still want to get the values for remaing conditions. what value i need to pass here.
I tried Null it giving me no rows. can some one help me on this.
Thank you in advance.
Vijay933325 wrote:
thank you,
since it is search criteria. I have to use OR instead of AND. this resolved my problem.
SELECT *
FROM
PRTY_RQST PR
JOIN BUSN_APPLC BIAP ON BIAP.BUSN_APPLC_ID = PR.BUSN_APPLC_ID
JOIN INTN_STATS INSTS ON INSTS.INTN_STATS_ID = PR.INTN_STATS_ID
JOIN INTN_PROCES_TYP INTPTY ON INTPTY.INTN_PROCES_TYP_ID = PR.INTN_PROCES_TYP_ID
LEFT JOIN RQST_TYP RQSTYP ON RQSTYP.RQST_TYP_ID = PR.RQST_TYP_ID
JOIN ADDTN_RQST_INFO ADTINF ON PR.PRTY_RQST_ID = ADTINF.PRTY_RQST_ID
JOIN ADDTN_INFO_KEY_TYP ADDKEY ON ADTINF.ADDTN_INFO_KEY_TYP_ID = ADDKEY.ADDTN_INFO_KEY_TYP_ID
JOIN PRTY_KEY PRTKEY ON PR.PRTY_RQST_ID = PRTKEY.PRTY_RQST_ID
JOIN PRTY_KEY_TYP PRKYTP ON PRTKEY.PRTY_KEY_TYP_ID = PRKYTP.PRTY_KEY_TYP_ID
WHERE (BIAP.BUSN_APPLC_NM = null )
OR (INTPTY.INTN_PROCES_TYP_NM = 'FulfillmentOrder')
OR (PR.UPDT_BY = 'update3')
OR (INSTS.INTN_STATS_NM = 'Submitted')
OR (PR.CHLD_RQST_IND = 'N')
OR (PR.TRACK_RQST_IND = 'Y')
OR (RQSTYP.RQST_TYP_NM = 'PensionPortfolioRebalance')
OR (RQSTYP.RQST_CLASS_NM = 'Composite')
OR (PRKYTP.PRTY_KEY_TYP_NM = 'NPIN')
OR (PRTKEY.PRTY_TYP_VAL = '101101' )
OR (ADDKEY.ADDTN_INFO_KEY_TYP_NM = 'PlanNumber')
OR (ADTINF.ADDTN_RQST_TYP_VALUE = 'TBMBUpdated');
AND (ADTINF.ADDTN_RQST_TYP_VAL_DT ='06-JUN-12 04.18.56.000000000 PM')
AND (ADTINF.ADDTN_RQST_TYP_VAL_NUM ='123123') ;
once again thank you all.But that's a completely different query than what was in the original post -
How to edit the where clause of View object in search example dynamically
Hi,
I am new to OA Framework. Can anybody please tell me how can I assign the where clause dynamically. I want to search only those rows whose creation date is between a 'Date form' and 'Date to' inputs from the search page
Thanks
Anupamuser567342 ,
I will advice u again pls refer dev guide, there u can find code sample for ur requirement, which can be accomplished using stringbuffer.
--Mukul -
WHERE clause in SELECT statement
hi experts..
i want to give 'OR' condition in the 'where' clause of 'SELECT' statement.
is it possible?
for examlpe..
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
VHILM = PC1 OR PC2 OR PC3.
ENDIF.
i want that VHILM should be one of those three.
how can i do this?
thanks..Hi ,
its possible,
Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
AND vhilm = pc1
OR vhilm = pc2
OR vhilm = pc3.
OR
Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
AND (vhilm = pc1 or vhilm = pc2 or vhilm = pc3).
Regards
Arani Bhaskar
Edited by: arani bhaskar on Mar 16, 2009 5:14 PM -
Case or Decode in the Where clause
Dear all,
My requirement is:
If user select other then "ALL"option from the LOV the following condition should be part of the where clause.
current_req_status = :block1.req_statusIf user select "ALL" from the lov no need to append the above condition in the where clause.
Please give me the sample code
select request_id,doc_name,doc_code,part_id,current_req_status from test_table
where req_type = 'I'
and doc_code = :BLOCK1.doc_code
and -- Here is the condition is changed based on
the :BLOCK1.req_status(LOV).
-- If user select other then "All" option from
this LOV the query append the below condition
current_req_status = :block1.req_status
-- Else no need append the above condition
in the query where clause.Edited by: roots on Apr 10, 2012 9:31 AM
Edited by: roots on Apr 10, 2012 9:38 AMHi InoL,
In the database column not having "ALL" value inside. so the match does not return any values.
My LOV has "A1,A2,A3,A4,....ALL" . the database column having "A1,A2,A3,A4.......". here no "ALL" value.
So if user select "ALL" option from this LOV, that means select all vaules from the database (A1,A2,A3,A4......)..
If user select A1 from the lov the select query include only the matched
column values.from example,
select....
where nvl(database_column,'X')= nvl(:Block1.LOV_value)If user select "ALL" option then no need for above condition in the where clause so that query returns all the rows from the database column.
hope I've clearly explain my requirement.
Thanks lot,
Roots.
Maybe you are looking for
-
IIResourceFactory, IUser etc. can't be resolved in EJB???
Hi, i have a EJB and want to create a new folder in my KM-Content by runtime. The problem is that the piece of code which i have to use can't be resolved in my EJB. Which libraries or variables should i have to insert into my project folder? IUs
-
Motion 4 and Ridiculous Crashes
I've been using Motion 4 for a few months now, and while I've experienced periods of repeated crashes -- which I've come to expect with Motion-- I'm seeing something new today: I open a simple Motion project. I simply select a layer. Motion crashes.
-
Transport protocol and authentication method
Hi gurus, i am trying to configure EBP-SUS, i am not having access to solution manager . I am working on SRM_SERVER 5.5. can somebody who has configured EBP-SUS give me more information about the transport protocol and the authenticaton method.
-
Create a ready to use image for SharePoint 2013 development environment.
Hi I have a requirement in which we are required to have an Image of the whole SharePoint 2013 environment, (ideally single server installation/standalone as I believe multi-tier would not be possible, or if possible suggest on that also), with all
-
How to import selected images from iPhoto 11 into Elements 9?
How do I import selected images or events from iPhoto 11 into albums in Elements 9 Organizer? I don't want all my thousands of images in Elements. Both iPhoto and Elements 9 are updated.