CAN USE SELECT OPTION FIELD IN FOR ALL ENTRIES CONCEPT
Hi sir/ madam,
can i write code like this .
i have data in itab1 .
select-options : s_matnr like lips-matnr.
SELECT VBELN VGBEL VGPOS MATNR
FROM LIPS
INTO TABLE I_LIPS
FOR ALL ENTRIES IN ITAB1
WHERE VBELN = ITAB1-VBELN AND
MATNR = S_MATNR.
Thanks & Regards
Suresh kumar
Hi Suresh,
To correct ur code syntactically, repacle the
=
operator with
IN
. This may be correct but from data consistency point of view this may not be the ideal thing to do.
You can foolow thw following steps:
1. Fetch data in ITAB1 using the MATNR in the select-option. I hope you do have
MATNR in ITAB1.
2.
SELECT VBELN VGBEL VGPOS MATNR
FROM LIPS
INTO TABLE I_LIPS
FOR ALL ENTRIES IN ITAB1
WHERE VBELN = ITAB1-VBELN AND
MATNR = ITAB1-MATNR.
This should be correct form data consistency view-point.
Hope this answers ur query. Please award points if u find the answer helpful.
Regards,
Suhas
Similar Messages
-
Regarding 'Select .... for all entries' statement
Hi experts,
Can anyone suggest me that whether we can use two internal tables in 'Select .... for all entries' statement?Hi,
You can use ranges instead of second for all entries.
Eg:
Say for example i need to write selec statement using fields from two int tables in where conidition namely itab1, itab2.
RANGES: r_vbeln FOR wa_tab1-vbeln.
LOOP AT itab1 INTO wa_tab1.
r_vbeln-sign = 'I'.
r_vbeln-option = 'EQ'.
r_vbeln-low = wa_tab1-vbeln.
APPEND r_vbeln.
ENDLOOP.
SELECT * FROM vbap INTO TABLE itab3
FOR ALL ENTRIES IN itab2
WHERE vbeln IN r_vbeln "range contains all vbeln from the table itab1
AND matwa = itab2-matwa.
Hope this helps you.
Regards,
Manoj Kumar P -
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 -
Using select-option in webdynpro for ABAP where I have two separate pages
Hi Experts,
I have a requirement where I have two pages. The first page is a selection screen that contains 2 select-options to select carrid and connid. There is also a button 'Submit'. The second page contains a ALV grid output based on the selection screen criteria.
Second page is opened on the clicking the 'Submit' button in first page.
How to design a ABAP webdynpro component for this scenario?
How to pass select-option values to the next page?
What nodes/attributes should I have to create in component controller?
Please provide me the step by step info.
I have seen the weblog by Rich Heilman at /people/rich.heilman2/blog/2005/12/20/using-select-options-in-a-web-dynproabap-application
But it has only one page. So I am not able to recreate my scenario based on this.
Thanks
GopalHi Experts,
I have a requirement where I have two pages. The first page is a selection screen that contains 2 select-options to select carrid and connid. There is also a button 'Submit'. The second page contains a ALV grid output based on the selection screen criteria.
Second page is opened on the clicking the 'Submit' button in first page.
How to design a ABAP webdynpro component for this scenario?
How to pass select-option values to the next page?
What nodes/attributes should I have to create in component controller?
Please provide me the step by step info.
I have seen the weblog by Rich Heilman at /people/rich.heilman2/blog/2005/12/20/using-select-options-in-a-web-dynproabap-application
But it has only one page. So I am not able to recreate my scenario based on this.
Thanks
Gopal -
I have the following SELECT statement:
SELECT recn, recnroot, ippers
INTO CORRESPONDING FIELDS OF TABLE <ITAB1>
FROM CCIHT_IP
FOR ALL ENTRIES IN <ITAB2>
WHERE ippers = <ITAB2>-ippers
AND valfr LE sy-datum
AND valto GE sy-datum
AND iptype = 'INJ'.
Did a trace, and the SQL executed is:
SELECT recn, recroot, ippers
FROM CCIHT_IP
WHERE mandt= ?
AND ippers IN (?1, ..., ?10)
AND valfr <= ?
AND valto >= ?
AND iptype = ?
FOR FETCH ONLY WITH UR
This is very slow.
To speed it up, I programmatically break up the SQL using a range table:
i.e.: WHERE ...
AND IPPERS IN <RANGE TABLE>
With the range table containing 1500 entries which is near the limit for IN statement. This is much faster.
The question is why with the FOR ALL ENTRIES the IN statement contains only 10 values and not the maximum allowed, is this a database config issue ?Hi,
as Thomas said for this case rsdb/max_in_blocking_factor is the parameter in question.
And yes, Andrew, you are right, FAE parameters should not be changed system wide
since the delivered default values are those values that turned out to be the best values
in systemwide tests.
However you can increase the value on statement level with a hint. So you can have both
the FAE and a non default blocking for a specific statement.
example:
SELECT recn, recnroot, ippers
INTO CORRESPONDING FIELDS OF TABLE <ITAB1>
FROM CCIHT_IP
FOR ALL ENTRIES IN <ITAB2>
WHERE ippers = <ITAB2>-ippers
AND valfr LE sy-datum
AND valto GE sy-datum
AND iptype = 'INJ'
%_hints db2 '&max_blocking_factor 500&&max_in_blocking_factor 500&u2019.
Use with care.
Kind regards,
Hermann -
Select inside loop into for all entries or joins
Experts please help in making it into for all entries or joins.
suppose assume this
zuser table has 2 fields usage and kunnr.
in i_table i always have 2 fields.
type
number
type will store user or nonuser
and number can store customer number or sales order number.
if the type is user then the numer will be customer number and
if the type is nonuser then the number will be sales order number.
and values in this table is like this
type number
user 100001210
nonuser 123200000
user 124573930
user 294839039
user 138393903
nonuser 382749239
type always have user or nonuser and corresponding to them we have customer numbers.
and now based on this we need to fine tune this code.
parameters :p_usage(20) type char
LOOP AT i_table.
IF i_table-type = 'NONUSER'.
SELECT single kunnr INTO skunnr FROM vbak WHERE
vbeln = i_table-value.
ENDIF.
ENDIF.
IF i_table-type = 'USER'.
skunnr = i_table-value.
ENDIF.
IF skunnr is not initial.
SELECT single usage FROM zuser
INTO v_usage
WHERE usage = p_usage
AND kunnr = skunnr.
IF v_usage IS NOT INITIAL.
i_export-kunnr = i_table-type.
i_export-auart = i_table-name.
i_export-flag = 'X'.
ELSE.
i_export-NAME = i_table-type.
i_export-age = i_table-name.
i_export-flag = ''.
ENDIF.
Append i_export to itab_final.
ENDIF.
ENDLOOP.
Moderator message - Moved to the correct forum
Edited by: Rob Burbank on Jul 2, 2009 2:53 PMU can have this as a solution to avoid ur loop.
declare to itabs as below:
data: i_table_user type standard table of i_table,
i_table_nonuser type standard table of i_table.
i_table_user[] = i_table[].
i_table_nonuser[] = i_table[].
delete i_table_user where user eq 'NONUSER' . (BY THIS YOU WILL HAVE ONLY USERS IN THIS ITAB)
delete i_table_NONuser where user eq 'USER' . (BY THIS YOU WILL HAVE ONLY NONUSERS IN THIS ITAB)
NOW AVOID LOOP AT ITAB AND WRITE YOUR 2 SELECT STATEMENT BY USING FOR ALL ENTRIES OF
IF YOU DONT NEED any of THESE ITABS FURTHER , refresh them to improve ur memory and performance.
HOPE THIS HELPS.
THANKS
KIRAN -
How to use dynamic internal table with FOR ALL ENTRIES
Hello SDNers,
I am having a dynamic internal table & want to use FOR ALL ENTRIES(FAE) using this dyn. table.
This works fine for me:
IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
SELECT field1 field2
FROM TABLE ztable
INTO TABLE itab "Itab is a static table
FOR ALL ENTRIES IN <lt_tmp>
WHERE (lv_dynwhere). "lv_dynwhere -> dynamic where clause
ENDIF.
SAP documentation says:
"The logical expression sql_cond of the WHERE condition can be comprised of several logical expressions using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one comparison with a column of the internal table itab that can be specified statically or dynamically. "
How do we specify the column of the internal table dynamically ? Can we do something like this:
IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
SELECT field1 field2
FROM TABLE
INTO TABLE itab "Itab is a static table
FOR ALL ENTRIES IN <lt_tmp>
WHERE key_field1 = (dynamic token for column1 of <lt_tmp>)
key_field2 = (dynamic token for column2 of <lt_tmp>)
ENDIF.
ENDIF.
Let me know if i am not clear about my requirement.
BR,
SuhasHello Thomas,
What i meant was something like this:
WHERE key_field1 = ('<LT_TMP-COL1>') AND
key_field2 = ('<LT_TMP-COL2>')
I am confused by what SAP means with "dynamic representation of internal table columns" in FAE ?
@Rob: I was referring to SAPNW 7.0 documentation & the phrase (release 6.40 & higher) is missing. Anyways fyi i am on ECC5.0 ABAP release 6.40.
@Subhankar: This is what Marcin had proposed in For all entries and dynamic table.
Thanks,
Suhas
Edited by: Suhas Saha on Apr 6, 2010 11:53 AM -
Using aggregate function along with for all entries: sugest alternative
My requirement:
For each record in i_vbap for which 'charg' is initial, need to determine batch using the following logic:
For the material (MATNR) in i_vbap, select the batch (CHARG) which has the largest (MAX) unrestricted inventory quantity (CLABS) from MCHB table.
How do I implement this logic without using select statement inside a loop as I cannot use MAX ( CLABS ) function along with FOR ALL ENTRIES in a SELECT?
Suggest an alternative.For each record in i_vbap for which 'charg' is initial ,fetch all the existing 'clabs' value.
[ Remember to include all the key fields in selct ]
Sort the new table .
Put a loop,use at end of 'charg' and append to another table. U get ur solution
I think this should be the most economic way to do so. -
How to use single buffered table with FOR ALL ENTRIES KEYWORD
Hai,
I'm Using TJ02T Database table, It is single buffered table but at the same time I want to use FOR ALL ENTRIES KEYWORD , Please Help me.
Regards,
S.JananiHi,
FOR ALL ENTRIES will not depend on the buffering nature of the table. The single buffered table will only only buffer one record into memory. You can still use the statement to query the values, but it may have performance problems if the data volume is high since the records are not completely buffered into memory, the time will spent in getting data from DB.
Thanks..
Preetham S -
Need to SUM on a field with FOR ALL ENTRIES
Hi All,
I need to use something like this appearing below ....but SUM is not allowed with FOR ALL ENTRIES ......Whats the efficient ALTERNATIVE ???
SELECT sum( menge ) INTO TABLE imseg
FROM mseg
FOR ALL ENTRIES IN iresb
WHERE matnr = iresb-matnr
AND bwart = '281'
AND aufpl = iresb-aufpl
AND aplzl = iresb-aplzl.
Any help will be rewarded & appreciated ...
Regards
JamanHi Karthik,
Thanx a ton....
How about the below approach .....its allowed & working fine ....also simplifying my work..
SELECT matnr menge rsnum rspos
INTO (ws-matnr, ws-menge, ws-rsnum, ws-rspos)
FROM mseg
FOR ALL ENTRIES IN iresb
WHERE matnr = iresb-matnr
AND bwart = mvtyp1
AND rsnum = iresb-rsnum
AND rspos = iresb-rspos.
imseg2-matnr = ws-matnr.
imseg2-menge = ws-menge.
imseg2-rsnum = ws-rsnum.
imseg2-rspos = ws-rspos.
COLLECT imseg2.
ENDSELECT. -
SELECT with and without for all entries giving different results
Hi All,
For some reason unknown to me ,
There is a difference in result between the below mentioned query however the logic is same.
1 . lw_ebeln-EBELN = '0000366416'.
APPEND lw_ebeln to lt_ebeln.
SELECT ebeln
FROM ekbe
INTO TABLE lt_ekbe
FOR ALL ENTRIES IN lt_ebeln
WHERE ebeln = lt_ebeln-ebeln
2. SELECT ebeln from ekbe into table lt_ekbe where
ebeln = '0000366416'..
I have tried a lot to find the reason but unable to.
Thanks,
FaizHi faizur,
Hope it help ful.
If you add the EBELP in Internal table, you will be getting same number of entries in both query.
For all entries Removes the Duplicate key.
Regards,
Venkat. -
How can I select a smaller font for all components of a Swing application?
The default size of font in Java Look and Feel is 12, how can I change it to 10 globally for my Swing application ?
Thanks for your help.
HelenIt is not very simple because all components don't use the same fonts and if you don't want to subclass the l&f you can do this :
after setting the l&f (in the main for example)
Font f = new Font("dialog", Font.PLAIN, 11);
UIManager.put("MenuItem.font", f);
UIManager.put("Menu.font", f);
UIManager.put("MenuItem.acceleratorFont", new Font("dialog", Font.PLAIN, 10));
UIManager.put("Label.font", f);
UIManager.put("Button.font", f);
UIManager.put("ToggleButton.font", f);
UIManager.put("ToolTip.font", f);
UIManager.put("List.font", f);
UIManager.put("Table.font", f);
UIManager.put("TextField.font", f);
UIManager.put("ComboBox.font", f);
UIManager.put("RadioButton.font", f);
UIManager.put("CheckBox.font", f);
UIManager.put("RadioButtonMenuItem.font", f);
UIManager.put("CheckBoxMenuItem.font", f);
UIManager.put("TableHeader.font", f);
UIManager.put("Spinner.font", f);
UIManager.put("Panel.font", f);etc...
Denis -
"inner join" PLUS "into corresponding fields" in "for all entries" ???
SAP provides the following example:
DATA: BEGIN OF wa,
struc1 TYPE scarr,
struc2 TYPE spfli,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY table_line.
SELECT *
FROM scarr
INNER JOIN spfli ON scarr~carrid = spfli~carrid
INTO TABLE itab.
LOOP AT itab INTO wa.
WRITE: / wa-struc1-carrid,
wa-struc1-carrname,
wa-struc2-connid.
ENDLOOP.
What should the syntax be if:
1) struc1 is your own type with just a few selected fields from scarr;
2) struc2 is your own type with just a few selected fields from spfli
3) you only want these fields in your SELECT (instead of the SELECT *).
Please provide answer only if you know your code works.
Thanks.
djhYes, aRs - thanks.
Someone in the shop here had an example that I coded from, and it's like yours:
REPORT ZFOO.
TABLES:
/sapapo/trprod,
/sapapo/matkey.
TYPES:
BEGIN OF tx_trprod_new,
MATID TYPE /SAPAPO/MATID,
matnr TYPE /sapapo/matnr,
END OF tx_trprod_new.
DATA:
it_trprod_new TYPE STANDARD TABLE OF tx_trprod_new,
v_num TYPE i.
SELECT /sapapo/trprod~matid
/sapapo/matkey~matnr
FROM /sapapo/trprod
JOIN /sapapo/matkey ON /sapapo/trprod~matid = /sapapo/matkey~matid
INTO
TABLE it_trprod_new
WHERE /sapapo/trprod~matid LIKE 'H%'. -
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 -
What is the condition for using 'for all entries' and why?
what is the condition for using 'for all entries' and why? can any body tell the reason for this ? its a big favour of me .
regards,
ravi.hi,
for all entries is used to join two or more tables.
It is same as join but performance wise for all entries is more effective.
You can only use FOR ALL ENTRIES IN ...WHERE ...in a SELECT statement.
SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT
statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol
itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result
set. If the internal table itab does not contain any entries, the system treats the statement as though there were
no WHERE cond condition, and selects all records (in the current client).
for example:
SELECT * FROM sflight INTO wa_sflight
FOR ALL ENTRIES IN ftab
WHERE CARRID = ftab-carrid AND
CONNID = ftab-connid AND
fldate = '20010228'.
this condition, return all entries of the sflight
hen using FOR ALL ENTRIES the number of matching records is restricted to the number of records in the internal table. If the number of records in the database tables is too large then join would cause overheads in performance. Additionally a JOIN bypasses the table buffering.
So for all entries is used for filtering out the data from the two tables based on the entries in them.
Advantages:
1) For all entries avoids inner join & so the performance increases.
2) For specified values in 1 itab, if you to fetch values from other table you can use it.
3) Use of select stmt in loop is gets avoided, as u can use read statement on the the new itab.
Maybe you are looking for
-
Firefox keeps saying it is not responding
i have a samsung netbook and have firefox 4 but when i go on the internet after a few mins it stops working and says on the blue line at the top 'not responding'. i have to restart my computer and start a over again. occasionally after a few mins it
-
Extraction Queue - SMQ1 - entries..
HI All, We are running some data loads from source SRM to BI . We have a Strange Issue: Without triggering process chains or Infopack groups in BI side, Extraction queues (SMQ1 TRFCs ) are filled automatically with some entries. It will causes
-
System Crashes when trying to print or save a document
Since upgrading to OS10.6.5, our system crashes (usually the affected software becomes non-responsive, but sometimes the entire computer freezes) whenever trying to print, clicking on printers/faxes within the preferences panel, trying to save a "Pag
-
Permanent solution to Runtime Error
I have a "Microsoft Visual C++ Runtime Error" using Photoshop Elements 11 and have cleared it by renaming the MediaDatabase.db3 file as suggested. The only problem is, it occurs every time I start Photoshop and it's getting a bit tiresome having to g
-
Re: Canon IXUS V installation - Camera connection not detected
I have installed this driver from the Cannon website but when I connect the camera I get a message saying " Camera connection not detected" followed by an error message saying pscN109 has stopped working. Then a Microsoft message saying no soloution