Select query like For all Entries
Hi,
I have a requirement like:
I need to extract data (BKTXT) from table BKPF based on some criteria, into one internal table and I need to query on REGUP table for the above data, the selection criteria on REGUP as follows:
BKTXT(Document Header Text with 25 Char) is a combination of DATE and character string.
Ex: bkpf-bktxt = 20060710-PL02 (YYYYMMDD)
it is like LAUFD + LAUFI (of table REGUP)
i.e: LAUFD (REGUP) = 07/10/2006 (MM/DD/YYYY) and LAUFI(REGUP) = PL02
here I am thinking to use a select query on REGUP using FOR ALL ENTRIES of table i_bkpf..
How can I change the date format YYYYMMDD to MM/DD/YYYY for my requirement?
(( Run-on Date (REGUP-LAUFD) = the first 8 characters in the Document Header Text (BKPF- BKTXT) in MM/DD/YYYY date format (e.g. 07/10/2006)
Run ID (REGUP-LAUFI) = the 10th character through the 15th character in the Document Header Text (BKPF- BKTXT)
It is not possible to do in the way you are thinking of doing. "For all entries" requires you to have the itab table field and the database table field to have the same type and length. So something like below <u>will not work</u>.
TABLES: regup.
DATA: BEGIN OF itab OCCURS 0,
text LIKE bkpf-bktxt.
DATA: END OF itab.
DATA: BEGIN OF itab_regup OCCURS 0.
INCLUDE STRUCTURE regup.
DATA: END OF itab_regup.
SELECT * INTO TABLE itab_regup
FROM regup FOR ALL ENTRIES IN itab
WHERE laufd = itab-text+0(8).
If you run this code, you will get an error as follows:
<i>"When using the addition "FOR ALL ENTRIES IN itab", the fields "LAUFD" and "ITAB-TEXT+0(8)" must have the same type and length."</i>
Similar Messages
-
Performance issue with select query and for all entries.
hi,
i have a report to be performance tuned.
the database table has around 20 million entries and 25 fields.
so, the report fetches the distinct values of two fields using one select query.
so, the first select query fetches around 150 entries from the table for 2 fields.
then it applies some logic and eliminates some entries and makes entries around 80-90...
and then it again applies the select query on the same table using for all entries applied on the internal table with 80-90 entries...
in short,
it accesses the same database table twice.
so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
is around 80-90 entries too much for using "for all entries"?
the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
i really cant find the way out...
please help.chinmay kulkarni wrote:Chinmay,
Even though you tried to ask the question with detailed explanation, unfortunately it is still not clear.
It is perfectly fine to access the same database twice. If that is working for you, I don't think there is any need to change the logic. As Rob mentioned, 80 or 8000 records is not a problem in "for all entries" clause.
>
> so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
>
It is not clear what you tried to do here. Did you try to bring all 20 million records into an internal table? That will certainly cause the program to short dump with memory shortage.
> the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
>
That is fine. Actually, it is better (performance wise) to do much of the work in ABAP than writing a complex WHERE clause that might bog down the database. -
Select SUM in FOR ALL ENTRIES Select Query
Hi ,
I am using for all entries select statment ,can any one guide me how can i use SUM in the select statment with for all entries .
Regards,
VeeraHi,
THis is not possible using for all entries.
Thanks,
Sriram Ponna. -
Select ... for all entries problem
Hi,
I'm making select statements to BKPF and BSEG, but I can't do an inner join between this two table because BSEG it's a cluster table so I have to do a SELECT... FOR ALL ENTRIES, but in SE16 I make the same query that I have writen in my program as shown below,
SELECT BUKRS BELNR GJAHR BUDAT MONAT
FROM BKPF INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE BUKRS = 'XXX'
AND GJAHR = '2005'
AND BELNR = '0000000250'. "just for proof
AND MONAT = '10'
The above query returns me 1 row in program and in SE16 and then I make the next query for BSEG to do the join
SELECT BUKRS BELNR GJAHR BSCHL SHKZG WRBTR HKONT
FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
and gjahr = it_bkpf-gjahr
and belnr = it_bkpf-belnr.
this query returns 897 rows and in SE16 this same query returns 901 rows
Why SELECT...FOR ALL ENTRIES brings me less rows affected by the query in SE16
Thanks for your help!!Hi,
Please use the following code for selcting the exact number of rows.
IF it_bkpf[] IS NOT INITIAL.
SELECT *
FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
and gjahr = it_bkpf-gjahr
and belnr = it_bkpf-belnr.
ENDIF.
Instead of * ,you can specify the exact fields required along with all the key fields as selection fields.Also it is must to check the condition it_bkpf[] IS NOT INITIAL before using the statement FOR ALL ENTRIES IN it_bkpf.Suppose if this condition is not used and if it_bkpf is initial,it will fetch all entries from the table.
Reward if helpful.
Regards,
Aravind -
Make this query into for all entries
Hello Experts,
please change this query into for all entries to increase performance
loop at itab1.
SELECT single b~vtext INTO itab2
FROM vbkd AS a
INNER JOIN tvkggt AS b
ON akdkg1 = bkdkgr
WHERE a~vbeln EQ itab1-vbeln_vauf
AND a~posnr EQ itab1-posnr_vauf.
endloop.
Thank you so much for all the replies.as I write again and again, then performance is mainly increased but correct index usage
SELECT single b~vtext
INTO itab2
FROM vbkd AS a
INNER JOIN tvkggt AS b
ON ..... spras ???
bkdkgr = akdkg1
WHERE a~vbeln EQ itab1-vbeln_vauf
AND a~posnr EQ itab1-posnr_vauf.
You access vbkd with the primary key vbeln and posnr
and then you switch to tvkggt where you need spras and kdgr for the primary key
With spras you statement is incorrect you get one text it is unclear in which language,
it might be that there is onyl one, but still you *** it to the statement to use the index.
spras = sy-langu might be o.k.
I.e.
IF NOT ( itab1 is initial ).
SELECT single b~vtext
INTO itab2
FROM vbkd AS a
INNER JOIN tvkggt AS b
ON b~spras = sy_langu
b~kdkgr = a~kdkg1
FOR ALL ENTRIES in itab1
WHERE a~vbeln EQ itab1-vbeln_vauf
AND a~posnr EQ itab1-posnr_vauf.
ENDIF.
Siegfried -
Facin problems in the 'Select... for all entries'
I am facing problem with this piece of code, please share ur thoughts on it. I have specified the inputs.
I am extracting the open items from the BSIS table for specified 3 account number.
Inputs to the prg:
field No. of values
r_bukrs 1
r_hkont 2
r_blart 6
r_budat date range of 1 yr
r_bldat nil
v_tosdef contain 1 account number
" In each FI document posted, one line will have the 'v_tosdef' account number and one account from the 'r_hkont' values."
So will this query efficient.
SELECT bukrs
hkont
gjahr
belnr
budat
bldat
xblnr
blart
shkzg
dmbtr
FROM bsis
INTO TABLE i_bsis
WHERE bukrs IN r_bukrs " Company code
AND hkont = v_tosdef " Account number
AND budat IN r_budat " Posting date
AND bldat IN r_bldat " Document date
AND blart IN r_blart. " Document type
IF sy-subrc <> 0.
MESSAGE i003.
STOP.
ENDIF.
*@ Collecting the BELNR & GJAHR From the extracted records
li_bsis[] = i_bsis[].
SORT li_bsis BY bukrs gjahr belnr.
DELETE ADJACENT
DUPLICATES FROM li_bsis
COMPARING bukrs gjahr belnr.
IF NOT li_bsis[] IS INITIAL.
SELECT bukrs
hkont
gjahr
belnr
budat
bldat
xblnr
blart
shkzg
dmbtr
FROM bsis
APPENDING TABLE i_bsis
FOR ALL ENTRIES IN li_bsis
WHERE bukrs = li_bsis-bukrs " Company code
AND hkont IN r_hkont " Account number
AND gjahr = li_bsis-gjahr " Fiscal year
AND belnr = li_bsis-belnr. " Document num
BSIS table size around 86GB
primary index size aroung 33GB
and the index quality is 54%
the CBO shows less cost, but the actual runs takes too much disk read's / bgets..
Message was edited by:
SandyHi Sandy,
You indicated the size of the tables and index, what is the total number of records in your BSIS?
In your range tables, make sure they are postive formed.
Ex. r_bukrs : I EQ '1001', and not I NE '1000'.
You should consider coding your statements to check for input for bldat, code it with r_bldat and then another set without. It should be better performance to not have empty where conditions. So two routines, Selects with bldat and without.
Don't know if you have a Basis person to help analyze the performance, but you should look at the indexes in BSIS. You may have several indexes that contain some of your input fields but they may be spread across several indexes or there may be none. But say you have 5 indexes and it happens that just one of your parameters are in each of those indexes. Well, it can only use one index so while you think you are providing alot of parameters to help performance only one field is being used to access the index. What you need to do then is to find an index that has the most fields in your where clause and see if you can add to that, so long it's not an SAP index. If it's a z index consider adding additional fields to it, or consider creating a new index.
You can at least analyze the first Select in your DEV client. Run a trace, ST05 and then execute your code. It will show you which index it has used if any.
Also, look at the query values it is passing to the database. You said you get 6 M records on the first Select. This just seem like a lot of records, which is for just one account number (v_tosdef) along with the other parameters. I'm wondering if there's a problem with your input data. With 6M in your first table, your FOR ALL ENTRIES statement will be executed 1.2 million times. Tyically the database interface breaks down your Select-For All entries statement into 5 records per query. Again, run ST05 and you will see this.
In SE16, on your BSIS table, what is your count of records if you enter only the account number?
As a test, you might want to try entering all your parameters in SE16, run ST05 to trace the SQL to see what it is doing. You may have to kill your SE16 session or it may time out on you. You can stop your ST05 trace before your SE16 finishes and it will still show how SAP is going after the data and what index it used.
Let me know if this helped any.
Regards,
Filler -
How does select stmt with for all entries uses Indexes
Hello all,
I goes through a number of documents but still confused how does select for all entries uses indexes if fields are not in sequences. i got pretty much the same results if i take like two cases on Hr tables HRP1000 and HRP1001(with for all entries based upon hrp1000). Here is the sequence of index fields on hrp1001 (MANDT, OTYPE, OBJID, PLVAR, RSIGN, RELAT, ISTAT, PRIOX, BEGDA, ENDDA, VARYF, SEQNR). in second case objid field is in sequence as in defined Index but i dont see significant increase in field even though the number of records are around 30000. My question is does it make a differrence to use field sequence (same as in table indexes) in comparison to redundant field sequence (not same as defined in table indexes), secondly how we can ge tto know if table index is used in Select for entries query i tried Explain in ST05 but its not clear if it uses any index at all in hrp1001 read.
here is the sample code i use to get test results.
test case 1
REPORT zdemo_perf_select.
DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: t1 TYPE timestampl,
t2 TYPE timestampl,
t3 TYPE timestampl
SELECT * FROM hrp1000 CLIENT SPECIFIED INTO TABLE it_hrp1000 bypassing buffer
WHERE mandt EQ sy-mandt AND
plvar EQ '01' AND
otype EQ 'S'AND
istat EQ '1' AND
begda <= sy-datum AND
endda >= sy-datum AND
langu EQ 'EN'.
GET TIME STAMP FIELD t1.
SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
FOR ALL ENTRIES IN it_hrp1000
WHERE mandt EQ sy-mandt AND
otype EQ 'S' AND
* objid EQ it_hrp1000-objid and
plvar EQ '01' AND
rsign EQ 'B' AND
relat EQ '007' AND
istat EQ '1' AND
begda LT sy-datum AND
endda GT sy-datum and
sclas EQ 'C' and
objid EQ it_hrp1000-objid.
* %_hints mssqlnt 'INDEX(HRP1001~0)'.
*delete it_hrp1001 where sclas ne 'C'.
GET TIME STAMP FIELD t2.
t3 = t1 - t2.
WRITE: 'Time taken - ', t3.
test case 2
REPORT zdemo_perf_select.
DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: t1 TYPE timestampl,
t2 TYPE timestampl,
t3 TYPE timestampl
SELECT * FROM hrp1000 CLIENT SPECIFIED INTO TABLE it_hrp1000 bypassing buffer
WHERE mandt EQ sy-mandt AND
plvar EQ '01' AND
otype EQ 'S'AND
istat EQ '1' AND
begda <= sy-datum AND
endda >= sy-datum AND
langu EQ 'EN'.
GET TIME STAMP FIELD t1.
SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
FOR ALL ENTRIES IN it_hrp1000
WHERE mandt EQ sy-mandt AND
otype EQ 'S' AND
objid EQ it_hrp1000-objid and
plvar EQ '01' AND
rsign EQ 'B' AND
relat EQ '007' AND
istat EQ '1' AND
begda LT sy-datum AND
endda GT sy-datum and
sclas EQ 'C'." and
* objid EQ it_hrp1000-objid.
* %_hints mssqlnt 'INDEX(HRP1001~0)'.
*delete it_hrp1001 where sclas ne 'C'.
GET TIME STAMP FIELD t2.
t3 = t1 - t2.
WRITE: 'Time taken - ', t3.Mani wrote:
Thank you for your answer, its very helpful but i am still nor sure how does parameter rsdb/max_blocking_factor affect records size.
Hi,
The blocking affects the size of the statement and the memory structures for returning the result.
So if your itab has 500 rows and your blocking is 5, the very same statement will be executed 100 times.
Nothing good or bad about this so far.
Assume, your average result for an inlist 5 statement is 25 records with an average size of 109 bytes.
You average result size will be 2725 byte plus overhead which will nearly perfectly fit into two 1500 byte ethernet frames.
Nothing to do in this case.
Assume your average result for an inlist 5 statement is 7 records with an average size of 67 bytes.
You average result size will be ~ 470 byte plus overhead which will only fill 1/3 of a 1500 byte ethernet frame.
In this case, setting the blocking to 12 ... 15 will give you 66% network transfer performance gain,
and reduces the number of calls to the DB by 50%, giving additional benefit.
Now this is an extreme example. The longer the average row length is, the lower will be the average loss in the network.
You have the same effects in memory structures, but on that layer you are fighting single micro seconds instead of
hundreds of these, so in real life it is rarely measurable.
Depending on table-statistics, oracle might decide for short inlists to use a concatanation instead of an inlist.
This is supposed to be more costy, but I never had a case where I could proove a big difference.
Values from 5 to 15 for blocking seem to be ok for me. If you have special statements in customer coding,
it #might# be benefitial to do the mentioned calculations and do some network tracing to see if you can squeeze your
network efficiency by tuning the blocking.
If you have jumbo frames enabled, it might be worth to be analyzed as well.
If you are only on a DB-CI system that is loopback connected to the DB, I doubt there might be a big outcome.
Hope this helps
Volker -
Select... for all entries in...
Hi,
Can anybody help me to sort out this issue. This select should work. I m filling an itab with distinct pernr. in temp it should give <b>all the records for which pernr should not be in itab.</b>
report ZTEST4.
data : begin of ITAB occurs 0,
PERNR like PA0001-PERNR,
ename like pa0001-ename,
end of ITAB.
data : temp like itab occurs 0 with header line.
clear : ITAB, TEMP.
refresh : ITAB,TEMP.
select distinct PERNR into table ITAB from PA0001 where PERNR le 10.
select PERNR ENAME into table TEMP from PA0001
for all entries in ITAB where pernr not in itab-pernr.
sort TEMP by PERNR.
break-point.Hi Sagar,
If i understand it well, you exclude all PERNR LE 10.
But first things first.
You cannot use the FOR ALL ENTRIES in your case (it doesn't allow the operator "NOT IN").
Your code should be:
REPORT ztest4.
TYPES: BEGIN OF ty_itab,
pernr TYPE persno,
ename TYPE emnam,
END OF ty_itab.
DATA : itab TYPE ty_itab occurs 0,
wtab TYPE ty_itab.
CLEAR: itab,
wtab.
SELECT pernr ename
INTO TABLE itab
FROM pa0001
WHERE pernr LE 10
ORDER BY pernr.
IF sy-subrc EQ 0.
DELETE ADJACENT DUPLICATES FROM itab COMPARING pernr.
ENDIF.
Regards,
Rob. -
Select fom table for all entries where field starts with value
Hello
I want to write a select like this
select * from bsis
into lt_bsis
for all entries in lt_itab
where xblnr like lt_itab-belnr%
I want to select all the entries from bsis where the field xblnr starts with the values found in lt_itab-belnr.
for example
ls_itab-belnr = 5100000028
bsis-xblnr = 510000002810001
510000002810002
510000002810003
520000002810001
and i want to select only the entries that start with 5100000028 in this case
Can anybody help?
ThanksHi,
I hope below example code will help you to fix your issue,
REPORT ytest.
TYPES : BEGIN OF ty_typ1,
val TYPE i,
END OF ty_typ1.
TYPES : BEGIN OF ty_typ2,
val1 TYPE hrobjid,
val2 TYPE hrobjid,
END OF ty_typ2.
DATA : int_typ1 TYPE TABLE OF ty_typ1,
int_typ2 TYPE TABLE OF ty_typ2,
wa_typ1 TYPE ty_typ1,
wa_typ2 TYPE ty_typ2,
int_1001 TYPE TABLE OF hrp1001,
wa_1001 TYPE hrp1001.
REFRESH : int_typ1, int_typ2, int_1001.
CLEAR : wa_typ1, wa_typ2, wa_1001.
wa_typ1-val = 500001.
APPEND wa_typ1 TO int_typ1.
wa_typ1-val = 500002.
APPEND wa_typ1 TO int_typ1.
wa_typ1-val = 500003.
APPEND wa_typ1 TO int_typ1.
wa_typ1-val = 500001.
APPEND wa_typ1 TO int_typ1.
SORT int_typ1 ASCENDING BY val.
DELETE ADJACENT DUPLICATES FROM int_typ1 COMPARING val.
LOOP AT int_typ1 INTO wa_typ1.
wa_typ2-val1 = ( wa_typ1-val * 100 ) + 1.
wa_typ2-val2 = wa_typ2-val1 + 98.
APPEND wa_typ2 TO int_typ2.
CLEAR : wa_typ1, wa_typ2.
ENDLOOP.
SELECT * FROM hrp1001 INTO TABLE int_1001
FOR ALL ENTRIES IN int_typ2 WHERE
plvar EQ '01' AND
otype EQ 'S' AND
sclas EQ 'O' AND
begda LE sy-datum AND
endda GE sy-datum AND
objid GE int_typ2-val1 AND
objid LE int_typ2-val2.
LOOP AT int_1001 INTO wa_1001.
WRITE : / wa_1001-objid.
ENDLOOP.
Thanks & Regards,
Harish Kumar N -
Select statment using FOR ALL ENTRIES not allow to do sum,
Hi All,
SELECT DELIV_NUMB
SUM( GRS_WGT_DL )
UNIT_OF_WT
FROM /BIC/AGSSD000600
INTO TABLE I_GROSS
FOR ALL ENTRIES IN I_LAYTWO
WHERE DELIV_NUMB = I_LAYTWO-DELIV_NUMB
GROUP BY DELIV_NUMB UNIT_OF_WT.
While compiling it shows the error
The addition "FOR ALL ENTRIES" excludes all aggregate functions with
the exception of "COUNT( * )", as the single element of the SELECT
clause.
Please give some solution to do sum
with regards,
Thambe .You could just select all entries into an internal table and then loop through and use COLLECT or similar to get your sum values.
Gareth. -
Advice required on a select statement using "FOR ALL ENTRIES"
Hi,
this is really intresting ...
I have a small requirement where in i have to find out
the valid entries in my internal table (T_MATNR) by using a select statement to a check table (MARA) which has all the fields present in the internal table T_MATNR.
Select statement is
SELECT MATNR
MTART
from MARA
for all entries in T_MATNR
into table T_MATNR
where matnr eq T_MATNR-MATNR.
If you observe the itab in the option 'FOR ALL ENTRIES' and the destination table is the same. I want to know whether this is correct? will it cause any performance issue? right now this statement is working fine for me.Hi,
U have to use
SELECT MATNR
MTART
from MARA
<b>into table I_MATNR(different table)</b>
for all entries in T_MATNR
where matnr eq T_MATNR-MATNR.
If u r specifying both same table name then for what entries it will retrieve, if u have alreay selected some entries and appending u can use
SELECT MATNR
MTART
from MARA
<b>into table T_MATNR</b>where matnr eq T_MATNR-MATNR.
then
SELECT MATNR
MTART
from MARA
<b>appending table T_MATNR</b>
for all entries in T_MATNR
where matnr eq T_MATNR-MATNR.
In this way u can do.
Hope u got it. -
Needed selection screen validation for all entries in the range
Hi all,
I'm using the below code for Material validation in selection-screen.
SELECT SINGLE MATNR FROM MARC INTO MARC-MATNR
WHERE MATNR IN S_MATNR.
IF sy-subrc NE 0.
MESSAGE e000(su) WITH text-035. "Invalid Material Number
ENDIF.
This validation is working only for one record in the range.
If I give multiple material numbers in the range having a record which doesn't exist in MARC, its not throwing the error.
Seems like loop should be placed at s_matnr. Is that correct procedure or any pointers on the same would be of great help.
Regards,
Vamsee Priya.Hi priya
Use this way,
REFRESH IT_LIPS. CLEAR IT_LIPS.
SELECT VBELN
POSNR
MATNR
WERKS
LFIMG
ARKTX
VGBEL
VGPOS
BWART
FROM LIPS INTO TABLE IT_LIPS
WHERE PSTYV IN
('ZZTC', 'ZTAD', 'ZMVN', 'ZCVA', 'ZCVB', 'ZCVC') AND "ASR 18721
WERKS IN ('1140', '1143', '1149').
IF IT_LIPS[] IS INITIAL.
MESSAGE E000 WITH TEXT-005.
endif.
revert back if you need any help..
Help us to help you, Manas -
Usage of FOR ALL ENTRIES in SELECT query
Hi All,
While writing SELECT query using FOR ALL ENTRIES, in the WHERE condition can we use IN operator on a range table?
Will this work out.
Thanks,
Anil KumarHI,
Yes you can use the in operator.
SELECT *
FROM MARC
INTO TAB:E i_mARC
FOR ALL ENTRIES IN I_MARA
WHERE MATNR EQ I_MARA_MATNR
AND WERKS IN S_WERKS. -
Allowing duplicate in FOR ALL ENTRIES statement
Hi folks,
I am using a select query using FOR ALL ENTRIES statement. I could observe one entry is missing from the table data.When i checked that in the data base table, there are two duplicate records among which one entry is missed in the output data from the query.Is duplicates are restricted if we use FOR ALL ENTRIES statement ? Is there any key word like 'ALLOWING DUPLICATES' for this ? if not what is the solution for this.Could any body help me regarding this.
Thanks,
Shyam.
Edited by: Matt on Jul 9, 2009 1:27 PMHi Shyam,
In For all entries you should give unique records only.
sort your base table with key which you are passing in for all entries clause.
delete all duplicate entries.
Hope this will help .
Regards,
Vijay -
LIKE in SELECT FOR ALL ENTRIES
Hello all,
select * from mara
into corresponding fields of tabel itab_mara
for all entries in table itab
where matnr LIKE itab-matnr.
for my requirement, I want to use the above statement. because in ITAB, i have MATNR with only 10 digit.
But the problem is system does not allow this syntax.
Do you have an idea which will avoid any other SELECT s and get away with it.
Thanks.Hi
Select Statements contd For All Entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Points to be must considered FOR ALL ENTRIES
Check that data is present in the driver table
Sorting the driver table
Removing duplicates from the driver table
Consider the following piece of extract
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
The above mentioned can be more optimized by using the following code.
Sort int_cntry by cntry.
Delete adjacent duplicates from int_cntry.
If NOT int_cntry[] is INITIAL.
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
Endif.
Maybe you are looking for
-
Error when running a parameterised query
I get an error when trying to run the following parameterised query : /SELECT FROM [@Payments] p/ declare @fromAccount as nvarchar(10) /* WHERE */ set @fromAccount = /* p.U_account */ N'[%8]' SELECT T1.[CardName], T0.[Code], T0.[U_code_ast], T0.[U_
-
PDF files does not open in IE 8
When I click on a link on a web page which is to open a pdf file in acrobat reader, it does not open and gives me a error mesage The instruction at "0x02d96433" referenced memory at "0x00000000". The memory could not be read and then it opens a blank
-
IPad stuck in recovery mode after unknown error occurred during update via iTunes
how can I save photos Stored on that iPad ? please help.
-
hi, somehow i managed to install 10g r2 f&r service on an x86 machine with rhel4 es update3. moving on, i was given working fmb and mmb ver 5 files (edited using developer2000 and run against 8.0.x db) by a collegue. i've also get 10g dev suite insta
-
Chart x label start from July to June in Financial Year
Hi All, I have a chart displaying comparing three financial years value by month, currently x axis value is showing from Jan to Dec, but it is not correct, I want to show x axis value from July to June in financial month order, won't show year number