‎2008 Jan 18 10:13 AM
Hi all,
Give me example to join three tables using
FOR ALL ENTRIES.
Thanks & Regards,
Azhar
‎2008 Jan 18 10:15 AM
select a~bukrs
a~ord41
a~ord42
a~ord43
b~afabe
b~knafa
b~aafam
b~aafag
c~kostl
d~afasl
d~ndjar
d~ndper
into corresponding fields of table gt_master
from ( ( anla as a inner join anlc as b
on abukrs = bbukrs
and aanln1 = banln1
and aanln2 = banln2 )
inner join anlz as c
on abukrs = cbukrs
and aanln1 = canln1
and aanln2 = canln2 )
inner join anlb as d
on abukrs = dbukrs
and aanln1 = danln1
and aanln2 = danln2
where a~bukrs in s_comp.
‎2008 Jan 18 10:16 AM
Hi,
In for all entries you can mention only one table , but you can put join on 3 tables in a select statement, but cant use 3 tables in for all entries.
Pankaj
‎2008 Jan 18 10:18 AM
HI,
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.
If the additions PACKAGE SIZE or UP TO n ROWS are specified together with FOR ALL ENTRIES, they are not passed to the database system but are applied instead to the resulting set once all selected rows on the application server have been imported.
With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set.
Addition FOR ALL ENTRIES is only possible for 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.
plz reward if helpful,
regards,
srikanth tulasi.
‎2008 Jan 18 10:45 AM
Hi,
Please check below code which downloads records from 3 tables into excel file.
if you want other file means you can specify other file type in the fm parameter
-
REPORT zstemp_qty2_ LINE-SIZE 255 .
DATA:it_vbak LIKE vbak OCCURS 0 WITH HEADER LINE.
DATA:v_file1 LIKE rlgrap-filename.
DATA:v_file2(80) TYPE c.
DATA:it_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.
DATA:it_mara LIKE mara OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM vbak INTO TABLE it_vbak UP TO 100 ROWS.
IF NOT it_vbak[] IS INITIAL.
SELECT * FROM vbap INTO TABLE it_vbap
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vbeln.
ENDIF.
LOOP AT it_vbap.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = it_vbap-matnr
IMPORTING
output = it_vbap-matnr.
MODIFY it_vbap TRANSPORTING matnr.CLEAR it_vbap.
ENDLOOP.
IF NOT it_vbap[] IS INITIAL.
SELECT * FROM mara INTO TABLE it_mara
FOR ALL ENTRIES IN it_vbap
WHERE matnr = it_vbap-matnr.
ENDIF.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
FIELD_NAME = ' '
IMPORTING
file_name = v_file1 .
v_file2 = v_file1.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
filename = v_file2
filetype = 'WK1'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
col_select = '1'
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = it_mara
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_mara.
WRITE:/ it_mara-matnr.
ENDLOOP.
regrds,
vasavi
reward if helpful.