How to modify the Standard PF-Status of ALV Grid?

Last Monday, I was on-leave at work as I need to go to the hospital for my last session for my upper back therapy. My wife accompanied all day which turned to be a date at the hospital. How sweet we are. :) Upon my return yesterday to work, I was loaded with so many tasks. All the developments I have finished last week were being tested by my counterpart. As expected, bugs are found. So all of them want to finish it as deadline is fast approaching. I was under pressure yesterday as everyone says, "this object is critical. We need to deliver on time!" 

Really??? Anyways, I have done all those stuff within the day. :) But I was exhausted with all those bugs and enhancement requested. Lesson learned: "Dont take a leave while project is going on. Otherwise, you will be under pressure upon return".  Hehehe...

Never mind that crazy day. Everyone of us once feel that pressure. Once you experience it, just smile and stay focus. So today, I would like to share with you this simple tutorial on how to modify the standard PF-Status of an ALV Report using the FM ALV_GRID_DISPLAY.

To have an idea about this topic today, take a look with this sample screenshot below. The button "download" is added into a standard ALV PF-Status.

Basically, some functional consultants request to have this kind of design since it is beneficial to the users from further processing like for instance, in this case, download to excel file. 

So lets start this tutorial now with the following steps. But before I forget, I assumed you have already created your own custom report program. In this tutorial, I will not discuss further on how to create your first report program. But in case, you haven't created yet, you can view this simple tutorial in ALV Report using ALV_GRID_DISPLAY.

Steps:

1. Since what we would like to achieve is to modify the standard PF-Status, our first step is to copy the GUI Status from the standard program. So, go to tcode SE80 and enter the following program name: SAPLKBBL. This is the program that handles all the standard PF-Status related to ALV display.


Once you displayed the objects of the program SAPLKBBL, scroll down and look for the GUI Status folder (refer screenshot above). From the list of statuses, locate this standard one below, "STANDARD_FULLSCREEN". Actually, you can select your own too from the lists. As for this tutorial, I selected the standard_fullscreen status which I commonly used.


2. Once I selected the status that I prefer, right click your mouse to open the context menu. From the menu, select "Copy". This popup window appears afterwards. Enter here the name of your custom program on the parameter in yellow. Then click the copy button.



3. Go back to your custom report program. Open it in SE38. Display all object list. As you will notice, the standard PF-Status is added automatically into your custom program. Look this sample screenshot below. Dont worry will all the functionality of the PF-Status. It is the same with the standard as long as you will not change the function codes. 


4. Open the copied standard status like the normal way you do. Then from the list of function codes, add your own custom code. Well, In this tutorial, I added the function code "Download" which will appear in the ALV status. After you added, save and activate it.



5. In your ABAP code, set your customized status this way:
1
2
3
4
5
6
7
8
*&--------------------------------------------------------------*
*&      Form  pf_status
*&--------------------------------------------------------------*
*       Set the PF Status of the ALV Grid
*---------------------------------------------------------------*
FORM pf_status USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS  'STANDARD_FULLSCREEN'.
ENDFORM.     

Then in your Function Module, REUSE_ALV_GRID_DISPLAY, call the name of your form, PF_STATUS. Once you execute your report, your newly added button besides from the standard buttons will be displayed into your ALV Grid.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-repid
      i_callback_pf_status_set = 'PF_STATUS'
      i_callback_user_command  = 'F_USER_COMMAND'
      is_layout                = gwa_layout
      it_fieldcat              = gi_fieldcatalog[]
      it_sort                  = gi_sort
    TABLES
      t_outtab                 = gi_output
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
  IF sy-subrc = 0.                                          "#EC NEEDED
    "do nothing
  ENDIF.


So that's it. A simple process to modify the standard PF-Status of an ALV Grid. If you have any questions or suggestions, please let me know. Leave your comments below. Thank you once again and I invite everyone to connect with me on my page @ABAPTHINKERS. See you next time. :)

No comments:

Post a Comment