Reg:- hirachy query.
Dear Frieds,
i have requirement but i have some restriction to use in plsql code.
like 1) In the Loop select is not used.
now requirement as below.
i have define one hierarchy Query which i have used in explicit cursor.
the cursor query return 3 parent departmentid like........(101,102,103)
it means 102 parent of 101 and 103 parent of 102.
now i want check this deparment id in another query one by one....like below...
select count(1) from mst_menu where deptid=101.
here i have condition.like if 101 deptid is present above table then execute select query ..if it not present then check next department id i.e. 102...
so,how can i execute select query if data is present and if no then how can i take next dept id to check.
pls help.
--Rajnish
NOT TESTED! an old fashioned approach because no database version was given
declare
the_list varchar2(4000) := '(101,102,103)';
dept_id varchar2(10);
present pls_integer;
flag boolean := false;
begin
the_list := replace(replace(the_list,'(',','),')',',');
items_no := length(the_list) - length(replace(the_list,',','')) - 1;
for i in 1 .. items_no loop
dept_id := substr(the_list,instr(the_list,',',1,i) + 1,instr(the_list,',',1,i + 1) - instr(the_list,',',1,i) - 1);
select count(*)
into present
from mst_menu
where deptid = dept_id;
if present != 0 then
flag := true;
exit;
end if;
end loop;
if flag then
null; -- execute the select query here
end if;
end;Regards
Etbin
Edited by: Etbin on 22.5.2010 11:16
corrected instr function calls - paramater ',' was missing
Similar Messages
-
hi all,
hope all r doing fine?
anyway i have a query which is mentioned below:-
select field1,.....fieldn
from <dbtable1>
into corresponding fields of table itab
where <condition>.
select field1,...fieldn
from <dbtable2>
appending corresponding fields of table itab
where <condition>.
the above two select stmts retrieve same set of fields from two different database tables into same internal table itab..
now my question is ...........is any other way to change 2nd select statement without using appending correspondin fields
but the functionality should remain the same as it is after changing..................
bcos appending corresponding is causing performance problem in data retrieval.
thanx alot in advance.
for sure points will be given for all the helpful answers
JackHi,
You can use like that:
select field1,.....fieldn
from <dbtable1>
into corresponding fields of table itab1
where <condition>.
select field1,...fieldn
from <dbtable2>
appending corresponding fields of table itab2
where <condition>.
now u use:
loop at itab2 into w_itab2.
read table itab1 into w_itab1 with key w_itab1-<primary field> = w_itab2-<Primary field>.
if sy-subrc = 0.
append w_final into i_final.
else continue.
endif.
endloop.
*i_final table having all data ( i.e itab2 & itab1 data) -
Hi Guys,
I got a problem with select query...could you polease help me out...plz check the second select query statement
when i open tstcp table i gave Ztable and then when I exceute i am able to get the list when i do it programatically it is not working .....
any suggestions...points will be rewarded..
select tabname
from dd02l into table i_dd02l where tabname like 'Z%' and
( tabclass = 'VIEW'
or
tabclass = 'TRANSP' ) and
( mainflag = 'X'
or
mainflag = '' ).
if not i_dd02l[] is initial.
loop at i_dd02l.
v_tabna = i_dd02l-tabname.
select single tcode
param into (v_tcode , v_param)
from tstcp where param like '%v_tabna%'.
i_tstcp-tcode = v_tcode.
i_tstcp-param = v_param.
append i_tstcp.
clear i_tstcp.
endloop.
endif.
Regards,
Ravi GanjiHi ,
The statement will not work because it will try to find all records which has v_tabna in its field.
So what you need to do is concatenate % before and after the value of the varaible v_tabna and store it in some varaible say v_value and use it in the where clause.
so your code will look like this
*v_tabna = i_dd02l-tabname.
concatenate '%' i_dd02l-tabname '%' into v_tabna
select single tcode
param into (v_tcode , v_param)
from tstcp where param like tabna.
Regards
Arun -
HI FRENDS
MY PROBLEM IS IN BELOW QUERY
select SUBSTR('Sales - Alternate Channels (Sub Department).Area Manager.1',1,7) from dual
HERE I WANT TO TAKE ONLY 'SALES' FROM THE STRING.
BUT SOME TIME INSTEAD OF SALES IT WILL COME 'Branch Operations' LIKE THAT THEN I WANT TAKE THESE STRING ONLY....
IN SHORT I WAN TO TAKE ONLY THAT STRING WHICH IS BEFORE '-'......NOT THAT VALUE WHICH AFTER '-'...
PL HELP.If u want srting before '-' than use instr to search '-'
e.g.
select substr('Branch Operations - Alternate Channels (Sub Department).Area Manager.1',1
,instr('Branch Operations - Alternate Channels (Sub Department).Area Manager.1','-',1)-1)
from dual
SQL> select substr('Branch Operations - Alternate Channels (Sub Department).Area Manager.1',1
2 ,instr('Branch Operations - Alternate Channels (Sub Department).Area Manager.1','-',1)-1)
3 from dual
4 /
SUBSTR('BRANCHOPERATIONS-ALTER
Branch Operations
SQL> select substr('Sales - Alternate Channels (Sub Department).Area Manager.1',1
2 ,instr('Sales - Alternate Channels (Sub Department).Area Manager.1','-',1)-1)
3 from dual
4 /
SUBSTR('SALES-ALTERNATECHANNEL
Sales -
Reg. Query for UDFs.
Hello All,
I've created a multiple UDFs Like, Vendor Name,Vendor Address,Vendor Excise Details like ECC No,Range, Division,VAT No,CST No. in Marketing Documents.
I want to write a query, for example if I select the Vendor Name, the vendor address and excise details should pick up automatically from that vendor master record. Please help.
Thanks,
Pratheeviraj.Dear Avijit,
Thanks for your reply.
I can't understand your solution. Can you please explain me in detail?
I'm giving the scenario in detail,
In the marketing document 'Outgoing Excise Invoice', I've created UDFs like vendor name, vendor address, vendor excise number, etc., my requirement is the moment I select the vendor in Vendor Name UDF, the address and excise number should get populated in the respective UDFs.
Thanks,
Pratheeviraj -
Reg.write query for report
Dear Experts
I am MM consultant and I am in need of generate reports.I don't know how to get the data from two table. Pls help me
with some codings
Thanks
Rajakumar.KHi.....
Check this... Here Iam joining MARA and MAKT tables.....
data: begin of itab occurs 0,
matnr like mara-matnr, <----like this you can select no.of fields from MARA
spras like makt-spras, <----like this you declare ur internal table with no.of fields of MAKT table
end of itab.
parameters: p_matnr like mara-matnr. <------ Later according to this material number you can display details
select p~matnr q~spras <----with p~ you can declare no.of from MARA, but those should me mention in above ITAB , also MAKT with q~
from
mara as p <---- p is for first table fileds
inner join <----- key word
makt as q <----- q is for second table fields
on p~matnr = q~matnr <----this is for link
into corresponding fields of table itab
where p~matnr = p_matnr. <------checking where condition with parameter
loop at itab.
write:/ itab-matnr, <--------here you can display the fields which you defined in ITAB
itab-spras.
endloop.
Also check this query....
Here you can display all the details of that tables...
data: begin of itab occurs 0,
matnr like mara-matnr,
spras like makt-spras,
end of itab.
data: p_matnr like mara-matnr.
select-options: g_matnr for p_matnr. <------First change
select p~matnr q~spras from mara as p inner join makt as q
on p~matnr = q~matnr
into corresponding fields of table itab
where p~matnr in g_matnr. <----second change
loop at itab.
write:/ itab-matnr,
itab-spras.
endloop.
Also check this code and get an idea about for all entries method and joining of more than two tables...
data: begin of itab occurs 0,
matnr like mara-matnr,
spras like makt-spras,
end of itab.
data: begin of jtab occurs 0,
matnr like marc-matnr,
werks like marc-werks,
end of jtab.
data: begin of t_out occurs 0,
matnr like mara-matnr,
spras like makt-spras,
werks like marc-werks,
end of t_out.
data: p_matnr like mara-matnr.
select-options: g_matnr for p_matnr.
select p~matnr q~spras from mara as p inner join makt as q
on p~matnr = q~matnr
into corresponding fields of table itab
where p~matnr in g_matnr.
if itab[] is not initial.
select * from marc into corresponding fields of table jtab
for all entries in itab
where matnr = itab-matnr.
endif.
loop at itab.
t_out-matnr = itab-matnr.
t_out-spras = itab-spras.
read table jtab with key matnr = itab-matnr.
if sy-subrc = 0.
t_out-werks = jtab-werks.
endif.
append t_out.
clear t_out.
endloop.
loop at t_out.
write:/ t_out-matnr,
t_out-spras,
t_out-werks.
endloop.
All the best!!
Thanks,
Naveen.I -
Reg: sql query that prints all sundays in the year
Hi all,
Please give me sql query that prints all sundays in year. And when ever we execute that query then that will prints the sysdate(that is execution date).
Thanks in Advance,
-prasad.
Edited by: prasad_orcl on Jun 5, 2009 9:13 PMHi,
Plz try this and let me know this works or not...
SELECT DATE DATES,TO_CHAR(DATE,'DAY') DAYS FROM FISCAL_CALENDAR
WHERE DATE_YEAR = 2009 AND
DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND
ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12) -1 AND
TRIM(TO_CHAR(DATE,'DAY')) = 'SUNDAY'
ORDER BY DATE
OUTPUT:
DATES DAYS
1/4/2009 SUNDAY
1/11/2009 SUNDAY
1/18/2009 SUNDAY
1/25/2009 SUNDAY
2/1/2009 SUNDAY
2/8/2009 SUNDAY
2/15/2009 SUNDAY
2/22/2009 SUNDAY
3/1/2009 SUNDAY
3/8/2009 SUNDAY
3/15/2009 SUNDAY
3/22/2009 SUNDAY
3/29/2009 SUNDAY
4/5/2009 SUNDAY
4/12/2009 SUNDAY
4/19/2009 SUNDAY
4/26/2009 SUNDAY
5/3/2009 SUNDAY
5/10/2009 SUNDAY
5/17/2009 SUNDAY
5/24/2009 SUNDAY
5/31/2009 SUNDAY
6/7/2009 SUNDAY
6/14/2009 SUNDAY
6/21/2009 SUNDAY
6/28/2009 SUNDAY
7/5/2009 SUNDAY
7/12/2009 SUNDAY
7/19/2009 SUNDAY
7/26/2009 SUNDAY
8/2/2009 SUNDAY
8/9/2009 SUNDAY
8/16/2009 SUNDAY
8/23/2009 SUNDAY
8/30/2009 SUNDAY
9/6/2009 SUNDAY
9/13/2009 SUNDAY
9/20/2009 SUNDAY
9/27/2009 SUNDAY
10/4/2009 SUNDAY
10/11/2009SUNDAY
10/18/2009SUNDAY
10/25/2009SUNDAY
11/1/2009 SUNDAY
11/8/2009 SUNDAY
11/15/2009SUNDAY
11/22/2009SUNDAY
11/29/2009SUNDAY
12/6/2009 SUNDAY
12/13/2009SUNDAY
12/20/2009SUNDAY
12/27/2009SUNDAY
Regards
Thiyag -
Hello ,
I would like to know more about how infosets are used in LDB's.
I was recently testing a LDB of Hedge Mgmt. i selected seveal param's and found that the order of fields in the query really makes a diff. LDB's are very senstive to ordering ?? Can any one give me more info on how Infosets and SAP queries work ?
Regards,
SriHi,
look here:
http://help.sap.com/saphelp_47x200/helpdata/en/d2/cb4138455611d189710000e8322d00/frameset.htm
http://help.sap.com/saphelp_47x200/helpdata/en/d2/cb43b2455611d189710000e8322d00/frameset.htm
A.
Message was edited by:
Andreas Mann -
hi friends,
i have query like below.
select d.child_id,d.location,d.parent_id
from btstarget.am_tm_chnl_prtnr_hrchy d , btstarget.am_tl_user_hrchy e
where d.child_id =e.fk_child_id
AND e.fk_ent_mst_customers = 13754
above query showing me output like below.
child_id location parent_id
1 Mumbai-1 3
2 NRI 4
3 NRI 2
4 Delhi 3
5 Delhi-1 4
6 Delhi-2 4
i wanted to show like below.
Location.
Mumbai-1
NRI
Delhi.Hi Rajnish,
Provided data is incorrect as it falls into an infinite loop.
Level 1 ----------------2---------------- 3------------------4--------------------5
1 Mumbai-1 3-----> 3 NRI 2------> 2 NRI 4---------> 4 Delhi 3------> 3 NRI 2
Level 5 and 2 are same so an infinite loop.
I modified the data & sample code is like this
with t as
(select 1 child_id,'Mumbai-1' location,3 parent_id from dual
union all select 2,'NRI',4 from dual
union all select 3,'NRI',4 from dual
union all select 4,'Delhi',5 from dual
union all select 5,'Delhi-1',6 from dual
union all select 6,'Delhi-2',null from dual
) select location from t connect by prior parent_id=child_id start with child_id=1
SQL> /
LOCATION
Mumbai-1
NRI
Delhi
Delhi-1
Delhi-2Edited by: Lokanath on २८ दिसंबर, २०१० २:३५ अपराह्न -
Hi,
my requirement is to create a screen layout like VA05 and add the extra radiobutton for that
and print the values corresponding to that radiobutton .. how we can write the code in SQ02
i am not that much familiar in ABAP Query can any help me
ManojaHi..
Report Program is better..using function module GUI_DOWNLOAD.
EX:
SELECT * FROM SPFLI into table t_spfli.
<b>CALL FUNCTION 'GUI_DOWNLOAD'</b>
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\RAM\TST.TXT'
FILETYPE = 'ASC'
FIELD_SEPERATOR = 'X'
TABLES
TABLE = T_SPFLI.
<b>Report writer:</b>
Why List & Label as Report Writer?
With the reporting tool List & Label you enhance your applications with reports, lists, diagrams, forms, labels, mail merges and web reporting with only a few lines of code. It takes only one step to add classic printing options, intelligent preview and comprehensive export functions. Moreover, you add real value to your application by integrating the List & Label Designer: provide your end users with the opportunity to create custom print projects. -
hi friends,
i facing issues in update query can i update multiple row.
query
update m_ent_pageurl
set url=(select replace(url,'PolicyManagerV2','employees') from m_ent_pageurl)
where pk_pageurl_id in (1,2,3,4,5)
i want update 5 records at a time.but its giving me error like "Single row subquery return".
is there any way to do date in update query only.
--rajnishtry this
update m_ent_pageurl a
set url=(select replace(url,'PolicyManagerV2','employees') from m_ent_pageurl b where b.pk_pageurl_id=a.pk_pageurl_id)
where pk_pageurl_id in (1,2,3,4,5) -
Hi,
What is infoset query in generic extraction? Why and when do we go for it? What is the advantage of it?
Any help would be appreciated the sdn way.
Regards,
Jon.Hi ,
<b>What are Info sets ?</b>
An InfoSet is a special view of a set of data (logical database, table join, table, sequential file). It serves as the data source for SAP Query. An InfoSet determines which tables or fields of these tables are referenced in an evaluation. InfoSets are usually based on logical databases.
InfoSets are only available if you have created them globally, independent of a client. You set this global area in the initial screen of InfoSet maintenance under Environment Work Areas.
If you are using an InfoSet to extract data, the system first collects all data in the main memory. The data is transferred to the BI system in packages using the Service API interface. The size of the main memory is therefore important with this type of extraction. It is suitable for limited datasets only.
When an InfoSet is created, a data source is selected in an application system. Since a data source can have a large number of fields, fields can be combined into logical units; the functional groups. Functional groups are groups of several fields that form a logical unit within an InfoSet. Any fields that you want to use in an extraction structure have to be assigned to a functional group. In generic data extraction using an InfoSet, all the fields of all functional groups for this InfoSet are available.
The relevance of SAP Query to BI lies in the definition of the extraction structure by selecting fields of a logical database, a table join or other datasets in an InfoSet. This allows you to use generic data extraction for master or transaction data from any InfoSet.
A query is generated for an InfoSet. The query gets the data and transfers it to the generic extractor.
<b>Extraction Step By Step :</b>
<b>R3 Side :</b>
SQ02 -> Create info set , Generate .
RS02 -> Create data source by giving info set name .
RSA3 -> Check the data source for entries.
<b>BW Side :</b>
Replicate DS.
Assign DS for IS .
Create TR , Activate
Create Cube , UR .
Create Info Pack ,Schedule the extraction .
Hope this helps..
Message was edited by:
Renjith Kumar -
Hi
I have a table with the following structure
col1 col2 col3 col4
A Null X Null
A X Null Null
A Null Null Y
I require the below output
A X X Y
Could you please help writing a sample query
Best Regards
Sridsridha wrote:
Hi
I have a table with the following structure
col1 col2 col3 col4
A Null X Null
A X Null Null
A Null Null Y
I require the below output
A X X Y
Try this.
select col1, max(col2), max(col3), max(col4) from table1 group by col1 -
Hi,
I need to develop a query with Purchase requisition to PO delivery history. For this we have 22 feilds.
Among them 18 fields we have identified in Bw(Multiprovider). for remaining our MM and abap team developing logics.
So after enhancing them in R/3 side how to proceed. this is 3.x flow and am new to this. so need u r help.
After enhancing fields how to modify the flow in bw ?? Thanks in advance.
Br,
RaviAny reply??
-
Reg:Infoset query Uploading..
Hi all,
I am facing problem in infoset query uploading.We have some queries in Old system we need them in ECC.I am using program RSAQR3TR to download and upload the queries (not import and export).
I am able to download but while uploading i am getting an error..
'F Error when generating transport dataset'....
Any inputs guys..
Thanks in advance,
KK
Edited by: krishna kishore on Apr 24, 2009 9:56 PM
Edited by: krishna kishore on Apr 27, 2009 4:02 PMHi all,
I am facing problem in infoset query uploading.We have some queries in Old system we need them in ECC.I am using program RSAQR3TR to download and upload the queries (not import and export).
I am able to download but while uploading i am getting an error..
'F Error when generating transport dataset'....
Any inputs guys..
Thanks in advance,
KK
Edited by: krishna kishore on Apr 24, 2009 9:56 PM
Edited by: krishna kishore on Apr 27, 2009 4:02 PM
Maybe you are looking for
-
IPhone 4 Stuck on 'Connect to iTunes' screen.
I.. was kinda trying to get rid of the iOS 7 update files which were automatically downloaded to my iPhones following this discussion page: https://discussions.apple.com/thread/5379403?start=0&tstart=0 Following the instructions posted there, I manag
-
How can I get Adobe Acrobat 9 Standard installed againg into my notebook Vaio windows7 Pro?
This Adobe software was preloaded in my Notebook and was unistalled by accident. I've tried to install it using my notebook tools however it doesn't work. I really appreciate your help. Best Regards, Oscar.
-
Data Block, Extents, and Segments in Datafiles
I'm trying to understand the relationship of Data Blocks, Extents, and Segments in Datafiles. What is the simpliest explanation for their relationships.
-
Enabling Suite Color Management on Bridge
When I go into Edit >>>Creative Suite Color Settings I receive an error window informing me that it hasn't been enabled and at least one qualifying product needs to be launched at least once to enable Suite Color Management. I have opened Illustrat
-
My mac mini sudenly frozed and won't boot in again.
while i surf the net with safari, safari just close itself and the screen was dim with a message to restart . after i do restart my mac mini it can't log in to os and fail to install new os from cd. i did test hardware and it error 4MEM/1/40000000 .