Offset in where clause of for all entries
Hi ,
I need to fetch VBELN from VBKD table based on Purchase order no which is fetched from a Z-table.So I am using for all entries with where condition as VBKD-BSTKD_M = Ztable-PONumber and fetching values from VBKD .But at times PO number in VBKD table can have additional things attached to it .
Eg Ztable-PO number = 12345678 , VBKD-BSTKD_M = 12345678-001 so I need to ignore the '-001' part and still fetch data from VBKD.So how can I do that.
Pls let me know if you have any ideas.
Thanks in advance,
Rajasekaran
Hi ,
We cannot use offset directly in where as it will result in syntax error as the field length for both fields have to match .In my case the length of both Ztable -PO number field and vbkd-bstkd_m are 35 characters.So cannot use offset directly in where clause of for all entries.
Pls let me know if you have any other ideas.
Thanks in advance,
Rajsekaran
Similar Messages
-
For all entries from 2 tables that have no common key
Hello
I have the next querry that i want to write in abap
AUFK -
>aufk-aufnr = afko- aufnr----> AFKO
AUFK---->aufk-pspel = afvc-projn -
>AFVC
AFKO-----> afko-rsnum = resb-rsnum -
> RESB
AFVC-----> afvc-aufpl = resb-aufpl -
> RESB
AFVC-----> afvc-vornr = resb-vornr -
> RESB
So that i have to start with AUFK and from there i read AFKO and AFVC and with the entries from AFKO and AFVC i have to do a select on RESB.
How can i do this
select from RESB
for all entries in AFKO
where ...
for all entries in AFVC
where... ?
I do not have any common key between AFVC and AFKO. How can i select the correct entries from RESB?
I have to mention that i have 1-1 entries for AUFK and AFKO
and 1-N entries for AUFK and AFVC
Thank youWhy don't you use afko-aufpl = afvc-aufpl ?
Regards,
Raymond -
Using for all entries of two internal tables in where clause of the select
Hi experts,
My requirement is, need to select Marc-minbe and wrpl-sobst, for all the entries of the two internal tables it_mara , and it_t001w.
here is the select queries i have used,
select matnr normt from mara into it_mara for all entries in it_data where normt = it_data-normt.
select konnr werks from t001w into it_t001w for all entries in it_data where konnr = it_data-konnr.
now i need to select minbe of marc table and sobse of wrpl table for all the entries of above internal tables, it_mara and it_t001w, using both matnr of it_mara and werks of it_t001w in where condition.
Pls advise how i can do it.
Thanks.
Moderator message: very basic, please work on this yourself first, these forums are not a substitute for ABAP training.
Edited by: Thomas Zloch on Dec 6, 2010 9:38 AMHi
call SE16 with table TFTIT in order to get a full list (it will be long...)
A list of FMs with parameters can be found in table FUNCT.
Finally go to sm37rsdf4
that will give you all the function modules with description
Here is the list:
http://www.erpgenie.com/abap/functions.htm
hope this helps...
Regards
CSM Reddy -
While using for all entries its ignoring details of where condition
i am using one select statement as follows
SELECT ORGVEND LOTNO INTO TABLE IT_ORG
FROM /BAY4/IC_IN_SEED
FOR ALL ENTRIES IN IT_DATA
WHERE LOTNO = IT_DATA-CHARG+0(9).
its showing error as below
In the use of FOR ALL ENTRIES, the long statement fur "CHARG" in this condition is ignored.
how to avoid that.
and
we are using one field called "MITTLEWERT"
we have declared it as type P decimals 2.
in report we are using one statement
SHIFT MITTELWERT LEFT DELETING LEADING ' '.
its showoing error that MITTLEWERT should be C,N,String soem thing likie that.........how to avoid thatHi,
i am using one select statement as follows
SELECT ORGVEND LOTNO INTO TABLE IT_ORG
FROM /BAY4/IC_IN_SEED
FOR ALL ENTRIES IN IT_DATA
WHERE LOTNO = IT_DATA-CHARG+0(9).
its showing error as below
In the use of FOR ALL ENTRIES, the long statement fur "CHARG" in this condition is ignored.
how to avoid that.
and
we are using one field called "MITTLEWERT"
we have declared it as type P decimals 2.
in report we are using one statement
SHIFT MITTELWERT LEFT DELETING LEADING ' '.
its showoing error that MITTLEWERT should be C,N,String soem thing likie that.........how to avoid that
first of all you can not use offset for for all entries which you have used in select query
SELECT ORGVEND LOTNO INTO TABLE IT_ORG
FROM /BAY4/IC_IN_SEED
FOR ALL ENTRIES IN IT_DATA
WHERE LOTNO = IT_DATA-CHARG+0(9). " You can not use IT_DATA-CHARG+0(9).
2) field MITTLEWER you have declared as type P decimals 2.
Keep in mind that P is not character tupe it is numeric type so it will have initial values as 0 and not ' ' (space).
try below kind of code
REPORT ZTEST_UM2.
DATA: a TYPE p DECIMALS 2 VALUE 000123 ,
lv_with_zeros(15) TYPE c.
WRITE: a to lv_with_zeros.
WRITE lv_with_zeros.
Hope above will help u.
Regards,
Umang mehta -
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 -
For all entries Where condition character length partilally has to be used
Hi,
I need to fetch all the data reocrds of one internal table into the other with the condition that in one of the field of first internal table only partial length of the character has to be used as a where condition.
Example:
Select xxxx
yyyyy
zzzzz
into it_tab2
for all entries in itab1
where field2 = itab1-field1(4).
where field1 of itab1 has length of 8 and field2 belongs to itab2.
As it throws the error msg :
it will ignore the length restriction mentioned in where condition of the for all entriesHi.
If you are trying to fetch from any database table based on your modified table use this logic.
Dfine another internal table same as itab1, with field one lenght as 4 char.
ex:
data: begin of it_tab2.
field1(4),
end of it_tab2.
loop at it_tab1.
it_tab2 = itab1+0(4).
append it_tab2.
clear it_tab2.
endloop.
now you can fetch from database table....using it_tab2.
Select xxxx
yyyyy
zzzzz
into it_tab3
for all entries in itab2
where field2 = itab2-field1(4).
If you only want to move the entries form one internal table to another internal table and truncate the field1 of itab1.
then no need to use any for all entries...
apply this logic
data: begin of it_tab2.
field1(4),
end of it_tab2.
loop at it_tab1.
it_tab2 = itab1+0(4).
append it_tab2.
clear it_tab2.
endloop.
Regards,
Satish -
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 -
SQL- Statement: for all entries, where
Hi all, I have a Statement
SELECT * FROM ltak
INTO TABLE lt_help for all entries in gt_tree
WHERE bdatu = gt_tree-node_key.
It doesnt want to compile, because the field bdatu is not of the same type like my field node_key.
How can I process this statement, or how can I convert it ?
Thanks,
Regards,
HProkoph
Edited by: Rob Burbank on Dec 17, 2009 9:26 AMHello,
This is what you were suggested before
"Add a extra field in the internal table gt_tree
data: begin of gt_tree occurs 0,
bdatu1 like ltak-bdatu,
end of gt_tree.
"before the select statement
loop at gt_tree.
gt_tree-bdatu1 = gt_tree-node_key.
modify gt_tree.
endloop.
SELECT * FROM ltak
INTO TABLE lt_help for all entries in gt_tree
WHERE bdatu = gt_tree-bdatu1.
Vikranth -
What is the usage of for all entries ?
What is the Usage of read table after using for all entries ?
In the following example what exactly it is doing ?
Usage of 'for all entries' in Select Statement
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
DATA: BEGIN OF T_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
MATNR LIKE VBAP-MATNR,
POSNR LIKE VBAP-POSNR,
END OF T_VBAP.
DATA: BEGIN OF T_VBFA OCCURS 0,
VBELV LIKE VBFA-VBELV,
VBELN LIKE VBFA-VBELN,
VBTYP_N LIKE VBFA-VBTYP_N,
END OF T_VBFA.
DATA: BEGIN OF T_VBAK OCCURS 0,
VBELN LIKE VBAK-VBELN,
IHREZ LIKE VBAK-IHREZ,
END OF T_VBAK.
DATA: BEGIN OF T_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
END OF T_KNA1.
DATA: BEGIN OF T_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF T_MAKT.
SELECT likpvbeln likplifex likpbldat likpwadat likpwadat_ist likpkodat likp~lfart
likpkunnr likpvstel lipsposnv lipslfimg lipsvrkme lipslgmng lips~meins
lipswerks lipslgort lipscharg lipsvbelv lipsposnr lipsmatnr
lipsvbeln LIPSVGBEL LIPSVGPOS vbupkosta vbupwbsta vbupposnr vbup~vbeln
VBAKIHREZ VBAKVBELN VBAP~VBELN
INTO CORRESPONDING FIELDS OF TABLE it_itab
FROM ( likp
INNER JOIN lips
ON lipsvbeln = likpvbeln
INNER JOIN vbup
ON vbupposnr = lipsposnr
and VBUPVBELN = LIPSVBELN )
left outer join VBAK
on VBAKVBELN = LIPSVGBEL
inner join VBAP
on VBAPVBELN = VBAKVBELN )
WHERE likp~vbeln IN so_vbeln
AND likp~lifex IN so_lifex
AND likp~lfart IN so_lfart
AND likp~kunnr IN so_kunnr
AND likp~vstel IN so_vstel
AND likp~bldat IN so_bldat
AND likp~wadat_ist IN so_wadat
AND vbup~kosta IN so_kosta
AND vbup~wbsta IN so_wbsta
AND LIPS~LFIMG NE 0.
SELECT VBELN IHREZ INTO TABLE T_VBAK
FROM VBAK
FOR ALL ENTRIES IN IT_ITAB
WHERE VBELN = IT_ITAB-VGBEL.
APPEND T_VBAK.
ENDSELECT.
SELECT VBELN MATNR POSNR INTO TABLE T_VBAP
FROM VBAP
FOR ALL ENTRIES IN IT_ITAB
WHERE VBELN = IT_ITAB-VGBEL AND
MATNR = IT_ITAB-MATNR AND
POSNR = IT_ITAB-VGPOS.
APPEND T_VBAP.
ENDSELECT.
SELECT VBELV VBELN VBTYP_N INTO TABLE T_VBFA
FROM VBFA
FOR ALL ENTRIES IN IT_ITAB
WHERE VBELV = IT_ITAB-VBELN AND
VBTYP_N = 'M' .
SELECT KUNNR NAME1 INTO TABLE T_KNA1
FROM KNA1
FOR ALL ENTRIES IN IT_ITAB
WHERE KUNNR = IT_ITAB-KUNNR.
APPEND T_KNA1.
ENDSELECT.
SELECT MATNR MAKTX INTO TABLE T_MAKT
FROM MAKT
FOR ALL ENTRIES IN IT_ITAB
WHERE MATNR = IT_ITAB-MATNR.
APPEND T_MAKT.
ENDSELECT.
*Populate field with color attributes
LOOP AT it_itab INTO wa_ITAB.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
REFRESH color.
colourize 'VBELN' 0. " .
WA_ITAB-farbe = color[].
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
IF ld_color = 3. "8
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ITAB-line_color.
WA_ITAB-NAME1 = ''.
WA_ITAB-MAKTX = ''.
WA_ITAB-IHREZ = ''.
WA_ITAB-VBELV = ''.
READ TABLE T_KNA1 WITH KEY KUNNR = WA_ITAB-KUNNR.
IF SY-SUBRC = 0.
WA_ITAB-NAME1 = T_KNA1-NAME1.
ENDIF.
READ TABLE T_MAKT WITH KEY MATNR = WA_ITAB-MATNR.
IF SY-SUBRC = 0.
WA_ITAB-MAKTX = T_MAKT-MAKTX.
ENDIF.
READ TABLE T_VBAK WITH KEY VBELN = WA_ITAB-VGBEL.
IF SY-SUBRC = 0.
WA_ITAB-IHREZ = T_VBAK-IHREZ.
ENDIF.
READ TABLE T_VBFA WITH KEY VBELV = WA_ITAB-VBELN.
IF SY-SUBRC = 0.
WA_ITAB-VBELVA = T_VBFA-VBELN.
ENDIF.
READ TABLE T_VBAP WITH KEY VBELN = WA_ITAB-VGBEL
POSNR = WA_ITAB-VGPOS
MATNR = WA_ITAB-MATNR.
IF SY-SUBRC = 0.
WA_ITAB-IHREZ = T_VBAK-IHREZ.
ENDIF.
wa_ekko-line_color = 'C410'.
MODIFY it_itab FROM wa_itab.
ENDLOOP.
ENDFORM. " data_retrievalhi Jyotirmoy,
The explanation below can give u an idea of wat is going in ur code..
Use of FOR ALL Entries
Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
Not Recommended
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
Recommended
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
Thankyou,
Regards. -
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. -
Dynamic Select Query including Dynamic Tables with For all Entries
Hello everyone,
I need to create a select query which involves using of Dynamic Tables.
Suppose I have a dynamic table <d1> which consist of let say 10 records.
Now i need to make a select query putting data into another dynamic table <d2>
CONCATENATE keyfield '=' '<d1>' INTO g_condition SEPARATED BY space.
CONCATENATE g_condition '-' keyfield INTO g_condition.
SELECT * FROM (wa_all_tables-name) INTO CORRESPONDING FIELDS OF TABLE <d1>
FOR ALL ENTRIES IN <d1>
WHERE (g_condition).
But it is giving dump.
Please help me on this....Short text
A condition specified at runtime has an unexpected format.
What happened?
Error in the ABAP Application Program
The current ABAP program "ZNG_CUSTOMWRITE" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
not caught in
procedure "WRITE_ARCHIVE_PROD" "(FORM)", nor was it propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The current ABAP program has tried to execute an Open SQL statement
which contains a WHERE, ON or HAVING condition with a dynamic part.
The part of the WHERE, ON or HAVING condition specified at runtime in
a field or an internal table, contains the invalid value "ZCOURIER-ZCOURIERID".
CONCATENATE keyfield '=' g_header INTO g_condition SEPARATED BY space.
CONCATENATE g_condition '-' keyfield INTO g_condition.
SELECT * FROM (wa_all_tables-name) INTO CORRESPONDING FIELDS OF TABLE <dyn_table1>
FOR ALL ENTRIES IN <dyn_table>
WHERE (g_condition). -
Performance optimization on select query for all entries
Hi All,
I want to optimize the select query in my Program.
The select query is taking lot of time to search the records for the given condition in the where clause
and more interestingly there are no records fetched from the database as the where condition does not matches.
It is taking more than 30 min to search the record and the result is no record found.
Below is my select query. I have also created the secondary Index for the same.
In My opinion FOR ALL ENTRIES is taking lot of time. Because there are more than 1200 records in internal table t_ajot
select banfn bnfpo bsart txz01 matnr Werks lgort matkl reswk menge meins flief ekorg
INTO CORRESPONDING FIELDS OF TABLE t_req
FROM eban
FOR ALL ENTRIES IN t_ajot
WHERE matkl >= t_ajot-matkl_low
AND matkl <= t_ajot-matkl_high
AND werks = t_ajot-werks
AND loekz = ' '
AND badat IN s_badat
AND bsart = 'NB'.
Please suggest.Hi,
that,
FOR ALL ENTRIES IN t_ajot
WHERE matkl >= t_ajot-matkl_low
AND matkl <= t_ajot-matkl_high
AND werks = t_ajot-werks
AND loekz = ' '
AND badat IN s_badat
AND bsart = 'NB'.
looks strange.
However:
How does your index look like?
What executoin plan do you get?
How do the statistics look like?
Whats the content of the variables t_ajot-... and s_badata?
Kind regards,
Hermann -
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 -
SELECT ... FOR ALL ENTRIES IN fails!!!
Hi,
we are on Kernel 640_REL unicode and found a Kernel error:
Using SELECT ... FOR ALL ENTRIES IN with a field list to be retrieved, the ABAP-Database interface obviously deletes duplicate records.
Our scenario is retrieval of open special ledger postings for customers from BSID.
The fields specified were
BUKRS KUNNR WAERS DMBTR WRBTR SHKZG UMSKZ
If a customer has more than one matching record with the same amount, only one of those is returned. The only way to get all matching records is to retrieve all key fields.
I forwarded to the people handling OSS-requests in our project. Before we get the solution, i want to issue a severe warning.
This failure is decribed in note 65554 for Kernel-Release <= 3.0F and <= 4.6D, also Release 6.10. But nothing newer.
After all those years of ABAP I did not expect they can't handle SQL.
regards,
ClemensHi Clemens
If I understand your post, I don't think there is an error, the following is from the online help:
"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. "
I believe that 'FOR ALL ENTRIES' is a union and therefore duplicate rows are removed. If you want each row to appear then you need to make the row unique by using all the key fields. I think it would also be better to inlcude all the key fields in the WHERE clause anyway.
Kind regards
Andy -
Can a JOIN statement be rewritten using FOR ALL ENTRIES in any case ?
I had a SELECT statement, like:
select p~key1 t~col3 t~col4 p~col2 p~col3
into table itab1
from ( table1 as p left outer join table2 as t
on p~key1 = t~key1 and t~col2 = someValue ).
Among which, table1 and table2 are fully buffered.
Code Inspector suggests that this statement should be, e.g., rewritten using FOR ALL ENTRIES.
Since FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT statement, which means the internal table right after it is not available for the RESULT clause of the SELECT statement, can the above statement be rewritten? If yes, how?
Thanks!hi ,
select pkey1 tcol3 tcol4 pcol2 p~col3
into table itab1
from ( table1 as p left outer join table2 as t
on pkey1 = tkey1 and t~col2 = someValue ).
<i>look below code</i>
select * from table2 into table int_tab2 where col2 = someValue.
select key1 col2 col3 into table int_tab1
FOR ALL ENTRIES IN int_tab2
WHERE key = int_tab2-key1.
then use read statements for manipulations
rgds
Anver
Maybe you are looking for
-
Timeout during allocate of Vertex RFC
Hi Guys. Im facing this odd issue after an offline backup is completed and brings the system. As you can see the Vertex RFC is no longer working and displays a timeout issue after a Sales programs tries to reach it. Also when testing the RFC is unabl
-
How to import XMP metadata in pdf
Could you please explain me, how to import XMP metadata in pdf file through "Live Cycle ES"?
-
Can preview, not publish
I am using Captivate 4 on Windows XP. I have several cp files I am working with. All publish to swf except one. This one file allows me to preview, but not publish. There is no error message generated. I click the "Publish" button, the mouse pointer
-
Hi, I want to transfer a database from one computer A to another computer B. On the B computer I created manually the database. If I imported one time the database with full = y, and appeared errors, the users were created but the tables were without
-
CCB2.4 and setting up user's password
Hi, In CCB2.4 is it possible to set password by the user itself? Not like the one done using Tomcat, where administrator has to set the password but something like windows password, which is set by the user itself.