Skip to Content
Technical Articles
Author's profile photo Mohit Sharma

Selection Screen Field with F4-Help to list out Variants

Introduction

Recently, while working in one of the requirements to upload an Electronic Bank Statement through a custom program, I had to provision the selection of a variant(actually maintained in the Standard EBS upload Transaction “FF_5”, Report “RFEBKA00″) on the selection screen of the custom program, as below:

Press F4

 

Note:

  1. In order to achieve the requirement, you should know the Report/Program Name, whose variants you want to know, like in this case the program name is RFEBKA00.

Approach – 1

  1. We can use the standard search help SKK_BSTM_VARID to get the variant list.
  2. After that, we have to use standard function modules DD_SHLP_GET_DIALOG_INFO  and F4IF_START_VALUE_REQUEST, to prepare the result set.

Note: In this example we are using single row selecting option, but in case you require to have multiple select option like below, you can use Approach – 1, by filling the parameter MULTISEL  = ‘X’ of FM – F4IF_START_VALUE_REQUEST.

Approach – 2 – (Minimal Coding) – Suggested by Georgi Slavov

  1. Use Function Module – RS_VARIANT_CATALOG.

Let’s see how we can achieve this requirement.

Code

Selection Screen

*&---------------------------------------------------------------------*
*& "Selection Screen
*&---------------------------------------------------------------------*
PARAMETERS: p_var TYPE variant.

Local Class Declaration

*&---------------------------------------------------------------------*
*&"Local Class Declaration
*&---------------------------------------------------------------------*

"--> DEFINITION 
CLASS lcl_variant DEFINITION FINAL.
  PUBLIC SECTION.
    METHODS: variant_list.
ENDCLASS.

"--IMPLEMENTATION
CLASS lcl_variant IMPLEMENTATION.
  METHOD variant_list.

    "Data Declarations
    DATA: ls_search_help TYPE shlp_descr_t,
          lt_interface   TYPE STANDARD TABLE OF ddshiface,
          lt_return      TYPE STANDARD TABLE OF ddshretval,
          lv_subrc       TYPE sysubrc.
    
"Provide the standard search help details
    ls_search_help = VALUE #( shlpname = 'SKK_BSTM_VARID' shlptype = 'SH' ).

    CALL FUNCTION 'DD_SHLP_GET_DIALOG_INFO'
      CHANGING
        shlp = ls_search_help.

"Pass the relevent parameters of the search help 'SKK_BSTM_VARID'
    lt_interface = VALUE #(
                  "Row - 1: Program Information
                  ( shlpfield = 'REPORT' value = 'RFEBKA00' )

                  "Row-2: Field(VARIANT), you want to read from table VARID
                  ( shlpfield = 'VARIANT' f4field = 'X' valtabname = 'VARID'
                    valfield = 'VARIANT'  dispfield = ' ' )
                 ).

    ls_search_help-interface = lt_interface.

    CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
      EXPORTING
        shlp          = ls_search_help
      IMPORTING
        rc            = lv_subrc
      TABLES
        return_values = lt_return.

    "Pass the selected value to the Selection Screen parameter.
    IF line_exists( lt_return[ 1 ] ) AND lv_subrc IS INITIAL.
      p_var = lt_return[ 1 ]-fieldval.
    ENDIF.

  ENDMETHOD.
ENDCLASS.

Execution Events

*&---------------------------------------------------------------------*
*& "Event - INITIALIZATION.
*&---------------------------------------------------------------------*
INITIALIZATION.
  DATA(go_variant) = NEW lcl_variant( ).
  
*&---------------------------------------------------------------------*
*& "Event - AT SELECTION-SCREEN ON VALUE-REQUEST
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.

*&------Approach - 1 --------------------------------------------------*
*&------Gives you the whole list in one shot---------------------------*
  IF go_variant IS BOUND.
    go_variant->variant_list( ).
  ENDIF.

