Select query doubt
hello all,
i am writting this code .....first select is working fine for me as i am getting 5 entires in table itab which i am expecting...
but for second when i loop itab itab then at that time i should get one record in table itab2 out of second select query........
but as i can see while debugging i am getting that entry at third time when i am in loop.....but it again i think it overwrites with next enter and making itab2 entry as 0 at the end.....
what might be problem.
even i write append itab2.
clear itab2.
same error i am getting...(here CDPOS is cluster table..is this because of this??)..pease help
selection-screen:begin of block test with frame title new.
select-options: s_ddate for vbak-vdatu.
selection-screen:end of block test.
select avbeln avdatu bnetpr bnetwr b~matnr into corresponding fields of table itab
from vbak as a inner join vbap as b on avbeln = bvbeln where
b~matnr = 'AUP-501'
and a~vdatu in s_ddate.
LOOP AT ITAB.
select * from CDPOS into table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
ENDLOOP.
Hi,
You are completely into wrong performance..
as per your query
selection-screen:begin of block test with frame title new.
select-options: s_ddate for vbak-vdatu.
selection-screen:end of block test.
select avbeln avdatu bnetpr bnetwr b~matnr into corresponding fields of table itab
from vbak as a inner join vbap as b on avbeln = bvbeln where
b~matnr = 'AUP-501'
and a~vdatu in s_ddate.
LOOP AT ITAB.
select * from CDPOS into table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
ENDLOOP.
The second query is inside loop and its moving data into itab2 for every record in internnale table ITAB and
finally itab2 contains the last records of ITAB data if CDPOs has the data for itab-vbeln(last records).
To over come you need to write the select as beloew
select * from CDPOS APPENDING table itab2 where
OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND
FNAME = 'NETPR'.
But I suggest you to write for all entries
select <the filed you need> from CDPOS
into table itab2
for all entries in itab
where OBJECTID = ITAB-VBELN AND
TABNAME = 'VBAP' AND FNAME = 'NETPR'.
Then
loop at ITAB.
Read table itab2 with key vbeln = itab-vbeln binary search.
If sy-subrc = 0.
<Write your code, functions etc>.
endif.
endloop.
regards,
Nazeer
Similar Messages
-
Doubt In a Select Query..
Hi..
I have a Doubt in a simple Query from the table NAST.
My query is as follows:--
Select kappl
objky
kschl
parnr
parvw
nacha
vsztp
from nast into table vit_nast
where kappl = p_kappl
and kschl in s_kschl
and parnr in s_parnr
and nacha = p_nacha
and vsztp in s_vsztp.
Now I want to select all the NAST records which are either not processed (NAST-VSTAT = 0) or incompletely processed (NAST-VSTAT = 2)(the field in the table NAST is VSTAT which denotes the Processing status of message)
So Can I add both the conditions in the WHERE clause of the the above Select Query?
Is there any other optimised way I can do that?
Thanksranges: r_stat for nast-vstat.
r_stat-low = '0'.
r_stat-option = 'EQ'.
r_stat-sign = 'I'.
append r_stat.
clear r_stat.
r_stat-low = '2'.
r_stat-option = 'EQ'.
r_stat-sign = 'I'.
append r_stat.
clear r_stat.
Select kappl
objky
kschl
parnr
parvw
nacha
vsztp
from nast into table vit_nast
where kappl = p_kappl
and kschl in s_kschl
and parnr in s_parnr
and nacha = p_nacha
and vsztp in s_vsztp
<b>and vstat in r_stat.</b>
check this..
Regards
vijay -
Hai,
I have problem in my select query,
My previous select query:
SELECT rrcty
ryear
rbukrs
rzzpspid
SUM( hslvt )
SUM( hsl01 )
SUM( hsl02 )
SUM( hsl03 )
SUM( hsl04 )
SUM( hsl05 )
SUM( hsl06 )
SUM( hsl07 )
SUM( hsl08 )
SUM( hsl09 )
SUM( hsl10 )
SUM( hsl11 )
SUM( hsl12 )
SUM( mslvt )
SUM( msl01 )
SUM( msl02 )
SUM( msl03 )
SUM( msl04 )
SUM( msl05 )
SUM( msl06 )
SUM( msl07 )
SUM( msl08 )
SUM( msl09 )
SUM( msl10 )
SUM( msl11 )
SUM( msl12 )
FROM zzsl5t
INTO TABLE it_erbproj
WHERE rldnr EQ c_rldnr AND
rrcty EQ c_rrcty AND
ryear EQ v_srr_fyear AND
rbukrs EQ v_srr_ccode AND
racct EQ v_racct AND
rzzpspid IN r_zzpspid
GROUP BY RRCTY ryear RBUKRS rzzpspid.
now i want change the above select query as,
If user enters input period 03 means,
i have to select
SELECT rrcty
ryear
rbukrs
rzzpspid
SUM( hslvt )
SUM( hsl01 )
SUM( hsl02 )
SUM( hsl03 )
SUM( mslvt )
SUM( msl01 )
SUM( msl02 )
SUM( msl03 )
only, not to select all the periods.
how can i give fields dynamically.
please suggest me.
ElamaranDuplicate message. Please close this one and look at my answer Doubt in Select query.
-
i want to count the no. of employees whose endda = '31/12/9999' and stat2 = '3'.
tables are pa0000.
can anyone tell me the select query?DATA: w_noemp TYPE i.
SELECT COUNT(*) INTO w_noemp FROM pa0000
WHERE endda = '99991231'
AND stat2 = '3'. -
Select query in case of Multiple line items
Hi Gurus ,
I've a doubt in general SQL select query. I want to know , if suppose I've an internal table - itab . I've fetched G/L Account numbers 1st, based on the input selections . Next , I want to loop on those G/L accounts. However, if the G/L account has multiple line items, then I personally use this select query -- >
loop at itab.
select <field> from <table> appending corresponding fields of <itab1> where hkont eq itab-hkont.
endloop.
Now, the execution time for this query is longer than expected. The biggest problem here is, i've to sum up the totals as well. So totaling is an added load. I want to reduce the execution time of this. Kindly suggest me some good method in case u have any.
I've pasted the code which I've written , for u ppl to understand--
SELECT DISTINCT HKONT BELNR
FROM BSIS
INTO CORRESPONDING FIELDS OF TABLE OTAB
WHERE HKONT IN S_RACCT
* AND PRCTR IN P_PRCTR
AND MONAT IN S_POPER
AND BUKRS EQ P_BUKRS
AND GJAHR EQ P_GJAHR
AND PRCTR IN S_PRCTR.
***The code below takes a lot of time to execute.***
LOOP AT OTAB .
SELECT DMBTR HKONT
FROM BSIS APPENDING CORRESPONDING FIELDS OF TABLE CREDITS
WHERE HKONT EQ OTAB-HKONT
AND BELNR EQ OTAB-BELNR
AND MONAT IN S_POPER
AND BUKRS EQ P_BUKRS
AND GJAHR EQ P_GJAHR
AND PRCTR IN S_PRCTR
AND SHKZG EQ 'H'.
COLLECT CREDITS.
ENDLOOP.Hi,
First of all try to avoid doing select into corresponding fields. THis would improve the performance of the program.
Try to do a single fetch from the BSIS table . fetch the hkont, belnr, dmbtr fields in to a master internal table. Manipulate and play with the data as required. Don't hit the data base table more than once (unless it is required) . This would improve the performance of your code.
Try to code this way.
types: begin of ty_bsis,
hkont type hkont,
belnr type belnr_d,
dmbtr type dmbtr,
end of ty_bsis.
data: it_bsis type standard table of ty_bsis,
wa_bsis type ty_bsis,
select hkont belnr dmbtr
from bsis
into table it_bsis
WHERE HKONT IN S_RACCT
AND PRCTR IN P_PRCTR
AND MONAT IN S_POPER
AND BUKRS EQ P_BUKRS
AND GJAHR EQ P_GJAHR
AND PRCTR IN S_PRCTR.
Using the data availabe in the it_bsis, you can manipulate as required.
Hope this would be helpful
Regards
Ramesh Sundaram -
Select query written on view giving dump
Hi All,
I have written the following query on COAS view in my code:
SELECT aufnr bukrs INTO TABLE gt_aufnr
FROM coas
WHERE
aufnr IN r_aufrm AND
auart IN s_auart AND
autyp = c_autyp_01 AND
kokrs = c_kokrs_mbca.
When records in range r_aufrm are too many like 6000 or so it gives me a run time error on this query - DBIF_RSQL_INVALID_RSQL. Error description says size of select query is large.
Question : Is this bug coming because I am using the view. If i select the records on table AUFK (only table on which the view is created), will it rectify the problem?? I am asking this because it's in production and I cant make any change and test then and there.
Note: the range r_aufrm contains two types of records for AUFNR - 1. with sign GE and others with sign LE. So I cannot use for all entries. If I still can, please tell me how?
Thanks a looot!
Waiting for the response,
NavitaThanks All!!
I think, this range limit has caused the problem. Range limit is 999 records.
Just one question I have. At runtime when I check the number of entries in r_aufrm in the query, I get 6000 entries. So, does it allow 6000 records to enter the range variable even if it has a limit of 999. Is it the case that, in select query only it will throw a dump if records in range exceed 999??
SELECT aufnr bukrs INTO TABLE gt_aufnr
FROM coas
WHERE
aufnr IN r_aufrm AND
auart IN s_auart AND
autyp = c_autyp_01 AND
kokrs = c_kokrs_mbca.
Please clear my doubt.
Thanks a lot for ur help!!!!
Navita -
Passing parameters to select query in DB link from invoke...
I am having a DB partner link which executes the select query based on user specified parameter.
Now i have created an invoke activity and specified input[this needs to be passed to query] and output parameters[this is query result]. This invoke activity calls DB partner link in which one parameter has been created to be used in select query. So my doubt is , will DB partner link take up the input parameter of invoke activity automatically or do we need to specify any mapping for this?When you create a db partnerlink the parameter you create for your select is the input and when you create the input variable in the invoke for this partnerlink it is created with the right type for the parameter.
Create an Assign before your invoke and assign a value to the input variable you created in the invoke. That value will be passed and used as the parameter in the select.
Heidi. -
Parenthesis within a select query.
I have a doubt as whether i can include Parenthesis within a select query
as below:-
SELECT C.CITY_CODE,A.DOCUMENT_TYPE,SUM(A.INSTRUMENT_AMounT) FROM
ppbs_RECEIPT_HEADER A,ppbs_DISTRIBUTOR_MASTER C WHERE
A.DISTRIBUTOR_ID = C.DISTRIBUTOR_ID AND
( A.STATUS not in( 'CN','BO') or (A.STATUS ='CN' and a.INSTRUMENT_AMOUNT<>a.UNAPPLIED_AMOUNT))
as we do in a If condition. Please help in solving the doubt as it is urgent.No, the result is correct, but is it correct to put the parenthesises around a condition in a normal select query as we do in a 'if' condition or a sub-query. Will the condition in the query be evaluated first and then the other conditions in the normal select query.
-
Hi Friends,
my code is :
itab-vbeln = bseg-vbeln.
if not itab-vbeln is initial.
select single vbeln inco1 inco2 into ( itab-vbeln itab-inco1 itab-inco2)
from vbrk where vbeln = itab-vbeln.
appned itab.
note : here inco1 inco2 are incoterms
my question is can we direct move the values of bseg-vbeln into itab-vbeln. ???
and i am generating the report with one varient , when i debug this report the
there is no value in bseg-vbeln. it is showing null value.thats why my select query is not working..but i want execute this select query final.
in output i want display the inco1 inco2 data.(incoterms)
any help please.
urgent.
regards,
vijay.Hi Vijay,
First you need to check it out whether <b>itab-vbeln = bseg-vbeln</b> is in with in LOOP or not (<b>if ITAB is intenal table</b>)
if itab is internal table you should write above statement with in loop, and also check it out in debug mode why bseg-vbeln value is not coming.
and one more thing you need to make small correction in ur code use ',' .
select single vbeln inco1 inco2 into ( <b>itab-vbeln, itab-inco1, itab-inco2</b>)
from vbrk where vbeln = itab-vbeln
Note: when ever use select single u should pass values into work area, dont use internal table .
<b>if you have more doubts just send your entire code then i will rewrite it.</b>
<b>Reward with points if useful.</b>
Regards,
Vijay Krishna -
Long Time for execution of select query
Hi,
I have a select query
select * from Table where Time1 and time 2;
The table has a large no. of colums than rows. So the query taking a lot of time to execute.
Is there any way we can reduce the time taken by the query.
Thanks
Jit
Message was edited by:
user637843select * from Table where Time1 and time 2;I doubt this query run for long time. More or less 1 millsecond, the time for Oracle to check the query syntax and return errors.
Nicolas. -
Select query inside PL/SQL block.
Hello Experts,
I am just a beginner with PL/SQL.
If I write a select query from client like SQL dev and fire it against a database, it gives me result.
Eg: select * from employee;
Now when I use the same Query inside a PL/SQL block suppose:
Declare
begin
select * from employee;
end;
This gives error on execution, mentioning that an INTO is expected etc...
I have doubts here:
1. Can't I use a plain select inside a PL/SQL block (if so why?)
I know this is kind of very basic question, I tried searching this on the forum but could not find the thread, please redirect me to the link if this is already answered.user8578271 wrote:
Hello Experts,
I am just a beginner with PL/SQL.
If I write a select query from client like SQL dev and fire it against a database, it gives me result.
Eg: select * from employee;
Now when I use the same Query inside a PL/SQL block suppose:
Declare
begin
select * from employee;
end;
This gives error on execution, mentioning that an INTO is expected etc...
I have doubts here:
1. Can't I use a plain select inside a PL/SQL block (if so why?) Because when you run a query in a tool like SQL Developer, or SQL*Plus or TOAD etc. then it opens up a cursor and fetches the data into internal memory structures before displaying it, and that is all done automatically and hidden from you. In PL/SQL, there is no interface to display the results of SQL queries, so you have to specifically tell it what to put the data into.
The syntax is (in basic terms)...
SELECT column1, column2... columnX
INTO variables or record structure
FROM ...Though that can only select a single row of data. If your query returns more than 1 row it will give a TOO_MANY_ROWS exception. If your query returns no rows you will get a NO_DATA_FOUND exception.
If you need to select multiple rows into variables etc., then you would need to "BULK COLLECT" into a collection/array structure, though this takes up valuable memory on the server and shouldn't be used unless necessary (and you understand the implications of doing it). -
Hello ABAP Gurus..
I dont have much idea about ABAP side but we have a requirement in our project where we need to fetch huge amount of data from backend and display it on the WebDynpro Java screen. I was going through the paging solution provided by SAP so that we can minimize the Java AS server memory and performance issues.
I was wondering if we can get the selective no of records from tables based on pagesize. What I mean here:
Suppose total no of record that I want to display on the WebDynpor screen is say 10000.
PageSize of my webdynpro table = 100 records
Now Can I write a select query (or is there any other way) to get data from backened table pagewise like at first hit I get records from 1 - 100, second hit I should get records from 101 - 200 , third hit from 201 - 300.. and so on till the lat record?
Is it possible? If yes, how can I acheive this?
-AbhinavHey Rob ,
Thanks for quick response.
However, I have a doubt here.
Suppose my PACKAGE SIZE is 100 and I fetch first 100 records in first RFC call, then how do i fetch records from 101 - 200 in the subsequent RFC call?
Also, I guess SELECT .. ENDSELECT has its own performance problems
- Abhinav -
Questions on the most efficient select query..
What is the difference between the two select query & please explain y is the 2nd select query more efficient??
DATA: MAX_MSGNR type t100-msgnr.
MAX_MSGNR = '000'.
SELECT * FROM T100 INTO T100_WA
WHERE SPRSL = 'D' AND
ARBGB = '00'.
CHECK: T100_WA-MSGNR > MAX_MSGNR.
MAX_MSGNR = T100_WA-MSGNR.
ENDSELECT.
DATA: MAX_MSGNR type t100-msgnr.
SELECT MAX( MSGNR ) FROM T100 INTO max_msgnr
WHERE SPRSL = 'D' AND
ARBGB = '00'.Hi,
First never use Check statement in the Select.
Next thing Select ... end select.
Coming to ur question In case of first select it will fetch each record from the data base and compares that record value with the variable(MAX_MSGNR) and assigns the value to the variable. And this process will continue till the select reads all the records of the data base. Also these operations happens on the data base server. SO this query not only affect ur program but also others who is accessing the same data base.
Second query is most efficient because of the aggregate function MAX. Here it will fetch all the records in single go and checks the max value for that column using
optimising algorithm. So number of checks, assignments(single assignment) and fetches will be less compared to first select. This is the main reason. Hope this clarified ur doubt.
Another thing is in first query we are selecting all the fields where as in second we are selecting only one field(required)
Thanks,
Vinod.
Edited by: Vinod Kumar Vemuru on Mar 13, 2008 4:55 PM -
Select query is correct or not
hai to all iam software trainee in core java
i have doubt on select query please give gudiance
select * from StudentDetails where Admnno=' "
i connected my application with ms-access db using jdbc-odbc
my question is i want retrieve data from ms-access so i use this select query is it correct or not
because
select * from StudentDetails this query working but it's working with where condition please help and try to understand my question
In advanced
thanks("select * from StudentDetails where Admnno ='' "+Admnno+"'")Is Admnno a numeric or character field? Either way, that syntax looks wonky.
For a numeric field:("select * from StudentDetails where Admnno = " + Admnno)and for a character field("select * from StudentDetails where Admnno = '" + Admnno + "'")db
Use code tags to post codes -- [code]CODE[/code] will display asCODEOr click the CODE button and paste your code between the tags that appear. -
Hi Experts,
I am having a select query in which I am using a variable in the where condition but it is giving error. Please suggest how to use variable in the select query.
The query I am using is a s below.
select * from zexc_rec into table it_ZEXC_REC
where
LIFNR in S_LIFNR and
DOCNO in S_DOCNO and
DOCTYP in doc_typ and
DATE1 in S_DATE1 and
MATNR in S_MATNR.
Here doc_typ is a variable.
Thanks.Rahul,
use RANGES type variable instead of variable . It acts as a select-options variable. Thn use this variable in SELECT query with IN.
Eg :
RANGES r_t510 FOR t510-lgart.
r_t510-low = '1600'.
APPEND r_t510.
r_t510-low = '3190'.
APPEND r_t510.
Note : can be use SIGN, OPTIONS properties too in RANGES type.
More deatils go through on HELP of RANGES
Rgds,
Ranjith
Maybe you are looking for
-
Not connecting to airport_express
Airport Express shows up in wi-fi menu but I am unable to select it. Everytime I select it, Airport Utility 6 pops up and says I need 5.6. I have it but I can't select The express without 6 starting up. OS X 10.7.4 Whaaaaaa!
-
Additional content downloads in Logic not showing up in library
I am trying to download and install the additional content downloads in Logic which from what I understand includes Jam Packs. I have downloaded and installed everything multiple times but cannot see it appear in the Logic library and cannot use them
-
Problems referencing a primary key field in a master-detail
Hello, I am making an application where I have a master-detail page. In the detail section it is possible to add new rows using the standard "Add row"-button that the wizard creates. The detail section has a column with a link in it. This link leads
-
SAP Enterprise Connector and service....
Hi everyone, After creating, via the plugin "SAP Enterprise Connector", a proxy pointing on a BAPI, how can I create a service for this (and a web service). I know that you can create a web service directly using ABAP transaction se37. But our SAP ve
-
im working in a proyect, that consist in send data to other db server that is not on the r3 database server, both database server are running on SQL Server 2000. The version of sap is 46b. S.O. Windows 2000 SERVER THe secondary database is in Window