Skip to Content

Even if this functionality has been introduced some years ago (as of SAP ECC 6.0) there are very few programs using the full potential of this tool. I would like to bring your attention to this not-so-known useful technique.

So what is it about ? Some people working with PP standard transactions like COOIS are already familiar with this. It is allowing to dynamically add some buttons in the toolbar of an ALV table and to link those buttons to some actions. Actions can be triggered by existing ok-codes, or call a given transaction with some parameters. It is even possible to execute some code from a class. Very useful and very customizable !

The best part of it to me (as I am a developer) is that it is possible to make it work with my own ALV grids.

Note: it works basically with an ALV grid so if you want to use it with the SALV framework you will have to retrieve the reference to your implicitly defined ALV grid. This technique has been used in some previous blog.

So, what do we need in order to allow using the navigation profile ?

  • Get the default profile either general or user-related (optional)
FORM profile_default_get CHANGING cs_prfkey TYPE navp_s_profile_key.
  DATA: ls_prfkey_def TYPE navp_s_profile_key.

  CLEAR gs_prfkey.
  gs_prfkey-report    = sy-repid.
  gs_prfkey-username  = sy-uname.

  CALL METHOD cl_navp_db=>get_default
    EXPORTING
      is_profile_key         = cs_prfkey
    RECEIVING
      rs_default_profile_key = ls_prfkey_def.

  cs_prfkey-profile = ls_prfkey_def-profile.

ENDFORM.                    " profile_default_get

Note that the key of a profile is flexible enough to allow several ALV tables. See structure navp_s_profile_key. Fields handle and log_group can be used as key fields.

 

  • Instanciate an object based on interface IF_NAVP. There is a factory class to do it. The reference to the ALV grid is passed as a parameter. You need to pass the internal table also.
DATA: go_navigation_profile TYPE REF TO if_navp,
      gs_variant_prof       TYPE disvariant,
      gs_profile_key        TYPE  navp_s_profile_key.

DATA: my_grid TYPE REF TO cl_gui_alv_grid.

PARAMETERS: p_profil TYPE navp_profile_name.   "Default profile chosen by user

FORM create_navprf .

  "Looks like a display variant, but is the key of the profile
  gs_variant_prof-report  = sy-repid.
  gs_variant_prof-variant = p_profil.  "could be also the field gs_prfkey_def-profile

  FREE go_navigation_profile.
  go_navigation_profile = cl_navp_factory=>factory(
      io_alv                        = my_grid
      is_profile_key                = gs_variant_prof
      iv_default                    = if_navp=>default_manual
      iv_save_mode                  = if_navp=>save_all
      it_table                      = gt_output ).

ENDFORM.                    " CREATE_NAVPRF

That’s it ! Now you have some new menu in the ALV toolbar : it allows to choose the navigation profile, to edit the profile and to manage. The buttons next to this menu are the ones inherited from the navigation profile (sample below: MD04 will run transaction MD04).

Clicking on Change, you get to a popup where you can see the different actions contained into the profile. You can also maintain the profile (depending on your authorizations – object C_NAV_PROF activity 23).

You are able to add and remove actions : transaction call, function call (meaning raising an ok-code), class call and menu. The menu option allows to group some actions into a menu.

So it is very convenient to build some toolbar that will give access to various actions. Of course, if it is an ok-code this one should be handled by the program in order to work. All standards functions from the ALV menu are available (like &DETAIL for example) but you can also program your own ok-codes. Typically you will retrieve the selected rows of the grid and process the data of the internal table. This should be done in some method handle_user_command of your listener for event user_command of the ALV grid.

You can transport a navigation profile by using the managing tool. You can call it with transaction NAVP_MANAGE. If the profile is not linked to your user, click on button “Standard Profiles” to switch to the general profiles.

 

Some reference in SAP doc : https://help.sap.com/doc/saphelp_me60/6.0.4/en-US/dd/ffb753128eb44ce10000000a174cb4/content.htm

 

 

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply