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 entries
Hi.
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
Similar Messages
-
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 -
hi gurus,
plz check my report using for all entries where i am give data in selection screen from date to date as 3.01.2007 to 4.02.2007
my code does not provide me data between above date to date.
it fetch data from other date like 26.06.2006 to some other
plz check code and give me solution for it.
TABLES: bseg, bkpf.
*ALV grid_data
TYPE-POOLS: slis.
INTERNAL TABLES
TYPES: BEGIN OF it_output,
bukrs TYPE bseg-bukrs, "Company Code
belnr TYPE bseg-belnr, "Accounting Document Number
gjahr TYPE bseg-gjahr, "Fiscal Year
buzei TYPE bseg-buzei, "Number of Line Item
augdt TYPE bseg-augdt, "Clearing Date
shkzg TYPE bseg-shkzg, "Debit/Credit Indicator
dmbtr TYPE bseg-dmbtr, "Amount in local currency
kostl TYPE bseg-kostl, "Cost Center
hkont TYPE bseg-hkont, "G/L Account
matnr TYPE bseg-matnr, "Material Number
werks TYPE bseg-werks, "Plant
erfmg TYPE bseg-erfmg, "Quantity in unit of entry
blart TYPE bkpf-blart, "Document type
bldat TYPE bkpf-bldat, "Document Date
budat TYPE bkpf-budat, "Posting Date
monat TYPE bkpf-monat, "Fiscal period
cpudt TYPE bkpf-cpudt, "Document Entry Date
usnam TYPE bkpf-usnam, "User name
tcode TYPE bkpf-tcode, "Transaction Code20
bktxt TYPE bkpf-bktxt, "Document Header Text
waers TYPE bkpf-waers, "Currency Key
awtyp TYPE bkpf-awtyp, "Reference procedure
awkey TYPE bkpf-awkey, "Object key
END OF it_output.
TYPES: BEGIN OF it_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr TYPE bkpf-gjahr,
blart TYPE bkpf-blart,
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
monat TYPE bkpf-monat,
cpudt TYPE bkpf-cpudt,
usnam TYPE bkpf-usnam,
tcode TYPE bkpf-tcode,
bktxt TYPE bkpf-bktxt,
waers TYPE bkpf-waers,
awtyp TYPE bkpf-awtyp,
awkey TYPE bkpf-awkey,
END OF it_bkpf.
DATA: lt_output TYPE it_output OCCURS 0 WITH HEADER LINE.
DATA: lt_bkpf TYPE it_bkpf OCCURS 0 WITH HEADER LINE.
ALV DECLARATION DATA *
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
it_heading TYPE slis_t_listheader,
it_sort TYPE slis_t_sortinfo_alv,
it_events TYPE slis_t_event,
it_alv_event TYPE slis_alv_event,
gv_repname TYPE syrepid,
gv_save TYPE char1,
is_layout TYPE slis_layout_alv.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE text-011.
SELECT-OPTIONS: s_bukrs FOR bseg-bukrs NO INTERVALS,
s_blart FOR bkpf-blart,
s_budat FOR bkpf-budat.
SELECTION-SCREEN END OF BLOCK bl.
START OF SELECTION *
START-OF-SELECTION.
PERFORM get_data.
End of Selection *
END-OF-SELECTION.
PERFORM build_field_catalog.
PERFORM eventstab.
PERFORM display_data.
FORMS *
*& Form get_data
Get Data
FORM get_data .
SELECT bukrs
belnr
gjahr
buzei
augdt
shkzg
dmbtr
kostl
hkont
matnr
werks
erfmg
INTO TABLE lt_output
FROM bseg
WHERE bukrs IN s_bukrs.
IF sy-subrc = 0.
SORT lt_output BY belnr.
DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
ENDIF.
IF NOT lt_output[] IS INITIAL.
SELECT bukrs
belnr
gjahr
blart
bldat
budat
monat
cpudt
usnam
tcode
bktxt
waers
awtyp
awkey
INTO TABLE lt_bkpf FROM bkpf
FOR ALL ENTRIES IN lt_output
WHERE bukrs = lt_output-bukrs AND
belnr = lt_output-belnr AND
gjahr = lt_output-gjahr."AND
blart IN s_blart AND
budat IN s_budat ." AND
blart = 'SA' OR
blart = 'SB' OR
blart = 'AB' OR
blart = 'ZC'.
*sort lt_bkpf by blart budat.
DELETE lt_bkpf WHERE blart NOT IN s_blart AND
budat NOT IN s_budat.
ENDIF.
SORT lt_bkpf BY bukrs belnr.
SORT lt_output[].
DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.
LOOP AT lt_output.
READ TABLE lt_bkpf WITH KEY bukrs = lt_output-bukrs
belnr = lt_output-belnr
budat = lt_output-budat
BINARY SEARCH.
IF sy-subrc = 0.
MOVE: lt_bkpf-gjahr TO lt_output-gjahr,
lt_bkpf-belnr TO lt_output-belnr,
lt_bkpf-blart TO lt_output-blart,
lt_bkpf-bldat TO lt_output-bldat,
lt_bkpf-budat TO lt_output-budat,
lt_bkpf-monat TO lt_output-monat,
lt_bkpf-cpudt TO lt_output-cpudt,
lt_bkpf-usnam TO lt_output-usnam,
lt_bkpf-tcode TO lt_output-tcode,
lt_bkpf-bktxt TO lt_output-bktxt,
lt_bkpf-waers TO lt_output-waers,
lt_bkpf-awtyp TO lt_output-awtyp,
lt_bkpf-awkey TO lt_output-awkey.
MODIFY lt_output.
ELSE.
DELETE lt_output.
ENDIF.
ENDLOOP.
ENDFORM. "get_data
thanks jayantHi Jayant,
You cannot retrieve data first from BSEG and then from BKPF.
It is not correct and you cannot get the correct data.
You should use BKPF which is header table first and then
using for all entries retrieve data from BSEG.
Use date field in the select statement condition for BKPF table retrieval and
you don't have posting date field in BSEG.
If you do like this, it will definitely work.
Retrieve data from BKPF using date condition in SELECT statement.
Then, using for all entries retrieve from BSEG.
Reward if helpful. -
Driver table in select for all entries
anyone please let me what is driver table in select for all entries and when do we go for select for all entries
Here is something from help
FOR ALL ENTRIES WHERE
Syntax
... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...
Effect
If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.
The internal table itab must have a structured line type and the component comp must be compatible with the column col.
The logical expression sql_cond of the WHERE condition can comprise various logical expressions by 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, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.
The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.
Notes
In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.
The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
Example
Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
PARAMETERS p_city TYPE spfli-cityfrom.
TYPES: BEGIN OF entry_tab_type,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
END OF entry_tab_type.
DATA: entry_tab TYPE TABLE OF entry_tab_type,
sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.
SELECT carrid connid
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE entry_tab
WHERE cityfrom = p_city.
SELECT carrid connid fldate
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE sflight_tab
FOR ALL ENTRIES IN entry_tab
WHERE carrid = entry_tab-carrid AND
connid = entry_tab-connid.
Regards,
Santosh -
Hi guru's what is the diff between for all entries & joins
hi guru's what is the diff between for all entries & joins
Hi Vasu,
Joins are used to fetch data fast from Database tables:
Tables are joined with the proper key fields to fetch the data properly.
If there are no proper key fields between tables don't use Joins;
Important thing is that don't USE JOINS FOR CLUSTER tableslike BSEG and KONV.
Only use for Transparenmt tables.
You can also use joins for the database VIews to fetch the data.
JOINS
... FROM tabref1 [INNER] JOIN tabref2 ON cond
Effect
The data is to be selected from transparent database tables and/or views determined by tabref1 and tabref2. tabref1 and tabref2 each have the same form as in variant 1 or are themselves Join expressions. The keyword INNER does not have to be specified. The database tables or views determined by tabref1 and tabref2 must be recognized by the ABAP Dictionary.
In a relational data structure, it is quite normal for data that belongs together to be split up across several tables to help the process of standardization (see relational databases). To regroup this information into a database query, you can link tables using the join command. This formulates conditions for the columns in the tables involved. The inner join contains all combinations of lines from the database table determined by tabref1 with lines from the table determined by tabref2, whose values together meet the logical condition (join condition) specified using ON>cond.
Inner join between table 1 and table 2, where column D in both tables in the join condition is set the same:
Table 1 Table 2
A
B
C
D
D
E
F
G
H
a1
b1
c1
1
1
e1
f1
g1
h1
a2
b2
c2
1
3
e2
f2
g2
h2
a3
b3
c3
2
4
e3
f3
g3
h3
a4
b4
c4
3
|--|||--|
Inner Join
A
B
C
D
D
E
F
G
H
a1
b1
c1
1
1
e1
f1
g1
h1
a2
b2
c2
1
1
e1
f1
g1
h1
a4
b4
c4
3
3
e2
f2
g2
h2
|--||||||||--|
Example
Output a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
DATA: DATE LIKE SFLIGHT-FLDATE,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID.
SELECT FCARRID FCONNID F~FLDATE
INTO (CARRID, CONNID, DATE)
FROM SFLIGHT AS F INNER JOIN SPFLI AS P
ON FCARRID = PCARRID AND
FCONNID = PCONNID
WHERE P~CITYFROM = 'FRANKFURT'
AND P~CITYTO = 'NEW YORK'
AND F~FLDATE BETWEEN '20010910' AND '20010920'
AND FSEATSOCC < FSEATSMAX.
WRITE: / DATE, CARRID, CONNID.
ENDSELECT.
If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or a table alias.
Note
In order to determine the result of a SELECT command where the FROM clause contains a join, the database system first creates a temporary table containing the lines that meet the ON condition. The WHERE condition is then applied to the temporary table. It does not matter in an inner join whether the condition is in the ON or WHEREclause. The following example returns the same solution as the previous one.
Example
Output of a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
DATA: DATE LIKE SFLIGHT-FLDATE,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID.
SELECT FCARRID FCONNID F~FLDATE
INTO (CARRID, CONNID, DATE)
FROM SFLIGHT AS F INNER JOIN SPFLI AS P
ON FCARRID = PCARRID
WHERE FCONNID = PCONNID
AND P~CITYFROM = 'FRANKFURT'
AND P~CITYTO = 'NEW YORK'
AND F~FLDATE BETWEEN '20010910' AND '20010920'
AND FSEATSOCC < FSEATSMAX.
WRITE: / DATE, CARRID, CONNID.
ENDSELECT.
Note
Since not all of the database systems supported by SAP use the standard syntax for ON conditions, the syntax has been restricted. It only allows those joins that produce the same results on all of the supported database systems:
Only a table or view may appear to the right of the JOIN operator, not another join expression.
Only AND is possible in the ON condition as a logical operator.
Each comparison in the ON condition must contain a field from the right-hand table.
If an outer join occurs in the FROM clause, all the ON conditions must contain at least one "real" JOIN condition (a condition that contains a field from tabref1 amd a field from tabref2.
Note
In some cases, '*' may be specified in the SELECT clause, and an internal table or work area is entered into the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the FROM clause, according to the structure of each table work area. There can then be gaps between table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, not simply by counting the total number of fields. For an example, see below:
Variant 3
... FROM tabref1 LEFT [OUTER] JOIN tabref2 ON cond
Effect
Selects the data from the transparent database tables and/or views specified in tabref1 and tabref2. tabref1 und tabref2 both have either the same form as in variant 1 or are themselves join expressions. The keyword OUTER can be omitted. The database tables or views specified in tabref1 and tabref2 must be recognized by the ABAP-Dictionary.
In order to determine the result of a SELECT command where the FROM clause contains a left outer join, the database system creates a temporary table containing the lines that meet the ON condition. The remaining fields from the left-hand table (tabref1) are then added to this table, and their corresponding fields from the right-hand table are filled with ZERO values. The system then applies the WHERE condition to the table.
Left outer join between table 1 and table 2 where column D in both tables set the join condition:
Table 1 Table 2
A
B
C
D
D
E
F
G
H
a1
b1
c1
1
1
e1
f1
g1
h1
a2
b2
c2
1
3
e2
f2
g2
h2
a3
b3
c3
2
4
e3
f3
g3
h3
a4
b4
c4
3
|--|||--|
Left Outer Join
A
B
C
D
D
E
F
G
H
a1
b1
c1
1
1
e1
f1
g1
h1
a2
b2
c2
1
1
e1
f1
g1
h1
a3
b3
c3
2
NULL
NULL
NULL
NULL
NULL
a4
b4
c4
3
3
e2
f2
g2
h2
|--||||||||--|
Example
Output a list of all custimers with their bookings for October 15th, 2001:
DATA: CUSTOMER TYPE SCUSTOM,
BOOKING TYPE SBOOK.
SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID)
FROM SCUSTOM LEFT OUTER JOIN SBOOK
ON SCUSTOMID = SBOOKCUSTOMID AND
SBOOK~FLDATE = '20011015'
ORDER BY SCUSTOMNAME SBOOKFLDATE.
WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID.
ENDSELECT.
If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or using an alias.
Note
For the resulting set of a SELECT command with a left outer join in the FROM clause, it is generally of crucial importance whether a logical condition is in the ON or WHERE condition. Since not all of the database systems supported by SAP themselves support the standard syntax and semantics of the left outer join, the syntax has been restricted to those cases that return the same solution in all database systems:
Only a table or view may come after the JOIN operator, not another join statement.
The only logical operator allowed in the ON condition is AND.
Each comparison in the ON condition must contain a field from the right-hand table.
Comparisons in the WHERE condition must not contain a field from the right-hand table.
The ON condition must contain at least one "real" JOIN condition (a condition in which a field from tabref1 as well as from tabref2 occurs).
Note
In some cases, '*' may be specivied as the field list in the SELECT clause, and an internal table or work area is entered in the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the llen in der FROM clause, according to the structure of each table work area. There can be gaps between the table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, as in the following example (not simply by counting the total number of fields).
Example
Example of a JOIN with more than two tables: Select all flights from Frankfurt to New York between September 10th and 20th, 2001 where there are available places, and display the name of the airline.
DATA: BEGIN OF WA,
FLIGHT TYPE SFLIGHT,
PFLI TYPE SPFLI,
CARR TYPE SCARR,
END OF WA.
SELECT * INTO WA
FROM ( SFLIGHT AS F INNER JOIN SPFLI AS P
ON FCARRID = PCARRID AND
FCONNID = PCONNID )
INNER JOIN SCARR AS C
ON FCARRID = CCARRID
WHERE P~CITYFROM = 'FRANKFURT'
AND P~CITYTO = 'NEW YORK'
AND F~FLDATE BETWEEN '20010910' AND '20010920'
AND FSEATSOCC < FSEATSMAX.
WRITE: / WA-CARR-CARRNAME, WA-FLIGHT-FLDATE, WA-FLIGHT-CARRID,
WA-FLIGHT-CONNID.
ENDSELECT.
And for all entries,
this will help u.
use of FOR ALL ENTRIES:
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
4
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.
cheers,
Hema. -
Like operator in for all entries
hi all,
may i know how to apply like for "for all entries"
where the first position is 9.
syntax is incorrect. hope can get help.
thanks
CONCATENATE itab-xx+0(1) '%' INTO v_kstar.
SELECT kstar txt20 INTO TABLE it_act
FROM aaa
FOR ALL ENTRIES IN itab
WHERE kstar like v_kstar AND
spras = sy-langu.in that case u have to call with in loop itself, may be there is another way also.
do v_times times
varying v_name
from dept-dept01
next dept-dept02.
concatenate p_rprctr '%' v_name into v_dep.
concatenate '%' v_name into v_dep.
select single mctxt into v_txt
from cskt
where cskt~spras = 'EN'
and cskt~kokrs = 'PEPS'
and cskt~kostl like v_dep
and cskt~datbi eq '99991231'.
concatenate v_txt '-' v_name into v_txt.
write: (47) v_txt centered no-gap ,
sy-vline no-gap .
hide v_name.
clear v_dep.
enddo.
its not a complete code , just a sample code.
Regards
Prabhu -
For all entries against Ranges
Hi,
I have a question regarding a Select query where I have to select some data and then store it in table and refer it for the 2nd Select.
eg: Select from table 1
into itab1.
select from table 2
into itab2
for all entries in itab1.
My question is should I use a Range for the 1st select instead of an itab.The itab1 will be containing max 50 records.
The problem with for all entries is that I cannot use 'UP TO ROWS' as it only deletes extra entries at application level and not database level. I will be selecting 1000 rows even if I want only 100 rows.
Please let me know ur viewsFrom a performance perspective ranges perform better than FOR ALL ENTRIES however the number of records you can use in your range is limited. You will get a run time dump if your range size increases beyond the allowable. If you are very confident that you have not more than 50 entries in your range, I would recommend that you use the range instead of FOR ALL ENTRIES.
An even better option would be to use a join of two tables. If you can provide specifics I could help you further. -
What is the use of for all entries in select statement
what is the use of for all entries in select statement
hi,
FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.
You can check the below code -
SELECT BUKRS BELNR GJAHR AUGDT
FROM BSEG
INTO TABLE I_BSEG
WHERE BUKRS = ....
SELECT BUKRS BELNR BLART BLDAT
FROM BKPF
INTO TABLE I_BKPF
FOR ALL ENTRIES IN I_BSEG
WHERE BUKRS = I_BSEG-BUKRS
AND BELNR = I_BSEG-BELNR
AND BLDAT IN SO_BLDAT.
*******************************8
look another example
what is the use of FOR ALL ENTRIES
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
4
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.
Hope this helps!
Regards,
Anver
<i>if hlped pls mark points</i> -
About for all entries in itab usage issue
hi
i will get a lot of material information first.
the next i will get inforamtion about table MARC AND MBEW.
one statement i use sap function to get MARC:
CALL FUNCTION 'MARC_ARRAY_READ'
EXPORTING
KZRFB = ' '
NEUFLAG = ' '
SPERRMODUS = ' '
STD_SPERRMODUS = ' '
EXCEPTION_ON_LOCK = ' '
IMPORTING
RETC = ret
TABLES
IPRE01 = ipre
MARC_TAB = disp
EXCEPTIONS
ENQUEUE_MODE_CHANGED = 1
LOCK_ON_MARC = 2
LOCK_SYSTEM_ERROR = 3
OTHERS = 4.
two statement if i use:
select matnr dispo ekgrp plifz
into table disp
from marc
for all entries in ipre
where werks = ipre-werks and
matnr = ipre-matnr.
which one will get better performce.
and
if ipre table have a lot of data, so in sap what about for all entries of Limit?
and will lose data to use for all entries of statements?
have function in sap to get data like 'MARC_ARRAY_READ' about MEBW.
THANK YOU!thank you!
what about for all entries of Limit?
and will lose data to use for all entries of statements?
exist function about get MEBW ARRAY?? -
Hi Friends,
please suggest me in performance innerjoin is better or for all entries is better to get data from two transparent tables.
Krishna.hi,
<b>for all entries is the better method.</b>
FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.
You can check the below code -
SELECT BUKRS BELNR GJAHR AUGDT
FROM BSEG
INTO TABLE I_BSEG
WHERE BUKRS = ....
SELECT BUKRS BELNR BLART BLDAT
FROM BKPF
INTO TABLE I_BKPF
FOR ALL ENTRIES IN I_BSEG
WHERE BUKRS = I_BSEG-BUKRS
AND BELNR = I_BSEG-BELNR
AND BLDAT IN SO_BLDAT.
*******************************8
look another example
what is the use of FOR ALL ENTRIES
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
4
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.
Hope this helps!
Regards,
Anver -
what is innerjoin & for all entries?
which one is used in which position,explain plzzzzzzzzzzzzzzzzz.
explain advantages & disadvantages?hi,
follow these links for knowing the difference between For all entries and joins.
http://www.erpgenie.com/abap/performance.htm#For%20all%20entries
http://blogs.ittoolbox.com/sap/db2/archives/for-all-entries-vs-db2-join-8912
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
To Impove the perfomance of program you can use for all entries instead of your inner join...This is always preferable..But before make a check and make sure that your internal table is not empty.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.
You can check the below code -
SELECT BUKRS BELNR GJAHR AUGDT
FROM BSEG
INTO TABLE I_BSEG
WHERE BUKRS = ....
SELECT BUKRS BELNR BLART BLDAT
FROM BKPF
INTO TABLE I_BKPF
FOR ALL ENTRIES IN I_BSEG
WHERE BUKRS = I_BSEG-BUKRS
AND BELNR = I_BSEG-BELNR
AND BLDAT IN SO_BLDAT
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.
http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_ForAllEntries.asp -
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 -
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,
RajasekaranHi ,
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 -
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
Maybe you are looking for
-
SAME Session id in 2 different Firefox browsers, 2 different logins?
Hi, I just had some weird stuff happen which I traced to working in 2 Firefox browsers, which I logged into my http://apex.oracle.com workspace, ran the same application in each browser and got the same Session Id in both. What causes this? Bill
-
Can we change Page Title text size
Hi, Is it possible to increase the text size of page Title text? Or any alternative to display big size text in that place? Regards, Ram
-
Issue using not equal to operator
Oracle: 10.2g Sample table data: -- Table psn type_number name category 1 carl 5 1 carl 5 1 carl 5 2 mike 5 2
-
HT4623 how do you restore your iphone to original settings
how do i restore my iphone to original settings
-
I have been unable to get RSPAN to work on 2 3550s connected together with an ISL trunk. I have a Sniffer on switch B, and a Windows PC on switch A. Unfortuneately, I found out the hard way that the reflector port takes the ISL trunk out of STP. When