How to use SET ID in select statement of SQ02
Hi,
I have a infoset, where for one of my Zfield, i have writen a select statement in order to get my ouput.
if aufk-aufnr = 'XYZ'.
select sum( FKBTR ) from fmifiit into zfmifiit
where fikrs = aufk-kokrs
and fipex IN capex
and wrttp NE '51'.
endif.
For the above statement, i have created (with 10 single values, table name FMCI, field name FIPEX) a SET id named CAPEX and used with IN operator.
But when i generating the infoset i am getting error like below
The IN operator with "CAPEX" is followed neither by an internal table nor by a value list
I was using IN opeartor for set ids during validation / substitutions, where if i have to validate multiple single values.
What to do here?
Regards,
Srinu
[OPEN-SQL|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_GENERAL.htm] set of statement, [SELECT|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] statement, [WHERE|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP.htm] addition requires a selection table (type range, [WHERE - IN seltab |http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_SELTAB.htm]) of parameter and not a set. We are in Abap here, not in a Customizing screen
You have to convert the set to a selection table in an ABAP coding before using it in a SELECT statement.
(Check FM like G_SET_TREE_IMPORT to import definition of set (values and intervals) and map them to a select-table, or ask a developper to perform it, look at G_SET_TREE_IMPORT -> select statement)
Regards,
Raymond
Similar Messages
-
Delete adjacent duplicates how to use in the below select statement
hi i have a problem
i am suing the below select statement
SELECT a~extno
a~guid_lclic " for next select
e~ctsim
e~ctsex
*revised spec 3rd
f~guid_pobj
f~amnt_flt
f~amcur
f~guid_mobj
e~srvll "pk
e~ctsty "PK
e~lgreg "PK
INTO TABLE gt_sagmeld
FROM /SAPSLL/LCLIC as a
INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
inner join /sapsll/legcon as f on fguid_lclic = aguid_lclic " for ccngn1 selection
inner join /sapsll/corcts as g on gguid_pobj = fguid_pobj
where a~extno in s_extno.
sort gt_sagmeld by guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ.
delete adjacent duplicates from gt_sagmeld comparing guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ .
now i am confused how to use delete adjacent dupliacate and on which fields
as first table /sal../lclic primary key is guid_lclic
and it is joined to table
legcon by guid_lclci ( not a primary key here)
legcon primary key is guid_legcon
and table 3 legsv by lgreg (pk here)
table 3 has tow more primary key srvll and ctsty also
NOW MY QUESTIO IS TAHT IS I USE ABOVE DELETE ADJACENT STATMENT IT FETCHES 20 LAKH RECORDS
I WANT TO REDUCE IS LET ME KNOW ON WHAT fields i need to use delete adjacen duplicates
or use comparing all fields?
regards
Arorahi sudha
if u see my select statement is contains four Primary keys
srvll
lgreg
ctsty
guid_lclic
but the next table connected to this table legcon is by guid_pobj and anothe table by guid_mobj
and if i take this gt_sagmeld to another temp table and i find abt 10 lakh uniques guid_pobj
similary 6 lakh guid_mobj so the next slect is hanpering because of this
not COMING TO OUR POINT IF I SORT ONLY BY OUR PRIMARY KEYS NOT TAKING INTO ACCOUNT TEH GUID_POBJ AND GUID_MOBJ
THE ENTRIES ARE VERY LESS BUT IF I TAKE INOT ACCCOUNT IN GT_SAGMELD THE ENTRIES ARE ABT 20 LAKH
SO I AM NOT SURE WHETHER TO TAKNE GUID_POBJ AND GUID_MOBJ INOT ACCOUNT FOR DELECTING ADJACENT DUPLICATES?
HENCE THE QUESTION OF ON WHICH FIRLD DELETE OR COMPARING ALL FIELDS I USE? -
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 -
[php+mysql] how to use variables in a select statement?
Hi all,
I'm searching for a way to use a variable in the select
statement of mysql
query.
I have this variable that can contain:
$var=field_1 field_2 field5
or
$var=field3 field4 field8
so, the variable content is not always the same.
I would like to filter a table selecting only the columns
specified by the
current $var content.
Is this possible to do something like this?
$var=field1 field5 field10
SELECT string_to_array($var)
FROM mytable
ORDER BY mysortfield ASC
Or, is there another way to select columns dynamically?
Thanks for any suggestion.
tonyHi all,
I'm searching for a way to use a variable in the select
statement of mysql
query.
I have this variable that can contain:
$var=field_1 field_2 field5
or
$var=field3 field4 field8
so, the variable content is not always the same.
I would like to filter a table selecting only the columns
specified by the
current $var content.
Is this possible to do something like this?
$var=field1 field5 field10
SELECT string_to_array($var)
FROM mytable
ORDER BY mysortfield ASC
Or, is there another way to select columns dynamically?
Thanks for any suggestion.
tony -
How to use anonymous block in select statement
Hello Experts.
I have one requirement which i can resolve using anonymous block in plsql. But i want implement it in select query only.
Database: Oracle 11.2.0
select count(*) from emp where name='xyz' and sal=50
if count(*)>0
then
select dept,sector from emp where name='xyz' and sal=50
here i dont have any primary key.
How can i achieve above using sql query not plsql. Here is one sloution which i have got but its not satisfying above requiremnt as i dont have any primary key columns
select toll_number from toll_details
where toll_id =(select toll_id from toll_details where toll_new_id='5263655214' group by toll_id having count(*)>0)
here toll_id is primary key, so used group by. But how to do this in my above requirement as i dont have primary key.
Appreciate any help on this.
Thank you897112 wrote:
Hello Experts.
I have one requirement which i can resolve using anonymous block in plsql. But i want implement it in select query only.
Database: Oracle 11.2.0
select count(*) from emp where name='xyz' and sal=50
if count(*)>0
then
select dept,sector from emp where name='xyz' and sal=50
here i dont have any primary key.
How can i achieve above using sql query not plsql. Here is one sloution which i have got but its not satisfying above requiremnt as i dont have any primary key columns
select toll_number from toll_details
where toll_id =(select toll_id from toll_details where toll_new_id='5263655214' group by toll_id having count(*)>0)
here toll_id is primary key, so used group by. But how to do this in my above requirement as i dont have primary key.
Appreciate any help on this.
Thank youTry this
SQL> create table plch_test(id number,name varchar2(20),sal number);
Table created.
SQL> insert into plch_test values(1,'XYZ',50);
1 row created.
SQL> insert into plch_test values(2,'AAA',100);
1 row created.
SQL> insert into plch_test values(3,'BBB',200);
1 row created.
SQL> insert into plch_test values(4,'CCC',400);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from plch_test;
ID NAME SAL
1 XYZ 50
2 AAA 100
3 BBB 200
4 CCC 400
SQL> ed
Wrote file afiedt.buf
1 select id,name
2 from plch_test a
3 where 1=(select count(*) from plch_test b where a.id=b.id)
4* and id=&id
SQL> /
Enter value for id: 2
old 4: and id=&id
new 4: and id=2
ID NAME
2 AAA
SQL> /
Enter value for id: 0
old 4: and id=&id
new 4: and id=0
no rows selectedHope this helps!!!
Regards,
Achyut -
How to use a function in select clause
hi gems...good evening...
I want to write a select clause from a function. The scenario is like below:
function parameters
CREATE OR REPLACE FUNCTION FUNCTION_DEMO(p_pid IN NUMBER,
p_bankerNum IN NUMBER,
p_banker_name IN VARCHAR2,
p_business_num IN NUMBER,
p_businesses IN table_typ_businesses)
return table_typ_bankers
as .......
global object and table types
CREATE OR REPLACE TYPE obj_typ_businesses AS OBJECT (businesses NUMBER);
CREATE OR REPLACE TYPE table_typ_businesses AS TABLE OF obj_typ_businesses;
CREATE OR REPLACE TYPE obj_typ_bankers AS OBJECT (banker_num NUMBER(10,0));
CREATE OR REPLACE TYPE table_typ_bankers IS TABLE OF obj_typ_bankers;
The select query
select * from
table(cast(FUNCTION_DEMO(1,
2,
'ALEX',
2,
table(cast(select businesses_id from reference_businesses) as table_typ_businesses) as table_typ_bankers)But it is giving error with Missing expression.
My function is compiled successfully. I just want to make the select query to view the output given by the function i.e the table type "table_typ_bankers".
Please help...thanks in advance..Hi ,
You can check this and change your code by taking this as an example. I just noted down with simple one input and return as collection type
and how to use/call it in select statement.
SQL> CREATE OR REPLACE TYPE obj_typ_businesses AS OBJECT (businesses NUMBER)
2 /
Type created.
SQL> CREATE OR REPLACE TYPE table_typ_businesses AS TABLE OF obj_typ_businesses
2 /
Type created.
SQL> CREATE OR REPLACE TYPE obj_typ_bankers AS OBJECT (banker_num NUMBER(10,2))
2 /
Type created.
SQL> CREATE OR REPLACE TYPE table_typ_bankers IS TABLE OF obj_typ_bankers
2 /
Type created.
/* Now creating a demo function and just focusing on your one input as collection type */
SQL> create or replace function f11 ( tab_rec IN table_typ_businesses)
2 return table_typ_bankers
3 is
4 t_val table_typ_bankers:= table_typ_bankers();
5 begin
6 dbms_output.put_line('tab_rec count -'||tab_rec.count);
7
8 for i in 1..tab_rec.count
9 loop
10 dbms_output.put_line ('tab_rec value ('||i||')'||tab_rec(i).businesses);
11 t_val.EXTEND;
12 t_val(i) := obj_typ_bankers(tab_rec(i).businesses * 12.50);
13 end loop;
14 return t_val;
15 end;
16 /
Function created.
/* To run your function by a select statement */
SQL> SELECT * FROM TABLE(f11(table_typ_businesses(obj_typ_businesses(5),
2 obj_typ_businesses(12),
3 obj_typ_businesses(18))
4 ) )
5 /
BANKER_NUM
62.5
150
225
tab_rec count -3
tab_rec value (1)5
tab_rec value (2)12
tab_rec value (3)18Hope this will help you... :)
Thanks!
Ashutosh -
How to add a dummy row in the result set of a SELECT statement.
Hello Everyone -
I have requirment to add a dummy row in the result set of a SELECT statement.
For e.g. lets say there is a table Payment having following colums:
Payment_id number
status varchar2(10)
amount number
payment_date date
so here is the data :-
Payment_id Status Amount payment_date
1 Applied 100 12/07/2008
2 Reversed 200 01/ 06/2009
3 Applied 300 01/ 07/2009
Here is my SQL
Select * form payment where payment_date >= 01/01/2009
Output will be
2 Reversed 200 01/ 06/2009
3 Applied 300 01/ 07/2009
My desired output is below
2 Reversed 200 01/ 06/2009
3 Applied 300 01/ 07/2009
2 Reversed -200 01/ 06/2009 ------(Dummy Row)
Thrid row here is the dummy row which I want to add when status is "Reversed"
I would be very thankful for any kind of help in this regard ...
Thanks,
GauravCartesion joining against a dummy table is a useful method of creating a dummy row:
with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual),
--- end of mimicking your table
dummy as (select 'Reversed' col1, 1 rn from dual union all
select 'Reversed' col1, 2 rn from dual)
select mt.cust_id,
mt.payment_id,
mt.status,
decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount,
mt.payment_date
from my_tab mt,
dummy
where mt.status = dummy.col1 (+)
order by mt.cust_id, mt.payment_id, dummy.rn nulls first;
CUST_ID PAYMENT_ID STATUS AMOUNT PAYMENT_DATE
1 1 Applied 100 07/12/2008
1 2 Reversed 200 06/01/2009
1 2 Reversed -200 06/01/2009
1 3 Applied 300 06/01/2009
2 1 Applied 100 07/12/2008
2 2 Reversed 200 05/01/2009
2 2 Reversed -200 05/01/2009
2 3 Applied 300 06/01/2009
2 4 Reversed -400 06/01/2009
2 4 Reversed 400 06/01/2009
2 5 Applied 500 07/01/2009Edited by: Boneist on 07-Jan-2009 23:10
NB. You may have to mess around with the ordering if that's not come back in the order you wanted. You didn't mention what the rules were for any expected ordering though, so I've made up my own *{;-)
Also, I added an identifier (cust_id) to differentiate between different sets of payments, since that's usually the case. Remove that if it's not applicable for your case. -
Using plsql tables in select statement of report query
Hi
Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
thanks in advance
sureshhi,
u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
declare
ur_file utl_file.file_type;
my_result varchar2(250);
begin
ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
utl_file.get_line(ur_file, my_result);
dbms_output.put_line(my_result);
utl_file.fclose(ur_file);
end;
make sure u have an entry in ur init.ora saying that your
utl_file_dir = '\your directory where ur files reside'
cheers!
[email protected] -
Error by using database procedure in select statement
hi ,
I have built a database procedure having one parameter with in out varchar type. that return value with some addition.
i am using it with some column in select statement only for display purpuses but i am facing error by doing that in select statement. that procedure is working well with bind variable but not with select statement.
plz help me how i can use a procedure in select statement. or can i do it or not.plz help me how i can use a procedure in select statement. or can i do it or not.A workaround could be to create a wrapper function for your procedure. One that only passes the input parameters and returns the output parameter.
The simply call this function in your select which internally calls the procedure. -
How to call user fuction in select statement.
hi,
i am facing some problem.How to call user functions in select statement.please send me answer with example.
Thanks
GopalLocations to Call User-Defined Functions
• Select list of a SELECT command
• Condition of the WHERE and HAVING clauses
• CONNECT BY, START WITH, ORDER BY, and GROUP
BY clauses
• VALUES clause of the INSERT command
• SET clause of the UPDATE command
Restrictions on Calling Functions from SQL Expressions
To be callable from SQL expressions, a user-defined
function must:
• Be a stored function
• Accept only IN parameters
• Accept only valid SQL data types, not PL/SQL
specific types, as parameters
• Return data types that are valid SQL data types,
not PL/SQL specific types
• Functions called from SQL expressions cannot
contain DML statements.
• Functions called from UPDATE/DELETE statements
on a table T cannot contain DML on the same table
T.
• Functions called from an UPDATE or a DELETE
statement on a table T cannot query the same table.
• Functions called from SQL statements cannot
contain statements that end the transactions.
• Calls to subprograms that break the previous
restriction are not allowed in the function.
jeneesh -
How to use SET & GET Parameters in Module Pool
Hi Friends,
Can anyone please tell how to use SET / GET parameters and PARAMETER ID for a text box (Input / Output field ) in module pool? What is the purpose and where do we need to do coding for it?
Note : I will definitely give the marks for good responses.
Thanks in advance,
PradeepHi Pradeep,
You can save values in the SAP memory using a parameter ID. These
are user and terminal-session specific, but available to all internal and
external sessions.
SET Parameter copies the corresponding field contents into the SAP
System memory in the PAI processing block.
GET Parameter copies the corresponding field contents from the SAP
memory at the end of the PBO processing block, after data has been
transferred from the program, if the screen field still has its initial value
You can link an input/output field to an area of the SAP memory in the
ABAP Dictionary.
When you use an input/output field that is defined in the ABAP
Dictionary, its parameter ID is displayed in the Dictionary attribute
Parameter ID in the Screen Painter.
Usage
SET PARAMETER ID: CAR FIELD space,
CON FIELD space,
DAY FIELD space.
Here is the link that explains the usage of GET/SET in detail
<a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db9e0435c111d1829f0000e829fbfe/content.htm">http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db9e0435c111d1829f0000e829fbfe/content.htm</a>
Regards,
Sharadha -
Plase can anybody tell me how to use SETS (GS01/02/03) in ABAP program
Plase can anybody tell me how to use SETS (GS01/02/03) in ABAP program
http://wiki.sdn.sap.com/wiki/display/Snippets/Reading+Sets+-+GS01+-+GS02+-+GS03
-
Using java function in select statement
Hi,
I am trying to use java function in select statement.
public class ClassA{
private static String MyConst = "foo";
public static String functionA(){
return MyConst;
in my query I have:
select
ClassA.functionA() AS id,
groupId AS newID,
from
myChannel[now]
ClassA is part of the application (no need to import).
I get and error of Invalid Expression on ClassA.functionA().
I also tried to declare the function in the processor element:
<wlevs:processor id="proc">
<wlevs:function function-name="A" exec-methode="functionA">
<bean class="mtPackage.ClassA"/>
</wlevs:function>
<wlevs:processor>
but then I get a different error in the processor XML file: "An InvocationTargetException was encoutered while attemting to register the user defind function A. The message was null"
What am I missing here?Hi,
From the above description, you have tried two manners to call method functionA() in the user defined class ClassA. One uses java cartridge manner directly and the other try to use user defined function manner.
For the java cartridge manner, the following CQL query should work if the ClassA is really included in the OEP app. I have done similar test before, it works.
select
ClassA.functionA() AS id,
groupId AS newID,
from
myChannel[now]
For user defined function manner, I think two things you need to change:
1. Need to declare the function in the EPN assembly file(under META-INF/spring/), not component configuration file(under META-INF/wlevs/). The following is an example:
<wlevs:processor id="proc">
<wlevs:function function-name="A" exec-methode="functionA">
<bean class="mtPackage.ClassA"/>
</wlevs:function>
</wlevs:processor>
2. Call the user defined function in the CQL query in the component configuration file under processor. For example:
select A() from myChannel
Regards,
XiYing -
How to put OR clause in SELECT statement
Hi
How to put OR clause in SELECT statement to return number_first/number_last to match records from another table's column.
<pre>
SELECT
a.id ,
flat_number ||' '|| a.number_first||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
</pre>
Thsi will return this as exact match.
ADDRESS 1
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
ADDRESS2
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
However this only matches number_first.
How can I get the query work that it will match both number_first and number_last (table b)in address 1 to match street_no in address2 ( table b).My oracle version is 10GR/2.Hi, I have a hard time understanding your request, and below is what I thought you want:
SELECT
a.id ,
flat_number ||' '|| (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last)||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
AND (B.street_no=a.number_first OR b.street_no=a.number_last);Not tested.
Also, since your B.street_no will be either a.number_first OR a.number_last, you could replace
(decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last) with just b.street_no.
Edited by: PhoenixBai on Aug 26, 2010 11:33 AM -
How to use case when in Select qry?
Hi Friends,
I want to use Case when in Select qry, my situation is like this
SELECT bmatnr blgort bj_3asiz bmat_kdauf b~mat_kdpos
SUM( ( case when bshkzg = 'S' then bmenge else 0 END ) -
( case when bshkzg = 'H' then bmenge else 0 END ) ) AS qty
INTO corresponding fields of table it_projsal
FROM mseg AS b
INNER JOIN mkpf AS a ON bmblnr = amblnr
AND bmandt = amandt
WHERE abudat < '20061201' AND blgort IN ('1050')
and b~mandt = '350'
GROUP BY bmatnr bj_3asiz bmat_kdauf bmat_kdpos b~lgor
If we give like this it gives an error.
Please help me, how to use or handle in select qry itself.
Regards
Shankarthis is not a way to select data from the DB tables.
first get all the data from the DB tables then u have to do SUM Ups .
Regards
prabhu
Maybe you are looking for
-
Installing OSX Tiger on external drive
I have tiger OS10.4 installed on my macbook pro. I have a few external drives, one of which I have tiger os10.4 installed and use as a startup drive for certain work (audio) that I do. I want to install tiger OS 10.4 on another newly acquired hard dr
-
CProjects - Assign Project Types to Ogr. unit
Hi, We are on cProjects 4.0. We require a Project Type to be valid only for an org. unit such that users of other org. unit cannot acccess this project type. Can we achieve this? Please suggest...
-
Hi Gurus For those of you who have completed a CRM 2007 implementation of Internet Sales on a Standalone System... What Best Practice Guides did you refer to for this? And any other documents if any? Maximum Points for a speedy and accurate reply. Pl
-
What is the best company for simple archive and storage in the cloud.
Yes, I moved to iCloud a while ago. Yeah, I realize that time is running out for my items stored on my MobileMe iDisk!! Has anyone found a company that offers cloud archive and storage with good encryption? I am really not interested in sharing of an
-
Lost microsoft office tools with mountain lion install
I installed Mountain Lion and now my Microsoft Office Tools are gone?