Automatic SAP ABAP ALV refresh, Get the code right here!
July 21, 2008 by Ameya Pimpalgaonkar
- Sandipan Das
- L&T Infotech
Scenario:
The following code is developed for Locomotive Repairing Workshop scenario which requires a ALV Report that automatically refresh its data after some specified time interval with out any user interventions. It goes like as user i.e. the supervisor will run a report that will show him the list of locomotive which has come for repairing.
When any locomotive come for repairing the data entry operator makes the entry and the data get saved in to database table ZLOCO_REPAIR.
The report program will continuously hit the database at some specific interval and shows the user the current status.
Concepts Used:
1. OOPS approach For ALV reports for display of data i.e. using the class CL_GUI_ALV_GRID.
2. GUI Controls i.e. using the class CL_GUI_TIMER.
The main concept is when the event ON_FINISHED of the class CL_GUI_TIMER gets trigger after the specified time interval the code for getting the data form the database gets executed.
Benefits:
- No need of Job scheduling required.
- No extra internal session is created.
No User intervention required.
First step is to create a screen say 9100 by using Graphical Painter. Put a custom control on the screen by drag and drop and specify a name say CUSTOM.
Program:
************************************************************************
*&---------------------------------------------------------------------*
*& Report ZLOCO_DISPLAY
*&---------------------------------------------------------------------*
REPORT ZLOCO_DISPLAY.
*****************Data declaration *********************************
TYPES: BEGIN OF STRUC_FINAL,
SEL(1).
TYPES: CELLTAB TYPE LVC_T_STYL,
EQUNR TYPE ZLOCO_REPAIR -EQUNR,
ZARR_DATE TYPE ZLOCO_ARR-ZARR_DATE,
ZARR_TIME TYPE ZLOCO_ARR-ZARR_TIME,
ZSTATUS TYPE ZLOCO_ARR-ZSTATUS,
STAT_FIN(10) TYPE C,
END OF STRUC_FINAL.
DATA: WA_FINAL TYPE STRUC_FINAL,
IT_FINAL TYPE STANDARD TABLE OF STRUC_FINAL WITH HEADER LINE,
IT_TEMP TYPE STANDARD TABLE OF STRUC_FINAL,
WA_TEMP TYPE STRUC_FINAL.
DATA: CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA:IT_FLDCAT TYPE LVC_T_FCAT,
WA_FLDCAT TYPE LVC_S_FCAT,
WA_LAYOUT TYPE LVC_S_LAYO.
DATA FLAG.
DATA: RF_GUI_TIMER TYPE REF TO CL_GUI_TIMER.
DATA: PA_REFRS TYPE I VALUE '5'.
DATA:OK_CODE TYPE SY-UCOMM.
Get rest of the code right here. Automatic ALV refresh code.
We encourage reader to post a comment as you can see this code is uniquely developed for MadeITsimple.com by our author, so let us appreciate his efforts by post comments.




Execellent man, superb…WOW..i really appreciate your effors brother. This is very unique code and posting them for everyone’s use is really nice of you. Are u writing some more fandu code like this? Anyways, congrats for the nice post.
Sandesh Kapur
Cognizant
Okey, nice program. But do you think using OOPS concepts might increase the length of code? Is there any way to shorten the code? i mean to optimizt it more? rest nice attempt and appreciated.
Terry
Thanks people for appreciating our author Sandipan’s efforts. he will be addressing all your comments soon. Mean while keep on commenting on the contents and code. If you find any lackings or more optimization is needed?
Thanks on behalf of MadeITsimple.com,
Admin
Hi Sandesh,
thanks for appreciating my efforts.
I am now working on the article regarding ALV report (Using the Function Module )which will be useful for the Freshers especially.