Skip to Content
Technical Articles
Author's profile photo Johan Wigert

The progress indicator in ABAP reports

I’m sure most of you have been asked to develop a report displaying a progress indicator during the execution of the report. I just developed a migration report which needs several minutes to execute, so I decided to put in a progress indicator.

When running the ATC check with abapOpenChecks for the report I’ve developed, I got an error telling me that function module SAPGUI_PROGRESS_INDICATOR should not be used. Even though this is documented in the documentation of check 53 for abapOpenChecks, an SAP Knowledge Base Search for information on what should be used instead of function module SAPGUI_PROGRESS_INDICATOR didn’t give me any results. The documentation at abapOpenChecks states that class CL_PROGRESS_INDICATOR should be used instead of the function module. I decided to write this short blog post to share this information with the community as well as to provide a tiny code example.

Instead of using the function module like this:

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
  EXPORTING
    percentage = progress_percent
    text       = progress_text.

 

You can use the class like this:

cl_progress_indicator=>progress_indicate(
    i_text = |Processing: { current_record }/{ total_records }|
    i_output_immediately = abap_true ).

 

The result isn’t exactly the same since the function module only works with percentages. This could easily be achieved with the class as well, but in this case, I was more interested in seeing how many of the total records had been processed.

Happy coding!

This blog post first appeared on the Developer Voyage blog at https://www.developervoyage.com/2019/11/11/the-progress-indicator-in-abap-reports.html

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Shai Sinai
      Shai Sinai

      For the matter of fact, method cl_progress_indicator=>progress_indicate has a few advantages over FM SAPGUI_PROGRESS_INDICATOR:

      1. It supports also background processing (Writes messages to job log).
      2. It includes also some "load-balancing", by updating progress bar only every pre-defined time window (10 seconds) instead of updating it on every call (unless parameter I_OUTPUT_IMMEDIATELY='X' is set).
      3. Percentage is calculated internally (when you transfer I_PROCESSED, I_TOTAL).
        You must set I_TEXT or I_MSGID/I_MSGNO with 3 message placeholders (&1, &2, &3) so it will work as expected.
      Author's profile photo Johan Wigert
      Johan Wigert
      Blog Post Author

      Thanks for a great comment!

      Regarding point 3, I made two examples and added them to the abapOpenChecks documentation.

      Author's profile photo Michelle Crapo
      Michelle Crapo

      Excellent blog.  One of those little things that I could easily miss. 🙂

      Author's profile photo Lars Hvam
      Lars Hvam

      Its configurable in abapOpenChecks if usage of SAPGUI_PROGRESS_INDICATOR should report errors, but by default abapOpenChecks is quite picky 🙂

      Author's profile photo Michael Koehler
      Michael Koehler

      Nice blog - knowing these little twists makes the difference between a good and a great developer!

      Author's profile photo Rashid Javed
      Rashid Javed

      First of all thanks a lot for mentioning this class. Nice Blog.

      On a lighter note, i very happily went to my system, SE24, displayed the class. checked the class documentation and this is the GEM i found ?

      Author's profile photo Rashid Javed
      Rashid Javed

      I just checked the documentation of FM PROGRESS_INDICATOR 🙂

       

      Author's profile photo David Encinas Fernandez
      David Encinas Fernandez

      Hi,

      Don't have experience with the class version but I was always trying to stay away from the progress bar when my programs was making updates on the DB or at least being very careful. If I remember correctly it is triggering an implicit commit at each GUI update.

       

      Regards,

      David.

      Author's profile photo Omkar Zemse
      Omkar Zemse

      Hi,

      SAPGUI_PROGRESS_INDICATOR works just fine. you have to add an additional line "WAIT UP TO SECONDS." to see the progress circle.
      Author's profile photo Jorge Augusto Portilla Garcia
      Jorge Augusto Portilla Garcia

      Nice!

      Author's profile photo Edo von Glan
      Edo von Glan

      The method also offers automatic text replacement:

      DATA(total) = lines( it ).
      LOOP AT it ASSIGNING <wa>.
        cl_progress_indicator=>progress_indicate( i_text = 'Progress: &1% (&2 von &3)'
                                                  i_processed = sy-tabix
                                                  i_total = total ).
      

      There is even a fourth placeholder:

      cl_progress_indicator=>progress_indicate( i_text = |&1% - Processing &4 (&2/&3)|
                                                i_processed = sy-tabix
                                                i_total = lines( it_trkorr_newest )
                                                i_msgv4 = get_trkorr_string( <trkorr> )
                                                i_output_immediately = abap_false ).