Performance tuning of this code.
Hello Friends,
Following is the piece of Code.. can some one please help me to optimise the code.
I want to do performance tuning on the same.
Any inputs on this would be valuable to me .
Thanking you all in anticipation.
<< Unformatted code removed >>
Edited by: Jitesh Pamnani on Apr 7, 2009 10:09 AM
Edited by: Jitesh Pamnani on Apr 7, 2009 10:09 AM
Edited by: Rob Burbank on Apr 7, 2009 11:05 AM
please read,
SQL trace:
/people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
for the first part, without SQL Trace it does not make much sense, to check your select statements.
I guess that one or several are slow. But there are too many.
Second part, use sorted tables or binary search!!!!!
Your coding is highly nonlinear, not only quadratic but even cubic!!!!
Read here for table types and runtimes
Measurements on internal tables: Reads and Loops:
/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables
Read here about nonlinearity:
Nonlinearity: The problem and background
/people/siegfried.boes/blog/2007/02/12/performance-problems-caused-by-nonlinear-coding
Read here for measuring:
SE30
/people/siegfried.boes/blog/2007/11/13/the-abap-runtime-trace-se30--quick-and-easy
Z_SE30_COMPARE
/people/siegfried.boes/blog/2008/01/15/a-tool-to-compare-runtime-measurements-zse30compare
Nonlinearity Check
/people/siegfried.boes/blog/2008/01/24/nonlinearity-check-using-the-zse30compare
If you do ot all I assume that your coding can becomes faster by factors 10 ... 100 or even more.
Siegfried
Similar Messages
-
Performance tuning on this code
Hi guys,
This piece of coding is taking ages to execute, any idea how can i fine tune it?
SELECT vbeln vbtyp_n vbtyp_v vbelv
INTO TABLE lt_vbfa1 FROM vbfa
FOR ALL ENTRIES IN lt_vbrp
WHERE vbeln = lt_vbrp-vbeln
AND vbtyp_n IN ('N','S')
AND vbtyp_v IN ('M','P','O').
Thanks in advance!Table VBFA (sales document flow) is to be used to find preceding documents, like cancelation invoices for an invoice.
Here original documents are to be found for a preceding document. Then it's better not to use table VBFA because its key is original document number. Then try to use VBRP-VGBEL (preceding document) or VBRP-AUBEL (preceding sales order). Here something like:
SELECT vbrk~vbeln vbrk~vbtyp vbrp~vgtyp vbrp~vgbel
INTO TABLE lt_vbfa1
FROM vbrk INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln
FOR ALL ENTRIES IN lt_vbrp
WHERE vbrk~vbeln = lt_vbrp-vbeln
AND vbrp~posnr = lt_vbrp-posnr
AND vbrk~vbtyp IN ('N','S')
AND vbrp~vgtyp IN ('M','P','O').
Regards Jack -
Performance tuning of this report
Hello friends iam attaching my report give the performance tuning for this report to avoid nested endloops. how to do without using nested endloops.
give me the reply urgent.
REPORT ZDEMO9 NO STANDARD PAGE HEADING
LINE-SIZE 250
LINE-COUNT 22(3). .
TABLES DECLARATION *
TABLES : MARA, "general material data
MAKT, "material description
MARC, "plant data for material
VBAP, "sales document for item data
EKKO, "purchasing document header
EKPO, "purchasing document item
KNA1. "customer master details
INTERNAL TABLE DECLARATION *
DATA : BEGIN OF T_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MEINS LIKE MARA-MEINS,
END OF T_MARA.
DATA : BEGIN OF T_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
SPRAS LIKE MAKT-SPRAS,
END OF T_MAKT.
DATA : BEGIN OF T_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
END OF T_MARC.
DATA : BEGIN OF T_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
LAND1 LIKE KNA1-LAND1,
END OF T_KNA1.
DATA : BEGIN OF T_VBAP OCCURS 0,
MATNR LIKE VBAP-MATNR,
POSNR LIKE VBAP-POSNR,
MATKL LIKE VBAP-MATKL,
VBELN LIKE VBAP-VBELN,
END OF T_VBAP.
DATA : BEGIN OF T_EKPO OCCURS 0,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
BUKRS LIKE EKPO-BUKRS,
WERKS LIKE EKPO-WERKS,
LGORT LIKE EKPO-LGORT,
MATNR LIKE EKPO-MATNR,
MANDT LIKE EKPO-MANDT,
END OF T_EKPO.
FINAL INTERNAL TABLE *
DATA : BEGIN OF T_FINAL OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MEINS LIKE MARA-MEINS,
WERKS LIKE MARC-WERKS,
MAKTX LIKE MAKT-MAKTX,
SPRAS LIKE MAKT-SPRAS,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATKL LIKE VBAP-MATKL,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
BUKRS LIKE EKPO-BUKRS,
KUNNR LIKE KNA1-KUNNR,
LAND1 LIKE KNA1-LAND1,
NAME1 LIKE KNA1-NAME1,
LGORT LIKE EKPO-LGORT,
END OF T_FINAL.
*DATA: BEGIN OF V_matnr OCCURS 0,
matnr LIKE mara-matnr,
END OF t_matnr.
data:
a(32) type c.
a = 'IBT000000000000000001000000000000000050'.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_BUKRS FOR EKPO-BUKRS,
S_KUNNR FOR KNA1-KUNNR,
S_WERKS FOR MARC-WERKS,
S_MATNR FOR MARA-MATNR obligatory.
SELECTION-SCREEN END OF BLOCK B1.
START OF SELECTION *
START-OF-SELECTION.
SELECT MATNR mtart meins
FROM MARA
INTO CORRESPONDING FIELDS OF TABLE T_MARA
WHERE MATNR IN S_MATNR.
SELECT MATNR WERKS
FROM MARC
INTO CORRESPONDING FIELDS OF TABLE T_MARC
FOR ALL ENTRIES IN T_MARA
WHERE MATNR = T_MARA-MATNR
and werks in s_werks.
select matnr maktx spras
from makt
into corresponding fields of table t_makt
for all entries in t_mara
where matnr = t_mara-matnr
and spras = sy-langu.
select matnr posnr matkl vbeln
from vbap
into corresponding fields of table t_vbap
for all entries in t_mara
where matnr = t_mara-matnr.
select matnr werks bukrs ebeln ebelp lgort
from ekpo
into corresponding fields of table t_ekpo
for all entries in t_mara
where matnr = t_mara-matnr
and werks in s_werks.
LOOP AT T_MARA.
MOVE T_MARA-matnr TO T_FINAL-matnr.
move t_mara-mtart to t_final-mtart.
move t_mara-meins to t_final-meins.
loop at t_marc where matnr eq t_mara-matnr.
move t_marc-werks to t_final-werks.
loop at t_makt.
move t_makt-maktx to t_final-maktx.
move t_makt-spras to t_final-spras.
loop at t_vbap.
move t_vbap-posnr to t_final-posnr.
move t_vbap-matkl to t_final-matkl.
move t_vbap-vbeln to t_final-vbeln.
loop at t_ekpo.
move t_ekpo-bukrs to t_final-bukrs.
move t_ekpo-ebeln to t_final-ebeln.
move t_ekpo-ebelp to t_final-ebelp.
move t_ekpo-lgort to t_final-lgort.
append t_final.
endloop.
endloop.
endloop.
endloop.
endloop.
SELECT werks KUNNR LAND1 NAME1
INTO CORRESPONDING FIELDS OF TABLE T_KNA1
FROM KNA1.
WHERE WERKS in s_werks.
loop at t_kna1.
move t_kna1-kunnr to t_final-kunnr.
move t_kna1-name1 to t_final-name1.
move t_kna1-land1 to t_final-land1.
append t_final.
endloop.
"endloop.
loop at t_final.
write : 4 t_final-matnr,
20 t_final-mtart,
28 t_final-meins,
46 t_final-werks,
58 t_final-maktx,
71 t_final-spras,
78 t_final-posnr,
100 t_final-matkl,
115 t_final-vbeln,
130 t_final-kunnr,
142 t_final-name1,
156 t_final-land1,
168 t_final-bukrs,
190 t_final-ebeln,
205 t_final-ebelp,
208 t_final-lgort.
endloop.
TOP-OF-PAGE *
top-of-page.
uline.
write : /60 'G E N E R A L D E T A I L S' COLOR 2 INVERSE OFF.
ULINE.
write :/ SY-VLINE, 'MATERIAL' COLOR 4, "12 SY-VLINE,
13 SY-VLINE, 'IND SECTOR',
28 SY-VLINE, 'UNITS',
43 SY-VLINE, 'PLANT',
55 SY-VLINE, 'MAT DESC',
68 SY-VLINE, 'LANGU',
70 SY-VLINE, 'SALES DOC ITEM',
95 SY-VLINE, 'MAT GROUP',
110 SY-VLINE, 'SALES DOC',
125 SY-VLINE, 'CUST ID',
140 SY-VLINE, 'NAME',
155 SY-VLINE, 'COUNTRY',
165 sy-vline, 'company code',
205 sy-vline, 'storge loc'.*& Report YTESTCHA *
REPORT ytestcha NO STANDARD PAGE HEADING
LINE-SIZE 250
LINE-COUNT 22(3). .
TABLES DECLARATION *
TABLES : mara, "general material data
makt, "material description
marc, "plant data for material
vbap, "sales document for item data
ekko, "purchasing document header
ekpo, "purchasing document item
kna1. "customer master details
INTERNAL TABLE DECLARATION *
*DECLARE TYPES FIRST AND THE INTERNAL TABLES
*DONT USE MATNR LIKE MARA-MATNR ,INSTEAD USE MARA TYPE MATNR WHERE MATNR
*IS THE DATA ELEMENT FOR FIELD MATNR.
TYPES: BEGIN OF ty_mara,
matnr TYPE matnr,
mtart TYPE mtart,
meins TYPE meins,
kunnr TYPE wettb,
END OF ty_mara.
TYPES: BEGIN OF ty_makt,
matnr TYPE matnr,
maktx TYPE maktx,
spras TYPE spras,
END OF ty_makt.
TYPES: BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
TYPES : BEGIN OF ty_kna1,
kunnr TYPE kunnr,
name1 TYPE name1_gp,
land1 TYPE land1_gp,
END OF ty_kna1.
TYPES: BEGIN OF ty_vbap,
matnr TYPE matnr,
posnr TYPE posnr_va,
matkl TYPE matkl,
vbeln TYPE vbeln_va,
END OF ty_vbap.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
bukrs TYPE bukrs,
werks TYPE werks_d,
lgort TYPE lgort_d,
matnr TYPE matnr,
mandt TYPE mandt,
END OF ty_ekpo.
DATA:t_mara TYPE TABLE OF ty_mara WITH HEADER LINE,
t_makt TYPE TABLE OF ty_makt WITH HEADER LINE,
t_marc TYPE TABLE OF ty_marc WITH HEADER LINE,
t_kna1 TYPE TABLE OF ty_kna1 WITH HEADER LINE,
t_vbap TYPE TABLE OF ty_vbap WITH HEADER LINE,
t_ekpo TYPE TABLE OF ty_ekpo WITH HEADER LINE.
FINAL INTERNAL TABLE *
TYPES: BEGIN OF ty_final,
matnr TYPE matnr,
mtart TYPE mtart,
meins TYPE meins,
werks TYPE werks_d,
maktx TYPE maktx,
spras TYPE spras,
vbeln TYPE vbeln_va,
posnr TYPE posnr_va,
matkl TYPE matkl,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
bukrs TYPE bukrs,
kunnr TYPE kunnr,
land1 TYPE land1_gp,
name1 TYPE name1_gp,
lgort TYPE lgort_d,
END OF ty_final.
DATA : t_final TYPE TABLE OF ty_final WITH HEADER LINE.
*DATA: BEGIN OF V_matnr OCCURS 0,
matnr LIKE mara-matnr,
END OF t_matnr.
DATA:
a(32) TYPE c.
a = 'IBT000000000000000001000000000000000050'.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_bukrs FOR ekpo-bukrs,
s_kunnr FOR kna1-kunnr,
s_werks FOR marc-werks,
s_matnr FOR mara-matnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
START OF SELECTION *
START-OF-SELECTION.
*USE SUBROUTINES
*get data
PERFORM get_data.
*populate final table
PERFORM populate_final_table.
END-OF-SELECTION.
*display output
PERFORM display_output.
TOP-OF-PAGE *
TOP-OF-PAGE.
ULINE.
WRITE : /60 'G E N E R A L D E T A I L S' COLOR 2 INVERSE OFF.
ULINE.
WRITE :/ sy-vline, 'MATERIAL' COLOR 4, "12 SY-VLINE,
13 sy-vline, 'IND SECTOR',
28 sy-vline, 'UNITS',
43 sy-vline, 'PLANT',
55 sy-vline, 'MAT DESC',
68 sy-vline, 'LANGU',
70 sy-vline, 'SALES DOC ITEM',
95 sy-vline, 'MAT GROUP',
110 sy-vline, 'SALES DOC',
125 sy-vline, 'CUST ID',
140 sy-vline, 'NAME',
155 sy-vline, 'COUNTRY',
165 sy-vline, 'company code',
205 sy-vline, 'storge loc'.
*& Form GET_DATA
text
--> p1 text
<-- p2 text
*TRY TO CLEAR AND REFRESH TABLES BEFORE SELECT
FORM get_data .
CLEAR t_mara.
REFRESH t_mara.
SELECT matnr
mtart
meins
kunnr
FROM mara
INTO TABLE t_mara
WHERE matnr IN s_matnr.
IF NOT t_mara[] IS INITIAL.
CLEAR t_marc.
REFRESH t_marc.
SELECT matnr
werks
FROM marc
INTO TABLE t_marc
FOR ALL ENTRIES IN t_mara
WHERE matnr = t_mara-matnr
AND werks IN s_werks.
CLEAR t_makt.
REFRESH t_makt.
SELECT matnr
maktx
spras
FROM makt
INTO TABLE t_makt
FOR ALL ENTRIES IN t_mara
WHERE matnr = t_mara-matnr
AND spras = sy-langu.
CLEAR t_vbap.
REFRESH t_vbap.
SELECT matnr
posnr
matkl
vbeln
FROM vbap
INTO TABLE t_vbap
FOR ALL ENTRIES IN t_mara
WHERE matnr = t_mara-matnr.
CLEAR t_ekpo.
REFRESH t_ekpo.
SELECT ebeln
ebelp
bukrs
werks
lgort
matnr
mandt
FROM ekpo
INTO TABLE t_ekpo
FOR ALL ENTRIES IN t_mara
WHERE matnr = t_mara-matnr
AND werks IN s_werks.
ENDIF.
CLEAR t_kna1.
REFRESH t_kna1.
SELECT kunnr
land1
name1
INTO TABLE t_kna1
FROM kna1.
WHERE WERKS in s_werks.
ENDFORM. " GET_DATA
*& Form POPULATE_FINAL_TABLE
text
--> p1 text
<-- p2 text
FORM populate_final_table .
*AVOID LOOPS AND TRY TO USE READ
CLEAR t_final.
REFRESH t_final.
LOOP AT t_mara.
MOVE t_mara-matnr TO t_final-matnr.
MOVE t_mara-mtart TO t_final-mtart.
MOVE t_mara-meins TO t_final-meins.
READ TABLE t_marc WITH KEY matnr = t_mara-matnr.
MOVE t_marc-werks TO t_final-werks.
READ TABLE t_makt WITH KEY matnr = t_mara-matnr.
MOVE t_makt-maktx TO t_final-maktx.
MOVE t_makt-spras TO t_final-spras.
READ TABLE t_vbap WITH KEY matnr = t_mara-matnr.
MOVE t_vbap-posnr TO t_final-posnr.
MOVE t_vbap-matkl TO t_final-matkl.
MOVE t_vbap-vbeln TO t_final-vbeln.
READ TABLE t_ekpo WITH KEY matnr = t_mara-matnr.
MOVE t_ekpo-bukrs TO t_final-bukrs.
MOVE t_ekpo-ebeln TO t_final-ebeln.
MOVE t_ekpo-ebelp TO t_final-ebelp.
MOVE t_ekpo-lgort TO t_final-lgort.
READ TABLE t_kna1 WITH KEY kunnr = t_mara-kunnr.
MOVE t_kna1-kunnr TO t_final-kunnr.
MOVE t_kna1-name1 TO t_final-name1.
MOVE t_kna1-land1 TO t_final-land1.
APPEND t_final.
CLEAR :t_final,t_mara,t_marc,t_makt,t_ekpo,t_vbap.
ENDLOOP.
ENDFORM. " POPULATE_FINAL_TABLE
*& Form DISPLAY_OUTPUT
text
--> p1 text
<-- p2 text
FORM display_output .
LOOP AT t_final.
WRITE : 4 t_final-matnr,
20 t_final-mtart,
28 t_final-meins,
46 t_final-werks,
58 t_final-maktx,
71 t_final-spras,
78 t_final-posnr,
100 t_final-matkl,
115 t_final-vbeln,
130 t_final-kunnr,
142 t_final-name1,
156 t_final-land1,
168 t_final-bukrs,
190 t_final-ebeln,
205 t_final-ebelp,
208 t_final-lgort.
ENDLOOP.
ENDFORM. " DISPLAY_OUTPUT -
Performance issue in this code
public int[][] init(int[][] a, int m, int n){
for(int j=0; j<n; j++){
for(int i=0; i<m; i++){
a[i][j] = i+j;
return a;
}Just a technical quest faced in one of the interview...
There is a performance issue in this code. Can you identify, correct and justify your answer?
Edited by: EJP on 17/10/2011 20:29mithu wrote:
public int[][] init(int[][] a, int m, int n){
for(int j=0; j<n; j++){
for(int i=0; i<m; i++){
a[i][j] = i+j;
return a;
}Just a technical quest faced in one of the interview...
There is a performance issue in this code. Can you identify, correct and justify your answer?Not a good question at all. There's no performance issue here that can be positively identified by inspection. The only potentially significant one is, as EJP pointed out, loss of locality of reference because of the order of the loops. But even that's not a guarantee, since I don't think array layouts are defined by the spec. We could only determine for sure that that's a performance problem by profiling. -
Performance issue of this code
Hi folks,
This report is working fine.But it is taking lot of time if i enter only company code.Could any one suggest me where is the problem.
kaki
REPORT Z1F_RFKEPL00 no standard page heading
line-size 140
line-count 65
message-id Z1.
TABLES: LFA1,t005t,bsak,bseg,t001,skat.
data: begin of t_bsak occurs 0,
bukrs like bsak-bukrs, "company code
lifnr like bsak-lifnr, "Vendor acc number
augdt like bsak-augdt, "Clearing date
AUGBL like bsak-AUGBL, "Clearing Document
GJAHR like bsak-GJAHR, "year
belnr like bsak-belnr, "Document number
BUZEI like bsak-BUZEI, "Line Item
budat like bsak-budat, "Posting Date in the Document
bldat like bsak-bldat, "Document date in document
blart like bsak-blart, "Document type
BSCHL like bsak-BSCHL, "Posting key
WAERS like bsak-WAERS, "Currency key
CPUDT like bsak-cpudt, "Accounting Document Entry Date
SHKZG like bsak-shkzg, "Debit/Credit Indicator
DMBTR like bsak-dmbtr, "Amount in local currency
WRBTR like bsak-wrbtr, "Amount in document currency
SGTXT like bsak-sgtxt, "Item Text
SAKNR LIKE bsak-saknr, "G/L Account Number
hkont like bsak-hkont, "General Ledger Account
SKFBT LIKE BSAK-SKFBT, "Amount Eligible for Cash Discount
KOSTL LIKE BSEG-KOSTL, "Cost center
ktopl like t001-ktopl, "chart of accounts
txt20 like skat-txt20, "Short test for the GL acc
name1 like lfa1-name1,
land1 like lfa1-land1,
landx like t005t-landx,
end of t_bsak.
data: begin of t_header occurs 0,
bukrs like bsak-bukrs,
hkont like bsak-hkont,
lifnr like bsak-lifnr,
waers like bsak-waers,
land1 like lfa1-land1,
name1 like lfa1-name1,
landx like t005t-landx,
end of t_header.
data: begin of t_lfa1 occurs 0,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
land1 like lfa1-land1,
landx like t005t-landx,
end of t_lfa1.
data: t_bseg like t_bsak occurs 0 with header line.
data: t_data like t_bsak occurs 0 with header line.
selection-screen begin of block blk1 with frame title text-001.
select-options: s_lifnr for bsak-lifnr,
s_bukrs for bsak-bukrs.
selection-screen end of block blk1.
selection-screen begin of block blk2 with frame title text-002.
parameters s_budat like bsik-budat default sy-datum.
select-options: s_augdt for bsak-augdt.
selection-screen end of block blk2.
selection-screen begin of block blk3 with frame title text-003.
parameters: stand as checkbox default 'X',
park as checkbox.
selection-screen end of block blk3.
start-of-selection.
perform process_data.
top-of-page.
perform set_page_header.
*& Form process_data
text
form process_data.
data: line like t_bsak occurs 0 with header line.
data: l_wrbtr(10) type c.
data: l_debit type bsak-wrbtr,l_credit type bsak-wrbtr,
l_balance type bsak-wrbtr.
data:l_hkont(10) type n.
select BUKRS LIFNR AUGDT AUGBL GJAHR BELNR BUZEI BUDAT BLDAT
CPUDT WAERS BLART BSCHL SHKZG DMBTR WRBTR SGTXT HKONT SKFBT
from bsak
into corresponding fields of table t_bsak
where
lifnr in s_lifnr and
BUKRS in s_bukrs and
budat le s_budat and " Open items
augdt in s_augdt order by lifnr.
if sy-subrc ne 0.
message i016.
leave list-processing.
endif.
sort t_bsak by BUDAT.
CHECK NOT t_bsak[] IS INITIAL.
select MANDT BUKRS LIFNR AUGDT AUGBL GJAHR BELNR
SHKZG DMBTR WRBTR SGTXT SKFBT KOSTL BSCHL hkont BUZEI
into corresponding fields of table t_bseg from bseg
FOR ALL ENTRIES IN t_bsak
where belnr = t_bsak-belnr and
bukrs = t_bsak-bukrs and
gjahr = t_bsak-gjahr
ORDER BY PRIMARY KEY .
loop at t_bsak.
to get vendor name
select single * from lfa1 where lifnr = t_bsak-lifnr.
move lfa1-lifnr to t_header-lifnr.
move lfa1-name1 to t_header-name1.
move lfa1-land1 to t_header-land1.
move t_bsak-bukrs to t_header-bukrs.
move t_bsak-hkont to t_header-hkont.
move t_bsak-waers to t_header-waers.
if sy-subrc = 0.
append t_header.
clear t_header.
endif.
to get vendor country
loop at t_header.
select single * from t005t where land1 = t_header-land1 and
SPRAS = 'E'.
move t005t-landx to t_header-landx.
if sy-subrc = 0.
modify t_header.
clear t_header.
endif.
endloop.
loop at t_bseg where belnr = t_bsak-belnr and
bukrs = t_bsak-bukrs and
gjahr = t_bsak-gjahr.
l_hkont = t_bseg-hkont.
*To get chart of accounts
select single * from t001 where bukrs = t_bseg-bukrs.
move t001-ktopl to t_bseg-ktopl.
*To get short text for the chart of accounts
select single * from skat where ktopl = t_bseg-ktopl and
saknr = l_hkont and
spras = 'E'.
t_data-bukrs = t_bsak-bukrs.
t_data-lifnr = t_bsak-lifnr.
t_data-augdt = t_bseg-augdt.
t_data-AUGBL = t_bseg-AUGBL.
t_data-GJAHR = t_bseg-GJAHR.
t_data-belnr = t_bsak-belnr.
t_data-BUZEI = t_bseg-BUZEI.
t_data-budat = t_bsak-budat.
t_data-bldat = t_bsak-bldat.
t_data-blart = t_bsak-blart.
t_data-BSCHL = t_bseg-BSCHL.
t_data-WAERS = t_bsak-WAERS.
t_data-CPUDT = t_bsak-cpudt.
t_data-SHKZG = t_bseg-shkzg.
t_data-DMBTR = t_bseg-dmbtr.
t_data-WRBTR = t_bseg-wrbtr.
t_data-SGTXT = t_bsak-sgtxt.
t_data-SAKNR = t_bseg-saknr.
t_data-hkont = t_bseg-hkont.
t_data-SKFBT = t_bseg-SKFBT.
t_data-KOSTL = t_bseg-KOSTL.
t_data-ktopl = t_bseg-ktopl.
t_data-txt20 = skat-txt20.
append t_data.
clear t_data.
endloop.
endloop.
sort t_header by lifnr.
delete adjacent duplicates from t_header.
*Display----
*to display header
data: l_buzei type bseg-buzei.
loop at t_header.
write:/1(6) t_header-bukrs color 2,
7(8) t_header-hkont color 2,
18(10) t_header-lifnr color 2.
write:/30(10) t_header-name1.
write:/30(10) t_header-landx.
uline.
loop at t_data where lifnr = t_header-lifnr.
l_wrbtr = t_data-wrbtr.
if t_data-wrbtr = t_data-skfbt.
concatenate l_wrbtr '-' into l_wrbtr.
endif.
write:/15(11) t_data-BUDAT no-zero color 7,
26(5) t_data-BLART color 7,
30(12) t_data-belnr color 7,
42(16) t_data-BLDAT color 7,
58(5) t_data-buzei color 7,
63(12) t_data-BSCHL color 7,
75(9) t_data-AUGDT color 7,
84(35) t_data-AUGBL color 7,
119(7) t_data-WAERS color 7,
126(12) l_wrbtr color 7.
write:/55 t_data-sgtxt.
write:/60(10) t_data-kostl,
70(10) t_data-hkont,
80(20) t_data-txt20.
clear l_wrbtr.
endloop.
write:/1(6) t_data-bukrs color 2,
7(8) t_data-hkont color 2,
18(10) t_data-lifnr color 2.
uline.
line[] = t_data[].
loop at line where lifnr = t_header-lifnr.
if line-shkzg = 'H'.
l_debit = l_debit + line-wrbtr.
endif.
if line-shkzg = 'S'.
l_credit = l_credit + line-wrbtr.
endif.
endloop.
write:/1(6) t_data-bukrs color 3,
7(8) t_data-hkont color 3,
18(10) t_data-lifnr color 3.
write:/1(6) t_data-bukrs color 3,
7(11) t_data-hkont color 3,
18(102) t_data-lifnr color 3.
l_balance = l_debit - l_credit.
write:115(15) l_debit color 3. write:135(1) 'D' color 3.
write:/115(15) l_credit color 3. write:135(1) 'C' color 3.
for balnce
write:/90(25) 'Bal.:' color 3.
write:115(15) l_balance color 3.
write:120(15) l_debit color 3.
write:138(2) 'D' color 3.
write:/120(15) l_credit color 3.
write:138(2) 'C' color 3.
for balnce
write:/90(00) 'Bal.:' color 3.
write:120(15) l_balance color 3.
clear: l_debit,l_credit,l_balance.
uline.
endloop.
endform. "process_data
*& Form set_page_header
text
FORM set_page_header.
call function 'Z_REPORT_TITLE'
EXPORTING
line_size = sy-linsz
sy_title = 'List of Vendor Line Items'
uline = 'X'
first_page_only = ' '.
write :1(15) 'Allocation' color col_heading,
15(10) 'Pstng' color col_heading,
25(5) 'Do' color col_heading,
30(10) 'Documnet' color col_heading,
40(10) 'Doc' color col_heading,
50(8) 'BusA' color col_heading,
58(5) 'LIm' color col_heading,
63(4) 'PK' color col_heading,
67(4) 'S' color col_heading,
71(4) 'P' color col_heading,
75(7) 'Clrg' color col_heading,
82(10) 'Clearing' color col_heading,
92(20) 'D/c discount Amnt' color col_heading,
112(5) 'Rsn' color col_heading,
117(2) 'G' color col_heading,
119(7) 'Curr-' color col_heading,
126(12) 'Amount in' color col_heading,
138(2) 'T' color col_heading.
write space.
write :1(15) 'number' color col_heading,
15(10) 'date' color col_heading,
25(5) 'ty' color col_heading,
30(10) 'number' color col_heading,
40(18) 'date' color col_heading,
58(5) '' color col_heading,
63(4) '' color col_heading,
67(4) 'I' color col_heading,
71(4) 'K' color col_heading,
75(7) 'date' color col_heading,
82(24) 'doc.no' color col_heading,
105(20) 'in LC' color col_heading,
112(5) 'code' color col_heading,
117(2) 'L' color col_heading,
119(7) 'ency' color col_heading,
126(12) 'doc.curr.' color col_heading,
138(2) 'X' color col_heading.
write space.
uline.
ENDFORM. " set_page_headerit will better to optimize the below part of your code -
loop at t_bsak.
to get vendor name
select single * from lfa1 where lifnr = t_bsak-lifnr.
move lfa1-lifnr to t_header-lifnr.
move lfa1-name1 to t_header-name1.
move lfa1-land1 to t_header-land1.
move t_bsak-bukrs to t_header-bukrs.
move t_bsak-hkont to t_header-hkont.
move t_bsak-waers to t_header-waers.
if sy-subrc = 0.
append t_header.
clear t_header.
endif.
to get vendor country
loop at t_header.
select single * from t005t where land1 = t_header-land1 and
SPRAS = 'E'.
move t005t-landx to t_header-landx.
if sy-subrc = 0.
modify t_header.
clear t_header.
endif.
endloop.
loop at t_bseg where belnr = t_bsak-belnr and
bukrs = t_bsak-bukrs and
gjahr = t_bsak-gjahr.
l_hkont = t_bseg-hkont.
*To get chart of accounts
select single * from t001 where bukrs = t_bseg-bukrs.
move t001-ktopl to t_bseg-ktopl.
*To get short text for the chart of accounts
select single * from skat where ktopl = t_bseg-ktopl and
saknr = l_hkont and
spras = 'E'.
t_data-bukrs = t_bsak-bukrs.
t_data-lifnr = t_bsak-lifnr.
t_data-augdt = t_bseg-augdt.
t_data-AUGBL = t_bseg-AUGBL.
t_data-GJAHR = t_bseg-GJAHR.
t_data-belnr = t_bsak-belnr.
t_data-BUZEI = t_bseg-BUZEI.
t_data-budat = t_bsak-budat.
t_data-bldat = t_bsak-bldat.
t_data-blart = t_bsak-blart.
t_data-BSCHL = t_bseg-BSCHL.
t_data-WAERS = t_bsak-WAERS.
t_data-CPUDT = t_bsak-cpudt.
t_data-SHKZG = t_bseg-shkzg.
t_data-DMBTR = t_bseg-dmbtr.
t_data-WRBTR = t_bseg-wrbtr.
t_data-SGTXT = t_bsak-sgtxt.
t_data-SAKNR = t_bseg-saknr.
t_data-hkont = t_bseg-hkont.
t_data-SKFBT = t_bseg-SKFBT.
t_data-KOSTL = t_bseg-KOSTL.
t_data-ktopl = t_bseg-ktopl.
t_data-txt20 = skat-txt20.
append t_data.
clear t_data.
endloop.
endloop.
You are selecting data from database inside the loop and specially you are populating t_header inside the loop and again looping on the same table to get value of t005t-landx. Here you are updating even those records which are already update by initial loop pass so multiple updation for already updated records.
Thanks,
Rajeev -
Performance Issue with this code
Hi Gurus,
Can anyone please help tweak the performance of this program.
REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SPREPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
[/code]2 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
[/code]3 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
[/code]4 FOR VBAK-ERDAT.
SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
[/code]5 FOR VBAP-KWMENG.
SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
[/code]6 FOR VBAP-UEPOS.
SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
[/code]7 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
TABLES: VBAP, MATERIALID, VBAK, VBEP.
SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KUNNR(10),
AUGRU(3),
KZTLF(1),
FILLER(12),
END OF ITAB2_SALESORD4.
CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',
C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
DATA: L_VBELN TYPE VBFA-VBELN,
L_POSNR TYPE VBFA-POSNN,
L_LVBELN TYPE VBFA-VBELN.
DATA: BEGIN OF ITAB_SUPER OCCURS 0,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
END OF ITAB_SUPER.
START-OF-SELECTION.
SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR VBAK~AUGRU VBAP~KZTLF
INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
, VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
, VBAP-ABGRU , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
FROM ( VBAK
INNER JOIN VBAP
ON VBAP~VBELN = VBAK~VBELN
INNER JOIN MATERIALID
ON MATERIALID~MATNR_INT = VBAP~MATNR )
WHERE VBAK~ERDAT IN SP$00004
AND VBAK~VBELN IN SP$00001
AND VBAP~KWMENG IN SP$00005
AND VBAP~MATWA IN SP$00007
AND VBAP~POSNR IN SP$00002
AND VBAP~PSTYV IN SP$00008
AND VBAP~UEPOS IN SP$00006
AND MATERIALID~MATNR_EXT IN SP$00003.
SELECT SINGLE VBELN POSNN
FROM VBFA
INTO (L_VBELN, L_POSNR)
WHERE VBELV = VBAK-VBELN AND
POSNV = VBAP-POSNR AND
VBTYP_N = 'J'.
IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
SELECT SINGLE VBELN
FROM LIPS
INTO L_LVBELN
WHERE VBELN = L_VBELN AND
POSNR = L_POSNR.
IF SY-SUBRC NE 0.
IF NOT VBAP-UEPOS IS INITIAL.
MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.
MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.
APPEND ITAB_SUPER.
ENDIF.
CONTINUE.
ENDIF.
ENDIF.
MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.
MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.
MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.
MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.
MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.
MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.
MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.
MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.
MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.
MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.
MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.
MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.
MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.
IF VBAK-AUGRU = C_REASON_VR.
MOVE C_REASON_EM TO ITAB2_SALESORD4-AUGRU.
ELSE.
MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.
ENDIF.
MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.
ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG
DECIMALS 0 RIGHT-JUSTIFIED.
OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
APPEND ITAB2_SALESORD4.
CLEAR ITAB2_SALESORD4.
ENDSELECT.
SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.
SORT ITAB_SUPER BY VBELN POSNR.
DATA: G_FILE LIKE RLGRAP-FILENAME,
ZDFLTVAL11(40),
ZDFLTVAL22(40).
SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
(ZDFLTVAL11,ZDFLTVAL22)
FROM ZLE_LOG_DFLT_VAL
WHERE LGNUM = ' '
AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
TRANSLATE ZDFLTVAL22 TO LOWER CASE.
CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
LOOP AT ITAB2_SALESORD4.
READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
POSNR = ITAB2_SALESORD4-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
CONTINUE.
ENDIF.
TRANSFER ITAB2_SALESORD4 TO G_FILE.
ENDLOOP.
CLOSE DATASET G_FILE.
[/code]8 FOR VBAP-PSTYV.
SELECTION-SCREEN: END OF BLOCK PROG.
DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
VBELN(10),
AUART(4),
POSNR(6),
WERKS(4),
MATNR_EXT(40),
ERDAT(8),
KWMENG(19),
VRKME(3),
UEPOS(6),
MATWA(40),
PSTYV(4),
ABGRU(2),
Z_PROM_SHP_DT(8),
BSTNK(20),
KThe first SELECT looks a bit shaky. Have you done a performance trace (ST05) to find out where the problem is?
Rob -
Is There any way to improve the performance on this code
Hi all can any one tell me how to improve the performance of this below code.
Actually i need to calculate opening balance of gl account so instead of using bseg am using bsis
So is there any way to improve this code performance.
Any help would be appreciated.
REPORT ZTEMP5 NO STANDARD PAGE HEADING LINE-SIZE 190.
data: begin of collect occurs 0,
MONAT TYPE MONAT,
HKONT TYPE HKONT,
BELNR TYPE BELNR_D,
BUDAT TYPE BUDAT,
WRBTR TYPE WRBTR,
SHKZG TYPE SHKZG,
SGTXT TYPE SGTXT,
AUFNR TYPE AUFNR_NEU,
TOT LIKE BSIS-WRBTR,
end of collect.
TYPES: BEGIN OF TY_BSIS,
MONAT TYPE MONAT,
HKONT TYPE HKONT,
BELNR TYPE BELNR_D,
BUDAT TYPE BUDAT,
WRBTR TYPE WRBTR,
SHKZG TYPE SHKZG,
SGTXT TYPE SGTXT,
AUFNR TYPE AUFNR_NEU,
END OF TY_BSIS.
DATA: IT_BSIS TYPE TABLE OF TY_BSIS,
WA_BSIS TYPE TY_BSIS.
DATA: TOT TYPE WRBTR,
SUMA TYPE WRBTR,
VALUE TYPE WRBTR,
VALUE1 TYPE WRBTR.
SELECTION-SCREEN: BEGIN OF BLOCK B1.
PARAMETERS: S_HKONT LIKE WA_BSIS-HKONT DEFAULT '0001460002' .
SELECT-OPTIONS: S_BUDAT FOR WA_BSIS-BUDAT,
S_AUFNR FOR WA_BSIS-AUFNR DEFAULT '200020',
S_BELNR FOR WA_BSIS-BELNR.
SELECTION-SCREEN: END OF BLOCK B1.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-NAME = 'S_HKONT'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
SELECT MONAT
HKONT
BELNR
BUDAT
WRBTR
SHKZG
SGTXT
AUFNR
FROM BSIS
INTO TABLE IT_BSIS
WHERE HKONT EQ S_HKONT
AND BELNR IN S_BELNR
AND BUDAT IN S_BUDAT
AND AUFNR IN S_AUFNR.
* if sy-subrc <> 0.
* message 'No Data' type 'I'.
* endif.
SELECT SUM( WRBTR )
FROM BSIS
INTO COLLECT-TOT
WHERE HKONT EQ S_HKONT
AND BUDAT < S_BUDAT-LOW
AND AUFNR IN S_AUFNR.
END-OF-SELECTION.
CLEAR: S_BUDAT, S_AUFNR, S_BELNR, S_HKONT.
LOOP AT IT_BSIS INTO WA_BSIS.
IF wa_bsis-SHKZG = 'H'.
wa_bsis-WRBTR = 0 - wa_bsis-WRBTR.
ENDIF.
collect-MONAT = wa_bsis-monat.
collect-HKONT = wa_bsis-hkont.
collect-BELNR = wa_bsis-belnr.
collect-BUDAT = wa_bsis-budat.
collect-WRBTR = wa_bsis-wrbtr.
collect-SHKZG = wa_bsis-shkzg.
collect-SGTXT = wa_bsis-sgtxt.
collect-AUFNR = wa_bsis-aufnr.
collect collect into collect.
CLEAR: COLLECT, WA_BSIS.
ENDLOOP.
LOOP AT COLLECT.
AT end of HKONT.
WRITE:/65 'OpeningBalance',
85 collect-tot.
skip 1.
ENDAT.
WRITE:/06 COLLECT-BELNR,
22 COLLECT-BUDAT,
32 COLLECT-WRBTR,
54 COLLECT-SGTXT.
AT end of MONAT.
SUM.
WRITE:/ COLLECT-MONAT COLOR 1.
WRITE:32 COLLECT-WRBTR COLOR 1.
VALUE = COLLECT-WRBTR.
SKIP 1.
ENDAT.
VALUE1 = COLLECT-TOT + VALUE.
AT end of MONAT.
WRITE:85 VALUE1.
ENDAT.
endloop.
CLEAR: COLLECT, SUMA, VALUE, VALUE1.
TOP-OF-PAGE.
WRITE:/06 'Doc No',
22 'Post Date',
39 'Amount',
54 'Text'.
Moderator message : See the Sticky threads (related for performance tuning) in this forum. Thread locked.
Edited by: Vinod Kumar on Oct 13, 2011 11:12 AMHi Ben,
both BSIS selects would become faster if you can add Company Code BUKRS as 1st field of WHERE clause, because it's the 1st field of primary key and HKONT is the 2nd field of primary key.
If you have no table index with HKONT as 1st field it's a full database access.
If possible, try to add BUKRS as 1st field of WHERE clause, otherwise ask for an additional BSIS index at your basis team.
Regards,
Klaus -
Can anyone plz tell me the steps for performance tuning.
hello friends
what is performance tuning?
can anyone plz tell me the steps for performance tuning.Hi Kishore, this will help u.
Following are the different tools provided by SAP for performance analysis of an ABAP object
Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
SQL Trace transaction ST05
The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on the SPFLI table in our test program is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table.
To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.
Need for performance tuning
In this world of SAP programming, ABAP is the universal language. In most of the projects, the focus is on getting a team of ABAP programmers as soon as possible, handing over the technical specifications to them and asking them to churn out the ABAP programs within the given deadlines.
Often due to this pressure of schedules and deliveries, the main focus of making a efficient program takes a back seat. An efficient ABAP program is one which delivers the required output to the user in a finite time as per the complexity of the program, rather than hearing the comment I put the program to run, have my lunch and come back to check the results.
Leaving aside the hyperbole, a performance optimized ABAP program saves the time of the end user, thus increasing the productivity of the user, and in turn keeping the user and the management happy.
This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs efficient in doing their work. This tutorial also assumes that the reader is well versed in all the concepts and syntax of ABAP programming.
Use of selection criteria
Instead of selecting all the data and doing the processing during the selection, it is advisable to restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code.
Not recommended
Select * from zflight.
Check : zflight-airln = LF and zflight-fligh = BW222.
Endselect.
Recommended
Select * from zflight where airln = LF and fligh = 222.
Endselect.
One more point to be noted here is of the select *. Often this is a lazy coding practice. When a programmer gives select * even if one or two fields are to be selected, this can significantly slow the program and put unnecessary load on the entire system. When the application server sends this request to the database server, and the database server has to pass on the entire structure for each row back to the application server. This consumes both CPU and networking resources, especially for large structures.
Thus it is advisable to select only those fields that are needed, so that the database server passes only a small amount of data back.
Also it is advisable to avoid selecting the data fields into local variables as this also puts unnecessary load on the server. Instead attempt must be made to select the fields into an internal table.
Use of aggregate functions
Use the already provided aggregate functions, instead of finding out the minimum/maximum values using ABAP code.
Not recommended
Maxnu = 0.
Select * from zflight where airln = LF and cntry = IN.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endselect.
Recommended
Select max( fligh ) from zflight into maxnu where airln = LF and cntry = IN.
The other aggregate functions that can be used are min (to find the minimum value), avg (to find the average of a Data interval), sum (to add up a data interval) and count (counting the lines in a data selection).
Use of Views instead of base tables
Many times ABAP programmers deal with base tables and nested selects. Instead it is always advisable to see whether there is any view provided by SAP on those base tables, so that the data can be filtered out directly, rather than specially coding for it.
Not recommended
Select * from zcntry where cntry like IN%.
Select single * from zflight where cntry = zcntry-cntry and airln = LF.
Endselect.
Recommended
Select * from zcnfl where cntry like IN% and airln = LF.
Endselect.
Check this links
http://www.sapdevelopment.co.uk/perform/performhome.htm
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/afbad390-0201-0010-daa4-9ef0168d41b6
kindly reward if found helpful.
cheers,
Hema. -
I want to do 1Z0-054 11g Performance Tuning
I want to do 1Z0-054 11g Performance Tuning
for this first needed 1Z0-007 or 1Z0-047 or 1Z0-051, then 1Z0-052 & 1Z0-054
1) Which should be best in 1Z0-007 or 1Z0-047 or 1Z0-051
2) Recommended books... where will get course materials.
Thanks
Harsh857317 wrote:
I want to do 1Z0-054 11g Performance Tuning
for this first needed 1Z0-007 or 1Z0-047 or 1Z0-051, then 1Z0-052 & 1Z0-054
1) Which should be best in 1Z0-007 or 1Z0-047 or 1Z0-051
2) Recommended books... where will get course materials.
Thanks
HarshI always think it is useful to be precise about these things:
You can take the exam +1Z0-054 11g Performance Tuning+ whenever you like. Simply book it, turn up and take it.
In the event you pass you've passed the exam!!! If you don't it is an expensive re-take.
However .....
While you;ve passed the exam you would not be a 'Oracle Database 11g Performance Tuning Certified Expert ' until Oracle confirms to you that certification, and Oracle you have identified all the requriements wht Oracle have detailed here:-
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=287
This indicates one of two additional pre-requisites to the exam pass:-
: Either (1) : A prior DBA 11g Certification.
: Or (2): Verification of your attendance to the Oracle Univerisity Oracle Database 11g: Performance Tuning training course.
Above you have sort of indicated the 11g DBA OCP credential requirements (omitting the mandatory training requirement) ( http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=198)
The journey to 'Oracle Database 11g Performance Tuning Certified Expert ' is a long one, and i suggest most people should look at the basics first. Begin by becoming familiar with http://certification.oracle.com.
If you wish to continue I would consider focusing on 1z0-051 as a first exam or possilby attempting to find suitable workforce development programme training (assuming oracle univerisity is too expensive). Please be aware IMHO Oracle are not responsible for WDP institutes and I suspect some are very bad.
https://workforce.oracle.com/pls/wdp/new_home.main -
Oracle Memory Issue/ performance tuning
I have Oracle 9i running on Window 2003 server. 2 GB memory is allocated to Oralce DB( even though server has 14GB memory)
Recently, the oracle process has been slow.. running query
I ran the window task manager. Here is the numbers that I see
Mem usage: 556660k
page Faults: 1075029451
VM size: 1174544 K
I am not sure how to analyze this data. why the page fault is so huge. and Mem usage is half of VM size?
How can I do the performance tuning on this box?I'm having a similar issue with Oracle 10g R2 64-bit on Windows 2003 x64. Performance on complicated queries is abysmal because [I think] most of the SGA is sitting in a page file, even though there is plenty of physical RAM to be had. Performance on simple queries is probably bad also, but it's not really noticable. Anyway, page faults skyrocket when I hit the "go" button on big queries. Our legacy system runs our test queries in about 5 minutes, but the new system takes at least 30 if not 60. The new system has 24 gigs of RAM, but at this point, I'm only allocating 1 gig to the SGA and 1/2 gig to the PGA. Windows reports oracle.exe has 418,000K in RAM and 1,282,000K in the page file (I rounded a bit). When I had the PGA set to 10 gigs, the page usage jumped to over 8 gigs.
I tried adding ORA_LPENABLE=1 to the registry, but this issue seems to be independent. Interestingly, the amount of RAM taken by oracle.exe goes down a bit (to around 150,000K) when I do this. I also added "everyone" to the security area "lock pages in memory", but again, this is probably unrelated.
I did an OS datafile copy and cloned the database to a 32-bit windows machine (I had to invalidate and recompile all objects to get this to work), and this 32-bit test machine now has the same problem.
Any ideas? -
How to improve the performance of this code
Hi gurus
code is given below with LDB
this code look big but most of lines are commented
plz help its urgent
thanks in advance
*& Report ZSALES_RECON
REPORT ZSALES_RECON.
TYPE-POOLS : SLIS.
nodes: bseg , bkpf.
data : begin of zbseg occurs 0,
kunnr like bseg-kunnr,
*lifnr like bseg-lifnr,
dmbtr like bseg-dmbtr,
*shkzg like bseg-shkzg,
*gsber like bseg-gsber,
bschl like bseg-bschl,
*sgtxt like bseg-sgtxt,
total like bseg-dmbtr,
hkont like bseg-hkont,
BUDAT LIKE Bkpf-BUDAT,
belnr LIKE BSEG-belnr,
cash like bseg-dmbtr,
credit like bseg-dmbtr,
abn_voucher like bseg-dmbtr,
barista_voucher like bseg-dmbtr,
accor like bseg-dmbtr,
sodexho like bseg-dmbtr,
gift like bseg-dmbtr,
corp like bseg-dmbtr,
card like bseg-dmbtr,
miscellaneous like bseg-dmbtr,
werks like bseg-werks,
gjahr like bseg-gjahr,
SR_NO TYPE I,
shkzg like bseg-shkzg,
end of zbseg,
TP_TBL_DATA like ZBSEG.
DATA : idx TYPE sy-tabix.
Report data to be shown.
data: it_data like ZBSEG.
Heading of the report.
data: t_heading type slis_t_listheader.
AT SELECTION-SCREEN.
get bkpf.
START-OF-SELECTION.
data : sum_mis like bseg-dmbtr,
sum_abn like bseg-dmbtr,
sum_cash like bseg-dmbtr,
sum_credit like bseg-dmbtr,
sum_card like bseg-dmbtr,
sum_barista_voucher like bseg-dmbtr,
sum_accor like bseg-dmbtr,
sum_sodexho like bseg-dmbtr,
sum_gift like bseg-dmbtr,
sum_corp like bseg-dmbtr.
data : wa1_total like bseg-dmbtr.
data : wa_belnr like bseg-belnr,
wa_kunnr like bseg-kunnr,
wa_werks like bseg-werks,
belnr1 like bseg-belnr,
wa_sr_no type i.
GET BSEG.
data : wa like line of zbseg.
data : count type i,
count1 type i.
move-corresponding bseg to zbseg.
*idx = sy-tabix.
on change of zbseg-belnr.
wa_kunnr = zbseg-kunnr.
wa_kunnr = wa_kunnr+6(4).
select single werks into wa_werks from bseg where belnr = zbseg-belnr
and kunnr = '' and gjahr = zbseg-gjahr.
if wa_kunnr = wa_werks.
if zbseg-bschl <> '01'.
clear: sum_mis,wa1_total,sum_abn,sum_cash,sum_credit,sum_card,
sum_barista_voucher,sum_accor,sum_sodexho,sum_gift,sum_corp.
wa-BUDAT = BKPF-BUDAT.
wa-bschl = zbseg-bschl.
wa-hkont = zbseg-hkont.
wa-belnr = zbseg-belnr.
wa_belnr = wa-belnr.
wa-shkzg = zbseg-shkzg.
wa-kunnr = zbseg-kunnr.
count = wa-sr_no.
*wa-sr_no = count + 1.
idx = idx + 1.
append wa to zbseg.
**count = wa-sr_no.
*wa-sr_no = wa-sr_no + 1.
clear wa-total.
endif.
endif.
endon.
*clear : wa1_total.
if wa_belnr = zbseg-belnr.
loop at zbseg into wa.
wa-total = wa1_total.
wa-bschl = zbseg-bschl.
wa-hkont = zbseg-hkont.
count = sy-tabix.
wa-sr_no = count.
count1 = count.
*wa_sr_no = count.
modify zbseg from wa transporting sr_no.
IF wa-bschl eq '40' and wa-hkont eq '0024013020'.
if sy-tabix = 1.
wa-cash = zbseg-dmbtr.
sum_cash = sum_cash + wa-cash.
wa-cash = sum_cash.
modify zbseg index idx from wa transporting cash.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060010'.
if sy-tabix = 1.
wa-credit = zbseg-dmbtr.
sum_credit = sum_credit + wa-credit.
wa-credit = sum_credit.
modify zbseg index idx from wa transporting credit.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060015'.
if sy-tabix = 1.
wa-abn_voucher = zbseg-dmbtr.
sum_abn = sum_abn + wa-abn_voucher.
wa-abn_voucher = sum_abn.
modify zbseg index idx from wa transporting abn_voucher.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060017'.
if sy-tabix = 1.
wa-barista_voucher = zbseg-dmbtr.
sum_barista_voucher = sum_barista_voucher + wa-barista_voucher.
wa-barista_voucher = sum_barista_voucher.
modify zbseg index idx from wa transporting barista_voucher.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060020'.
if sy-tabix = 1.
wa-sodexho = zbseg-dmbtr.
sum_sodexho = sum_sodexho + wa-sodexho.
wa-sodexho = sum_sodexho.
modify zbseg index idx from wa transporting sodexho.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026060030'.
if sy-tabix = 1.
wa-accor = zbseg-dmbtr.
sum_accor = sum_accor + wa-accor.
wa-accor = sum_accor.
modify zbseg index idx from wa transporting accor.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026070040'.
if sy-tabix = 1.
wa-gift = zbseg-dmbtr.
sum_gift = sum_gift + wa-gift.
wa-gift = sum_gift.
modify zbseg index idx from wa transporting gift.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026060070'.
if sy-tabix = 1.
wa-card = zbseg-dmbtr.
sum_card = sum_card + wa-card.
wa-card = sum_card.
modify zbseg index idx from wa transporting card.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026060018'.
if sy-tabix = 1.
wa-corp = zbseg-dmbtr.
sum_corp = sum_corp + wa-corp.
wa-corp = sum_corp.
modify zbseg index idx from wa transporting corp.
endif.
endif.
*IF wa-bschl eq '11' .
*wa-total = zbseg-dmbtr.
*modify zbseg index idx from wa transporting total.
*endif.
IF wa-bschl EQ '40' or wa-bschl = '01' .
if sy-tabix = 1.
wa-total = zbseg-dmbtr.
wa1_total = wa1_total + wa-total.
wa-total = wa1_total.
*if idx = 2.
*modify zbseg index 1 from wa transporting total.
*else.
modify zbseg index idx from wa transporting total.
*endif.
endif.
endif.
*IF zbseg-TOTAL NE zbseg-DMBTR.
IF wa-BSCHL NE '11' AND wa-BSCHL NE '40'. "AND wa-BSCHL NE '01'.
if sy-tabix = 1.
if wa-shkzg = 'S'.
wa-miscellaneous = - wa-miscellaneous.
endif.
wa-miscellaneous = ZBSEG-DMBTR.
sum_mis = sum_mis + wa-miscellaneous.
wa-miscellaneous = sum_mis.
modify zbseg index idx from wa transporting miscellaneous.
endif.
ENDIF.
*wa1-miscellaneous = wa-miscellaneous.
*modify zbseg index idx from wa.
*ENDIF.
*append wa to zbseg.
*clear:zbseg-dmbtr.
endloop.
endif.
*****endif.
*****endon.
*ENDFORM.
*append zbseg.
*endloop.
End-of-selection.
perform build_alv using zbseg t_heading.
*& Form build_alv
Builds and display the ALV Grid.
form build_alv using t_data
*tp_tbl_data
t_heading type slis_t_listheader.
ALV required data objects.
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_sort type slis_t_sortinfo_alv.
refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.
Field Catalog
perform set_fieldcat2 using:
1 'SR_NO' 'SR_NO' 'BKPF' '5' space space 'SR NO' space space space
space space space space space t_fieldcat ,
2 'BELNR' 'BELNR' 'BKPF' '10' space space 'Document No' space space
space space space space space space t_fieldcat ,
3 'BUDAT' 'BUDAT' 'BKPF' '10' space space 'Document Date' space
space space space space space space space t_fieldcat ,
4 'KUNNR' space space space space space 'Site' space space
space space space space space space t_fieldcat ,
5 'TOTAL' space 'BSEG' space space space 'Total' space space space
space space space space 'X' t_fieldcat ,
6 'CASH' 'CASH' 'BSEG' space space space 'Cash Sales'
space space space space space space space 'X' t_fieldcat ,
7 'CREDIT' 'CREDIT' 'BSEG' space space space 'Credit Card'
space space space space space space space 'X' t_fieldcat ,
8 'ABN_VOUCHER' space 'BSEG' space space space 'ABN Voucher' space
space
space space space space space 'X' t_fieldcat ,
9 'BARISTA_VOUCHER' space 'BSEG' '15' space space 'BARISTA Voucher'
space space
space space space space space 'X' t_fieldcat ,
10 'CORP' 'CORP' 'BSEG' space space space 'ABN Corp' space space
space space space space space 'X' t_fieldcat ,
11 'SODEXHO' 'SODEXHO' 'BSEG' space space space 'Sodexho' space
space space space space space space 'X' t_fieldcat ,
12 'ACCOR' 'ACCOR' 'BSEG' space space space 'Accor'
space space space space space space space 'X' t_fieldcat ,
13 'GIFT' 'GIFT' 'BSEG' space space space 'Gift Coupon'
space space space space space space space 'X' t_fieldcat ,
14 'CARD' 'CARD' 'BSEG' space space space 'Diners Card' space
space space space space space space 'X' t_fieldcat ,
15 'MISCELLANEOUS' space 'BKPF' '18' space space
'Miscellaneous Income' space space space space space space space 'X'
t_fieldcat .
*14 'KBETR' 'KBETR' 'KONP' '10' space space 'Tax %age' space space
*space space space space space space t_fieldcat ,
*15 'MWSKZ1' 'MWSKZ1' 'RBKP' space space space 'Tax Type' space
*space
space space space space space space t_fieldcat ,
*16 'AMT' 'AMT' 'RBKP' space space space 'Amount Payable' space
*space
space space space space space 'X' t_fieldcat ,
*17 'WERKS' 'SITE' 'RSEG' space space space 'State' space space
*space space space space space space t_fieldcat .
*18 'GSBER' 'GSBER' 'RBKP' space space space 'Business Area' space
*space space space space space space space t_fieldcat .
Layout
x_layout-zebra = 'X'.
Top of page heading
perform set_top_page_heading using t_heading t_event.
Events
perform set_events using t_event.
GUI Status
w_status = ''.
w_repid = sy-repid.
Title
w_title = <<If you want to set a title for
the ALV, please, uncomment and edit this line>>.
User commands
w_comm = 'USER_COMMAND'.
Order
Example
PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
Displays the ALV grid
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = zbseg
t_data
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " build_alv.
*& Form set_top_page_heading
Creates the report headings.
form set_top_page_heading using t_heading type slis_t_listheader
t_events type slis_t_event.
data: x_heading type slis_listheader,
x_event type line of slis_t_event.
Report title
clear t_heading[].
clear x_heading.
x_heading-typ = 'H'.
x_heading-info = 'SALES RECONCILIATION REPORT'(001).
append x_heading to t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-form = 'TOP_OF_PAGE'.
append x_event to t_events.
endform.
*& Form set_events
Sets the events for ALV.
The TOP_OF_PAGE event is alredy being registered in
the set_top_page_heading subroutine.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
Example
clear x_event.
x_event-name = .
x_event-form = .
append x_event to t_event.
endform.
*& Form set_order
Adds an entry to the order table.
FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
t_sort TYPE slis_t_sortinfo_alv.
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = p_fieldname.
x_sort-tabname = p_tabname.
x_sort-up = p_up.
x_sort-down = p_down.
x_sort-subtot = p_subtot.
APPEND x_sort TO t_sort.
ENDFORM. "set_order
*& Form set_fieldcat2
Adds an entry to the field catalog.
p_colpos: Column position.
p_fieldname: Field of internal table which is being described by
* this record of the field catalog.
p_ref_fieldname: (Optional) Table field / data element which
* describes the properties of the field.
* If this field is not given, it is copied from
* the fieldname.
p_ref_tabname: (Optional) Table which holds the field referenced
* by <<p_ref_fieldname>>.
If this is not given, the parameter
<<p_ref_fieldname>> references a data element.
p_outputlen: (Optional) Column width.
p_noout: (Optional) If set to 'X', states that the field is not
* showed initially. If so, the field has to be
included in the report at runtime using the display
options.
p_seltext_m: (Optional) Medium label to be used as column header.
p_seltext_l: (Optional) Long label to be used as column header.
p_seltext_s: (Optional) Small label to be used as column header.
p_reptext_ddic: (Optional) Extra small (heading) label to be
* used as column header.
p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
or REPTEXT_DDIC as text for column header.
p_hotspot: (Optional) If set to 'X', this field will be used
* as a hotspot area for cursor, alolowing the user
* to click on the field.
p_showasicon: (Optional) If set to 'X', this field will be shown
as an icon and the contents of the field will set
* which icon to show.
p_checkbox: (Optional) If set to 'X', this field will be shown
as a checkbox.
p_edit: (Optional) If set to 'X', this field will be editable.
p_dosum: (Optional) If set to 'X', this field will be summed
(aggregation function) according to the grouping set
by the order functions.
t_fieldcat: Table which contains the whole fieldcat.
FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
t_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set reference fieldname, tablenam and rollname.
If p_ref_tabname is not given, the ref_fieldname given
is a data element.
If p_ref_tabname is given, the ref_fieldname given is a
field of a table.
In case ref_fieldname is not given,
it is copied from the fieldname.
IF p_ref_tabname IS INITIAL.
wa_fieldcat-rollname = p_ref_fieldname.
ELSE.
wa_fieldcat-ref_tabname = p_ref_tabname.
IF p_ref_fieldname EQ space.
wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.
ELSE.
wa_fieldcat-ref_fieldname = p_ref_fieldname.
ENDIF.
ENDIF.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
Set as editable or not.
IF NOT p_edit IS INITIAL.
wa_fieldcat-input = 'X'.
wa_fieldcat-edit = 'X'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
======================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = <<If you want to set a logo, please,
uncomment and edit this line>>
it_list_commentary = t_heading.
endform. " alv_top_of_page
*& Form user_command
Called on user_command ALV event.
Executes custom commands.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
Example Code
Executes a command considering the sy-ucomm.
CASE r_ucomm.
WHEN '&IC1'.
Set your "double click action" response here.
Example code: Create and display a status message.
DATA: w_msg TYPE string,
w_row(4) TYPE n.
w_row = rs_selfield-tabindex.
CONCATENATE 'You have clicked row' w_row
'field' rs_selfield-fieldname
'with value' rs_selfield-value
INTO w_msg SEPARATED BY space.
MESSAGE w_msg TYPE 'S'.
ENDCASE.
End of example code.
endform. "user_command
*********************************ldb code start from here *************************************************************
DATABASE PROGRAM OF LOGICAL DATABASE ZBRM_3
top-include and nxxx-include are generated automatically
Do NOT change their names manually!!!
*include DBZBRM_3TOP . " header
*include DBZBRM_3NXXX . " all system routines
include DBZBRM_3F001 . " user defined include
PROGRAM SAPDBZBRM_3 DEFINING DATABASE ZBRM_3.
TABLES:
BKPF,
BSEG.
Hilfsfelder
DATA:
BR_SBUKRS LIKE BKPF-BUKRS,
BR_SBELNR LIKE BKPF-BELNR,
BR_SGJAHR LIKE BKPF-GJAHR,
BR_SBUDAT LIKE BKPF-BUDAT,
BR_SGSBER LIKE BSEG-GSBER.
BR_SBUZEI LIKE BSEG-BUZEI,
BR_SEBELN LIKE BSEG-EBELN,
BR_SEBELP LIKE BSEG-EBELP,
BR_SZEKKN LIKE BSEG-ZEKKN.
working areas for the authority check "n435991
for the company code "n435991
*TYPES : BEGIN OF STYPE_BUKRS, "n435991
BUKRS LIKE T001-BUKRS, "n435991
WAERS LIKE T001-WAERS, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_BUKRS. "n435991
"n435991
*DATA : G_S_BUKRS TYPE STYPE_BUKRS, "n435991
G_T_BUKRS TYPE STYPE_BUKRS OCCURS 0. "n435991
"n435991
for the document type "n435991
*TYPES : BEGIN OF STYPE_BLART, "n435991
BLART LIKE BKPF-BLART, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_BLART. "n435991
"n435991
*DATA : G_S_BLART TYPE STYPE_BLART, "n435991
G_T_BLART TYPE STYPE_BLART OCCURS 0. "n435991
"n435991
for the business area "n435991
*TYPES : BEGIN OF STYPE_GSBER, "n435991
GSBER LIKE BSEG-GSBER, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_GSBER. "n435991
"n435991
*DATA : G_S_GSBER TYPE STYPE_GSBER, "n435991
G_T_GSBER TYPE STYPE_GSBER OCCURS 0. "n435991
"n435991
for the purchasing organization "n435991
*TYPES : BEGIN OF STYPE_EKORG, "n435991
EKORG LIKE EKKO-EKORG, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_EKORG. "n435991
"n435991
*DATA : G_S_EKORG TYPE STYPE_EKORG, "n435991
G_T_EKORG TYPE STYPE_EKORG OCCURS 0. "n435991
"n435991
for the plant "n435991
*TYPES : BEGIN OF STYPE_WERKS, "n435991
WERKS LIKE EKPO-WERKS, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_WERKS. "n435991
"n435991
*DATA : G_S_WERKS TYPE STYPE_WERKS, "n435991
G_T_WERKS TYPE STYPE_WERKS OCCURS 0. "n435991
"n435991
*DATA : G_F_TABIX LIKE SY-TABIX. "n435991
"n435991
working tables for array database access "n934526
*types : begin of stype_key, "n934526
bukrs type bkpf-bukrs, "n934526
belnr type bkpf-belnr, "n934526
gjahr type bkpf-gjahr, "n934526
end of stype_key, "n934526
"n934526
stab_key type standard table of "n934526
stype_key "n934526
with default key. "n934526
Initialwerte setzen
FORM INIT.
ENDFORM.
Selection Screen: Process before output
FORM PBO.
ENDFORM.
Selection Screen: Process after input
FORM PAI USING FNAME MARK.
CHECK MARK = SPACE.
ENDFORM.
Lesen BKPF und Uebergabe an den Selektionsreport
FORM PUT_BKPF.
define locla working areas "n934526
data : l_t_key type stab_key, "n934526
l_t_key_block type stab_key, "n934526
l_t_bkpf type standard table of bkpf. "n934526
"n934526
----------------------------------------------------------"n934526
"n934526
database seletion improved "n934526
at first read all FI doc keys into a lean table "n934526
data: wa like bkpf-belnr.
SELECT * FROM BKPF
where budat in br_budat
AND GJAHR EQ BR_GJAHR-LOW
AND BLART = 'RV'.
AND BLART IN BR_BLAR "n934526
"n934526
check sy-subrc is initial. "n934526
"n934526
then process the found FI doc keys in small blocks "n934526
do. "n934526
if l_t_key[] is initial. "n934526
exit. " no more keys -> leave this DO loop "n934526
endif. "n934526
"n934526
form small blocks with 100 FI docs each "n934526
refresh l_t_key_block. "n934526
append lines of l_t_key from 1 to 100 "n934526
to l_t_key_block. "n934526
delete l_t_key from 1 to 100. "n934526
"n934526
read the complete FI doc headers for the block "n934526
SELECT * FROM BKPF "n934526
into corresponding fields of table l_t_bkpf "n934526
for all entries in l_t_key_block "n934526
WHERE BUKRS = l_t_key_block-BUKRS "n934526
AND BELNR = l_t_key_block-BELNR "n934526
AND GJAHR = l_t_key_block-GJAHR. "n934526
"n934526
provide the complete structure for the PUT "n934526
loop at l_t_bkpf into bkpf. "n934526
process this company code : authority and read T001 "n934526
PERFORM F1000_COMPANY_CODE. "n934526
"n934526
go on if the first authority check was successful "n934526
CHECK : G_S_BUKRS-RETCODE IS INITIAL. "n934526
"n934526
set the currency key and save the keys "n934526
MOVE : G_S_BUKRS-WAERS TO T001-WAERS, "n934526
BKPF-BUKRS TO BR_SBUKRS, "n934526
MOVE BKPF-BELNR TO BR_SBELNR.
MOVE BKPF-GJAHR TO BR_SGJAHR . "n934526
BKPF-GJAHR TO BR_SGJAHR. "n934526
PUT BKPF. "n934526
endloop. "n934526
enddo. "n934526
ENDSELECT.
ENDFORM.
Lesen BSEG und Uebergabe an den Selektionsreport
FORM PUT_BSEG.
define local working areas "n934526
data : l_t_bseg type standard table of bseg. "n934526
"n934526
----------------------------------------------------------"n934526
BR_SGSBER = BR_GSBER-LOW.
"n934526
SELECT * FROM BSEG "n934526
WHERE BELNR EQ BR_SBELNR
AND GJAHR EQ BR_SGJAHR
AND GSBER EQ BR_SGSBER.
check sy-subrc is initial. "n934526
"n934526
loop at l_t_bseg into bseg. "n934526
MOVE BSEG-BUZEI TO BR_SBUZEI.
MOVE BSEG-EBELN TO BR_SEBELN.
MOVE BSEG-EBELP TO BR_SEBELP.
MOVE BSEG-ZEKKN TO BR_SZEKKN.
PUT BSEG.
endSELECT. "n934526
ENDFORM.
"n435991
FORM AUTHORITYCHECK_BKPF "n435991
"n435991
"n435991
*FORM AUTHORITYCHECK_BKPF. "n435991
"n435991
the authority-check for the company code was successful; "n435991
check authority for the document type here "n435991
"n435991
does the buffer contain this document type ? "n435991
READ TABLE G_T_BLART INTO G_S_BLART "n435991
WITH KEY BLART = BKPF-BLART BINARY SEARCH. "n435991
"n435991
CASE SY-SUBRC. "n435991
WHEN 0. "document type is known "n435991
"n435991
WHEN 4. "docment type is new --> insert "n435991
MOVE SY-TABIX TO G_F_TABIX. "n435991
PERFORM F1200_CREATE_BLART_ENTRY. "n435991
INSERT G_S_BLART INTO G_T_BLART "n435991
INDEX G_F_TABIX. "n435991
"n435991
WHEN 8. "document type is new --> append "n435991
PERFORM F1200_CREATE_BLART_ENTRY. "n435991
APPEND G_S_BLART TO G_T_BLART. "n435991
ENDCASE. "n435991
"n435991
set the return code "n435991
MOVE G_S_BLART-RETCODE TO SY-SUBRC. "n435991
"n435991
*ENDFORM. "authoritycheck_bkpf "n435991
"n435991
"n435991
FORM AUTHORITYCHECK_BSEG "n435991
"n435991
"n435991
*FORM AUTHORITYCHECK_BSEG. "n435991
"n435991
does the buffer contain this document type ? "n435991
READ TABLE G_T_GSBER INTO G_S_GSBER "n435991
WITH KEY GSBER = BSEG-GSBER BINARY SEARCH. "n435991
"n435991
CASE SY-SUBRC. "n435991
WHEN 0. "business area is known "n435991
"n435991
WHEN 4. "business area is new --> insert "n435991
MOVE SY-TABIX TO G_F_TABIX. "n435991
PERFORM F1300_CREATE_GSBER_ENTRY. "n435991
INSERT G_S_GSBER INTO G_T_GSBER "n435991
INDEX G_F_TABIX. "n435991
"n435991
WHEN 8. "business area is new --> append "n435991
PERFORM F1300_CREATE_GSBER_ENTRY. "n435991
APPEND G_S_GSBER TO G_T_GSBER. "n435991
ENDCASE. "n435991
"n435991
set the return code "n435991
MOVE G_S_GSBER-RETCODE TO SY-SUBRC. "n435991
"n435991
*ENDFORM. "authoritycheck_bseg "n435991
"n435991ABAP provides few tools to analyse the perfomance of the objects, which was developed by us.
Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
SQL Trace transaction ST05
by using this tool we can analyse the perfomance issues related to DATABASE calls.
Perfomance Techniques for improve the perfomance of the object.
1) ABAP/4 programs can take a very long time to execute, and can make other processes have to wait before executing. Here are some tips to speed up your programs and reduce the load your programs put on the system:
2) Use the GET RUN TIME command to help evaluate performance. It's hard to know whether that optimization technique REALLY helps unless you test it out.
3) Using this tool can help you know what is effective, under what kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small pieces of your program, rather than the whole program.
4) Generally, try to reduce I/O first, then memory, then CPU activity. I/O operations that read/write to hard disk are always the most expensive operations. Memory, if not controlled, may have to be written to swap space on the hard disk, which therefore increases your I/O read/writes to disk. CPU activity can be reduced by careful program design, and by using commands such as SUM (SQL) and COLLECT (ABAP/4).
5) Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are only read if they are used. This can make a very big difference.
6) Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the system's paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the systems administrator to decide the maximum amount of RAM your program should use, and from that, calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap space.
Use as many table keys as possible in the WHERE part of your select statements.
7)Whenever possible, design the program to access a relatively constant number of records (for instance, if you only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
8) Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 -> Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go To Utilities -> Table Contents to query the table contents and see the number of records. This is extremely useful in optimizing a program's memory allocation.
9) Try to make the user interface such that the program gradually unfolds more information to the user, rather than giving a huge list of information all at once to the user.
10) Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
11) Use SELECT A B C INTO TABLE ITAB whenever possible. This will read all of the records into the itab in one operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement. Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to access.
12) If the number of records you are reading is constantly growing, you may be able to break it into chunks of relatively constant size. For instance, if you have to read all records from 1991 to present, you can break it into quarters, and read all records one quarter at a time. This will reduce I/O operations. Test extensively with GET RUN TIME when using this method.
13) Know how to use the 'collect' command. It can be very efficient.
14) Use the SELECT SINGLE command whenever possible.
15) Many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by calculating a total that has already been calculated and stored.
Some tips:
1) Use joins where possible as redundant data is not fetched.
2) Use select single where ever possible.
3) Calling methods of a global class is faster than calling function modules.
4) Use constants instead of literals
5) Use WHILE instead of a DO-EXIT-ENDDO.
6) Unnecessary MOVEs should be avoided by using the explicit work area operations
see the follwing links for a brief insifght into performance tuning,
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_Introduction.asp
1. Debuggerhttp://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
2. Run Time Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
3. SQL trace
http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
4. CATT - Computer Aided Testing Too
http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
5. Test Workbench
http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
6. Coverage Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
7. Runtime Monitor
http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
8. Memory Inspector
http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
9. ECATT - Extended Computer Aided testing tool.
http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
Performance tuning for Data Selection Statement
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm -
Performance tuning in PL/SQL code
Hi,
I am working on already existing PL/SQL code which is written by someone else on validation and conversion of data from a temporary table to base table. It usually has 3.5 million rows. and the procedure takes arount 2.5 - 3 hrs to complete.
Can I enhance the PL/SQL code for better performance ? or, is this OK to take so long to process these many rows?
Thanks!
YoginiCan I enhance the PL/SQL code for better performance ? Probably you can enhance it.
or, is this OK to take so long to process these many rows? It should take a few minutes, not several hours.
But please provide some more details like your database version etc.
I suggest to TRACE the session that executes the PL/SQL code, with WAIT events, so you'll see where and on what time is spent, you'll identify your 'problem statements very quickly' (after you or your DBA have TKPROF'ed the trace file).
SQL> alter session set events '10046 trace name context forever, level 12';
SQL> execute your PL/SQL code here
SQL> exitWill give you a .trc file in your udump directory on the server.
http://www.oracle-base.com/articles/10g/SQLTrace10046TrcsessAndTkprof10g.php
Also this informative thread can give you more ideas:
HOW TO: Post a SQL statement tuning request - template posting
as well as doing a search on 10046 at AskTom, http://asktom.oracle.com will give you more examples.
and reading Oracle's Performance Tuning Guide: http://www.oracle.com/pls/db102/to_toc?pathname=server.102%2Fb14211%2Ftoc.htm&remark=portal+%28Getting+Started%29 -
Performance tuning of a customised Transaction Code which for interface
Hii All ,
I am new to performance tuning please guide me How to do performance tuning of Custom T-code through I am aware of all T-codes for performance tuning.
Please guide hoe to do it and what are basic need to before to start Performance tuning ?
Thanks
ABAP Pro
Moderator message: Please Read before Posting in the Performance and Tuning Forum
Locked by: Thomas Zloch on Jun 7, 2011 9:37 AMI recommend :
1. use SQL tracing with DBMS_MONITOR and then TKPROF on raw SQL trace file
2. call the function as it used in your production environment
See good examples in http://www.oracle-base.com/articles/10g/SQLTrace10046TrcsessAndTkprof10g.php (just refer to DBMS_MONITOR examples and TKPROF).
Note that SQL trace will only trace SQL and not PL/SQL. If SQL elapsed time does not match function call elapsed time close enough, you need to use DBMS_PROFILER to know where PL/SQL non SQL code elapsed time is used.
I don't recommend using EXPLAIN PLAN because it has known limitations http://docs.oracle.com/cd/E11882_01/server.112/e16638/ex_plan.htm#PFGRF94673 (others have said "EXPLAIN PLAN lies" - you can google for this expression ....).
Edited by: P. Forstmann on 10 févr. 2012 19:44 -
Hello
Need to tune this code.Its taking too much time.
REFRESH: T_BVOR.
IF NOT I_TEM[] IS INITIAL.
SELECT BVORG BUKRS GJAHR BELNR INTO
CORRESPONDING FIELDS OF
TABLE T_BVOR
FROM BVOR
FOR ALL ENTRIES IN I_TEM
WHERE BVORG = I_TEM-BVORG
AND GJAHR = I_TEM-GJAHR.
ENDIF.
IF SY-SUBRC EQ 0.
SORT T_BVOR BY BVORG GJAHR.
ENDIF.
CLEAR: WA_BVOR.
SORT I_TEM BY BVORG GJAHR.
LOOP AT T_BVOR INTO WA_BVOR.
CLEAR: I_TEM.
READ TABLE I_TEM WITH KEY BVORG = WA_BVOR-BVORG
GJAHR = WA_BVOR-GJAHR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE I_TEM-BLART TO WA_BVOR-BLART.
ENDIF.
MODIFY T_BVOR FROM WA_BVOR TRANSPORTING BLART.
ENDLOOP.
SORT T_BVOR BY BUKRS BELNR GJAHR.
IF NOT T_BVOR[] IS INITIAL.
LOOP AT I_BVOR.
REFRESH: GT_BSEG.
SELECT BUKRS
BELNR GJAHR BSCHL KOSTL HKONT
EBELN PRCTR ZZINFO3 TXGRP
FROM BSEG
INTO CORRESPONDING FIELDS
OF TABLE GT_BSEG
FOR ALL ENTRIES IN T_BVOR
WHERE BUKRS = T_BVOR-BUKRS
AND BELNR = T_BVOR-BELNR
AND GJAHR = T_BVOR-GJAHR
AND NOT HKONT IN RANGE_HKONT.
ENDIF.
SORT GT_BSEG BY BUKRS BELNR GJAHR.
DELETE ADJACENT DUPLICATES FROM GT_BSEG
COMPARING BUKRS BELNR GJAHR.
CLEAR: WA_BSEG.
LOOP AT GT_BSEG INTO WA_BSEG.
CLEAR: WA_BVOR.
READ TABLE T_BVOR INTO WA_BVOR WITH KEY
BUKRS = WA_BSEG-BUKRS
BELNR = WA_BSEG-BELNR
GJAHR = WA_BSEG-GJAHR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE WA_BVOR-BLART TO WA_BSEG-BLART.
MOVE WA_BVOR-BVORG TO WA_BSEG-BVORG.
ENDIF.
MODIFY GT_BSEG FROM WA_BSEG TRANSPORTING BLART BVORG.
ENDLOOP.
REFRESH: GT_BSEG1,GT_BSEG2.
SORT T_DOCS BY BSCHL BLART.
SORT GT_BSEG BY BVORG.
CLEAR: WA_BSEG.
LOOP AT GT_BSEG INTO WA_BSEG.
CLEAR: T_DOCS.
LOOP AT T_DOCS WHERE BSCHL = WA_BSEG-BSCHL
AND BLART = WA_BSEG-BLART.
IF T_DOCS-BSCHL = '40' OR T_DOCS-BSCHL = '50'
OR T_DOCS-BSCHL = '81' OR T_DOCS-BSCHL = '91'.
MOVE-CORRESPONDING WA_BSEG TO WA_BSEG1.
APPEND WA_BSEG1 TO GT_BSEG1.
CLEAR: WA_BSEG1.
ENDIF.
IF T_DOCS-BSCHL = '31' OR T_DOCS-BSCHL = '32'
OR T_DOCS-BSCHL = '21' OR T_DOCS-BSCHL = '22'
OR ( T_DOCS-ZDATATYP = 'TAXRPT02' AND
( T_DOCS-BSCHL = '40' OR T_DOCS-BSCHL = '50' ) ).
MOVE-CORRESPONDING WA_BSEG TO WA_BSEG1.
APPEND WA_BSEG2 TO GT_BSEG2.
CLEAR: WA_BSEG2.
ENDIF.
ENDLOOP.
ENDLOOP.
SORT GT_BSEG1 BY TXGRP.
SORT GT_BSEG2 BY BUKRS BELNR GJAHR.
LOOP AT i_bseg.
CLEAR: WA_BSEG2.
LOOP AT GT_BSEG2 INTO WA_BSEG2.
CLEAR : GT_ALV_ITEM.
LOOP AT GT_ALV_ITEM WHERE
BUKRS = WA_BSEG2-BUKRS AND
BELNR = WA_BSEG2-BELNR AND
GJAHR = WA_BSEG2-GJAHR.
CLEAR: WA_BSEG1.
LOOP AT GT_BSEG1 INTO WA_BSEG1
WHERE GJAHR = GT_ALV_ITEM-GJAHR AND
TXGRP = GT_ALV_ITEM-TXGRP AND
BVORG = WA_BSEG2-BVORG.
MOVE: WA_BSEG1-BUKRS TO GT_ALV_ITEM-BUKRS,
WA_BSEG1-EBELN TO GT_ALV_ITEM-EBELN,
WA_BSEG1-HKONT TO GT_ALV_ITEM-HKONT,
WA_BSEG1-BELNR TO GT_ALV_ITEM-BELNR,
WA_BSEG1-KOSTL TO GT_ALV_ITEM-KOSTL,
WA_BSEG1-PRCTR TO GT_ALV_ITEM-PRCTR,
WA_BSEG1-ZZINFO3 TO GT_ALV_ITEM-ZZINFO3." M003a
CLEAR: WA_BSEG1.
ENDLOOP.
MODIFY GT_ALV_ITEM INDEX SY-TABIX.
IF gt_alv_item-txjlv = 6.EXIT.ENDIF.
ENDIF.
ENDLOOP.
CLEAR: WA_BSEG2.
ENDLOOP.
Thanks
SunilWays of Performance Tuning
1. Selection Criteria
2. Select Statements
Select Queries
SQL Interface
Aggregate Functions
For all Entries
Select Over more than one internal table
Selection Criteria
1. Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement.
2. Select with selection list.
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list
SELECT CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
WHERE SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
Select Statements Select Queries
1. Avoid nested selects
SELECT * FROM EKKO INTO EKKO_WA.
SELECT * FROM EKAN INTO EKAN_WA
WHERE EBELN = EKKO_WA-EBELN.
ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
FROM EKKO AS P INNER JOIN EKAN AS F
ON PEBELN = FEBELN.
Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.
2. Select all the records in a single shot using into table clause of select statement rather than to use Append statements.
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table
SELECT CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
WHERE SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
3. When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index.
To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.
4. For testing existence, use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit.
SELECT * FROM SBOOK INTO SBOOK_WA
UP TO 1 ROWS
WHERE CARRID = 'LH'.
ENDSELECT.
The above code is more optimized as compared to the code mentioned below for testing existence of a record.
SELECT * FROM SBOOK INTO SBOOK_WA
WHERE CARRID = 'LH'.
EXIT.
ENDSELECT.
5. Use Select Single if all primary key fields are supplied in the Where condition .
If all primary key fields are supplied in the Where conditions you can even use Select Single.
Select Single requires one communication with the database system, whereas Select-Endselect needs two.
Select Statements SQL Interface
1. Use column updates instead of single-row updates
to update your database tables.
SELECT * FROM SFLIGHT INTO SFLIGHT_WA.
SFLIGHT_WA-SEATSOCC =
SFLIGHT_WA-SEATSOCC - 1.
UPDATE SFLIGHT FROM SFLIGHT_WA.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
UPDATE SFLIGHT
SET SEATSOCC = SEATSOCC - 1.
2. For all frequently used Select statements, try to use an index.
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
WHERE CARRID = 'LH'
AND CONNID = '0400'.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
WHERE MANDT IN ( SELECT MANDT FROM T000 )
AND CARRID = 'LH'
AND CONNID = '0400'.
ENDSELECT.
3. Using buffered tables improves the performance considerably.
Bypassing the buffer increases the network considerably
SELECT SINGLE * FROM T100 INTO T100_WA
BYPASSING BUFFER
WHERE SPRSL = 'D'
AND ARBGB = '00'
AND MSGNR = '999'.
The above mentioned code can be more optimized by using the following code
SELECT SINGLE * FROM T100 INTO T100_WA
WHERE SPRSL = 'D'
AND ARBGB = '00'
AND MSGNR = '999'.
Select Statements Aggregate Functions
If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself.
Some of the Aggregate functions allowed in SAP are MAX, MIN, AVG, SUM, COUNT, COUNT( * )
Consider the following extract.
Maxno = 0.
Select * from zflight where airln = LF and cntry = IN.
Check zflight-fligh > maxno.
Maxno = zflight-fligh.
Endselect.
The above mentioned code can be much more optimized by using the following code.
Select max( fligh ) from zflight into maxno where airln = LF and cntry = IN.
Select Statements For All Entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Points to be must considered FOR ALL ENTRIES
Check that data is present in the driver table
Sorting the driver table
Removing duplicates from the driver table
Consider the following piece of extract
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
The above mentioned can be more optimized by using the following code.
Sort int_cntry by cntry.
Delete adjacent duplicates from int_cntry.
If NOT int_cntry[] is INITIAL.
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
Endif.
Select Statements Select Over more than one Internal table
1. Its better to use a views instead of nested Select statements.
SELECT * FROM DD01L INTO DD01L_WA
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
SELECT SINGLE * FROM DD01T INTO DD01T_WA
WHERE DOMNAME = DD01L_WA-DOMNAME
AND AS4LOCAL = 'A'
AND AS4VERS = DD01L_WA-AS4VERS
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
The above code can be more optimized by extracting all the data from view DD01V_WA
SELECT * FROM DD01V INTO DD01V_WA
WHERE DOMNAME LIKE 'CHAR%'
AND DDLANGUAGE = SY-LANGU.
ENDSELECT
2. To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.
SELECT * FROM EKKO INTO EKKO_WA.
SELECT * FROM EKAN INTO EKAN_WA
WHERE EBELN = EKKO_WA-EBELN.
ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
FROM EKKO AS P INNER JOIN EKAN AS F
ON PEBELN = FEBELN.
3. Instead of using nested Select loops it is often better to use subqueries.
SELECT * FROM SPFLI
INTO TABLE T_SPFLI
WHERE CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK'.
SELECT * FROM SFLIGHT AS F
INTO SFLIGHT_WA
FOR ALL ENTRIES IN T_SPFLI
WHERE SEATSOCC < F~SEATSMAX
AND CARRID = T_SPFLI-CARRID
AND CONNID = T_SPFLI-CONNID
AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
The above mentioned code can be even more optimized by using subqueries instead of for all entries.
SELECT * FROM SFLIGHT AS F INTO SFLIGHT_WA
WHERE SEATSOCC < F~SEATSMAX
AND EXISTS ( SELECT * FROM SPFLI
WHERE CARRID = F~CARRID
AND CONNID = F~CONNID
AND CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK' )
AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
1. Table operations should be done using explicit work areas rather than via header lines.
READ TABLE ITAB INTO WA WITH KEY K = 'X BINARY SEARCH.
IS MUCH FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY K = 'X'.
If TAB has n entries, linear search runs in O( n ) time, whereas binary search takes only O( log2( n ) ).
2. Always try to use binary search instead of linear search. But dont forget to sort your internal table before that.
READ TABLE ITAB INTO WA WITH KEY K = 'X'. IS FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY (NAME) = 'X'.
3. A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime.
4. A binary search using secondary index takes considerably less time.
5. LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified condition internally.
LOOP AT ITAB INTO WA WHERE K = 'X'.
ENDLOOP.
The above code is much faster than using
LOOP AT ITAB INTO WA.
CHECK WA-K = 'X'.
ENDLOOP.
6. Modifying selected components using MODIFY itab TRANSPORTING f1 f2.. accelerates the task of updating a line of an internal table.
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1 TRANSPORTING DATE.
The above code is more optimized as compared to
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1.
7. Accessing the table entries directly in a "LOOP ... ASSIGNING ..." accelerates the task of updating a set of lines of an internal table considerably
Modifying selected components only makes the program faster as compared to Modifying all lines completely.
e.g,
LOOP AT ITAB ASSIGNING <WA>.
I = SY-TABIX MOD 2.
IF I = 0.
<WA>-FLAG = 'X'.
ENDIF.
ENDLOOP.
The above code works faster as compared to
LOOP AT ITAB INTO WA.
I = SY-TABIX MOD 2.
IF I = 0.
WA-FLAG = 'X'.
MODIFY ITAB FROM WA.
ENDIF.
ENDLOOP.
8. If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.
LOOP AT ITAB1 INTO WA1.
READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.
IF SY-SUBRC = 0.
ADD: WA1-VAL1 TO WA2-VAL1,
WA1-VAL2 TO WA2-VAL2.
MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.
ELSE.
INSERT WA1 INTO ITAB2 INDEX SY-TABIX.
ENDIF.
ENDLOOP.
The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by
LOOP AT ITAB1 INTO WA.
COLLECT WA INTO ITAB2.
ENDLOOP.
SORT ITAB2 BY K.
COLLECT, however, uses a hash algorithm and is therefore independent
of the number of entries (i.e. O(1)) .
9. "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to LOOP-APPEND-ENDLOOP.
APPEND LINES OF ITAB1 TO ITAB2.
This is more optimized as compared to
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
10. DELETE ADJACENT DUPLICATES accelerates the task of deleting duplicate entries considerably as compared to READ-LOOP-DELETE-ENDLOOP.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.
This is much more optimized as compared to
READ TABLE ITAB INDEX 1 INTO PREV_LINE.
LOOP AT ITAB FROM 2 INTO WA.
IF WA = PREV_LINE.
DELETE ITAB.
ELSE.
PREV_LINE = WA.
ENDIF.
ENDLOOP.
11. "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to DO -DELETE-ENDDO.
DELETE ITAB FROM 450 TO 550.
This is much more optimized as compared to
DO 101 TIMES.
DELETE ITAB INDEX 450.
ENDDO.
12. Copying internal tables by using ITAB2[ ] = ITAB1[ ] as compared to LOOP-APPEND-ENDLOOP.
ITAB2[] = ITAB1[].
This is much more optimized as compared to
REFRESH ITAB2.
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
13. Specify the sort key as restrictively as possible to run the program faster.
SORT ITAB BY K. makes the program runs faster as compared to SORT ITAB.
Internal Tables contd
Hashed and Sorted tables
1. For single read access hashed tables are more optimized as compared to sorted tables.
2. For partial sequential access sorted tables are more optimized as compared to hashed tables
Hashed And Sorted Tables
Point # 1
Consider the following example where HTAB is a hashed table and STAB is a sorted table
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE HTAB INTO WA WITH TABLE KEY K = N.
IF SY-SUBRC = 0.
ENDIF.
ENDDO.
This runs faster for single read access as compared to the following same code for sorted table
DO 250 TIMES.
N = 4 * SY-INDEX.
READ TABLE STAB INTO WA WITH TABLE KEY K = N.
IF SY-SUBRC = 0.
ENDIF.
ENDDO.
Point # 2
Similarly for Partial Sequential access the STAB runs faster as compared to HTAB
LOOP AT STAB INTO WA WHERE K = SUBKEY.
ENDLOOP.
This runs faster as compared to
LOOP AT HTAB INTO WA WHERE K = SUBKEY.
ENDLOOP. -
How to optimize the performance of this code ?
I've two Movie clips on a flash project. One of them is fixed and the other can be moved by arrow buttons on the keyboard. The two Movie clips have irregular shapes, so HitTestObject and HitTestPoint doesn't work very well. I've a function that detects collision of two movie clips using bitmap. I wanted to update the position of the movable Movie clip so I put the collision detection function under the code of ENTER_FRAME event listener. It works very well, but when I add many fixed movie clips ( about 10 fixed movie clips in one frame ), the game (.swf file) becomes slower and the performance of the PC becomes slower. I thought that my collision detection function has a negative effect on PC performance so I used the class on this page : https://forums.adobe.com/thread/873737
but the same thing happens.
Would you tell me how to speed up the execution of my codes ?
Here is part of my code :
stage.addEventListener(Event.ENTER_FRAME, myOnEnterFrame);
function myOnEnterFrame(event:Event):void
if (doThisFn) // doThisFn is a variable to allow or prevent the movable movie clip form being moved with keyboard arrows
if ( left && !right ) {
player.x -= speed;
player.rotation = player.rotation - speed ;
if( right && !left ) {
player.x += speed;
player.rotation = player.rotation + speed ;
if( up && !down ) {
player.y -= speed;
if( down && !up ) {
player.y += speed;
// The fixed movie clips are wall1 ,wall2 , wall3 , wall4 , ... and so on
// the following code checks how many walls exists on each frame and pushes them into the wallA array
for(var i:int=0;i<1000;i++) // We can put up to 1000 wall object into the wallA array
if(this['wall'+i]) // If the object wall exists, push it into the wallA array
wallA.push(this['wall'+i]);
for(i=0;i<wallA.length;i++)
if( h.hitF (player , wallA[i] ) || gameOverTest ) // This code checks if the player ( the movable movie clip ) hits the walls or not
trace ( "second try" ) ;
gameOver.visible = true ;
doThisFn = false ;
//I think the following codes are easy to excite and run. I think the performance issue is due to previous codes.
if (player.hitTestObject(door))
win.visible = true ;
doThisFn = false ;
if (key) // if there is a key on frame
if (player.hitTestObject(key))
key.visible = false ;
switch( currentFrame )
case 4:
wallA[0].visible = false ;
wallA[0].x = 50000;
break;
case 5:
wall14.play();
wall8.x = 430 ;
break;it's a simple question that usually has no simple answer.
here's an excerpt from a book (Flash Game Development: In a Social, Mobile and 3D World) i wrote.
Optimization Techniques
Unfortunately, I know of no completely satisfactory way to organize this information. In what follows, I discuss memory management first with sub-topics listed in alphabetical order. Then I discuss CPU/GPU management with sub-topics listed in alphabetical order.
That may seem logical but there are, at least, two problems with that organization.
1. I do not believe it is the most helpful way to organize this information.
2. Memory management affects CPU/GPU usage, so everything in the Memory Management section could also be listed in the CPU/GPU section.
Anyway, I am going to also list the information two other ways, from easiest to hardest to implement and from greatest to least benefit.
Both of those later listings are subjective and are dependent on developer experience and capabilities, as well as, the test situation and test environment. I very much doubt there would be a consensus on ordering of these lists. Nevertheless, I think they still are worthwhile.
Easiest to Hardest to Implement
1. Do not use Filters.
2. Always use reverse for-loops and avoid do-loops and avoid while-loops.
3. Explicitly stop Timers to ready them for gc (garbage collection).
4. Use weak event listeners and remove listeners.
5. Strictly type variables whenever possible.
6. Explicitly disable mouse interactivity when mouse interactivity not needed.
7. Replace dispatchEvents with callback functions whenever possible.
8. Stop Sounds to enable Sounds and SoundChannels to be gc'd.
9. Use the most basic DisplayObject needed.
10. Always use cacheAsBitmap and cacheAsBitmapMatrix with air apps (i.e., mobile devices).
11. Reuse Objects whenever possible.
12. Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
13. Pool Objects instead of creating and gc'ing Objects.
14. Use partial blitting.
15. Use stage blitting.
16. Use Stage3D
Greatest to Least Benefit
Use stage blitting (if there is enough system memory).
Use Stage3D.
Use partial blitting.
Use cacheAsBitmap and cacheAsBitmapMatrix with mobile devices.
Explicitly disable mouse interactivity when mouse interactivity not needed.
Do not use Filters.
Use the most basic DisplayObject needed.
Reuse Objects whenever possible.
Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
Use reverse for-loops and avoid do-loops and while-loops.
Pool Objects instead of creating and gc'ing Objects.
Strictly type variables whenever possible.
Use weak event listeners and remove listeners.
Replace dispatchEvents with callback functions whenever possible.
Explicitly stop Timers to ready for gc.
16. Stop Sounds to enable Sounds and SoundChannels to be gc'd.
Maybe you are looking for
-
Error when importing csv file onto ftp server database
Hi all, i have a csv fiile that has to be imported to a ftp server database. The code works when i am trying out the application on localhost, and the data in the file is successfully uploaded and sent in the database. however, this becomes an issue
-
IPod works with Windows but not iMac
I have an 80GB iPod Classic that works perfect on my computer running Windows Vista and iTunes 7. I have only ever used it with iTunes. My iPod's format is FAT32 (Windows). And it's running software Version 1.1.2 and disk use is enabled. When i try a
-
I have a Tab Control with approx. 15 tabs. After the user changes anything (adding text, changing a ring control, etc. ) from the default configuration on any of the 15 tabs, I would like a change to that individual tab only (say color change, text c
-
Help in modifying the Sequence Model
Hi, I would like to do one of the following: 1) Modify the Single Pass execution entry point, so that, it will call the 'PreUUT' sequence in the same way as the 'testUUTs' entry point. or 2) Add a new Entry point that does what is described in (1) ab
-
Visited Links - Override all link colors
Hi, I'm using RH8 in WebHelp and IE. I read all the former postings regarding people having the same problem and some mentioned a fix in a .css but the .css wasn't available with the posting of March 25, 2008. My visited link color seems to override