*&------Approach - 2 --------------------------------------------------*
*&------Gives you the whole list in two step, if pop_up = 'X' ---------*
  CALL FUNCTION 'RS_VARIANT_CATALOG'
    EXPORTING
      report      = 'RFEBKA00'
      new_title   = 'Variant List'
      pop_up      = abap_true
    IMPORTING
      sel_variant = p_var
    EXCEPTIONS
      OTHERS      = 0.
"Relevent Exception Handling below.

Conclusion

In this way, we can provision the selection of a variant maintained in some other application on the selection screen of the custom program.

Note

Please excuse for the naming convention used; you can use as per the standards maintained in your project.

For any issues, improvements, additions or any other concerns, please feel free to contact me.

I look forward for your feedback and suggestions.

Keep learning!! Keep improving!!

 

 

Assigned Tags

      15 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      or you could use SELECT * FROM VARID and call F4IF_INT_TABLE_VALUE_REQUEST, it's safer and shorter than using a "standard" search help which might be removed or changed in the future.

       

      Author's profile photo Mohit Sharma
      Mohit Sharma
      Blog Post Author

      That search help was last changed 16 years ago. This blog post is all about what we have right now.

      There might be many ways of achieving a requirement, maybe this is one of them.

      Thanks! 🙂

      Author's profile photo Sandra Rossi
      Sandra Rossi

      Yep, it's exactly the argument of people who use any standard object, but some of them are removed in each version. We all know Murphy law. I also experienced it. Rule-of-thumb is to avoid using non-released objects, only use released objects. Of course, VARID itself is not released, but by experience the big pieces are changed or removed more rarely than little objects.

      Author's profile photo Mohit Sharma
      Mohit Sharma
      Blog Post Author

      I agree!! Thanks Sandra!

      Author's profile photo Umesh Bombale
      Umesh Bombale

      Very well written....

      Author's profile photo Mohit Sharma
      Mohit Sharma
      Blog Post Author

      Thanks Umesh!!

      Author's profile photo Akash Dhakulkar
      Akash Dhakulkar

      "Handy tips make coding easy"

      Nice one and thanks for sharing !

      Author's profile photo Mohit Sharma
      Mohit Sharma
      Blog Post Author

      Thanks Akash!!

      Author's profile photo Georgi Slavov
      Georgi Slavov

      I had the same need, and implemented it like this

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR pmonvar.
      
        CALL FUNCTION 'RS_VARIANT_CATALOG'
          EXPORTING
            report      = 'Name_of_report' " where we are interested at variants list
            new_title   = TEXT-005
            pop_up      = abap_true
          IMPORTING
            sel_variant = pmonvar
          EXCEPTIONS
            OTHERS      = 0.

      I think it is less code, and the fm will be available in every kind of SAP NW system, plus it is released, belongs to the BASIS(BC-ABA-TO), and is for me logical choice to use.

      Author's profile photo Mohit Sharma
      Mohit Sharma
      Blog Post Author

      Thanks Georgi. Its a 2 step variant finding option, whereas the one used by me above gives you the whole list in one shot. Also the FM 'RS_VARIANT_CATALOG' allows you to select only one variant at a time, whereas, the later one can allow you to select multiple values as well, if required.

      Don't go by the amount of lines of code put together above,  😛 .

      But, I like the FM shared by you and have used it multiple times as well in the past. I have incorporated in this blog post.
      Thanks again. Keep sharing, keep learning!!

      Author's profile photo Georgi Slavov
      Georgi Slavov

      If parameter pop_up is not set to true, the whole list is immediately displayed.

      Author's profile photo Georgi Slavov
      Georgi Slavov

      Plus it is not only about amount of (custom) code. In case for a certain use case SAP has foreseen an API, why develop it by yourself...

      Author's profile photo Mohit Sharma
      Mohit Sharma
      Blog Post Author

      I did not develop DD_SHLP_GET_DIALOG_INFO & F4IF_START_VALUE_REQUEST

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      When incorporating someone's suggestion in the post, it's customary to mention the person's name.

      Author's profile photo Mohit Sharma
      Mohit Sharma
      Blog Post Author

      Though, I have mentioned in the comment above, but forgot to have that in the blog post. My bad. Thanks for the reminder.