Inner Joins & for all entries
Hi
1) SELECT RSEGBUKRS RSEGBELNR RSEGGJAHR RSEGBUZEI RBKPLIFNR RSEGWERKS RSEGEBELN RSEGEBELP RSEGMATNR RSEGWRBTR RBKPRBSTAT RBKPZUONR RBKPRMWWR RBKPWAERS RBKP~KURSF
INTO TABLE I_RSEG
FROM RBKP
INNER JOIN RSEG
ON
RBKPBELNR = RSEGBELNR AND
RBKPGJAHR = RSEGGJAHR
FOR ALL ENTRIES IN I_BKPF
WHERE RBKP~BELNR = I_BKPF-BELNR
AND RBKP~GJAHR = I_BKPF-GJAHR
AND RSEG~WERKS IN S_WERKS
AND RBKP~LIFNR IN S_LIFNR.
2) IF NOT I_BKPF[] IS INITIAL.
SELECT belnr gjahr lifnr rbstat zuonr rmwwr waers kursf stblg
FROM rbkp into corresponding fields of table i_rbkp1
FOR ALL ENTRIES IN I_BKPF
WHERE BELNR = I_BKPF-BELNR
AND GJAHR = I_BKPF-GJAHR
AND LIFNR = S_LIFNR.
ENDIF.
I am replacing the first select statment using inner join with for all entries. but it is not yelding same result.First select statement retrieves records while second one does not using same where conditions. How inner join would work,can we replace inner join using for all entries.
Regards,
Karthik.k
any one suggest..
Regards,
Karthik
Similar Messages
-
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 -
Hi
1) SELECT RSEGBUKRS RSEGBELNR RSEGGJAHR RSEGBUZEI RBKPLIFNR RSEGWERKS RSEGEBELN RSEGEBELP RSEGMATNR RSEGWRBTR RBKPRBSTAT RBKPZUONR RBKPRMWWR RBKPWAERS RBKP~KURSF
INTO TABLE I_RSEG
FROM RBKP
INNER JOIN RSEG
ON
RBKPBELNR = RSEGBELNR AND
RBKPGJAHR = RSEGGJAHR
FOR ALL ENTRIES IN I_BKPF
WHERE RBKP~BELNR = I_BKPF-BELNR
AND RBKP~GJAHR = I_BKPF-GJAHR
AND RSEG~WERKS IN S_WERKS
AND RBKP~LIFNR IN S_LIFNR.
2) IF NOT I_BKPF[] IS INITIAL.
SELECT belnr gjahr lifnr rbstat zuonr rmwwr waers kursf stblg
FROM rbkp into corresponding fields of table i_rbkp1
FOR ALL ENTRIES IN I_BKPF
WHERE BELNR = I_BKPF-BELNR
AND GJAHR = I_BKPF-GJAHR
AND LIFNR = S_LIFNR.
ENDIF.
I am replacing the first select statment using inner join with for all entries. but it is not yelding same result.First select statement retrieves records while second one does not using same where conditions. How inner join would work,can we replace inner join using for all entries.
Regards,
Karthik.kHi karthik,
Your second query will work fine, but you made a small mistake. When using select options in the where clause of the query we should not use '=' symbol instead you shoud use IN or BETWEEN AND. your query can be written as
IF NOT I_BKPF[] IS INITIAL.
SELECT belnr gjahr lifnr rbstat zuonr rmwwr waers kursf stblg
FROM rbkp into corresponding fields of table i_rbkp1
FOR ALL ENTRIES IN I_BKPF
WHERE BELNR = I_BKPF-BELNR
AND GJAHR = I_BKPF-GJAHR
AND LIFNR IN S_LIFNR.
ENDIF.
if values in both From and To are specified for the selection parameter S_LIFNR in selection screen, then you can use the above query or the query below
IF NOT I_BKPF[] IS INITIAL.
SELECT belnr gjahr lifnr rbstat zuonr rmwwr waers kursf stblg
FROM rbkp into corresponding fields of table i_rbkp1
FOR ALL ENTRIES IN I_BKPF
WHERE BELNR = I_BKPF-BELNR
AND GJAHR = I_BKPF-GJAHR
AND ( LIFNR between S_LIFNR-LOW and S_LIFNR-HIGH ).
ENDIF. -
In which case i want to use inner join & for alll entries statement
Dear all,
In which scenario i want to use for all entries statement and in which scenario i want to use innerjoin operation in ABAP.
please give me the solution.
Regards
syamDear all,
In which scenario i want to use for all entries statement and in which scenario i want to use innerjoin operation in ABAP.
please give me the solution.
Regards
syam -
Inner join with for-all entries
Why is the below inner join-for all entries does not result in expected output ?
REPORT ZTST3 .
tables : ztst1,ztst2 .
* table ztst1 has 4 fields : mandt,ebeln,ebelp,etenr,char4. ; ztst2 has
* 3 fields : mandt,ebeln,ebelp,matnr
*Entries in ztst1
* EBELN EBELP ETERN CHAR4
* 5000000000 00010 0001 abc
* 5000000000 00010 0002 cbd
* 5000000000 00010 0003 efg
*Entries in ztst2
* EBELN EBELP matnr
* 5000000000 00010 matabc
*expected itab after inner join
* EBELN EBELP CHAR4 MAtnr
* 5000000000 00010 abc matabc
* 5000000000 00010 cbd matabc
* 5000000000 00010 efg matabc
data : begin of itab1 occurs 0,
ebeln type ebeln,
ebelp type ebelp,
end of itab1.
data : begin of itab occurs 0,
ebeln type ebeln,
ebelp type ebelp,
char4 type char4,
matnr type matnr,
end of itab.
start-of-selection.
itab1-ebeln = '5000000000'.
itab1-ebelp = '00010'.
append itab1.
select ztst1~ebeln
ztst1~ebelp
ztst1~char4
ztst2~matnr into corresponding fields of table itab
from ztst1 inner join ztst2
on ztst1~ebeln = ztst2~ebeln and
ztst1~ebeln = ztst2~ebelp
for all entries in itab1
where
ztst1~ebeln eq itab1-ebeln and
ztst1~ebelp eq itab1-ebelp .
* why does it return no entries;
break-point.For example in the bellow case
*Entries in ztst1
EBELN EBELP ETERN CHAR4
5000000000 00010 0001 abc
5000000000 00010 0002 cbd
5000000000 00010 0003 efg
5000000002 00020 0003 efg
5000000002 00020 0003 efg
*Entries in ztst2
EBELN EBELP matnr
5000000000 00010 matabc
5000000002 00020 abc
may it will return you 2 records yes, than I think you have under stand the working of u201Cfor all entriesu201D ?
And the following case I think it will work fine.
*Entries in ztst1
key EBELN EBELP ETERN CHAR4
1 5000000000 00010 0001 abc
2 5000000000 00010 0002 cbd
3 5000000000 00010 0003 efg
4 5000000002 00020 0003 efg
5 5000000002 00020 0003 efg
*Entries in ztst2
EBELN EBELP matnr
5000000000 00010 matabc
5000000002 00020 abc
select ztst1~key
ztst1~ebeln
ztst1~ebelp
ztst1~char4
ztst2~matnr into corresponding fields of table itab
from ztst1 inner join ztst2
on ztst1~ebeln = ztst2~ebeln and
ztst1~ebelp = ztst2~ebelp
for all entries in itab1
where
ztst1~ebeln eq itab1-ebeln and
ztst1~ebelp eq itab1-ebelp .
Sorry, I donu2019t have system with me right now and I am sending you with out testing but I am sure that it is working the same way.
Please Reply if any problem
Kind Regards,
Faisal -
Hi Expert,
Could you please help me in this inner join , Inner join is performance wise is not good so i want to replace instated of inner join for all entries. But when i am checking records of internal table there is difference. in inner join i am getting 11 records but for all entries i am getting 5 records .
Please help me out where excatly i have done mistake.
SELECT maralvorm maramatkl
maramatnr marameins
maraprdha maraspart
marcausss marcbearz
marcbeskz marcbstmi
marc~wzeit
marcdisgr marcmaabc * marcdismm marcdispo
marcdispr marcdzeit
marcplifz marcdisls
marcbstma marcbstrf
marc~basmg
marceisbe marcfevor
marcfxhor marclvorm
marcmatnr marcmmsta
marcprctr marcsobsl
marctranz marcwerks
marc~xchar
marclgpro marcfhori
marc~rgekz
mbewbklas mbewbwkey
mbewlbkum mbewsalk3
mbewmatnr mbewpeinh
mbewstprs maktmaktx
maktmatnr cepcabtei
cepc~prctr
marcschgt marcminbe
marc~ekgrp
marc~eprio
marc~kausf
marc~shflg
marc~shzet
marc~fabkz
marc~lgrad
marc~shpro
marc~eislo
marc~rwpro
marc~lgfsb
marczzfdwe marczzfdwi
marczzsspe marczzsspi
INTO TABLE i_matl
FROM ( mara
INNER JOIN marc
ON marcmatnr = maramatnr
INNER JOIN mbew
ON mbewmatnr = marcmatnr
AND mbewbwkey = marcwerks
INNER JOIN makt
ON maktmatnr = maramatnr
INNER JOIN cepc
ON cepcprctr = marcprctr
AND cepcdatbi >= sy-datum ) "* WHERE maralvorm IN sp$00094
AND mara~matkl IN sp$00084
AND mara~meins IN sp$00091
AND mara~prdha IN sp$00066
AND mara~spart IN sp$00085
AND marc~disgr IN sp$00089
AND marc~dismm IN sp$00067
AND marc~dispo IN sp$00061
AND marc~dispr IN sp$00083
AND marc~fevor IN sp$00090
AND marc~lvorm IN sp$00092
AND marc~mmsta IN sp$00086
AND marc~beskz IN s_beskz
AND marc~sobsl IN sp$00068
AND marc~werks IN sp$00062
AND marc~xchar IN sp$00093
AND marc~maabc IN sp$00099
AND marc~lgrad IN s_lgrad
AND marc~lgpro IN s_lgpro
AND marc~rwpro IN s_rwpro
AND marc~lgfsb IN s_lgfsb
AND marc~schgt INs_schgt * AND marc~shflg IN s_shflg
AND marc~shzet IN s_shzet
AND marc~fabkz IN s_fabkz
AND marc~shpro IN s_shpro
AND marc~eislo IN s_eislo
AND marc~zzfdwe IN s_zzfdwe
AND marc~zzfdwi IN s_zzfdwi
AND marc~zzsspe IN s_zzsspe
AND marc~zzsspi IN s_zzsspi
AND mbew~bklas IN sp$00063
AND mbew~lbkum IN sp$00088
AND makt~maktx IN sp$00059
AND makt~spras = c_en
AND makt~matnr IN sp$00060
AND cepc~prctr IN sp$00087.
I am using for all entries
fetching data from marc data base table
SELECT matnr werks lvorm xchar mmsta
maabc ekgrp dispr dismm
dispo plifz ausss disls
beskz sobsl minbe eisbe
bstmi bstma bstrf fhori
rgekz fevor bearz tranz
basmg dzeit wzeit lgrad
prctr fxhor lgpro disgr
kausf rwpro lgfsb schgt
eprio shflg shzet fabkz
shpro eislo zzfdwe zzfdwi
zzsspe zzsspi
FROM marc INTO TABLE i_marc
WHERE werks IN sp$00062
AND lvorm IN sp$00092
AND xchar IN sp$00093
AND mmsta IN sp$00086
AND maabc IN sp$00099
AND dispr IN sp$00083
AND dismm IN sp$00067
AND dispo IN sp$00061
AND beskz IN s_beskz
AND sobsl IN sp$00068
AND fevor IN sp$00090
AND lgrad IN s_lgrad
AND lgpro IN s_lgpro
AND disgr IN sp$00089
AND rwpro IN s_rwpro
AND lgfsb IN s_lgfsb
AND schgt IN s_schgt
AND shflg IN s_shflg
AND shzet IN s_shzet
AND fabkz IN s_fabkz
AND shpro IN s_shpro
AND eislo IN s_eislo
AND zzfdwe IN s_zzfdwe
AND zzfdwi IN s_zzfdwi
AND zzsspe IN s_zzsspe
AND zzsspi IN s_zzsspi.
IF sy-subrc EQ 0.
SORT i_marc BY matnr werks.
ENDIF.
DELETE ADJACENT DUPLICATES FROM i_marc comparing matnr werks.
*fetching data from mara data base table
IF NOT i_marc[] IS INITIAL.
SELECT matnr lvorm matkl
meins spart prdha
FROM mara INTO TABLE i_mara
FOR ALL ENTRIES IN i_marc
WHERE matnr = i_marc-matnr
AND lvorm IN sp$00094
AND matkl IN sp$00084
AND meins IN sp$00091
AND prdha IN sp$00066
AND spart IN sp$00085.
ENDIF.
IF sy-subrc EQ 0.
SORT i_mara BY matnr.
ENDIF.
DELETE ADJACENT DUPLICATES FROM i_mara comparing matnr.
*fetching data from mbew data base table
IF NOT i_mara[] IS INITIAL.
SELECT matnr bwkey bwtar lbkum
salk3 stprs peinh bklas
FROM mbew INTO TABLE i_mbew
FOR ALL ENTRIES IN i_marc
WHERE matnr = i_marc-matnr
AND bwkey = i_marc-werks
AND bklas IN sp$00063
AND lbkum IN sp$00088.
ENDIF.
IF sy-subrc EQ 0.
SORT i_mbew BY matnr bwkey bwtar.
ENDIF.
*DELETE ADJACENT DUPLICATES FROM i_mbew comparing matnr bwkey bwtar.
*fetching data from makt data base table
IF NOT i_mara[] IS INITIAL.
SELECT matnr spras maktx
FROM makt INTO TABLE i_makt
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr
AND maktx IN sp$00059
AND makt~spras = c_en.
ENDIF.
IF sy-subrc EQ 0.
SORT i_makt BY matnr spras.
ENDIF.
DELETE ADJACENT DUPLICATES FROM i_makt.
*fetching data from cpec data base table
IF NOT i_marc[] IS INITIAL.
SELECT prctr datbi kokrs abtei
FROM cepc INTO TABLE i_cepc
FOR ALL ENTRIES IN i_marc
WHERE prctr = i_marc-prctr
AND prctr IN sp$00087
AND datbi >= sy-datum.
ENDIF.
IF sy-subrc EQ 0.
SORT i_cepc BY prctr datbi kokrs.
ENDIF.
*DELETE ADJACENT DUPLICATES FROM i_cepc.
LOOP AT i_cepc INTO wa_cpec.
read table i_marc into wa_marc with key
prctr = wa_cpec-prctr binary search.
if sy-subrc = 0.
i_matl-abtei = wa_cpec-abtei.
i_matl-prctr1 = wa_cpec-prctr.
i_matl-ausss = wa_marc-ausss.
i_matl-bearz = wa_marc-bearz.
i_matl-beskz = wa_marc-beskz.
i_matl-bstmi = wa_marc-bstmi.
i_matl-wzeit = wa_marc-wzeit.
i_matl-disgr = wa_marc-disgr.
i_matl-maabc = wa_marc-maabc.
i_matl-dismm = wa_marc-dismm.
i_matl-dispo = wa_marc-dispo.
i_matl-dispr = wa_marc-dispr.
i_matl-dzeit = wa_marc-dzeit.
i_matl-plifz = wa_marc-plifz.
i_matl-disls = wa_marc-disls.
i_matl-bstma = wa_marc-bstma.
i_matl-bstrf = wa_marc-bstrf.
i_matl-basmg = wa_marc-basmg.
i_matl-eisbe = wa_marc-eisbe.
i_matl-fevor = wa_marc-fevor.
i_matl-fxhor = wa_marc-fxhor.
i_matl-lvorm1 = wa_marc-fevor.
i_matl-matnr1 = wa_marc-matnr.
i_matl-mmsta = wa_marc-mmsta.
i_matl-prctr = wa_marc-prctr.
i_matl-sobsl = wa_marc-sobsl.
i_matl-tranz = wa_marc-tranz.
i_matl-werks = wa_marc-werks.
i_matl-xchar = wa_marc-xchar.
i_matl-lgpro = wa_marc-lgpro.
i_matl-fhori = wa_marc-fhori.
i_matl-rgekz = wa_marc-rgekz.
i_matl-schgt = wa_marc-schgt.
i_matl-minbe = wa_marc-minbe.
i_matl-ekgrp = wa_marc-ekgrp.
i_matl-eprio = wa_marc-eprio.
i_matl-kausf = wa_marc-kausf.
i_matl-shflg = wa_marc-shflg.
i_matl-shzet = wa_marc-shzet.
i_matl-fabkz = wa_marc-fabkz.
i_matl-lgrad = wa_marc-lgrad.
i_matl-shpro = wa_marc-shpro.
i_matl-eislo = wa_marc-eislo.
i_matl-rwpro = wa_marc-rwpro.
i_matl-lgfsb = wa_marc-lgfsb.
i_matl-zzfdwe = wa_marc-zzfdwe.
i_matl-zzfdwi = wa_marc-zzfdwi.
i_matl-zzsspe = wa_marc-zzsspe.
i_matl-zzsspi = wa_marc-zzsspi.
endif.
READ TABLE i_mara INTO wa_mara WITH KEY
matnr = wa_marc-matnr binary search.
i_matl-lvorm = wa_mara-lvorm.
i_matl-matkl = wa_mara-matkl.
i_matl-matnr = wa_mara-matnr.
i_matl-meins = wa_mara-meins.
i_matl-prdha = wa_mara-prdha.
i_matl-spart = wa_mara-spart.
READ TABLE i_makt INTO wa_makt WITH KEY
matnr = wa_mara-matnr binary search.
i_matl-matnr3 = wa_makt-matnr.
i_matl-maktx = wa_makt-maktx.
READ TABLE i_mbew INTO wa_mbew WITH KEY
matnr = wa_marc-matnr binary search.
i_matl-bklas = wa_mbew-bklas.
i_matl-bwkey = wa_mbew-bwkey.
i_matl-lbkum = wa_mbew-lbkum.
i_matl-salk3 = wa_mbew-salk3.
i_matl-matnr2 = wa_mbew-matnr.
i_matl-peinh = wa_mbew-peinh.
i_matl-stprs = wa_mbew-stprs.
READ TABLE i_cepc INTO wa_cpec WITH KEY
prctr = wa_marc-prctr.
APPEND i_matl.
CLEAR: wa_cpec, wa_mbew, wa_mara, wa_marc.
ENDLOOP.
Thaks
Waiting your reply.Hi Sasmita,
I think your final loop is the problem. As you are looping through the CEPC internal table, and reading the other tables. For different materials there might be a same profit center, the read table will fetch you only first occurance of the profit center from the mara or marc table.
So loop through either mara or marc table and read the remaining and populate your final internal tables. This might solve your problem.
Regards,
Ramesh Babu S
*Reward points if it is helpful.... -
For All Entries is NOT better than INNER JOIN in most cases
I quote from Siegfried Boes' excellent post here: Will writing an inner join be better or creating a view?
For all the FOR ALL ENTRIES lovers ... there is no proof for these reappearing recommendation.
There is nearly nobody who receives forum points, who recommends FOR ALL ENTRIES instead of Joins. What is the reason ???
It is easier to prove the opposite. A Join is a nested loop inside the database, a FOR ALL ENTRIES is partly outside of the database. FOR ALL ENTRIES works in blocks, joins on totals.
FOR ALL ENTRIES are not recommded on really large tables, because the chances are too high that
too many records are transferred.
People prefer FOR ALL ENTRIES, because JOINs are not so easy to understand. Joins can go wrong, but with a bit of understanding they can be fixed.
Some Joins are slow and can not be fixed, but then the FOR ALL ENTRIES would be extremely slow.
There are several kinds of views:
- projection views, i.e. only one table involved just fields reduced
- join views, several tables, joins conditions stored in dictionary
- materialized views, here the joined data are actually stored in the database. Storing and synchronisation has to be done manually.
Only the last one creates real overhead. It should be the exception.
Join Views and Joins are nearly identical. The view is better for reuse. The join is better in complicated, becuase if the access goes wrong, it can often be fixed by adding a hint. Hints can not be added to views.
Abraham Bukit points out:
If it is cluster table, (you can't use join). If it is buffered table, I would also say avoid join.
If they all are transaction table which are not buffered and are not cluster tables.
He further supports Siegfried's statement that FAE is easier to undestand than INNER JOINs.
Thomas Zloch says, regarding buffered tables:
At least think twice, maybe compare runtimes if in doubt.
So, unless someone has some EVIDENCE that FOR ALL ENTRIES is better, I don't think we want to see this discussed further.
Kind regards
MattTo give food for thought here's an example I gave in a thread:
If you have a statement like
SELECT ... FOR ALL ENTRIES IN FAE_itab WHERE f = FAE_itab-f.
SAP sends it to the database depending how the parameter rsdb/prefer_union_all is set:
rsdb/prefer_union_all = 0 =>
SELECT ... WHERE f = FAE_itab[1]-f
OR f = FAE_itab[2]-f
OR f = FAE_itab[N]-f
You have some influence of the generated statement type: Instead of OR'ed fields an IN list can be used
if you have only a single coulmn N to compare:
rsdb/prefer_in_itab_opt parameter:
SELECT ... WHERE f IN (itab[1]-f, itab[2]-f, ..., itab[N]-f)
rsdb/prefer_union_all = 1 =>
SELECT ... WHERE f = FAE_itab[1]-f
UNION ALL SELECT ... WHERE f = FAE_itab[2]-f
UNION ALL SELECT ... WHERE f = FAE_itab[N]-f
see: Note 48230 - Parameters for the SELECT ... FOR ALL ENTRIES statement
As you can see for the 2nd parameter several statements are generated and combined with a UNION ALL,
the first setting generates statements with OR's (or uses IN if possible) for the entries in FAE_itab.
I give you a little example here (my parameters are set in a way that the OR's are translated to IN lists; i traced the execution in ST05)
Select myid into table t_tabcount from mydbtable
for all entries in t_table " 484 entries
where myid = t_table-myid .
ST05 trace:
|Transaction SEU_INT|Work process no 0|Proc.type DIA|Client 200|User |
|Duration |Obj. name |Op. |Recs.|RC |Statement|
| 640|mydbtable |PREPARE| | 0|SELECT WHERE "myid" IN ( :A0 , :A1 , :A2 , :A3 , :A4 ) AND "myid" = :A5|
| 2|mydbtable |OPEN | | 0|SELECT WHERE "myid" IN ( 1 , 2 , 3 , 4 , 5 ) AND "myid" = 72 |
| 2.536|mydbtable |FETCH | 0| 1403| |
| 3|mydbtable |REOPEN | | 0|SELECT WHERE "myid" IN ( 6 , 7 , 8 , 9 , 10 ) AND "myid" = 72 |
| 118|mydbtable |FETCH | 0| |
| 2|mydbtable |REOPEN | | 0|SELECT WHERE "myid" IN ( 11 , 12 , 13 , 14 , 15 ) AND "myid" = 72 |
| 3|mydbtable |REOPEN | | 0|SELECT WHERE "myid" IN ( 475 , 476 , 477 , 478 , 479 ) AND "myid" = 72 |
| 94|mydbtable |FETCH | 0| 1403| |
| 2|mydbtable |REOPEN | | 0|SELECT WHERE "myid" IN ( 480 , 481 , 482 , 483 , 484 ) AND "myid" = 72 |
You see the IN list contained 5 entries each , wich made up about 97 statements for all 484 entries.
For every statment you have a single fetch operation wich means a separate access to the database.
If you would replace the FAE with a join you would only have one fetch to the database.
With the example above we can derive these observations:
1. From database point of view these settings kill performance when you access a big table and/or have a lot of entries or columns in your FAE_itab. Furthermore, you hide information what data you will access
at all and thus you block the database from creating a more efficient execution plan because it DOESN'T KNOW wich data you will select in the next step. I.e. it may be more efficient to scan the table in one shot instead of having many index accesses - but the database can make this decision only if it can examine ONE statement that has ALL the information of what data to retrieve.
2. A second impact is that with every statement execution you trigger the allocation of database resources
wich will contribute to the overhead described above.
Said that, FAE can never be a replacement for joining big tables (think of having a table with thousands of records in a FAE table )
Edited by: kishan P on Nov 2, 2010 2:16 PM - Format Fixed -
Replacing a inner join with for all entries
Hi Team,
In a already developed program I am replacing a inner join with select query follow up with for-all-entris and passing the data to final internal table but in both the case the result should be same then only my replacement will be correct. But my no records in both cases differs. This happening because when i am selecting data from first data base table is 32 lines. then I am doing fo-all-entries moving all the duplicate entries then the no records are four. but in final internal table i am looping the first internal table. So in final internal table the no of records are 32. But in inner join query the records are 16.So please let me know how resolve this issue?
Thanks and REgards
DeepaHi Thomas,
Thanks for ur suggestion.
The solved that in below.
In select query I did not change anything The way I had written the code was correct.
I think many of us know how to write that how to make the performance better in that way.
I made the change when I transfered the to final internal table.
The original Inner join code:
select a~field1 a~field2 a~field3 b~field2 b~field3 b~field4
from dbtab1 as a inner join dbtab2 as b
on a~field1 = b~field1 into it_final where
a~field1 in s_field1. [Field1 in both the table are key field]
Before code:
Sort itab1 by key-fields.
sort itab2 by keyfields.
loop at itab1 into wa1.
move: wa1-field1 to wa_final-field1,
wa1-field2 to wa_final-field2,
wa1-field3 to wa_final-field3.
read table itab2 into wa2 witk key field1 = wa1-field1 binary search.
if sy-subrc = 0.
move : wa2-field2 to wa_final-field4,
wa2-field3 to wa_final-field5,
wa2-field4 to wa_final-field6.
append wa_final to it_final.
endif.
Clear : wa1, wa2, wa_final.
endloop.
In this case if the one key fieild value is not present there in second internal table but its there in first internal table still it will read that row with 2nd internal values having zeroes. Normally what does not happen in inner join case if the key field value will same in both the case ,then that will fetch only those rows.
Changed Code
loop at itab1 into wa1.
read table itab2 into wa2 witk key field1 = wa1-field1 binary search.
if sy-subrc = 0.
move: wa1-field1 to wa_final-field1,
wa1-field2 to wa_final-field2,
wa1-field3 to wa_final-field3.
move : wa2-field2 to wa_final-field4,
wa2-field3 to wa_final-field5,
wa2-field4 to wa_final-field6.
append wa_final to it_final.
endif.
Clear : wa1, wa2, wa_final.
endloop.
In this case the values will read to final internal table if both key field matches.
With Regards
Deepa -
INNER JOIN with FOR ALL ENTRIES IN Performance ?
I am using following the following <b>Select using Inner join with For All Entries in.</b>
SELECT kebeln kebelp kvbeln kvbelp
FROM ekkn AS k INNER JOIN ekbe AS b ON kebeln = bebeln
AND kebelp = bebelp
INTO TABLE gi_purchase
FOR ALL ENTRIES
IN gi_sales
WHERE k~mandt EQ sy-mandt
AND k~vbeln EQ gi_sales-vbeln
AND k~vbelp EQ gi_sales-posnr
AND b~budat EQ p_date.
If i am not doing inner join then I will have to do 2 select with for all entries in on ekkn and ekbe tables and then compare them.
<b>I want to know which one has better performance
Inner join with for all entries in
or
2 Selects with for all entries in</b>the join is almost aways faster:
<a href="/people/rob.burbank/blog/2007/03/19/joins-vs-for-all-entries--which-performs-better">JOINS vs. FOR ALL ENTRIES - Which Performs Better?</a>
<a href="http://blogs.ittoolbox.com/sap/db2/archives/for-all-entries-vs-db2-join-8912">FOR ALL ENTRIES vs DB2 JOIN</a>
Rob -
Inner Join with For All Entries - Performance ?
I am using following the following <b>Select using Inner join with For All Entries in.</b>
SELECT kebeln kebelp kvbeln kvbelp
FROM ekkn AS k INNER JOIN ekbe AS b ON kebeln = bebeln
AND kebelp = bebelp
INTO TABLE gi_purchase
FOR ALL ENTRIES
IN gi_sales
WHERE k~mandt EQ sy-mandt
AND k~vbeln EQ gi_sales-vbeln
AND k~vbelp EQ gi_sales-posnr
AND b~budat EQ p_date.
If i am not doing inner join then I will have to do 2 select with for all entries in on ekkn and ekbe tables and then compare them.
<b>I want to know which one has better performance
Inner join with for all entries in
or
2 Selects with for all entries in</b><b></b>An Inner Join with for all entries should be done if you add this....
IF NOT gi_sales[] IS INITIAL.
SELECT k~ebeln k~ebelp k~vbeln k~vbelp
FROM ekkn AS k INNER JOIN ekbe AS b ON k~ebeln = b~ebeln
AND k~ebelp = b~ebelp
INTO TABLE gi_purchase
FOR ALL ENTRIES
IN gi_sales
WHERE k~mandt EQ sy-mandt
AND k~vbeln EQ gi_sales-vbeln
AND k~vbelp EQ gi_sales-posnr
AND b~budat EQ p_date.
ENDIF.
Also, while you use an index or the complete key for the SELECT, your not going to suffer from lack of performance -;)
Greetings,
Blag. -
Inner join and select for all entries with respect to performance
Hi Friends,
I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient? and how? can you explain me in detail ?
Regards,
DineshINNER JOIN->
The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm
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. -
Can anyone give me an example of for all entries in case of inner join
Hi abapers,
I am trying to replace an inner join with for all entries.
So kindly give me a demo code so that i can understand the use and apply it.
And plz tell me in which case it is better to use for all entries and in which case to use inner join so that better performance will occur.
With Regards
AnsumanHello Ansuman,
For example:
DATA:
BEGIN OF fs_eket,
ebeln LIKE ekko-ebeln, " Purchasing Document Number
ebelp LIKE ekpo-ebelp, " Item Number of Purchasing Doc
END OF fs_eket. " fs_eket
DATA:
t_eket LIKE " Purchase table
STANDARD TABLE
OF fs_eket.
Using joins:
select ebeln ebelp
into corresponding fields of table t_eket
from ekko join ekpo
on ekkoebeln eq ekpoebeln
where ebeln in s_sbeln.
The select statement can be replaced by
SELECT ebeln
FROM ekko
INTO CORRESPONDING FIELDS OF TABLE t_eket
WHERE ebeln IN s_ebeln.
IF sy-subrc EQ 0.
sort t_eket by ebeln.
SELECT ebeln
ebelp
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE t_eket
FOR ALL ENTRIES IN t_eket
WHERE ebeln EQ t_eket-ebeln.
The duplicate entries are removed by using FOR ALL ENTRIES. Or else by using the join, you have teh sort the table by key fields and then delete adjacent duplicates.
Hope it helps you
Regards
Indu -
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 -
Inner join and select for all entries with respect to performance in SAP
Hi Friends,
I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient?
Regards,
DineshI did some testing a while ago and found that a JOIN is usually a bit more efficient than FOR ALL ENTRIES. This wasn't always the case though, so the best thing to do is to write it both ways and see which is faster.
Rob -
Plz change code from inner join to for all entries
REPORT : ZSD00009 *
DESCRIPTION : REPORT FOR TRACTOR ON STOCK AGING *
CODED BY : DINESH AGARWAL *
SPECS BY : AJAY KOTHI *
START DATE : 07TH JUNE , 2000 *
CHANGED : MANOJ SINGH 01/02/2001 *
CHANGED : YOGINDER KAURA 27TH JULY 2001 *
REPORT ZMUSA_SD00009 .
TABLES : vbrk,vbrp,vbfa,ser01,objk,knvv,mara,mbew, t005u,
t171t,kna1,equi,ihpa, cabn, ausp.
DATA : BEGIN OF itab OCCURS 0,
bzirk1 LIKE vbrk-bzirk,
bzirk LIKE KNA1-regio, "added by dhiraj - 23.11.2007
LAND1 LIKE KNA1-LAND1,
kunde LIKE equi-kunde,
vbeln LIKE vbrk-vbeln,
fkdat LIKE vbrk-fkdat,
matkl LIKE mara-matkl,
sernr LIKE objk-sernr,
equnr LIKE objk-equnr ,
matnr LIKE vbrp-matnr,
spart LIKE vbrp-spart,
vbelv LIKE vbrp-vbelv,
posnv LIKE vbrp-posnv,
days1(1) TYPE n ,
days2(1) TYPE n ,
days3(1) TYPE n ,
days4(1) TYPE n ,
days5(1) TYPE n ,
werks like vbrp-werks,
END OF itab.
DATA : BEGIN OF itab_grp OCCURS 0,
werks like vbrp-werks,
matkl LIKE mara-matkl,
bzirk1 LIKE vbrk-bzirk,
bzirk LIKE KNA1-regio, "added by dhiraj - 23.11.2007
kunde LIKE equi-kunde,
vbeln LIKE vbrk-vbeln,
fkdat LIKE vbrk-fkdat,
sernr LIKE objk-sernr,
equnr LIKE objk-equnr ,
matnr LIKE vbrp-matnr,
spart LIKE vbrp-spart,
vbelv LIKE vbrp-vbelv,
posnv LIKE vbrp-posnv,
days1(1) TYPE n ,
days2(1) TYPE n ,
days3(1) TYPE n ,
days4(1) TYPE n ,
days5(1) TYPE n ,
END OF itab_grp.
DATA : BEGIN OF dealer ,
days1(3) TYPE p ,
days2(3) TYPE p ,
days3(3) TYPE p ,
days4(3) TYPE p ,
days5(3) TYPE p ,
END OF dealer .
DATA : state LIKE dealer .
DATA : matgr LIKE dealer .
DATA : plant LIKE dealer .
DATA : BEGIN OF us,
days1(4) TYPE p ,
days2(4) TYPE p ,
days3(4) TYPE p ,
days4(4) TYPE p ,
days5(4) TYPE p ,
END OF us .
DATA : lin TYPE i , check_box(1) ,
dealer_total TYPE i,state_total TYPE i,
matgr_total TYPE i,plant_total TYPE i,
us_total TYPE i .
DATA vobjnr(22) .
DATA no_of_days TYPE i .
DATA flag_fkdat.
DATA atinn1 LIKE cabn-atinn.
DATA atinn LIKE cabn-atinn.
DATA : atflv LIKE ausp-atflv.
DATA : atflv1(8) TYPE n.
DATA : invdate TYPE sy-datum.
DATA invoicenum(10) TYPE n .
DATA : BEGIN OF it_regio OCCURS 0,
regio LIKE kna1-regio,
END OF it_regio.
data : it001w like table of t001w with header line.
TABLES vbpa.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : werks FOR vbrp-werks,
vkorg FOR vbrk-vkorg,
vtweg FOR vbrk-vtweg,
spart FOR vbrp-spart.
SELECTION-SCREEN END OF BLOCK block1 .
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-002.
SELECT-OPTIONS : matkl FOR mara-matkl,
bzirk FOR vbrk-regio," changed by dhiraj - 23.11.2007
kunrg FOR vbrk-kunrg ,
fkdat FOR vbrk-fkdat.
SELECTION-SCREEN END OF BLOCK block2 .
SELECTION-SCREEN BEGIN OF BLOCK block3 WITH FRAME TITLE text-003.
PARAMETERS : days1(2) TYPE p OBLIGATORY DEFAULT '90' ,
days2(2) TYPE p OBLIGATORY DEFAULT '90',
days3(2) TYPE p OBLIGATORY DEFAULT '180',
days4(2) TYPE p OBLIGATORY DEFAULT '270',
days5(2) TYPE p OBLIGATORY DEFAULT '365'.
SELECTION-SCREEN END OF BLOCK block3 .
SELECTION-SCREEN BEGIN OF BLOCK reptype WITH FRAME TITLE text-201 .
PARAMETERS : detail RADIOBUTTON GROUP rep ,
summary RADIOBUTTON GROUP rep ,
grp_summ RADIOBUTTON GROUP rep .
SELECTION-SCREEN END OF BLOCK reptype .
*start of code by Kalpana for Authority check for REGIO */
AT SELECTION-SCREEN .
SELECT regio FROM kna1 INTO TABLE it_regio
WHERE regio IN bzirk
AND kunnr IN kunrg.
CLEAR it_regio.
LOOP AT it_regio.
AUTHORITY-CHECK OBJECT 'Z:AO_REGIO'
ID 'REGIO' FIELD it_regio.
IF sy-subrc NE 0.
MESSAGE e173(zma) WITH it_regio.
ENDIF.
ENDLOOP.
*End of code by Kalpana for Authority check for REGIO */
IF days1 NE days2 .
MESSAGE e000(8i) WITH text-004 text-009 text-005.
ELSEIF days3 LE days2 .
MESSAGE e000(8i) WITH text-006 text-010 text-005 .
ELSEIF days4 LE days3 .
MESSAGE e000(8i) WITH text-007 text-010 text-006 .
ELSEIF days5 LE days4 .
MESSAGE e000(8i) WITH text-008 text-010 text-007 .
ENDIF .
START-OF-SELECTION .
select abzirk akunrg avbeln afkdat b~matnr
cmatkl dvbelv dposnv fsernr f~equnr
into corresponding fields of table itab
from ( ( ( ( ( vbrk as a inner join vbrp as b
on avbeln = bvbeln )
inner join mara as c on cmatnr = bmatnr )
inner join vbfa as d on dvbeln = bvbeln
and dposnn = bposnr )
inner join ser01 as e on elief_nr = dvbelv
and eposnr = dposnv )
inner join objk as f on fobknr = eobknr )
where a~vkorg in vkorg
and a~vtweg in vtweg
and a~bzirk in bzirk
and a~fkdat in fkdat
and c~matkl in matkl
and a~kunrg in kunrg
and b~spart in spart
and c~mtart = 'FERT'
and d~vbtyp_n = 'M'
and a~vbtyp = 'M'
and a~fksto = ' '
and b~vgtyp = 'J' .
REFRESH itab.
CLEAR itab .
CLEAR cabn .
select * from t001w into table it001w where werks in werks.
SELECT SINGLE atinn INTO atinn1 FROM cabn
WHERE atnam = 'INVOICEDATE'.
*************************modified by dhiraj - 23.11.2007*****************
SELECT kbzirk aatflv ekunde eequnr esernr ematnr m~matkl
INTO CORRESPONDING FIELDS OF itab
FROM ( ( ( equi AS e INNER JOIN ausp AS a
ON eequnr = aobjek )
INNER JOIN mara AS m ON ematnr = mmatnr )
INNER JOIN knvv AS k ON kkunnr = ekunde
AND kspart = mspart )
WHERE m~mtart = 'FERT'
AND m~spart IN spart
AND m~matkl IN matkl
AND e~kunde <> ' '
AND e~kunde IN kunrg
AND k~bzirk IN bzirk
and a~atinn = atinn1
AND k~vkorg = 'M001'
AND k~vtweg = '90'.
SELECT kbzirk nregio nland1 aatflv ekunde eequnr esernr ematnr m~matkl
INTO CORRESPONDING FIELDS OF itab
FROM ( ( ( ( equi AS e INNER JOIN ausp AS a
ON eequnr = aobjek )
INNER JOIN mara AS m ON ematnr = mmatnr )
INNER JOIN knvv AS k ON kkunnr = ekunde
AND kspart = mspart )
INNER JOIN kna1 as n ON nkunnr = kkunnr )
WHERE m~mtart = 'FERT'
AND m~spart IN spart
AND m~matkl IN matkl
AND e~kunde <> ' '
AND e~kunde IN kunrg
AND nregio IN bzirk "k-bzirk changed to nregio by dhiraj-23.11.2007
and a~atinn = atinn1
AND k~vkorg = 'F041'
AND k~vtweg = '01'.
added by krunal for plant as select-option
clear ausp.
select single * from cabn where atnam = 'DELIVERINGPLANT'.
SELECT SINGLE * FROM ausp
WHERE objek = itab-equnr
AND atinn = CABN-ATINN.
CLEAR CABN.
read table it001w with key werks = ausp-atwrt.
if sy-subrc <> 0.
continue.
else.
itab-werks = ausp-atwrt.
endif.
*end addition
CLEAR : ausp, knvv .
SELECT SINGLE * FROM ausp
WHERE objek = itab-equnr
AND atinn = atinn1 .
MOVE ausp-atflv TO atflv1 .
MOVE atflv1 TO invdate .
MOVE invdate TO itab-fkdat.
CLEAR : cabn, ausp, atinn.
SELECT SINGLE atinn INTO atinn FROM cabn
WHERE atnam = 'INVOICENO' .
SELECT SINGLE * FROM ausp
WHERE objek = itab-equnr
AND atinn = atinn.
MOVE ausp-atflv TO invoicenum .
MOVE invoicenum TO itab-vbeln.
IF NOT fkdat-low IS INITIAL .
IF invdate GE fkdat-low AND invdate LE fkdat-high .
APPEND itab.
ELSE.
CONTINUE.
ENDIF.
ELSE.
APPEND itab.
ENDIF.
ENDSELECT.
SORT itab BY sernr matnr .
DELETE ADJACENT DUPLICATES FROM itab COMPARING sernr matnr .
SORT itab BY equnr .
LOOP AT itab .
CONCATENATE 'IE' itab-equnr INTO vobjnr .
SELECT SINGLE * FROM ihpa WHERE objnr = vobjnr
AND parvw = 'RE'
AND obtyp = 'IEQ'
AND kzloesch EQ space. " Yogi on 27/06/2001
IF sy-subrc EQ 0 .
DELETE itab INDEX sy-tabix .
CONTINUE .
ELSE .
no_of_days = sy-datum - itab-fkdat .
IF no_of_days LE days1 .
itab-days1 = 1 .
ELSEIF no_of_days GT days2 AND no_of_days LE days3.
itab-days2 = 1 .
ELSEIF no_of_days GT days3 AND no_of_days LE days4.
itab-days3 = 1 .
ELSEIF no_of_days GT days4 AND no_of_days LE days5.
itab-days4 = 1 .
ELSEIF no_of_days GT days5 .
itab-days5 = 1 .
ENDIF .
MODIFY itab INDEX sy-tabix .
ENDIF .
ENDLOOP .
END-OF-SELECTION .
DESCRIBE TABLE itab LINES lin .
IF lin GT 0 .
SORT itab BY bzirk kunde vbeln .
IF detail = 'X' .
PERFORM disp_list .
ELSEIF summary = 'X' .
PERFORM summary_list .
ELSEIF grp_summ = 'X' .
PERFORM grp_summ_list .
ENDIF.
ELSE .
MESSAGE i000(8i) WITH 'No Records exist as per Selection Condititon' .
ENDIF .
TOP-OF-PAGE .
WRITE : / text-011 , ' - ' , sy-datum .
*& Form DISP_LIST
text
--> p1 text
<-- p2 text
FORM disp_list.
LOOP AT itab.
********changes made by dhiraj - 23.11.2007********************
AT NEW bzirk.
SKIP .
SELECT SINGLE * FROM t171t WHERE bzirk = itab-bzirk
AND spras = 'E' .
SELECT SINGLE * FROM t005u WHERE spras = sy-langu
AND BLAND = itab-bzirk AND LAND1 = ITAB-LAND1.
PERFORM list_heading.
FORMAT COLOR 4 INTENSIFIED ON.
WRITE :/ 'Sales Region : ',itab-bzirk,30 t005u-BEZEI
,81 ''.
ULINE .
ENDAT.
AT NEW kunde.
SELECT SINGLE * FROM kna1 WHERE kunnr = itab-kunde .
FORMAT COLOR 3 INTENSIFIED ON.
WRITE :/ 'Dealer : ',itab-kunde,30(25) kna1-name1,
60 'City : ' ,kna1-ort01, 81 ''.
ULINE .
ENDAT.
AT NEW fkdat .
FORMAT COLOR OFF INTENSIFIED OFF .
WRITE : /5 itab-vbeln,
20 itab-fkdat .
CLEAR flag_fkdat .
ENDAT .
at new matkl .
format color 2 intensified on.
write :/ 'Material Group : ',itab-matkl, 81 ''.
skip .
endat .
mcnt = mcnt + 1 .
dealer-days1 = dealer-days1 + itab-days1 .
dealer-days2 = dealer-days2 + itab-days2 .
dealer-days3 = dealer-days3 + itab-days3 .
dealer-days4 = dealer-days4 + itab-days4 .
dealer-days5 = dealer-days5 + itab-days5 .
state-days1 = state-days1 + itab-days1 .
state-days2 = state-days2 + itab-days2 .
state-days3 = state-days3 + itab-days3 .
state-days4 = state-days4 + itab-days4 .
state-days5 = state-days5 + itab-days5 .
IF flag_fkdat EQ 'Y' .
NEW-LINE .
ENDIF .
WRITE : 35 itab-matnr, "krunal
55 itab-sernr,
72 itab-werks, "krunal
83 itab-days1 ,
93 itab-days2 ,
103 itab-days3 ,
113 itab-days4 ,
123 itab-days5 .
PERFORM get_musa_ta.
flag_fkdat = 'Y' .
at end of matkl .
skip .
format color 2 intensified on.
write :/ 'Total For : ',itab-matkl, ' - ' , mcnt .
clear mcnt .
uline .
endat .
AT END OF kunde.
dealer_total = dealer-days1 + dealer-days2 + dealer-days3
+ dealer-days4 + dealer-days5 .
FORMAT COLOR 3 INTENSIFIED ON.
WRITE :/ 'Total for : ',itab-kunde,' - ' ,
79 dealer-days1 ,
89 dealer-days2 ,
99 dealer-days3 ,
109 dealer-days4 ,
119 dealer-days5 ,
129 dealer_total .
CLEAR : dealer_total , dealer .
ULINE .
ENDAT.
AT END OF bzirk.
state_total = state-days1 + state-days2 + state-days3
+ state-days4 + state-days5 .
FORMAT COLOR 4 INTENSIFIED ON.
WRITE :/ 'Total for : ',itab-bzirk,' - ' ,
79 state-days1 ,
89 state-days2 ,
99 state-days3 ,
109 state-days4 ,
119 state-days5 ,
129 state_total .
CLEAR : state_total , state .
ULINE.
ENDAT.
ENDLOOP.
ENDFORM. " DISP_LIST
*& Form LIST_HEADING
text
--> p1 text
<-- p2 text
FORM list_heading.
DATA : text1(7) , text2(7) , text3(7) , text4(7) , text5(7),
text11(4) , text12(4) , text13(4) , text14(4) , text15(4) .
text11 = days1 .
text12 = days2 .
text13 = days3 .
text14 = days4 .
text15 = days5 .
CONCATENATE : '=<' text11 INTO text1 ,
'>' text12 INTO text2 ,
'>' text13 INTO text3 ,
'>' text14 INTO text4 ,
'>' text15 INTO text5 .
ULINE.
FORMAT COLOR 1 INTENSIFIED OFF.
WRITE :/5 'Invoice No.',
20 'Invoice Dt',
34 'Material',
55 'Serial No .' ,
72 'Plant',
79 text1 ,
89 text2 ,
99 text3 ,
109 text4 ,
119 text5 ,
129 'Floor' ,
139 'Total' .
ULINE.
ENDFORM. " LIST_HEADING
*& Form SUMMARY_LIST
text
--> p1 text
<-- p2 text
FORM summary_list.
CLEAR : us, us_total .
LOOP AT itab.
AT FIRST.
SKIP .
******modified by dhiraj- 23.11.2007*******************************
SELECT SINGLE * FROM t171t WHERE bzirk = itab-bzirk
AND spras = 'E' .
SELECT SINGLE * FROM t005u WHERE spras = sy-langu
AND BLAND = itab-bzirk AND LAND1 = ITAB-LAND1.
PERFORM list_heading_summary.
format color 4 intensified on.
write :/ 'Sales District : ',itab-bzirk,30 t171t-bztxt
,81 ''.
ULINE .
ENDAT.
AT NEW kunde.
SELECT SINGLE * FROM kna1 WHERE kunnr = itab-kunde .
format color 3 intensified on.
write :/ 'Dealer : ',itab-kunde,30(25) kna1-name1,
60 'City : ' ,kna1-ort01, 81 ''.
uline .
ENDAT.
AT NEW fkdat .
format color off intensified off .
write : /5 itab-vbeln,
20 itab-fkdat .
CLEAR flag_fkdat .
ENDAT .
at new matkl .
format color 2 intensified on.
write :/ 'Material Group : ',itab-matkl, 81 ''.
skip .
endat .
mcnt = mcnt + 1 .
dealer-days1 = dealer-days1 + itab-days1 .
dealer-days2 = dealer-days2 + itab-days2 .
dealer-days3 = dealer-days3 + itab-days3 .
dealer-days4 = dealer-days4 + itab-days4 .
dealer-days5 = dealer-days5 + itab-days5 .
state-days1 = state-days1 + itab-days1 .
state-days2 = state-days2 + itab-days2 .
state-days3 = state-days3 + itab-days3 .
state-days4 = state-days4 + itab-days4 .
state-days5 = state-days5 + itab-days5 .
us-days1 = us-days1 + itab-days1 .
us-days2 = us-days2 + itab-days2 .
us-days3 = us-days3 + itab-days3 .
us-days4 = us-days4 + itab-days4 .
us-days5 = us-days5 + itab-days5 .
IF flag_fkdat EQ 'Y' .
NEW-LINE .
ENDIF .
write : 42 itab-sernr ,
59 itab-days1 ,
69 itab-days2 ,
79 itab-days3 ,
89 itab-days4 ,
99 itab-days5 .
flag_fkdat = 'Y' .
at end of matkl .
skip .
format color 2 intensified on.
write :/ 'Total For : ',itab-matkl, ' - ' , mcnt .
clear mcnt .
uline .
endat .
AT END OF kunde.
dealer_total = dealer-days1 + dealer-days2 + dealer-days3
+ dealer-days4 + dealer-days5 .
format color 3 intensified on.
write :/ 'Total for : ',itab-kunde,' - ' ,
57 dealer-days1 ,
67 dealer-days2 ,
77 dealer-days3 ,
87 dealer-days4 ,
97 dealer-days5 ,
107 dealer_total .
CLEAR : dealer_total , dealer .
uline .
ENDAT.
AT END OF bzirk.
**************modified by dhiraj - 23.11.2007****************
SELECT SINGLE * FROM t171t WHERE bzirk = itab-bzirk
AND spras = 'E' .
SELECT SINGLE * FROM t005u WHERE spras = sy-langu
AND BLAND = itab-bzirk AND LAND1 = ITAB-LAND1.
state_total = state-days1 + state-days2 + state-days3
+ state-days4 + state-days5 .
FORMAT COLOR 4 INTENSIFIED ON.
WRITE :/10 t171t-bztxt, " 'Total for : ',itab-bzirk,' - ' ,
57 state-days1 ,
67 state-days2 ,
77 state-days3 ,
87 state-days4 ,
97 state-days5 ,
107 state_total .
CLEAR : state_total , state .
ULINE.
ENDAT.
us_total = us-days1 + us-days2 + us-days3 + us-days4 + us-days5 .
ENDLOOP.
SKIP 2.
FORMAT COLOR 5 INTENSIFIED ON.
WRITE :/10 'Total for US : ' ,
55 us-days1 ,
65 us-days2 ,
75 us-days3 ,
85 us-days4 ,
95 us-days5 ,
105 us_total .
ENDFORM. " SUMMARY_LIST
*& Form LIST_HEADING_SUMMARY
text
--> p1 text
<-- p2 text
FORM list_heading_summary.
DATA : text1(7) , text2(7) , text3(7) , text4(7) , text5(7),
text11(4) , text12(4) , text13(4) , text14(4) , text15(4) .
text11 = days1 .
text12 = days2 .
text13 = days3 .
text14 = days4 .
text15 = days5 .
CONCATENATE : '=<' text11 INTO text1 ,
'>' text12 INTO text2 ,
'>' text13 INTO text3 ,
'>' text14 INTO text4 ,
'>' text15 INTO text5 .
ULINE.
FORMAT COLOR 1 INTENSIFIED OFF.
WRITE :/10 'State',
57 text1 ,
67 text2 ,
77 text3 ,
87 text4 ,
97 text5 ,
110 'Total' .
ULINE.
ENDFORM. " LIST_HEADING_SUMMARY
*& Form LIST_HEADING_SUMMARY
text
--> p1 text
<-- p2 text
FORM list_heading_grp_summary.
DATA : text1(7) , text2(7) , text3(7) , text4(7) , text5(7),
text11(4) , text12(4) , text13(4) , text14(4) , text15(4) .
text11 = days1 .
text12 = days2 .
text13 = days3 .
text14 = days4 .
text15 = days5 .
CONCATENATE : '=<' text11 INTO text1 ,
'>' text12 INTO text2 ,
'>' text13 INTO text3 ,
'>' text14 INTO text4 ,
'>' text15 INTO text5 .
ULINE.
FORMAT COLOR 1 INTENSIFIED OFF.
WRITE :/10 'Material Group',
57 text1 ,
67 text2 ,
77 text3 ,
87 text4 ,
97 text5 ,
110 'Total' .
ULINE.
ENDFORM. " LIST_HEADING_GRP_SUMMARY
*& Form GET_MUSA_TA
text
--> p1 text
<-- p2 text
FORM get_musa_ta.
CLEAR vbpa .
SELECT SINGLE * FROM vbpa
WHERE vbeln = itab-vbeln
AND parvw = 'RE' .
and kunnr = 'TA001' .
IF sy-subrc = 0 .
IF vbpa-kunnr = 'TA001' .
WRITE : 129 'TA ' .
ELSE.
WRITE : 129 'MUSA' .
ENDIF.
ENDIF.
ENDFORM. " GET_MUSA_TA
*& Form grp_summ_list
text
--> p1 text
<-- p2 text
FORM grp_summ_list .
CLEAR : us, us_total .
itab_grp[] = itab[] .
sort itab_grp BY werks matkl.
LOOP AT itab_grp.
AT FIRST.
SKIP .
PERFORM list_heading_grp_summary.
ULINE .
ENDAT.
matgr-days1 = matgr-days1 + itab_grp-days1 .
matgr-days2 = matgr-days2 + itab_grp-days2 .
matgr-days3 = matgr-days3 + itab_grp-days3 .
matgr-days4 = matgr-days4 + itab_grp-days4 .
matgr-days5 = matgr-days5 + itab_grp-days5 .
plant-days1 = plant-days1 + matgr-days1 .
plant-days2 = plant-days2 + matgr-days2 .
plant-days3 = plant-days3 + matgr-days3 .
plant-days4 = plant-days4 + matgr-days4 .
plant-days5 = plant-days5 + matgr-days5 .
us-days1 = us-days1 + itab_grp-days1 .
us-days2 = us-days2 + itab_grp-days2 .
us-days3 = us-days3 + itab_grp-days3 .
us-days4 = us-days4 + itab_grp-days4 .
us-days5 = us-days5 + itab_grp-days5 .
IF flag_fkdat EQ 'Y' .
NEW-LINE .
ENDIF .
write : 42 itab-sernr ,
59 itab-days1 ,
69 itab-days2 ,
79 itab-days3 ,
89 itab-days4 ,
99 itab-days5 .
flag_fkdat = 'Y' .
AT END OF matkl.
matgr_total = matgr-days1 + matgr-days2 + matgr-days3
+ matgr-days4 + matgr-days5 .
FORMAT COLOR 4 INTENSIFIED ON.
WRITE :/10 itab_grp-matkl, " 'Total for : ',itab_grp-matkl,' - ' ,
57 matgr-days1 ,
67 matgr-days2 ,
77 matgr-days3 ,
87 matgr-days4 ,
97 matgr-days5 ,
107 matgr_total .
CLEAR : matgr_total , matgr .
ULINE.
ENDAT.
AT END OF werks.
plant_total = plant-days1 + plant-days2 + plant-days3
+ plant-days4 + plant-days5 .
FORMAT COLOR 4 INTENSIFIED ON.
WRITE :/10 itab_grp-werks, " 'Total for : ',itab_grp-werks,' - ' ,
57 plant-days1 ,
67 plant-days2 ,
77 plant-days3 ,
87 plant-days4 ,
97 plant-days5 ,
107 plant_total .
CLEAR : plant_total , plant .
ULINE.
ENDAT.
us_total = us-days1 + us-days2 + us-days3 + us-days4 + us-days5 .
ENDLOOP.
SKIP 2.
FORMAT COLOR 5 INTENSIFIED ON.
WRITE :/10 'Total : ' ,
55 us-days1 ,
65 us-days2 ,
75 us-days3 ,
85 us-days4 ,
95 us-days5 ,
105 us_total .
ENDFORM. " grp_summ_list{SELECT OBJEK CUOBJ
INTO CORRESPONDING FIELDS OF TABLE TAB_INOB
FROM INOB
WHERE OBJEK IN R_MATNR.
SELECT ATWRT OBJEK ATINN
INTO CORRESPONDING FIELDS OF TABLE TAB_AUSP
FROM AUSP
FOR ALL ENTRIES IN TAB_INOB
WHERE OBJEK = TAB_INOB-CUOBJ.
SELECT ATNAM
INTO TABLE TAB_CABN
FROM CABN
FOR ALL ENTRIES IN TAB_INOB
WHERE ATNAM = 'ZCURSEASON'
OR ATNAM = 'ZCURYEAR'
AND ATINN = TAB_AUSP-ATINN.
after this you can gether the data into one internal table.
Form one inter nal table it_final.
loop at TAB_INOB.
it_final-OBJEK = tab_inob-OBJEK.
it_final-CUOBJ = tab_inob-CUOBJ.
READ TABLE TAB_CABN WITH KEY OBJEK = TAB_INOB-CUOBJ.
IT_FINAL-ATWRT = TAB_CABN-ATWRT.
IT_FINAL-ATINN = TAB_CABN-ATINN.
DO SAME FOR THIRD TABLE
AFFTER DO ALL
APPEND IT_FINAL.
ENDLOOP.}
Maybe you are looking for
-
I bought the normal x plane thinking it was the hi definition version, I did not play the regular but bought the hi rev version to . I would like a refund so that I can buy another app with that money. I uninstalled x plane ( regular)
-
Lot number generation when ever GR is done
Dear All, As there is a requirement like Lot number generation when ever GR is done. For each material Lot Number is defined by the client. And there is partial receipt of Goods. Whenever you do GR system automatically generates Lot number. So we nee
-
Footnotes Separator Bug in Indesign CS4?
Has anyone come across a bug where InDesign inserts a "continued footnote" separator-line above a footnote even though it's not meant to be there (because the footnote is not continued?) Thanks, Ariel
-
Non-application exception occurred while processing method createReportsExc
Hi, Any one get the following exception Non-application exception occurred while processing method createReportsExcelFile on bean BeanId(bsd#bsdejb.jar#ReportsDownload, null): java.lang.NoSuchMethodError: java.lang.RuntimeException: method <init>(Lja
-
Windows 7 and no Internet connectivity
I just installed windows 7 on my Mac. When I try to get online it says windows did not detect a properly installed network adaptor. If you have a network adaptor, you need to reinstall. How do I do this? Do I install on the windows partion?