Without select upto
Hi ,
I have one internal table in where i am getting some 5000 records from ztable , now from this 5000 records i want to take only few records i.e for example my internal table is
companycode currency
1001 25$
1001 50$
and in the last rows i have
2000 45$
2000 45$
now wht i want is without using select upto i want to select 5 records with 1001 company code and 5 records from 2000.
Please help me out
cheers,
bhavana
Hi Bhavana ,
what you do is make use of at new command in loop endloop.
and while doing that use counter and move data to another internal table till counter is <= 5 and then use that new internal table for further use .
such as
sort itab by company code
data : cnt type i value 1 .
loop at itab .
at new companycode .
while cnt <= 5 .
move corresponding fields of itab to itab1 .
append itab1 .
clear itab1 .
endwhile .
clear itab .
endloop.
do changes according to your requirment .
Regards
Deepak.
Similar Messages
-
Difference between select single * & select upto 1 rows
difference between select single * & select upto 1 rows
Hi,
According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
Select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
The best way to find out is through sql trace or runtime analysis.
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
Mainly: to read data from
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Mainly: to check if entries exist.
Select Single
You need to mention all the key fields of the table.
No END SELECT required.
More performance compared to upto 1 row.
Where as UP to 1 row.
YOu can use if you do not have all the primiary key fields available.
END SELECT requeired.
Since all keys are not passing, possiblities of have other rows which satisfies the condition.
Select Statement with EndSelect is a loop, which in a single run retrieves a single Record. This Record has to be stored in a Work Area and then appended into an Internal Table.
Select Statements without EndSelect is not a loop and it retrieves the whole Record set matching the Criteria in a single shot and has to be Stored in an Internal Table Directly.
The most important thing to remember about the SELECT SINGLE is
There are several things to remember:
1) It retrieves only one row
2) It does not need an ENDSELECT statement
3) THE FULL KEY OF THE TABLE MUST BE INCLUDED IN
THE WHERE CLAUSE OF THE SELECT STATEMENT
Regards -
frends please provide me the detail document and scenarios where we use with examples about select single and select upto n rows ?
Hi,
A lot of people use the SELECT SINGLE statement to check for the existence of a value in a database. Other people prefer to use the 'UP TO 1 ROWS' variant of the SELECT statement.
So what's the difference between using 'SELECT SINGLE' statement as against a 'SELECT .... UP TO 1 ROWS' statement ?
If you're considering the statements
SELECT SINGLE field INTO w_field FROM table.
and
SELECT field INTO w_field FROM table UP TO 1 ROWS. ENDSELECT.
then looking at the result, not much apart from the extra ENDSELECT statement. Look at the run time and memory usage and they may be worlds apart.
Why is this ?? The answer is simple.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Get the difference ??
If not, here is a good example, credit for this example goes to Richard Harper, a friend of mine on sapfans.com :
Create a Ztable called ZDifference with 2 fields in it, MANDT of type MANDT and POSNR of type POSNR. Make sure both of these are keys. Also create a table maintenance dialog for it (SE11->Utilities->Table Maintenance Generator). Fill the table with ten rows 000001-000010.
Then run the program shown below:
Report Z_Difference
Message-id 38
Line-Size 80
Line-Count 0
No Standard Page Heading.
Start-Of-Selection.
Data: w_Single type Posnr,
t_Rows type standard table of Posnr
initial size 0
with header line.
Select single Posnr
from zDifference
into w_Single.
Select Posnr
into table t_Rows
from zDifference
up to 1 rows
order by Posnr descending.
Write :/ 'Select single:', w_Single.
Skip 1.
Write :/ 'Up to 1 rows :'.
Loop at t_Rows.
Write t_Rows.
EndLoop.
You should see the output:
Select single: 000001
Up to 1 rows : 000010
The first 'SELECT' statement selected the first record in the database according to any selection criterion in the 'WHERE' clause. This is what a 'SELECT SINGLE' does. The second 'SELECT' has asked the database to reverse the order of the records before returning the first row of the result.
In order to be able to do this the database has read the entire table, sort it and then return the first record. If there was no ORDER BY clause then the results would have been identical (ie both '000001') but the second select if given a big enough table to look at would be far slower.
Note that this causes a problem in the Extended Program Check if the full key is not specified in a 'SELECT SINGLE'. Replacing the 'SELECT SINGLE' by an "UP TO 1 ROWS" will give the same exact results without any warning but the program will run slower and consume more memory. This is a good example of a warning that we should ignore... considering you are sure of what you are doing !!
Regards,
Ferry Lianto -
Select Single & Select upto -- req when to use?
Hi Guys!
Can u pls tell me when to use select single * & when to use select upto 1 rows. with eg.
Thanks.According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
Select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
The best way to find out is through sql trace or runtime analysis.
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
Mainly: to read data from
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Mainly: to check if entries exist.
Select Single
You need to mention all the key fields of the table.
No END SELECT required.
More performance compared to upto 1 row.
Where as UP to 1 row.
YOu can use if you do not have all the primiary key fields available.
END SELECT requeired.
Since all keys are not passing, possiblities of have other rows which satisfies the condition.
Select Statement with EndSelect is a loop, which in a single run retrieves a single Record. This Record has to be stored in a Work Area and then appended into an Internal Table.
Select Statements without EndSelect is not a loop and it retrieves the whole Record set matching the Criteria in a single shot and has to be Stored in an Internal Table Directly.
The most important thing to remember about the SELECT SINGLE is
There are several things to remember:
1) It retrieves only one row
2) It does not need an ENDSELECT statement
3) THE FULL KEY OF THE TABLE MUST BE INCLUDED IN
THE WHERE CLAUSE OF THE SELECT STATEMENT
to say in simple
SELECT SINGLE:
1. Select single is based on PRIMARY KEY
2. It will take the first record directly without searching of all relevant records.(Though you have lot of records for given condition)
SELECT UPTO 1 ROW :
It will check all records for given condition and take the first record .
It means in select single no searching, where as other searching.
Therefore, select single more efficient than UPTO 1 ROW. -
Select single * & Select * upto one row
What is the difference between Select single * & Select * upto one row?Performance wise which is a better one?
Hi,
According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
Select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
The best way to find out is through sql trace or runtime analysis.
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
Mainly: to read data from
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Mainly: to check if entries exist.
Select Single
You need to mention all the key fields of the table.
No END SELECT required.
More performance compared to upto 1 row.
Where as UP to 1 row.
YOu can use if you do not have all the primiary key fields available.
END SELECT requeired.
Since all keys are not passing, possiblities of have other rows which satisfies the condition.
Select Statement with EndSelect is a loop, which in a single run retrieves a single Record. This Record has to be stored in a Work Area and then appended into an Internal Table.
Select Statements without EndSelect is not a loop and it retrieves the whole Record set matching the Criteria in a single shot and has to be Stored in an Internal Table Directly.
The most important thing to remember about the SELECT SINGLE is
There are several things to remember:
1) It retrieves only one row
2) It does not need an ENDSELECT statement
3) THE FULL KEY OF THE TABLE MUST BE INCLUDED IN
THE WHERE CLAUSE OF THE SELECT STATEMENT
Regards -
Diff between select single and select upto 1 rows.
Hello aLL,
PL tell what is technical diff between select single and select upto 1 rows and how it is affecting the performance.
RushikeshHi
Knowing when to use SELECT SINGLE or SELECT ... UP TO 1 ROWS
A lot of people use the SELECT SINGLE statement to check for the existence of a value in a database. Other people prefer to use the 'UP TO 1 ROWS' variant of the SELECT statement.
So what's the difference between using 'SELECT SINGLE' statement as against a 'SELECT .... UP TO 1 ROWS' statement ?
If you're considering the statements
SELECT SINGLE field INTO w_field FROM table.
and
SELECT field INTO w_field FROM table UP TO 1 ROWS. ENDSELECT.
then looking at the result, not much apart from the extra ENDSELECT statement. Look at the run time and memory usage and they may be worlds apart.
Why is this ?? The answer is simple.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Get the difference ??
If not, here is a good example, credit for this example goes to Richard Harper, a friend of mine on sapfans.com :
Create a Ztable called ZDifference with 2 fields in it, MANDT of type MANDT and POSNR of type POSNR. Make sure both of these are keys. Also create a table maintenance dialog for it (SE11->Utilities->Table Maintenance Generator). Fill the table with ten rows 000001-000010.
Then run the program shown below:
Code:
Program: Z_Difference
Purpose: A program that demonstrates the difference
between SELECT SINGLE and SELECT UP TO n ROWS.
This program requires the data table Z_DIFFERENCE
to have been created according to the structure
outlined in the text above and populated with
at least 10 records.
Creation Date: 21/04/2004
Requested By:
Reference Doc:
Author: R Harper
Modification History:
Date Reason Transport Who
Report Z_Difference
Message-id 38
Line-Size 80
Line-Count 0
No Standard Page Heading.
Start-Of-Selection.
Data: w_Single type Posnr,
t_Rows type standard table of Posnr
initial size 0
with header line.
Select single Posnr
from zDifference
into w_Single.
Select Posnr
into table t_Rows
from zDifference
up to 1 rows
order by Posnr descending.
Write :/ 'Select single:', w_Single.
Skip 1.
Write :/ 'Up to 1 rows :'.
Loop at t_Rows.
Write t_Rows.
EndLoop.
You should see the output:
Select single: 000001
Up to 1 rows : 000010
The first 'SELECT' statement selected the first record in the database according to any selection criterion in the 'WHERE' clause. This is what a 'SELECT SINGLE' does. The second 'SELECT' has asked the database to reverse the order of the records before returning the first row of the result.
In order to be able to do this the database has read the entire table, sort it and then return the first record. If there was no ORDER BY clause then the results would have been identical (ie both '000001') but the second select if given a big enough table to look at would be far slower.
Note that this causes a problem in the Extended Program Check if the full key is not specified in a 'SELECT SINGLE'. Replacing the 'SELECT SINGLE' by an "UP TO 1 ROWS" will give the same exact results without any warning but the program will run slower and consume more memory. This is a good example of a warning that we should ignore... considering you are sure of what you are doing !! -
How delete on ipad 2 2000 emails without selecting one at a time?
gow can I delete over 2000 emails from my iPad 2 without selecting them one at a time?
You can't on the iPad itself, unfortunately. Your best bet is to use your computer to mass delete the emails, You can also change how far back your various email accounts sync messages to your iPad. That will significantly reduce the amount of daily emails on your device.
-
Is there a way to do a mass delete of emails without selecting each one of them individually?
Is there a way to do a mass deleye on the IPhone 4s without selecting each email individually?
No. You can tap the EDIT button, then tap a bunch of emails to select them, then tap DELETE. But you still have to tap each message.
-
Is there a way to download music from the cloud at one time without selecting each one individualy
just looking to see if all your songs in the cloud can be downloaded into your device without selecting each one individually
Hi smokea,
If you go to More>Purchased>Music>Not on this Phone>All Songs, you will see a Download All button in the top right-hand side of the screen.
(sorry about the info that was here previously)....
Cheers,
GB -
Can I send a text to a "group" contact without selecting each individual member?
Can I send a text to a "group" contact without selecting each individual member? I have a group formed in my contacts, but I still have to select each member in that group to send a text or email from my phone.
There are apps that allow you to address sms messages to groups (such as Speed Names: https://itunes.apple.com/us/app/speed-names-contacts-groups/id285124918?mt=8), but not iMessages. Perhaps this will change with a future iOS update.
The only point of having them at the moment is to allow you to limit the view to only contacts belonging to a group, so that you can more easily add the individual members of the group. But at the present time, you still have to add them individually. -
How to create a variant for a program without selection screen
Hi All,
I've created one program which takes the data from 30 tables and loads into one final table.
This program is already moved to Production.
But while creating variant it's not allowing, since the program doesn't have the selection screen.
Is there anyway where I can create a variant in production without selection screen directly as the program code is already moved to production.
Thank You,
Regards,
Karthik.ChHi ,
Are you running this program in a process chain?? -
How do I print all responses as pdf forms without selecting and printing just one response at a time?
Sorry this is not supported at this time. You can only download the responses as PDF one at a time.
You can export the response table and print the whole table but if you want to print each response individually you have to do it manually. Sorry.
Gen -
When i use view as list in finder and open a folder with many files i cant right click with mouse without selecting or highlighting a file....i just want to right click to paste an item or create a new folder...what can i do?
Thx for that im gonna try it....but is there a way to do it without using toolbar or cmd-c...? i mean using only the mouse?why does it have to highlight the file even though i click a bit next to it....?using icon view i can right click next to the folder and i wont have a problem but with list view that i prefer using it will highlight the whole row.....and i dont find free space to right click cause i got many files
-
I am trying to import photo's on i photo. It downloads all of the pictures on my camera, how do i only select the photos i want? Is there a way to do this without selecting one photo at a time? is there a way to select multiple images? thanks!
To select consecutive images click and drag the cursor over multiple thumbnails to select all at once.
To select multiple images that are randomly located hold down the Command(⌘) key and click on those images you want to select.
Or to select consecutive images from a list of images that are together hold down the Shift key and and click on the first photo you want to select and the on the last photo you want in the list.
OT -
Select Single * and Select upto one row
Hi all,
Can anybody tell me what is difference between Select single * and select upto one row?
And which one is better?
Thanks in advance.......According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
The best way to find out is through sql trace or runtime analysis.
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
Mainly: to read data from
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Mainly: to check if entries exist.
Select Single is the best one compared to UPto one rows.
Select Single will get the first record from the table which satisfies the given condition.So it will interact once with the database.
UTO 1 rows will get the list of the records for the given match and iwll show the first record from the list.So it will take time to get the record.
SELECT SINGLE VBELN from VBAK
where MATNR = '1M20'.
---Thjis will get the first matched record and will display the record
SELECT VBELN from VBAK
where MATNR = '1M20' upto 1 rows.
---Thjis will get the list of matched records and will display the first record
The Major difference between Select Single and Select UPTO 1 rows is The Usage Of Buffer for each.
Select Single will search for all the satisfied data and bring all that data into Buffer and later it will give to that data to the program.
Select UPTO 1 Rows will end the search after getting the 1st satisfied record and gives that record to the program.
Thus Select Single will take much processing time when compare with Select UPTO 1 rows.
Also
check these threads..
Difference between Select Single and Selct upto 1 row
Difference between Select Single and Select upto 1 row
Difference between select single and select upto one row
Difference between 'select single *' and 'select upto 1 rows'
difference between select single and select up to 1 rows
regards,
srinivas
<b>*reward for useful answers*</b>
Maybe you are looking for
-
I found I could not open my email within hotmail. Hotmail itself works in IE and Google Chrome so I know it is FF. I can open the account but not individual emails nor can I delete junk mail. Nothing within the hotmail window seems to work.
-
Can Not installed latest iTunes 10.5.2 for Windows XP
To System support, I am having trouble installed latest iTunes 10.5.2 for Windows XP. When I start install the exe file, I got an error message: "There is problem with this Windows Installer package. A program run as part of the setup did not finish
-
[solved] xorg 1.6 - dual-monitor not working any more
I switched to arch64 and with it came the new xorg 1.6. Now X won't start with the configuaration I used before and I can't figure out what to do about it. I want to use two monitors (laptop + external) with an Intel X4500 HD und xf86-video-intel. I
-
Problems in exporting data to Excel from WebDynpro
Hi, I'm trying to transport data to Excel using the WebDynpro Binary Cache. The table data I have has certain special characters like & , < and > . I get an XML Parse error while trying to retrieve the XML List from the Binary Cache. The detailed err
-
Modem relay or passthrough? Power meter trying to be read...
Hello Everyone! I am stuck with a problem and don't know how to proceed. Our power company has a modem (old as cold) in their power meter. We have a PRI hitting a VGW (2921 router), this VGW hands off the call to a VG204. They are negated to upgrade