Using delete and FOR ALL ENTRIES
Hi,
We have a error message regarding the following code :
Delete FROM TABLE FOR ALL ENTRIES IN lt_TABLE WHERE
TABLE_KEY1 = LT_TABLE_KEY1
Could we use the For All entries with "Select" ?
For information, the error message is "Unable to interpret "FOR". Possible causes: Incorrect spelling or comma error.
Thank you.
Hi,
Check the below syntax, if you want to delete from database
DELETE FROM sflight
WHERE carrid = p_carrid AND
fldate = sy-datum AND
seatsocc = 0.
Just a suggestion. May be from next time you can use F1 help for syntax:
1. Place the cursor on the delete keword in your program and press F1 - You willl get all the possible syntax for delete statement
2. Else open the transaction ABAPDOCU, Click Keyword Help, Enter the required keyword(delete in this case) and press cont.. You will get the syntax.
Hope thsi will help you.
Regards,
Swarna Munukoti.
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. -
Is "Joins & For all entries" in same SQL Query Possible?
Hi all Professional,
Can we use "Inner Joins" and "For All Entries In" in the same SQL Query. if possible then pls clarify this query.
Here I am using three Transparent Table and fetching data from them.
SELECT abukrs abelnr ahkont axref2 ashkzg awrbtr agsber azfbdt azterm amwskz asgtxt axref1 agjahr abuzei
bkunnr bwerks bmenge bmeins bmatnr bkoart
cbukrs cbelnr cblart cbldat cbudat cxblnr cgjahr cstgrd cstblg cstblg c~xreversal
INTO CORRESPONDING FIELDS OF TABLE it_bsid FROM ( ( bsid AS a
INNER JOIN acctit AS b ON abukrs = bbukrs )
INNER JOIN bkpf AS c ON cbukrs = abukrs
AND cbelnr = abelnr
AND cgjahr = agjahr )
FOR ALL ENTRIES IN it_bkpf
WHERE
a~belnr EQ it_bkpf-belnr
AND a~gjahr EQ it_bkpf-gjahr
AND a~bukrs EQ it_bkpf-bukrs
AND a~gsber IN so_bus.
After executing this query, I'm getting Dump Error.
Error analysis
When the program was running, it was established that more
memory was needed than the operating system is able to provide savely.
To avoid a system crash, you must prevent this
situation.
Last error logged in SAP kernel
Component............ "EM"
Place................ "SAP-Server Development_DVL_01 on host Development (wp
2)"
Version.............. 37
Error code........... 7
Error text........... "Warning: EM-Memory exhausted: Workprocess gets PRIV "
Description.......... " "
System call.......... " "
Module............... "emxx.c"
Line................. 1886
Pls resolve, if anybody knows.
Thanks
DevinderHi,
During testing i notice that splitting into multiple selects does improve performance. But the best performance I achieved using DB Hints instead of splitting the select statements.
Generally performance of joins together with for all entries is bad.
However if you will look into SAP note 1662726 you will notice that this issue (bad performance in using join and for all entries together) has been addressed.
Even though the note is for HANA DB, FM RSDU_CREATE_HINT_FAE can be used independent of DB.
On HANA DB performance improvement is huge (i achieved 62 seconds using DB Hints compared to 1656 seconds using for all entries). On Oracle DB the same code initially run in 99 seconds with for all entries and with DB Hints in 82 seconds for ~ 1.000.000 records and ~660 seconds compared to 1349 seconds for ~8.000.000 records..
Sample code from SAP Note below:
Original statement:
SELECT COL1 COL2 COL3 COL4 COL5
FROM TAB1
INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
FOR ALL ENTRIES IN LT_SOURCE_TMP
WHERE COL3 = LT_SOURCE_TMP-COL3
AND COL4 = LT_SOURCE_TMP-COL4
AND COL5 = LT_SOURCE_TMP-COL5
Revision:
DATA: L_T_TABLNM TYPE RSDU_T_TABLNM,
L_LINES TYPE I,
L_HINT TYPE RSDU_HINT.
APPEND 'TAB1' TO L_T_TABLNM.
L_LINES = LINES( LT_SOURCE_TMP ).
CALL FUNCTION 'RSDU_CREATE_HINT_FAE'
EXPORTING
I_T_TABLNM = L_T_TABLNM
I_FAE_FIELDS = 3
I_FAE_LINES = L_LINES
I_EQUI_JOIN = RS_C_TRUE
IMPORTING
E_HINT = L_HINT
EXCEPTIONS
OTHERS = 0.
SELECT COL1 COL2 COL3 COL4 COL5
FROM TAB1
INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
FOR ALL ENTRIES IN LT_SOURCE_TMP
WHERE COL3 = LT_SOURCE_TMP-COL3
AND COL4 = LT_SOURCE_TMP-COL4
AND COL5 = LT_SOURCE_TMP-COL5
%_HINTS ADABAS L_HINT.
Best regards,
Octavian -
Two questions :
<b>(1) I use join with for all entries: the performance will go down?:</b>
SELECT t1~MBLNR t1~MJAHR ZEILE BUDAT
INTO TABLE gt_mseg
FROM MSEG as T1 INNER JOIN MKPF AS T2
ON T1~MBLNR = T2~MBLNR and
T2~MJAHR = T2~MJAHR
FOR ALL ENTRIES IN gt_coss
WHERE T1~MJAHR = gt_coss-GJAHR AND
T1~AUFNR = gt_coss-aufnr AND
( BWART = '261' OR
BWART = '262' ) AND
T2~BUDAT IN r_budat.
<b>(2) With "For all entries", if itab is too long, performance will go down?. In affirmative case. What can I do?</b>Hi Jose,
You'll have to make sure your global table gt_coss isn't empty.
A nasty little habit of the IN statement (for all entries is a kind of IN statement)
is that when it is empty, the system selekts all records.
You might know this when u use Select-Options in your statement (like r_budat).
Also there is an OSS note on he for all entries (531337) problems on i-series database.
Greetings Fred. -
Is it not recommended to use FOR ALL ENTRIES in version 4.5B
Hi,
Is it not recommended to used For all entries in version 4.5B as Size limit for SQL is 32KB hence we should not be using FOR ALL ENTRIES, instead of this we should be using select inside the loop?
Can anyone please let me know if this is correct and if you can provide me the SAP documentation on the specific statement.
Regards
RiaHi Ria,
From what I understand, you cannot use JOINS with FOR ALL ENTRIES in 4.5b & lower versions. In general the SELECT..FOR ALL ENTRIES statement has been in use from 3.1i versions. For more information, PL take a look at OSS Note #652634.
Regards,
Suresh Datti -
Can we use inner joins with for all entries?
Hi,
Can we use innerjoin on two tables MARA and MAKT against the materials in
the internal table.
If so ,please let me know whether there is performance issue.Because if there is
bad performance issue or something else like thise means,my project manager
wont allow to include.
So can one let me know about this.
Thanks,
BalajiHi Arunkumar,
I think you are not clear.My question is can I use innerjoin with
for all entries.For example below is my code.
SELECT A~MATNR
B~MAKTX
A~MTART
A~MATKL
FROM MARA AS A INNER JOIN MAKT AS B
ON AMATNR = BMATNR
INTO TABLE IT_MARA_MAKT
FOR ALL ENTRIES IN IT_MATNR
WHERE A~MATNR = IT_MATNR-MATNR
AND A~EXTWG = P_EXTWG
AND A~SPART = P_SPART.
Can we use like this for all entries along with innerjoins.
Thanks,
Balaji -
Select -- for all entries.. fetching Duplicates
Hi,
Im using a Select- for all entries structure. Actually Select will supress the Duplicates .But i have a table which has 20000 entries , but my select --for all entries fetching around 56000 records..!
Any idea/ anybody have Experience this kind of Problem..?
If i sort the internal table would it resolve the proble..? Because its not happening in all cases.. but for few cases only its extracting duplicates.. other times..its supressing the duplicates.
Appreciate any advise.Hi,
Just check the table is not initial and then write select statement.
if not internaltable1[] is initial.
select field into table internaltable2 for all entries in internaltable1 where field1 = internaltable1-field1.
endif.
*Then sort the internaltable2
sort internaltable2 by field.
delete adjacent dulpcates from internaltable2 comparing field.
Hope this helps.
Regards,
J.Jayanthi -
Alternative for / Problems with: "For all entries in data_package"
Hi Guys
I doing some ABAP in a Start Rotine in BW and would like to do the following:
select * from /BI0/PMATERIAL into table 0mat
for all entries in DATA_PACKAGE
where material = DATA_PACKAGE-/bic/zmaterial.
But I get the following error:
E:When using the addition "FOR ALL ENTRIES IN itab", the fields "MATERIAL" and "DATA_PACKAGE-/BIC/ZMATERIAL" must have the same type and length. and length.
ZMATERIAL:
- Length: 28
- Type: CHAR - Character String
ZMATERIAL:
- Length: 18
- Type: CHAR - Character String
According to the error message "For all entries" cannot be used in this case since the lengths are not identical, but is there an alternative way to do what I would like to do?
Thanks in advance, kind regards,
TorbenHi
one thing you can try like this define one variable in other itab of same type
then loop at the first table and assign it to new field and modify the itab
then use this field with for all entries
Regards
Shiva -
FOR ALL ENTRIES IN with two tables
Hi Guy's,
I have two int. tables, gt_likp, gt_lips.
I need to use "FOR ALL ENTRIES IN" with this two tables.
SELECT matnr
vkorg
vtweg
ypcogsl
FROM mvke
INTO TABLE gt_mvke
<b> "FOR ALL ENTRIES IN gt_likp gt_lips"</b>
WHERE matnr = gwa_liefpos_tab-matnr
AND vkorg = gt_likp-vkorg
AND vtweg = gt_lips-vtweg.
How to do this?
Please Help.
Thanks in Advance.Hi,
Fill gt_likp-vkorg values in a range(r_vkorg). Use gt_lips in FOR ALL ENTRIES.
Basically you can use only 1 internal table with FOR ALL ENTRIES statement.
SELECT matnr
vkorg
vtweg
ypcogsl
FROM mvke
INTO TABLE gt_mvke
FOR ALL ENTRIES IN gt_lips
WHERE matnr = gwa_liefpos_tab-matnr
AND vkorg in r_vkorg
AND vtweg = gt_lips-vtweg.
- SRao -
Extract Cube data for all entries of an internal table
Hi
I want to fetch the data from the cube for all entries of another internal table.
Scenario : Fetching the COMPANY_CODE and DATE into an internal table and for those company codes and Dates, I have to fetch the records of the Cube.,
I am using the Function Module : RSDRI_INFOPROV_READ
But not sure how to accommodate the multiple selections condition for this.
Selection Required:
*For all entries of it_cc
where comp_code = it_cc-comp_code and
date = it_cc-date.*
Please help me how to such multiple conditions and "for all entries" functionality for fetching the data from the cube.
Thanks.
Veera Karthik GHI
You can try like this
LOOP AT lt_donotcall_old .
<ls_donotcall>-examination_date = sy-date.
<ls_donotcall>-examination_time = sy-time.
ENDLOOP.
append it_donotcall_old.
Reward all helpfull answers
Regards
Pavan -
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> -
Dynamic SELECT containing 'FOR ALL ENTRIES'
Hi,
I am trying to do a slect from a table in which the table and the field to be selected will be dynamically populated using Field Symbol
Something like this,
SELECT * FROM <FS_TABLE>
INTO CORRESPONDING FIELDS OF TABLE <FS_IT_TABLE>
FOR ALL ENTRIES IN T_TABLE
WHERE <FS_FIELD> EQ T_TABLE-FIELD1.
I know that <FS_FIELD> cannot be used along with 'FOR ALL ENTRIES'. Is there any other way to achieve this?Hi!
Try out the dynamical WHERE conditions then:
PARAMETERS: column TYPE c LENGTH 8,
value TYPE c LENGTH 30.
DATA spfli_wa TYPE spfli.
DATA cond_syntax TYPE string.
CONCATENATE column '= value'
INTO cond_syntax SEPARATED BY space.
TRY.
SELECT SINGLE *
FROM spfli
INTO spfli_wa
WHERE (cond_syntax).
CATCH cx_sy_dynamic_osql_error.
MESSAGE `Wrong WHERE condition!` TYPE 'I'.
ENDTRY.
Regards
Tamá -
Hi all,
When i was trying to use for all entries, i am not able to pull records inside my internal table. Though both of the tables have the common key fields between them(and ofcourse have entries in that). Now what i have analyzed was, the first table is having 7 primary keys and the one i am using for 'for all entries' comes 6th. Does this gives any impact in pulling records inside my internal table?.Else please give me a possible solution for this. The alternate statement(a normal select query with * ) that i had used for this reserved my dialog processor for a while. Which resulted in 'time exceeded' short dump.Hi,
The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
Hope this is useful
Reema -
Select for all entries+offset
Folks,
please find my code below:
SELECT partner bpkind FROM but000 INTO TABLE i_but000
FOR ALL ENTRIES IN lt_cmst_rtcm_bw
WHERE partner = lt_cmst_rtcm_bw-tk_partner_i+0(10).
SORT i_but000 BY partner.
partner is of length 10, tk_partner_i is of length 32.
when i use this offset value for comparison, its giving me the correct output. no errors.
but am getting this warning:
Bei der Verwendung von FOR ALL ENTRIES wird die Längenangabe für "TK_PARTNER_I" in dieser Bedingung ignoriert.
Do i have to mind this warning??..
if this is to be considered, please suggest me an alternate solution to use "For all entries" in this case.
Thanks in advance..
Yog>
yogaprakash srirangan wrote:
> Hi,
>
> Actually i am writing this code in CRM system's CMOD-User exit program.
>
> when i remove the offset i am getting this error:
>
> When using the addition "FOR ALL ENTRIES IN itab", the fields "PARTNER" and "LT_CMST_RTCM_BW-TK_PARTNER_I" must have the same type and length.and length.
>
> but with offset its generating warning and internal table is getting filled..
>
> so can you please explain me on this?..
>
> Thanks,
> Yog
Wow! It seems you have indeed found a bug! With the length specification you get a warning, without you get an error!
I've also written a little test program
TYPES: BEGIN OF mandt_ty,
mandt TYPE char6,
END OF mandt_ty.
DATA: t_mandt TYPE STANDARD TABLE OF mandt_ty WITH NON-UNIQUE KEY mandt,
l_mandt TYPE mandt_ty.
DATA: lt_t000 TYPE STANDARD TABLE OF t000 WITH NON-UNIQUE KEY mandt,
ls_t000 TYPE t000.
l_mandt-mandt = '1201'.
INSERT l_mandt INTO TABLE t_mandt.
SELECT * FROM t000 INTO TABLE lt_t000 FOR ALL ENTRIES IN t_mandt WHERE mandt = t_mandt-mandt+1(3).
*SELECT * FROM t000 INTO TABLE lt_t000 FOR ALL ENTRIES IN t_mandt WHERE mandt = t_mandt-mandt.
LOOP AT lt_t000 INTO ls_t000.
WRITE: ls_t000-mandt.
ENDLOOP.
And it seems that the offset isn't being ignored. I've also done and SQL trace, and this confirms that the offset isn't being ignored - the SQL issued actually says SELECT WHERE "MANDT" = '020' even though I've set it in the table to be 1201.
So it seems that, at the moment, you can safely ignore the message. But if SAP ever enforce it, or they make it an error instead of a warning, there will be problems.
matt -
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
Maybe you are looking for
-
Ipod's battery is low and won't be recognized by the computer to charge.
Hola, So, I fell asleep the other night and forgot to turn my Ipod Nano Video off. When I saw it in the morning it said, "Low Battery" at the top of the screen, had the icon of a battery and a triangle, and below that it says, "Connect to Power". I p
-
Samsung Monitor acting strange when connected with digital cable.
I have a Powermac G5 dual 2.7 GHz desktop. I am connecting a Samsung 2233BW monitor. When I connect the monitor from its digital connection using the digital cable I have a problem bringing the monitor back from sleep mode. I get horizontal jagged li
-
Error When Sending Service Request Through OWSM Gateway
We are trying to test using OWSM Gateways and Server Agents to sign and then verify messages being passed to a web service on a server. We have been able to get this to work with a simple HelloWorld type service without any problems. We then followed
-
Is there any plan to fix the Javascript function on CS6 from SPRY to JQuery?
-
I am trying to connect to a network on my ipad but keep getting a message saying " Unable to join the network" and the omly opion is dismiss.....Can anyone help me find out what is wrong please?