Friday, April 27, 2012
  • Use SELECT_OPTIONS_RESTRICT function module to make use of SELECT-OPTIONS easier on the selection screen.
  • This function module simplifies the handling of SELECT-OPTIONS on the selection screen by restricting possible selection options and signs. By calling this function module, you can restrict the number of selectio options available for the chosen selection field. You can also disable the function allowing users to enter values to be excluded from the selection (SIGN = 'E'). The set of options (and signs) listed here can be extended for the 'multiple selection' screen.
  • Call function module at INITIALIZATION event. 
REPORT test_restrict_so.

TYPE-POOLS:sscr.
TABLES : pa0001.
"Selection-screen
SELECT-OPTIONS :
     s_pernr FOR pa0001-pernr.
"Types
TYPES:
      ty_so_restrict TYPE sscr_restrict,
      ty_so_opt_list TYPE sscr_opt_list,
      ty_sscr_ass    TYPE sscr_ass.
"Work areas
DATA:
      wa_so_restrict TYPE ty_so_restrict,
      wa_so_opt_list TYPE ty_so_opt_list,
      wa_sscr_ass    TYPE ty_sscr_ass.
"Internal tables
DATA:
      it_so_restrict TYPE ty_so_restrict,
      it_so_opt_list TYPE ty_so_opt_list.


INITIALIZATION.

  wa_so_opt_list-name = 'OBJECTKEY1'.
  wa_so_opt_list-options-eq = 'X'.
  wa_so_opt_list-options-bt = 'X'.
  APPEND wa_so_opt_list TO it_so_restrict-opt_list_tab.

  wa_sscr_ass-kind    = 'S'.
  wa_sscr_ass-name    = 'S_PERNR'.
  wa_sscr_ass-sg_main = 'I'.
  wa_sscr_ass-sg_addy = space.
  wa_sscr_ass-op_main = 'OBJECTKEY1'.
  APPEND wa_sscr_ass TO it_so_restrict-ass_tab.

  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
      restriction            = it_so_restrict
    EXCEPTIONS
      too_late               = 1
      repeated               = 2
      selopt_without_options = 3
      selopt_without_signs   = 4
      invalid_sign           = 5
      empty_option_list      = 6
      invalid_kind           = 7
      repeated_kind_a        = 8
      OTHERS                 = 9.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Output

1 comment:

  1. This post is extremely radiant. I extremely like this post. It is outstanding amongst other posts that I’ve read in quite a while. Much obliged for this better than average post. I truly value it! sap fico training institutes in hyderabad

    ReplyDelete

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.