SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Text Control on the Selection Screen (Editable/Non-Editable)

By Chirag Modi, Infosys

Introduction

Sometimes there is requirement to enter more than 255 characters in a select-option/parameter on the selection screen. During such scenario we can make use of edit text control. Edit Text Control can be called on pressing the pushbutton which can be provided against the required select-option/parameter.

This document provides the steps for creating Edit Text Control (Editable and Non-Editable) on the selection screen.  

Steps

1)  Selection Screen creation  

Create Parameter and corresponding pushbutton in the selection screen for which text control needs to be created..

*/.. Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*/.. Parameter for Text Edit Control
PARAMETERS: P_TEXT      TYPE char40 MODIF ID md1.
SELECTION-SCREEN PUSHBUTTON 75(8) but1 USER-COMMAND click MODIF ID md1.
SELECTION-SCREEN END OF BLOCK b1. 

For the Parameter P_TEXT provide pushbutton "BUT1".On pressing this pushbutton "Edit Text Control" should be displayed in which text more than 255 characters can be entered and used accordingly.  

The above selection screen would be displayed as:-

 

2) The next step is to provide ICON/Text for the above declared Pushbutton.

  Call FM "ICON_CREATE" to provide the ICON for the pushbutton. This FM should be called at " INITIALIZATION".

  gv_icon_name =  'ICON_DISPLAY_MORE'.
  gv_quickinfo    =  'TE'.
  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name                   = gv_icon_name
      text                      = 'TE'
      info                      = gv_quickinfo
    IMPORTING
      RESULT                = gv_icon_result
    EXCEPTIONS
      icon_not_found              = 1
      outputfield_too_short   = 2
      OTHERS                             = 3.
  IF sy-subrc EQ 0.
    but1 = gv_icon_result.
  ENDIF.

Selection Screen after the above Step:- 

3) On clicking this pushbutton, edit text control should be displayed. For this Call the screen (can be any number) 9001 in "AT SELECTION-SCREEN" .

 IF sscrfields-ucomm EQ 'CLICK'.
    CALL SCREEN 9001 STARTING AT 10 5.
 ENDIF.

4) Create screen 9001 (Modal Screen in this case) by double clicking on "9001".

Create a custom control on the screen with name "CONTAINER".

Now, add the logic for displaying the edit control in PBO and PAI Modules of screen 9001.

Description: C:\Users\chirag_modi01\Desktop\Untitled.png  

5) In PBO, create object container GV_CONTAINER. Then create text editor object by exporting the container GV_CONTAINER.

    IF gv_container IS INITIAL.
    CREATE OBJECT gv_container
      EXPORTING
        container_name              = 'CONTAINER'
      EXCEPTIONS
        cntl_error                         = 1
        cntl_system_error           = 2
        create_error                     = 3
        lifetime_error                   = 4
        lifetime_dynpro_dynpro_link = 5.
  ENDIF.
  CREATE OBJECT gv_text_editor
    EXPORTING
      parent                 = gv_container
      wordwrap_mode          = '2'
      wordwrap_position      = '250'
    EXCEPTIONS
      error_cntl_create      = 1
      error_cntl_init           = 2
      error_cntl_link           = 3
      error_dp_create        = 4
      gui_type_not_supported = 5.
  gv_text_newtxt = p_text.
  IF gv_text_newtxt <> gv_text_oldtxt.
    REFRESH gi_texttab.
    APPEND gv_text_newtxt TO gi_texttab.
  ENDIF.
  gv_text_editor->set_text_as_r3table( EXPORTING table = gi_texttab[] ).
  gv_text_oldtxt = gv_text_newtxt.
*/.. Set focus on the editor.
  CALL METHOD cl_gui_docking_container=>set_focus
    EXPORTING
      control = gv_text_editor.
  CALL METHOD gv_text_editor->set_readonly_mode
    EXPORTING
      readonly_mode          = 0
    EXCEPTIONS
      error_cntl_call_method = 1
      invalid_parameter      = 2
      OTHERS                 = 3.

Note- In case u want to make this text edit control read only i.e. non editable then pass import parameter readonly_mode = "1" instead of "0" in the method gv_text_editor->set_readonly_mode.  

6) Define and Create GUI Status and Title Bar in the PBO.

  set pf-status 'POPUP'.

  set titlebar 'POPUP'.  

7) In PAI of Screen 9001, User Commands of the screen will be handled:-

  case sy-ucomm.
    when 'OK'.
      gv_text_editor->get_text_as_r3table( importing table =
      gi_texttab[] ).
      export tab from gi_texttab[] to memory id 'ABC' compression on.
      call method cl_gui_cfw=>flush
        exceptions
          others = 3.
      set screen 0.leave screen.
    when 'CANCEL'.
      set screen 0.leave screen.
  endcase.

The Text which is written in text edit control is collected into the internal table GI_TEXTTAB[] and can be used as per the requirement.

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image