‎2009 Apr 14 10:37 AM
Hello,
I am writing a report, and i have a perform for select which is very slow, so i d like to have a progress bar
like [this|http://abaplovers.blogspot.com/2008/05/abap-code-for-progress-bar.html], but i dont know how can this be applied in a select clause. Can anyone help ?
‎2009 Apr 14 10:55 AM
here's the code.
TABLES: EKKO, "PO Header
EKPO, "PO Item
EKBE, "PO History (Invoice)
RBKP, "Document Header: Invoice Receipt
MAKT, "Material Descriptions
LFA1. "Vendor Master
"Structure
TYPES: BEGIN OF TS_POINV, "Basic PO-invoice data structure
BELNR LIKE RBKP-BELNR, "Accounting Document Number
BEWTP LIKE EKBE-BEWTP, "PO history category
GJAHR LIKE EKBE-GJAHR, "Material Document Year
BUDAT LIKE EKBE-BUDAT, "Posting Date in the Document
EBELN LIKE EKBE-EBELN, "Purchasing Document Number
EBELP LIKE EKBE-EBELP, "Item Number of Purchasing Document
RLIFNR LIKE RBKP-LIFNR, "Invoice vendor
NAME1 LIKE LFA1-NAME1, "Vendor's name1
LAND1 LIKE LFA1-LAND1, "Vendor's land
MATNR LIKE EKPO-MATNR, "Material Number
TXZ01 LIKE EKPO-TXZ01, "short text
DFINVPO TYPE P DECIMALS 6, "Invoice Po difference per unit
BWAERS LIKE EKBE-WAERS, "Currency Key
BPMNG LIKE EKBE-BPMNG, "Invoice Quantity in purchase order price unit
PBPRME LIKE EKPO-BPRME,"Order Price Unit (Purchasing)
WRBTR LIKE EKBE-WRBTR, "Amount in po currency
INVPRAM TYPE P DECIMALS 6, "Invoice price per quantity
MENGE LIKE EKPO-MENGE, "Purchase order quantity
BPRME LIKE EKPO-BPRME, "Order Price Unit (Purchasing)
NETWR LIKE EKPO-NETWR, "Net order value in PO currency
POPRAM TYPE P DECIMALS 6, "PO price per quantity.
SAMEQNT TYPE C LENGTH 1,
DFINVPO_PR TYPE P DECIMALS 2,
END OF TS_POINV,
TT_POINV TYPE TABLE OF TS_POINV.
DATA: GT_POINV TYPE TABLE OF TS_POINV,
GW_POINV LIKE LINE OF GT_POINV.
SELECTION-SCREEN BEGIN OF BLOCK B001.
SELECT-OPTIONS: S_BUDAT FOR GW_POINV-BUDAT. "invoice date
SELECTION-SCREEN END OF BLOCK B001.
SELECT
B~BUDAT
B~BELNR
B~BEWTP
B~BPMNG
B~WRBTR
P~BPRME AS PBPRME
B~WAERS AS BWAERS
B~DMBTR
B~HSWAE AS IHSWAE
B~EBELN
B~EBELP
P~MATNR
P~MENGE
P~BPRME
P~NETWR
K~WAERS AS KWAERS
K~WKURS
B~HSWAE AS PHSWAE
R~LIFNR AS RLIFNR
B~GJAHR
L~NAME1
P~TXZ01
L~LAND1
B~GJAHR
FROM
EKBE AS B
INNER JOIN
EKPO AS P
ON BEBELN = PEBELN
AND BEBELP = PEBELP
INNER JOIN
EKKO AS K
ON KEBELN = BEBELN
INNER JOIN
RBKP AS R
ON BBELNR = RBELNR
AND BGJAHR = RGJAHR
AND RLIFNR = KLIFNR "Same vendor
INNER JOIN
LFA1 AS L
ON LLIFNR = RLIFNR
INTO CORRESPONDING FIELDS OF TABLE
GT_POINV
WHERE
B~BUDAT IN S_BUDAT.
‎2009 Apr 14 10:44 AM
‎2009 Apr 14 10:45 AM
Stratos,
Please paste the select query here.
I will try to write the code for you.
It all depends on using sy-tabix value which needs to be passed on to the FM mentioned by you.
Thanks,
Babu Kilari
‎2009 Apr 14 10:48 AM
Hi Stratos
Try this
DATA : lv_per TYPE syst-tabix ,
lv_lst_p TYPE syst-tabix ,
lv_total TYPE syst-tabix ,
lv_char TYPE string .
DESCRIBE TABLE i_afpo LINES lv_total .
LOOP AT i_afpo ASSIGNING <fs_afpo> .
* Progress Indicator
lv_lst_p = ( sy-tabix * 100 ) / lv_total .
* There is no point in updating frontend if % remains same
IF lv_lst_p NE lv_per .
lv_per = lv_lst_p .
lv_char = lv_per .
CONCATENATE 'Processing'(002)
lv_char
'%'(003)
INTO lv_char
SEPARATED BY space .
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = lv_per
text = lv_char.
ENDIF.
ENDLOOP.Regards
Hareesh Menon
‎2009 Apr 14 10:53 AM
‎2009 Apr 14 10:53 AM
If you are using a SELECT.......ENDSELECT or selecting the documents within an LOOP.....ENDLOOP, call the FM "SAPGUI_PROGRESS_INDICATOR" with destination as SAPGUI. Pass on the document number or something, which would show you the current selection on the SAP GUI.
SELECT vbeln " SD document no.
FROM vbpa
INTO (w_vbeln)
WHERE parvw EQ c_patnr_func_z1
AND lifnr EQ w_lifnr.
fs_sales_patnr_doc-vbeln = w_vbeln.
CLEAR w_vbeln.
* To display the processing status of the report on status bar.
PERFORM display_sapgui_status USING w_vbeln.
* To fetch the sales documents of type ZEXC, ZORR and ZORE from VBAK
PERFORM get_sales_docs_zexc_zorr_zore.
ENDSELECT.
*----------------------------------------------------------------------*
* FORM DISPLAY_SAPGUI_STATUS *
*----------------------------------------------------------------------*
* Subroutine for displaying the current processing status on SAPGUI *
* status bar. *
*----------------------------------------------------------------------*
* --> P_W_STATUS - Process status text *
*----------------------------------------------------------------------*
FORM display_sapgui_status USING p_w_status LIKE w_vbeln.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
DESTINATION 'SAPGUI'
KEEPING LOGICAL UNIT OF WORK
EXPORTING
text = p_w_status
EXCEPTIONS
system_failure
communication_failure.
ENDFORM. " DISPLAY_SAPGUI_STATUS
‎2009 Apr 14 10:55 AM
here's the code.
TABLES: EKKO, "PO Header
EKPO, "PO Item
EKBE, "PO History (Invoice)
RBKP, "Document Header: Invoice Receipt
MAKT, "Material Descriptions
LFA1. "Vendor Master
"Structure
TYPES: BEGIN OF TS_POINV, "Basic PO-invoice data structure
BELNR LIKE RBKP-BELNR, "Accounting Document Number
BEWTP LIKE EKBE-BEWTP, "PO history category
GJAHR LIKE EKBE-GJAHR, "Material Document Year
BUDAT LIKE EKBE-BUDAT, "Posting Date in the Document
EBELN LIKE EKBE-EBELN, "Purchasing Document Number
EBELP LIKE EKBE-EBELP, "Item Number of Purchasing Document
RLIFNR LIKE RBKP-LIFNR, "Invoice vendor
NAME1 LIKE LFA1-NAME1, "Vendor's name1
LAND1 LIKE LFA1-LAND1, "Vendor's land
MATNR LIKE EKPO-MATNR, "Material Number
TXZ01 LIKE EKPO-TXZ01, "short text
DFINVPO TYPE P DECIMALS 6, "Invoice Po difference per unit
BWAERS LIKE EKBE-WAERS, "Currency Key
BPMNG LIKE EKBE-BPMNG, "Invoice Quantity in purchase order price unit
PBPRME LIKE EKPO-BPRME,"Order Price Unit (Purchasing)
WRBTR LIKE EKBE-WRBTR, "Amount in po currency
INVPRAM TYPE P DECIMALS 6, "Invoice price per quantity
MENGE LIKE EKPO-MENGE, "Purchase order quantity
BPRME LIKE EKPO-BPRME, "Order Price Unit (Purchasing)
NETWR LIKE EKPO-NETWR, "Net order value in PO currency
POPRAM TYPE P DECIMALS 6, "PO price per quantity.
SAMEQNT TYPE C LENGTH 1,
DFINVPO_PR TYPE P DECIMALS 2,
END OF TS_POINV,
TT_POINV TYPE TABLE OF TS_POINV.
DATA: GT_POINV TYPE TABLE OF TS_POINV,
GW_POINV LIKE LINE OF GT_POINV.
SELECTION-SCREEN BEGIN OF BLOCK B001.
SELECT-OPTIONS: S_BUDAT FOR GW_POINV-BUDAT. "invoice date
SELECTION-SCREEN END OF BLOCK B001.
SELECT
B~BUDAT
B~BELNR
B~BEWTP
B~BPMNG
B~WRBTR
P~BPRME AS PBPRME
B~WAERS AS BWAERS
B~DMBTR
B~HSWAE AS IHSWAE
B~EBELN
B~EBELP
P~MATNR
P~MENGE
P~BPRME
P~NETWR
K~WAERS AS KWAERS
K~WKURS
B~HSWAE AS PHSWAE
R~LIFNR AS RLIFNR
B~GJAHR
L~NAME1
P~TXZ01
L~LAND1
B~GJAHR
FROM
EKBE AS B
INNER JOIN
EKPO AS P
ON BEBELN = PEBELN
AND BEBELP = PEBELP
INNER JOIN
EKKO AS K
ON KEBELN = BEBELN
INNER JOIN
RBKP AS R
ON BBELNR = RBELNR
AND BGJAHR = RGJAHR
AND RLIFNR = KLIFNR "Same vendor
INNER JOIN
LFA1 AS L
ON LLIFNR = RLIFNR
INTO CORRESPONDING FIELDS OF TABLE
GT_POINV
WHERE
B~BUDAT IN S_BUDAT.
‎2009 Apr 14 11:07 AM
Hi Stratos,
I think it might not work for in the case of Joins. You can use the Progress Bar Indicator for the data fetching on a single table I guess. Here there is no scope for Select and Endselect, Loop and Endloop Isn it?
Try using For All Entries instead of using JOIN. This will improve performance too.
Meanwhile, I will try to get something out of it as I am free.
Thanks,
Babu Kilari
Edited by: Babu Kilari on Apr 14, 2009 12:08 PM
‎2009 Apr 14 11:11 AM
what do you mean by "Try using For All Entries instead of using JOIN. This will improve performance too"
?
‎2009 Apr 14 11:13 AM
I am suggesting you to use FOR ALL ENTRIES Statement instead of using JOINS.
You had written the code completely using JOINS. That is the reason it is taking time.
You got it what I meant?
‎2009 Apr 14 11:15 AM
Not necessarily Babu.
Check the thread opened by Gareth abt FAE Vs Joins. The thread is available in the sticky.
pk
Edited by: kishan P on Apr 14, 2009 3:51 PM
‎2009 Apr 15 4:32 PM
The problem is not that you are using a JOIN. The problem is that you are doing an array fetch all at one time, so you cannot show the progress. You could do this if you changed it to a SELECT/ENDSELECT construct, but since performance is a problem, that would be counterproductive.
Rob
‎2009 Apr 15 6:20 PM
Thx Rob Burbank that's the solution i was thinking myself.
It's not only the fetch. It's the sy-index. In the debbuger you pass with F5 all the select statment, thus
you cannot have the sy-index in the progress "loop".
By the way i think that you dont need to have a progress bar in a select statment, because a select was made for executing quickly.
that's all. thanks everyone for the replies..
cu
‎2009 Apr 14 10:59 AM
Before the select statement you need to call Function Module. Look at sample one below...
data:
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = '50'
text = g_text.
‎2009 Apr 14 11:06 AM
before the select ? and how the sy-index will be count for the percentage ?
‎2009 Apr 15 4:09 PM
Hi,
Please run the report RSMON000_ALV .
after running the report in the output TIME column displays how many seconds each select query
is taking.
Thanks & Regards,
Sateesh.