Open SQL , Selecting Values Problem
Hello,
I have a table like the following
Book ID Min Value
5705 10.00
5705 15.00
5705 22.00
5706 10.00
5706 50.00
If I have a value, such as 8.00, how can I use a single select to bring back just one record, in this case it would be the Minimum Value 10.00 only, ie it has to be less than or equal to the minimum value , and the lowest figure?
Thanks
hi ,
u can use following select query to get the Desired OUTPUT.
TABLES : DBTAB.
DATA: l_book_id,l_minvalue.
SELECT book_id minvalue INTO l_book_id l_minvalue FROM DBTAB WHERE minvalue = select min( minvalue ) from DBTAB.
ENDSELECT
Regards
vikas.
Similar Messages
-
Parsing an OPEN SQL select statement
Hi all,
I want to parse an open SQL select statement to get the list of tables and the corresponding fields in the select statement.
Is there some ABAP-internal syntax from the SAP Database Interface that does this? or is the only option to do this is to manually break the statement?
Thanks.
GirishHi,
I doubt if there is something like that available to use. It think you will have to write a parser for yourself.
Regards -
How do I concatenate 2 fields in an Open SQL Select
Hi,
I have an internal table (simplified) that looks like this:
BEGIN OF t_konv,
kwert_vprs TYPE kwert,
knumv_kposn type char16,
END OF t_konv.
From an Open SQL Select statement I need to put kwert into kwert and I need to combine knumv and kposn into knumv_kposn.
Here is my select, but I do not know how to specify the last 2 fields as being concatenated into kmunv_kposn in my internal table.
SELECT hkwert hknumv h~kposn
INTO TABLE it_konv
FROM konv AS h
FOR ALL ENTRIES IN it_bil_sal
WHERE h~knumv = it_bil_sal-knumv
AND h~kposn = it_bil_sal-posnr.
Any help is much appreciated!
Thx,
AndyRight now, concatenating them is my solution to some other issue, so yea, I'd like to make it work this way, if possible.
That's a thought...I could do as you try. It just sucks that I can't do it in the select...it's so simple in ANSI SQL:
Select fielda || fieldb from...
Thanks alot for your help, Rob.
Andy -
Adding columns in a open sql select query
Hi Everyone,
I would like to add the values of n columns of a table and place them in one column, how can i achieve this in open sql.
In oracle native sql the query will look like this:
Select col1 + col2 + col3 AS col
from tab1;
On a similar grounds, i would like to concatenate the contents of n columns into one column. The oracle native sql will look like this:
select col1 || col2 || col3
from tab1;
How can I do this in Open SQL.
Thanks in advance.
Prabhu.Hi Prabhu,
I'm afraid what you're trying to do is not possible using the Open SQL. You will have to get the data from all the three columns into an internal table and then write your own logic to accomplish the same.
data : begin of itab occurs 0,
col1 type i,
col2 type i,
col3 type i,
col4 type i,
end of itab.
field-symbols: <fs_itab> like line of itab.
SELECT COL1
COL2
COL3
INTO TABLE ITAB.
LOOP AT ITAB assigning <fs_itab>.
<fs_itab>-col4 = <fs_itab>-col1 + <fs_itab>-col2 + <fs_itab>-col3.
ENDLOOP.
Regards,
Anand Mandalika. -
hi friends,
i've a view called "risk_efforts" with fields user_id,user_name,wknd_dt,week_day,prod_efforts,unprod_efforts.
Name Type
ROW_ID NUMBER
USER_ID VARCHAR2(14)
USER_NAME VARCHAR2(50)
WKND_DT VARCHAR2(8)
WEEK_DAY VARCHAR2(250)
PROD_EFFORTS NUMBER
UNPROD_EFFORTS NUMBER
data is like this:
when there is some data in prod_efforts, unprod_efforts will be null
when there is some data in unprod_efforts, prod_efforts will be null
for example:
USER_ID USER_NAME WKND_DT WEEK_DAY PROD_EFFORTS UNPROD_EFFORTS
G666999 GTest 20100403 TUE null 3
G666999 GTest 20100403 TUE 14 null
now i want to combine these 2 rows into 1 row i.e o/p should be like this
USER_ID USER_NAME WKND_DT WEEK_DAY PROD_EFFORTS UNPROD_EFFORTS
G666999 GTest 20100403 TUE 14 3
i've tried all combinations but couldn't get the query. Please help me with the exact SQL select query.
thanks,
GirishWelcome to the forum.
First read this:
Urgency in online postings
Secondly, it's always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
You have provided #3 and #4. However with no usable form of sample data forum members will often not respond as quickly as they could if you provided #2.
I'm just wagering a guess here but what about this:SELECT ROW_ID
, USER_ID
, WKND_DT
, WEEK_DAY
, MAX(PROD_EFFORTS) AS PROD_EFFORTS
, MAX(UNPROD_EFFORTS) AS UNPROD_EFFORTS
FROM RISK_EFFORTS
GROUP BY ROW_ID
, USER_ID
, WKND_DT
, WEEK_DAY -
OPEN SQL (SELECT DATA)
Hi, everybody!
Recent i found a few code but i don't know this mean of code. fllows as.
SELECT BMATNR BWERKS E~MTARP AS MTART
CSPART DMAKTX
APPENDING CORRESPONDING FIELDS
OF TABLE LT_PMAT
FROM STPO AS A
INNER JOIN MAST AS B
ON BSTLNR = ASTLNR
INNER JOIN MARA AS C
ON CMATNR = BMATNR
INNER JOIN MARC AS E
ON EMATNR = BMATNR
AND EWERKS = BWERKS
LEFT OUTER JOIN MAKT AS D
ON DMATNR = BMATNR
AND D~SPRAS = C_E
FOR ALL ENTRIES IN LT_CMAT
WHERE A~STLTY EQ C_M "Material Bom
AND A~IDNRK EQ LT_CMAT-MATNR
AND B~WERKS IN R_WERKS
AND B~STLAN IN R_STLAN
AND B~STLAL IN R_STLAL
%_HINTS ORACLE
'LEADING(T_00) USE_NL(T_00 T_01 T_02 T_03 T_04)'.
look bold-face!
I don't know what is "%" and code of last-line !
Please help me!
Thanks Advanced!%_HINTS ORACLE means you are giving hints/instructions to oracle database, for the sole purpose of database optimization.
The DB optimizer follows certain rules to decided use of index, buffer etc. %_HINTS overrides it by giving specific instruction to oracle.
See OSS Note 129385 for furthur information on using %_HINTS -
How to get different field in two are more different table using open sql
Dear all,
This SenthilMani am very new into sap abap am having doubt in reports how get the different fields from different tables like mara,marc,mard using open sql and native sql program give me some tips to get the data .
with regards,
senthilHI ,
1) If u want to select data from more the two table then u can use FOR ALL ENTRIES.
EX ..Open sql
select matnr from mara into table t_mara.
select matnr werks from marc into table t_marc for all entries in t_mara where matnr = t_mara-matnr.
2) U can join more than one table.
ex:
select mara~matnr
marc~werks
from mara join marc into table t_maramarc
on maramatnr = marcmatnr
3) Using native sql ...only u can use JOIN statement -
Hi all,
some of our users are asking if it is possible to customise the Select Value screen when filtering characteristics.
In some cases they would prefer to have the History option as starting point, in other the Single Values.
Is there any possibility how to maintain this in general for a characteristic?
Is there any table where this is stored.
Could users change their starting point individually?
We are on Netweaver, SAP GUI patch 9, BEx patch 7.01.
Thanks
StefanHi Deepak,
required change is:
Open a query, Select Values for Variables popup appears, Choose the "Select from List" option to open the Select values dialogue box.
This box is opened as standard with History. I would like to know if there is the possibility to open it with Favorties or Single Values instead and if this can be customised for each user.
Br
Stefan -
SQL Open Sales Orders Value using today's currency rates
Hi experts,
I am creating a report for displaying the open sales order values (and other fields) using current currency rate (where applicable). I developed the below query. The only problem with this query is that it ignores the order rows in which the currency field is blank (Don't understand why this happens in SAP). Do you have other ideas?
Thanks & Regards,
IC
SELECT
T0.DocNum as 'Sales Ord No', T0.DocDate as "Ord Date", T0.CardCode as "Cust Code", T0.CardName as "Customer Name", T1.ItemCode,
T1.Dscription, T3.ItmsGrpNam, T1.U_SU, T1.U_SULEN, T1.U_SUQTY, T2.InvntryUom as 'Stock UOM', T1.Quantity as 'Ord Qty', T1.Quantity*T2.U_ITWTSTU as 'Weight (KG)', T1.Quantity-T1.OpenQty as "Qty Delivered", T1.OpenQty as 'Bal Qty', T1.Price*T1.Quantity/T4.Rate AS "Ord Value (GBP)", T1.Price*T1.OpenQty/T4.Rate AS "Open Qty Val (GBP)", T1.Price/T4.Rate AS "Price (GBP)", T1.Price*T1.OpenQty as "Ord Value (BP Currency)", T1.Price as 'Price (BP Curr)', T1.Currency as 'Cur Ind', T4.[Rate] AS 'Curr Rate', T0.DocDueDate as "Due Date", T1.WhsCode as 'Del WHG'
FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod, ORTT T4 WHERE T0.DocCur <> 'GBP' AND T1.Currency=T4.Currency AND T4.[RateDate] = [%0] AND T1.OpenQty > 0
UNION ALL
SELECT
T0.DocNum as 'Sales Ord No', T0.DocDate as "Ord Date", T0.CardCode as "Cust Code", T0.CardName as "Customer Name", T1.ItemCode, T1.Dscription, T3.ItmsGrpNam, T1.U_SU, T1.U_SULEN, T1.U_SUQTY, T2.InvntryUom as 'Stock UOM', T1.Quantity as 'Ord Qty', T1.Quantity*T2.U_ITWTSTU as 'Weight (KG)', T1.Quantity-T1.OpenQty as "Qty Delivered", T1.OpenQty as 'Bal Qty', T1.LineTotal AS "Ord Value (GBP)", T1.LineTotal/T1.Quantity*T1.OpenQty AS "Open Qty Val (GBP)", T1.LineTotal/T1.Quantity AS "Price (GBP)", T1.Price*T1.OpenQty as "Ord Value (BP Currency)",T1.Price as 'Price (BP Curr)', T1.Currency as 'Cur Ind', T1.[Rate] AS 'Curr Rate', T0.DocDueDate as "Due Date", T1.WhsCode as 'Del WHG'
FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod WHERE T0.DocCur = 'GBP' AND T1.OpenQty > 0 ORDER BY 2,1Hi,
Try:
SELECT
T0.DocNum as 'Sales Ord No', T0.DocDate as "Ord Date", T0.CardCode as "Cust Code", T0.CardName as "Customer Name",
T1.ItemCode, T1.Dscription, T3.ItmsGrpNam, T1.U_SU, T1.U_SULEN, T1.U_SUQTY, T2.InvntryUom as 'Stock UOM',
T1.Quantity as 'Ord Qty', T1.Quantity*T2.U_ITWTSTU as 'Weight (KG)', T1.Quantity-T1.OpenQty as "Qty Delivered",
T1.OpenQty as 'Bal Qty', T1.Price*T1.Quantity/T4.Rate AS "Ord Value (GBP)",
T1.Price*T1.OpenQty/T4.Rate AS "Open Qty Val (GBP)", T1.Price/T4.Rate AS "Price (GBP)",
T1.Price*T1.OpenQty as "Ord Value (BP Currency)", T1.Price as 'Price (BP Curr)',
T1.Currency as 'Cur Ind', T4.[Rate] AS 'Curr Rate', T0.DocDueDate as "Due Date", T1.WhsCode as 'Del WHG'
FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
LEFT JOIN ORTT T4 ON T1.Currency=T4.Currency AND T4.[RateDate] = [%0] AND T4.Rate != 0
WHERE T0.DocCur != 'GBP' AND AND T1.OpenQty > 0
Thanks,
Gordon -
How do I pass selected values from dynamic LOV to Command SQL in Oracle
My environment:
Crystal 11
Oracle 10
I've created and tuned a SQL script for a report. In the Database Expert, I've copied the SQL into a Command. I've modified the Command to create 3 parameters.
I need help with the following:
1) How do I create a dynamic, cascading LOV and associated prompt group for the three parameters defined in the Command?
2) How do I pass the user selected valueS from the prompt group into the Command SQL as limits applied to the query executed against the database?I have the same problem with same environment .
The main report is having a 2 level cascading dynamic parameters.
I created a sub report with a command as below.
*select * from (*
select DATUM,MSEC,CNT,B1_NAME,B2_NAME,B3_NAME,ELEM_NAME,INFO_NAME,m.INFOTYPE,V.NAME,rank()
over (partition by B1_NAME,B2_NAME,B3_NAME order by DATUM desc ,MSEC desc,CNT desc) currentRank
from MESSAGES m,INTYDE i,VANAME v
where DATUM <=SYSDATE and trim(B1_NAME)='{?B1Name}'
and trim(B2_NAME)='{?B2Name}'
and m.INFOTYPE=i.INFOTYPE
and i.VALUE_NAME_NUMBER = v.VALNUM) where currentRank=1
I needs to pass cmbination of B1Name and B2Name from main report. I created a formula like
formula=Join({?B1Name},{?B2Name}),'|'); But this is showing some error.
and How I will substitute this in my command . As I new to Crystal XI help expected. -
F-32 : Problem with Open Item selection
Hi,
We have a strange problem with open Item selection for customer clearing in t-code F-32
In My QA system
if I input spl GL indicator ="*" and uncheck Normal OI tick,
the system selects all open items,
(those with spl GL indicator and those without spl GL indicator)
In My Dev system
If I input spl GL indicator ="*" and uncheck Normal OI tick
the system does not select any open items,
Please let me know which setting controls this behaviour ?
Regards
SachinHello,
Check your data in FBL5N for the option "Special GL Transactions". There could be that there is no data in the system with SPECIAL GL TRANSACTIONS.
In F-32, there is no value like *
You need to input right Special GL Indicator. "*" will not work here.
I am sure in both the systems if you put "*" and UNTICK your normal transaction, you will NOT get any items to clear.
Please DOUBLE CHECK whether you have unticked normal transaction.
Regards,
Ravi -
Problems getting selected values from HtmlSelectManyCheckbox
Hello,
I am having problems getting values via getSelectedValues() from my HtmlSelectManyCheckbox component. The method returns an object array but the values are the same as the initial selectItems property.
JSP:
<h:selectManyCheckbox id="checkBox"
binding="#{userEditBean.manyCheckbox}"
value="#{userEditBean.groupIds}"
layout="pageDirection">
<f:selectItems value="#{userEditBean.allGroups}"/>
</h:selectManyCheckbox>
<h:commandButton action="#{userEditBean.ok}" value="OK"/>Bean:
public class UserEditBean extends BaseBean {
private HtmlSelectManyCheckbox manyCheckbox = new HtmlSelectManyCheckbox();
private String[] groupIds= {};
private List allGroups = new ArrayList();
public String[] getGroupIds() {
groupIds= backing.getSomeIds();
return groupIds;
public void setGroupIds(String[] ids) {
this.groupIds= ids;
public HtmlSelectManyCheckbox getManyCheckbox() {
return manyCheckbox;
public void setManyCheckbox(HtmlSelectManyCheckbox newC) {
this.manyCheckbox = newC;
public List getAllGroups() {
allGroups = backing.getAllGroups();
return allGroups;
public void setAllGroups(List newList) {
this.allGroups = newList;
public String ok() {
Object o = manyCheckbox.getSelectedValues();
}The problem is, the getSelectedValues() returns the values from the initial state of the page. The is no mark of the changes made by the user. Any help will be appreciated
Thanks,
MatekYour approach is somewhat odd. The selected values are just reflected in the groupIds, but you're overridding it with backing.getSomeIds() each time when the getter is called.
Here is a basic working example:<h:selectManyCheckbox value="#{myBean.selectedItems}">
<f:selectItems value="#{myBean.selectItems}"/>
</h:selectManyCheckbox>
<h:commandButton value="submit" action="#{myBean.action}" />MyBeanprivate List<String> selectedItems;
private List<SelectItem> selectItems;
// + getters + setters
// You can use initialization block or constructor to prepopulate the selectItems.
selectItems = new ArrayList<SelectItem>();
//or
public MyBean() {
selectItems = new ArrayList<SelectItem>();
public void action() {
// The selected items are reflected in selectedItems.
for (String selectedItem : selectedItems) {
System.out.println(selectedItem);
} -
Passing multiple select value from BI publisher to PL/SQL functions
Hi - I have designed a report which pass parameters (Multi select) into a function to get the output result. When a single parameter value is passed to the function, report is being displayed. When multi select value is passed to the function it is returning the error `wrong number or types of arguments in call to 'F_PROCESS_WAVE_DATA'. When i checked the parameters passed to the function, i can see each multi select value is treated as different value and is assigned to different parameter in the function.
Any help on passing the multi select parameter into function will be helpful.
Regards,
Vikram.All - Issue was resolved. I followed the following steps to resolve the issue
1. Create a PL/SQL table type variable as VARCHAR2 in the database - Say as Larray
2. Create PL/SQL type record and table for the record in database. Lrec, Ltable
3. In BI report pass multiple select LOV variable as Larray(variable).
4. In DB function, Parameter should be defined as LARRAY.
5. Return PL/SQL table type Ltable from the function.
Regards,
Vikram. -
Problem while setting the selected value of h:selectOneMenu to bean
Hi all,
I am new to JSF. I am working on application where i have combo boxe on the page. I am setting some values to the combobox from database using <f:selectItems> tag and one value using <f:selectItem> tag. The value combobox value selected by user is set to the bean property which is String. I am able to display all the values in the combobox but when clicked on button (present at the end of form) i am getting following error-
ERROR HtmlRendererUtils:354 - Error finding Converter for
component with id interviewStageOneForm:acceptanceChannelList
I am setting the combobox selected value to the to the bean property which is String and the value selected in also String. Then which converter it is asking for. I am not able to find out what is the problem.
Your suggestions will be really appreciated.
Here is my code snippet:-
JSF:-
<h:selectOneMenu id="acceptanceChannelList"
value="#{interviewStageOneBean.index}">
<f:selectItem itemValue="Select" itemLabel="#{Message.combo_select}" />
<f:selectItems value="#{MasterDataBean.acceptanceChannelList}" /> <!-- The list coming from database-->
</h:selectOneMenu>Bean:-
public class InterviewStageOneBean {
private String index;
public String getIndex() {
return index;
public void setIndex(String index) {
this.index = index;
}Hi!
First I would try next:
Try to leave out
<f:selectItem itemValue="Select" itemLabel="#{Message.combo_select}" />
line. And check if it works after that. If it didn't repeat step but you leave in message selectItem and dump out database selectItem line.
Second:
I would check acceptanceChannelList creation and what type of objects you put while doing setValue and setLabel on UISelectItem
Probably selectItem value has been assigned an object of type the engine doesn't know how to convert from String to it. -
How to exit from SQL*Plus based on the return value of a SQL select stment?
Hi
I have a SQL script executed from SQL*Plus. I would like to know if SQL*Plus
supports any kind of branching or exiting from script execution based on a
returned value of a SQL select statement. I am on 9i.
Regards,
Tamas Szecsyin sqlplus, you have whenever
ex:
whenever sqlerror exit failure
insert into ...
-- if this fails, then you will be out
insert into ...
-- if this fails, then you will be out
whenever sqlerror continue
insert into ...
-- if this fails, this continues
insert into ...and you have PL/SQL
declare x number;
begin
select count(*) into x from emp;
if (x=14) then null; end if;
end;
/note that you can mix those in some case
-- exit if there is no row in emp
whenever sqlerror exit 1
var dummy number
exec select count(*) into :dummy from emp having count(*)!=0
Maybe you are looking for
-
How to convert character streams to byte streams?
Hi, I know InputStreamReader can convert byte streams to character streams? But how to convert the character streams back to byte streams? Is there a Java class for that? Thanks in advance.
-
How can I find a client's IP Address who accesses my applet. I have a method as follows but I always get 127.0.0.1 private String getHostIP() String address; String tmp = ""; try InetAddress thisIp = InetAddress
-
HT5295 Does anyone know how to rate a podcast on this new podcast app?
Surely Apple must have included this feature in the new app.... This is how I track whether or not I want to delete a podcast. This is stupid.
-
I've been trying for some time. It seems to install fine until it reaches 95 percent finished. Then, it freezes up and nothing else happens. I've tried deleting all the old files under Adobe Flash and re-installing the latest version for mac. Not
-
Windows 7 DVD Maker "Error Synchronizing Project"
I installed Windows 7 RC 7100 on a new hard disk and did not install any other software. I tried to create a DVD-Video by inserting JPG images, AVI files and some MP3 files as slide background music. I was not able to Preview the movie and when I tri