Monday, March 5, 2018

Renaming Selection Text of Fields on Selection Screen

Here is a little tricks for you to change the name of the field text label in selection screen.
A Simple Case Requirement when you can handle 2 types of documents like Sales Document and Billing Document, then you want to change the label of the VBELN into sales/billing according the the selection of a radio button you have chosen. Well you can simply follow the following steps:

  1. Define Seltext table and workarea
    
        DATA it_seltexts TYPE TABLE OF rsseltexts.
        DATA wa_seltexts TYPE rsseltexts. 
    
    
  2. You can set a new selection text for several fields by inserting the record into it_seltexts table
    
         wa_seltexts-kind = ' '. "Type of the field P/S (Parameters /Select Options)
         wa_seltexts-name = ' ' "Name of the field
         wa_seltexts-text = ' '. "Seletion text of the field
         INSERT wa_seltexts INTO TABLE it_seltexts.
    
    
  3. Finally, Call modify function to execute the changes according the it_seltexts table
    
         CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
           EXPORTING
             program  = sy-repid
           TABLES
             seltexts = it_seltexts
     *           EXCEPTIONS
     *       PROGRAM_NOT_FOUND                 = 1
     *       PROGRAM_CANNOT_BE_GENERATED       = 2
     *       OTHERS   = 3
           .
         IF sy-subrc <> 0.
        ENDIF.