How to write Select statement for this codition
I need to check whether SGTXT contains BELNR value.
SGTXT is a text field and It should be matched with BELNR
How to write select statement for this.
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT should have the given BELNR Value.
Plz note : Here I cannot give as SGTXT = BELNR as coz BELNR have only 10 digits.
Hi,
data temp(12).
concatenate '%' belnr '%' into temp.
Select AUGBL AUGDT into t_BSAD
from BSAD
where SGTXT like temp.
If belnr is having multiple values,just create a internal table as follows.
types : begin of ty,
belnr....
temp(12),
end of ty.
data itab_ type standard table of ty.
data wa type ty.
loop at itab into wa.
concatenate '%' wa-belnr '%' into wa-temp.
modify itab from wa index sy-tabix transporting temp.
endloop.
Change your select statement accordingly.
Kindly reward poits if it helps.
Similar Messages
-
How to write select query for this
Hi,
I had a html form and in the for i had drop down box and it needs to select multiple values from the drop down box. When i select multiple values then i have to write the SQL select statement query .
When i try to write the select statement and trying to run i am getting error.
select * from Table
where emo_no = '1,2,3'
this is how i write query please suggest me how to write query for selecting multiple values from the drop down box.
Thanksselect * from Table
where emo_no in ( 1,2,3)
for integer values
select * from Table
where emo_no in ('1','2','3')
for characters
If we talk about large scale applications that may have millions of records, I would suggest this.
declare @t table (v int)
insert into t (v) values (1)
insert into t (v) valves (2)
insert into t (v) values (3)
select *
from table
inner join @t t on table.emo_no = t.v
Using "in" for a where clause is not so bad for filtering on a few values, but if you are filtering a lot of rows and a lot of values (emo_no) the performance degrades quickly for some reasons beyond the scope of this.
This is just one solution, I'll through this out as well, instead of an in memory (@t) table, doing a disk based temp table (#t) and creating an index on the column "v".
create table #t (v int)
insert into #t (v) values (1)
insert into #t (v) valves (2)
insert into #t (v) values (3)
create index ix_t on #t (v)
select *
from table
inner join #t t on table.emo_no = t.v
drop table #t
Pardon any syntax errors and careful using a drop statement.
Sometimes in memory tables work better than disk temp tables, it takes some testing and trial and error depending on your datasets to determine the best solution.
Probably too much info ;-)
Byron Mann
[email protected]
[email protected]
Software Architect
hosting.com | hostmysite.com
http://www.hostmysite.com/?utm_source=bb -
How to write select statement in XSL-FO type XML program
Hi All,
Could you please anyone explain briefly how to write select statement in XSL-FO XML Program.
Requirement:
In the seeded program, OAF page is creating one XML file and through XSL-FO type XML Pulisher loading data and generating PDF output. as per the requirement some of the informations are missing in the XML file and for modifing the OAF page will be taking someting. we are planing to write a select query inside the XSL-FO program to get the required information.
Could you please help me how to write a select statement inside the XSL-FO type programs.
Please give me some example program for this...
Thanks in Advance.
Regards,
SenthilHi ,
Please check the below code and modified plant as select-option
Check the below code :
tables : mara,
mast.
data : begin of i_data occurs 0,
matnr like mara-matnr,
end of i_data.
select-options : s_matnr for mara-matnr,
<b>S_werks for mast-werks.</b>
start-of-selection.
select a~matnr into table i_data
from mara as a inner join mast as b on amatnr = bmatnr
where <b>b~werks in s_werks</b>
and a~matnr in s_matnr
and a~mtart = 'AA'
or a~mtart = 'UT'
and b~stlan = '1'.
loop at i_data.
write:/ i_data-matnr.
endloop.
Hope you got it.
Thanks
Seshu -
How to write complex sql for this
Hi ALL,
I have a requirement like this
I have 5 tables which i have to join to get the result
but there no join column to 2 other table.
I want to get all the applications using cobal,running on UNIX.
How to write the query for this
1.APP
APP_i DESC
1 Accounts
2 Payments
3 order transfer
4 Order processing
2.Techgy
techid techdesc
1 cobal
2 Java
3.APP_Techgy
APP_I Techid
1 1
2 1
3 1
4 2
4.Pltfrm
pltfmid pltfrmdesc
1 Windows NT
2 UNIX
5.APP_Pltfrm
APP_I pltfrmid
1 1
2 1
3 2
4 2
ouput must be
APP_i Desc techDESC pltfrmdesc
3 ordertranfer Cobal UNIX
Thanks in advanceThis ('descr' in place of 'desc')?
SQL> select a.app_i, a.descr, t.techdesc, p.pltfrmdesc
from app_techgy atc,
app a,
techgy t,
app_pltfrm ap,
pltfrm p
where atc.techid = t.techid
and atc.app_i = a.app_i
and atc.app_i = ap.app_i
and ap.pltfrmid = p.pltfmid
order by a.app_i
APP_I DESCR TECHDESC PLTFRMDESC
1 accounts cobal windows nt
2 payments cobal windows nt
3 order transfer cobal unix
4 order processing java unix
4 rows selected. -
How to write SELECT statement using tables ekko,ekpo and eket?
Hi,
I got a problem in performance tuning using below tables?
how to write SELECT statement using tables EKKO,EKPO and EKET and in conditon ( WHERE clause) use only fields
ekko~ebeln IN ebeln
ekko~loekz EQ ' '
ekko~lifnr IN lifnr
ekko~ekorg IN ekorg
ekko~ekgrp IN ekgrp
ekpo~werks IN werks
ekpo~pstyp EQ '3'
ekpo~loekz EQ space
ekpo~elikz EQ space
ekpo~menge NE 0
eket~rsnum NE space.
Thanks in Advance.
bye.Hi,
ekko~ebeln IN ebeln
ekko~loekz EQ ' '
ekko~lifnr IN lifnr
ekko~ekorg IN ekorg
ekko~ekgrp IN ekgrp
ekpo~werks IN werks
ekpo~pstyp EQ '3'
ekpo~loekz EQ space
ekpo~elikz EQ space
ekpo~menge NE 0 " Remove this from where clause
eket~rsnum NE space. " Remove this from where clause
' instead delete the entries after fetching into the table
DELETE it_itab WHERE menge EQ '0' AND rsnum EQ ' '.
Regards
Bala Krishna -
Regarding select statement for this requirement
Hi................
good evening
here is a requirement.
i want to retrieve data from the following table.but how to join these table is my dought.
tables fields
t001w--werks " plant id
t001w--name1 " pl;ant name
t001w--regio " plant address
ekko--ebeln " purchase order
ekko-erdat : creation date
ekko-ernam "name of the person
ekpo-ebelp " item
ekpo-bstyp "purchase order type
eket-erdat " delivery date
mara-matnr " material number
these are the tables and fields.now we want to retrive data from these tables
how we have to code select statement.
selection-screen is
plant id
order type
delivery date
please provide select statement for this requirement.
thanks and regards.
k.swaminath reddy.Is this what you are looking for?
SQL> CREATE OR REPLACE FUNCTION f_team
2 RETURN VARCHAR2
3 IS
4 s_return VARCHAR2(500);
5 BEGIN
6 FOR i IN ( select team from t_team order by 1) LOOP
7 s_return := s_return || i.team || ', ';
8 END LOOP;
9
10 RETURN substr(s_return, 1, length(s_return) - 2);
11 END;
12 /
Function created.
SQL> SELECT f_team FROM dual;
F_TEAM
Australia, Bangladesh, England, India, Kenya, Pakistan, South Africa, UAE, USA, West Indies, Zimbabwe
SQL> -
How to write a PCR for this ?
Hi SAP-HR Experts .
Dear friends , My Company Requires a specific requiremnt that at the date of any Employee's
B'day his one day salary should get doubled and he is entitled to get one leave on his B'day .
I do not know how to write a PCR for this ?
May some Body tell me how to meet this requirement Please .
tell me please step by step how to go through ...
It will be great help for me .
Best regards : rajneeeshI think you can make it with something like this:
Write a PCR in schema, you can call the rule with "actio";
000860 ACTIO 9BIR AR Birthday
Rule 9BIR
9BIR Rule for Birthday
NUM=FG C Set " F (fixed indicator for deadline calculation); G (Birth date from infotype 0002);C (complete months)
NUM/12 División " Number of completed months divided by 12
NUMV0O2L Off.Lng en arg.var. " the last two places of the number are entered in the variable argument.
" if the rest is not 00, there is nothing to do
00 " if the rest is 00
ZERO= N AmtNumRteZeit = 0 "
AMT= 1002 Set " wagetype of salary
AMT/TKDIVI División " divides the amount by Partial Period Parameter Whole Month
ADDWTI1002 Input table " accumulates into 1002
Example: an employee with birthday 01.01.1977 in IT0002
Payrroll in january 08
wagetype 1002 before rule 9BIR:
3 1002 Salario Bas01 30,33 30,00 909,90
Rule 9BIR
NUM=FG C Set; NUM= 372
NUM/12 ; 372/12= 31 rest=00
AMT=1002 ; AMT= 909,90
AMT/TKDIVI ; 909,90/31= 29,35
ADDWTI1002 ; 909,90 + 29,35= 939,25
wagetype 1002 before rule 9BIR:
3 1002 Salario Bas01 30,33 30,00 939,25
Hope this helps. Manuel -
How to write select statement directly in java file instead of using vo
Hi,
I have written the following code in my java file:
if(empvo==null)
empvo=worklistamimpl2.createViewObject("InvoiceVO", "xxetfc.oracle.apps.icx.icatalog.shopping.server.InvoiceVO");
if(empvo!=null){
OAViewObject oaviewobject2 = (OAViewObject)worklistamimpl2.findViewObject("InvoiceVO");
OAViewObjectImpl oaviewobjectimpl = (OAViewObjectImpl)oapagecontext.getApplicationModule(oawebbean).findViewObject("InvoiceVO");
oaviewobject2.setWhereClause("Invoice_num="+" ' " + s + " ' ");
oaviewobjectimpl.executeQuery();
String abc = (String)oaviewobjectimpl.first().getAttribute("Invoice_id");
It is giving me error as
oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (select invoice_id from ap_invoices_all) QRSLT WHERE (Invoice_num='ERS15022012_3')
1. Why is this error coming.. how to solve this
2. Instead of using vo how can i write select statement directly in the above code
Thanks,
Edited by: user10873676 on Apr 9, 2012 1:18 AM
Edited by: user10873676 on Apr 9, 2012 1:21 AMit says java.sql.SQLSyntaxErrorException: ORA-00904: "INVOICE_NUM": invalid identifier
where as invoice_num column is present in my table -
Hi frenz, i m bharath a new bee to oracle,my problem is
the given table is
userid billno amount
1 101 1000
2 102 2000
3 103 3000
4 104 4000
output table should be:
userid billno amount total*
1 101 1000
2 102 2000 *3000*
3 103 3000 *6000*
4 104 4000 *10000*
I need a select query for the above output.
i.e,here i calculated total as sum(amount) for each row,i.e,3000 = 1000+2000,6000 = 1000+2000+3000,10000 = 1000+2000+3000+4000 by this way my calculation for total field
kindly send me a query.This is trivial with analytics:
SQL> select empno, sal, sum(sal) over (order by empno)
2 from emp
3 /
EMPNO SAL SUM(SAL)OVER(ORDERBYEMPNO)
7369 800 800
7499 1600 2400
7521 1250 3650
7566 2975 6625
7654 1250 7875
7698 2850 10725
7782 2450 13175
7788 3000 16175
7839 5000 21175
7844 1500 22675
7876 1100 23775
7900 950 24725
7902 3000 27725
7934 1300 29025
14 rows selected.
SQL> You might want to get your keyboard checked - the question mark key seems to be stuck.
Cheers, APC
blog: http://radiofreetooting.blogspot.com -
How to write select statement ?
Hi,
i have requirement like below :
In selection screen we have material number as selection options and plant as single entry.
Based on the input.
We have to extract the material number and plant based on MTART = AA or UT in MARA table and STLAN = 1 in MAST table.
how to write a select statment to pick values from selection option and extract those material and plant which fullfill above conditions.
Please let me know..
its urgent
please help..
i have written code like below..
types: begin of x_it_mat,
matnr type mkal-matnr,
werks type mkal-werks,
stlan type mast-stlan,
end of x_it_mat.
types: begin of x_it_mat1,
matnr type mkal-matnr,
werks type mkal-werks,
mtart type mara-mtart,
end of x_it_mat1.
data : it_mat type table of x_it_mat,
wa_mat like line of it_mat.
data : it_mat1 type table of x_it_mat1,
wa_mat1 like line of it_mat1.
TABLES: MKAL , MAST , MARA.
SELECTION-SCREEN BEGIN OF BLOCK matnr
WITH FRAME TITLE TEXT-001.
select-options :
so_matnr for mkal-matnr.
SELECTION-SCREEN END OF BLOCK matnr.
SELECTION-SCREEN BEGIN OF BLOCK plant
WITH FRAME TITLE TEXT-002.
parameter p_werks type mkal-werks.
SELECTION-SCREEN END OF BLOCK plant.
select matnr
werks
stlan
from mkal INTO table it_mat
where matnr in so_matnr
and werks = p_werks.
after this how to write another select statement to extract material by satisfiying above 2 conditions..Hi ,
Please check the below code and modified plant as select-option
Check the below code :
tables : mara,
mast.
data : begin of i_data occurs 0,
matnr like mara-matnr,
end of i_data.
select-options : s_matnr for mara-matnr,
<b>S_werks for mast-werks.</b>
start-of-selection.
select a~matnr into table i_data
from mara as a inner join mast as b on amatnr = bmatnr
where <b>b~werks in s_werks</b>
and a~matnr in s_matnr
and a~mtart = 'AA'
or a~mtart = 'UT'
and b~stlan = '1'.
loop at i_data.
write:/ i_data-matnr.
endloop.
Hope you got it.
Thanks
Seshu -
How to write select statement before the loop and how to use read statemnt
Hi,
Recently our system has changed from 4.6 to ECC6.
As its migrated its showing lots of errors like in between loop and endloop there should be no select statemnt........
Can any one please tell how to write that coding in ECC6 , how can i change the code......
In between loop and endloop i am having lots of select statemnts.....ple tell thye coding how can i select before the loop starts and
how to read that internal table in loop.Hi Deepthi,
You can do as per below:
1) Select the required entries from the tables you need (VBAK, VBAP, KNA1, etc)
SELECT VBELN ERDAT KUNNR
into table it_vbak
from VBAK
where VBELN = S_VBELN. "Selection criteria
If sy-subrc = 0.
SELECT VBELN POSNR MATNR
into table it_vbap
from VBAP
for all entries in it_vbak
where VBELN = it_vbak-vbeln
SELECT KUNNR NAME1
into table it_vbak
from VBAK
where VBELN = it_vbak-vbeln.
endif.
2) Loop at the entries, and read internal table it-kna1 for customer info.
Loop at it_vbak into wa_vbak.
read table it_kna1 into wa_kna1 with key kunnr = wa_vbak-kunnr.
if sy-subrc = 0.
endif.
loop at it_vbap into wa_vbap where vbeln = wa_vbak-vbeln.
endloop.
endloop.
This is the basic idea and short example of how to extract entries and read internal table.
Hope this helps.
Regards,
Patrick -
How to write select statement into SCRIPT editor
hello,
i build a sap script for purchase order printing for exporting.
now after all po order print fine then our client want some more should be print into layout regarding po header.
At the soul my q is can i write select query into script editor itself.
thanks and regards
amit.You cannot write your select statement inside your SAPscript, to overcome this SAP has provided us an option of calling sub-routines.. go through the below example
Go through this example
Ex. SAPSCRIPT
/: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>
/:USING &<field name>&
/:CHANGING &<field name1& "It will be returned back from sub-routine
/:ENDPERFORM
Then create subroutine pool program(of your own name) and you have to write the code.
FORM ><subroutine name> tables int_cond structure itcsy
outt_cond structure itcsy.
data : value(20), value1(20). "do your own declarations
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
*****Write your select statement
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1.
ENDFORM.
Just rough idea given above.
Regards,
SaiRam -
How to write a query for this output
I have a string ' if i know good acting , I am a hero '
now if 'hero' is present in the string it will return ' i am hero' else
'you are hero'
How to write a sql query to return the same .SQL> select (case
2 when '&a' like '%hero%' then 'I am hero'
3 ELSE 'u r hero'
4 end) output from dual;
Enter value for a: if i know good acting , I am a hero
old 2: when '&a' like '%hero%' then 'I am hero'
new 2: when 'if i know good acting , I am a hero ' like '%hero%' then 'I am hero'
OUTPUT
I am hero
SQL> /
Enter value for a: jkhkh
old 2: when '&a' like '%hero%' then 'I am hero'
new 2: when 'jkhkh' like '%hero%' then 'I am hero'
OUTPUT
u r hero
Hope this helps. -
How to write selection Query for the following requirment.
Hi All,
I am new to ABAP, I need a help ,
I need to select all plants(WERKS) from MARC at Plant/Material level,
then I need to take all sales organozation(VKORG) from T001w,
then I need the company code(BUKRS) from TVKO based on VKORG,
then I need the currency key(WAERS) from T001 based on BUKRS,
Can any one help me in writing selection Query for the same?
Thanks All,
Debrup.Hi,
Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
If you struck up anywhere revert back.
Regards
Karthik D -
How to write select query for all the user tables in database
Can any one tell me how to select the columns from all the user tables in a database
Here I had 3columns as input...
1.phone no
2.memberid
3.sub no.
I have to select call time,record,agn from all the tables in a database...all database tables have the same column names but some may have additional columns..
Eg: select call time, record,agn from ah_t_table where phone no= 6186759765,memberid=j34563298
Query has to execute not only for this table but for all user tables in the database..all tables will start with ah_t
I am trying for this query since 30days...
Help me please....any kind of help is appreciated.....Hi,
user13113704 wrote:
... i need to include the symbol (') for the numbers(values) to get selected..
eg: phone no= '6284056879'To include a single-quote in a string literal, use 2 or them in a row, as shown below.
Starting in Oracle 10, you can also use Q-notation:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#i42617
...and also can you tell me how to execute the output of this script. What front end are you using? If it's SQL*Plus, then you can SPOOL the query to a file, and then execute that file, like this:
-- Suppress SQL*Plus features that interfere with raw output
SET FEEDBACK OFF
SET PAGESIZE 0
-- Run preliminary query to generate main query
SPOOL c:\my_sql_dir\all_ah_t.sql
SELECT 'select call time, record, agn from '
|| owner
|| '.'
|| table_name
|| ' where phone_no = ''6186759765'' and memberid = j34563298'
|| CASE
WHEN ROW_NUMBER () OVER ( ORDER BY owner DESC
, table_name DESC
) = 1
THEN ';'
ELSE ' UNION ALL'
END AS txt
FROM all_tables
WHERE SUBSTR (table_name, 1, 4) = 'AH_T'
ORDER BY owner
, table_name
SPOOL OFF
-- Restore SQL*Plus features that interfere with raw output (if desired)
SET FEEDBACK ON
SET PAGESIZE 50
-- Run main query:
@c:\my_sql_dir\all_ah_t.sql
so that i form a temporary view for this script as a table(or store the result in a temp table) and my problem will be solved..Sorry, I don't understand. What is a "temporary view"?
Maybe you are looking for
-
Why do we need Profiles ?
Hi all, I know it a bit stupid question you would think but do read it complete before answering. 1. When we create a role the role name is given and tcodes are assigned to it. Then we go to the authorization tab, before that it asks us to save the r
-
Working with Layers | Learn Photoshop Elements 9 | Adobe TV
With layers, you can work nondestructively and save all of your creative ideas in a single file. Learn about the various options in the Layers panel and how to harness the true power of Photoshop Elements by working with layers. http://adobe.ly/ynakt
-
IDOC structure for HRMD_A07
Dear All, We want to create IDOC HRMD_A07 through SAP PI in ECC to create employee. Please guide how we can get the output structure like e1plogi e1pityp e1p0000 e1pityp e1p0001 e1pityp e1p0002 Whereas the standard IDOC structure is like as follows:
-
Com/sun/corba/se/connection/ORBSocketFactory
Is the class com/sun/corba/se/connection/ORBSocketFactory in the JRE 1.5. I get my WLS 8.1 client working with 1.4 but it desn't work anymore with 1.5 due to the following error: java.lang.NoClassDefFoundError: com/sun/corba/se/connection/ORBSocketFa
-
Alternate to Apple Brand Power Supply?
So I've run through two power supplies (both broken where it connects with the computer) and I'd really rather not buy another apple brand supply. I understand the strange outside ring is only for the color on the charger so it's probably and any ada