Sunday, 17 August 2014

F1 HELP FOR PARAMETERS : RADIOBUTTON , CHECKBOX , SELECT-OPTIOS PROGRAMATICALLY IN SAP ABAP:

In this SAP ABAP tutorial I will show you how what F1 help is and how to use it.
 F1 help contains the documentation (usually the name of the field , 
their technical attributes , their uses etc.) about the field.
 F1 help can be standard or can be custom to meet specific client requirements.
Whenever we are pressing F1 help it is triggering the event
AT SELECTION-SCREEN ON HELP-REQUEST FOR <field_name>.
Where <field_name> may be parameters, checkbox, radiobutton etc.
So by pressing F1 help all the codes inside the event AT SELECTION-SCREEN ON HELP-REQUEST FOR <field_name> will be triggered.
Whenever we are referring to standard data element then F1 help will automatically come if the documentation of that field is maintained.
Please refer to the following source code :

E.g. : REPORT  ztest_r_04.

PARAMETERSp_matnr TYPE matnr.
Output:
SAP ABAP
SAP ABAP





Now press F1
SAP ABAP
SAP ABAP




The documentation came because matnr is a standard data element and its F1 help is maintained by SAP.
You can check the F1 help documentation by going to the data element and click on the documentation button on the application toolbar.
SAP ABAP
SAP ABAP











However, you can override the standard F1 help documentation with your client specific documentation.
Function module COPO_POPUP_TO_DISPLAY_TEXTLIST’ is used to call the documentation screen.
In the exporting parameter pass the title name to be displayed in the title bar of the pop-up screen for F1 help and in the tables parameter pass an internal table of typeTLINE.
Populate the internal table with two fields TDFORMAT - Tag column (U1) and TDLINE - Text Line (text to be displayed in the F1 help screen)
Please refer to the following source code:

REPORT  ztest_r_04.

PARAMETERS p_matnr TYPE matnr.
DATA gt_text  TYPE TABLE OF tline INITIAL SIZE 1,
       gs_text  TYPE tline.
AT SELECTION-SCREEN ON HELP-REQUEST FOR p_matnr.

  REFRESH gt_text[].
  CLEAR gs_text.

  gs_text-tdformat 'U1'.
  gs_text-tdline 'F1 HELP FOR RADIO BUTTON GREAT'.
  APPEND gs_text TO gt_text.
  CLEAR gs_text.

  CALL FUNCTION 'COPO_POPUP_TO_DISPLAY_TEXTLIST'
    EXPORTING
      titel      'F1 HELP'
    TABLES
      text_table gt_text.
Output :
SAP ABAP
SAP ABAP




Now press F1
SAP ABAP
SAP ABAP












As you can see the above F1 HELP Documentation is custom defined documentation that is made by us.
Now , let us learn how to make F1 help for radiobutton, checkbox, elementary data types (I, f, p, c, n) etc.
Please refer to the following source code :
REPORT  ztestr_f1_help.

DATA : gt_text  TYPE TABLE OF tline INITIAL SIZE 1,
              gs_text  TYPE tline.

PARAMETERS : p_matnr  TYPE matnr,
             rb_great RADIOBUTTON GROUP rad1 DEFAULT 'X',
             rb_less  RADIOBUTTON GROUP rad1,
             ck_show  AS CHECKBOX,
             p_row    TYPE i.

AT SELECTION-SCREEN ON HELP-REQUEST FOR rb_great.

  REFRESH : gt_text[].
  CLEAR : gs_text.

  gs_text-tdformat = 'U1'.
  gs_text-tdline = 'F1 HELP FOR RADIO BUTTON GREAT'.
  APPEND gs_text TO gt_text.
  CLEAR gs_text.

  CALL FUNCTION 'COPO_POPUP_TO_DISPLAY_TEXTLIST'
    EXPORTING
      titel      = 'F1 HELP'
    TABLES
      text_table = gt_text.

AT SELECTION-SCREEN ON HELP-REQUEST FOR rb_less.

  REFRESH : gt_text[].
  CLEAR : gs_text.

  gs_text-tdformat = 'U1'.
  gs_text-tdline = 'F1 HELP FOR RADIO BUTTON LESS'.
  APPEND gs_text TO gt_text.
  CLEAR gs_text.

  CALL FUNCTION 'COPO_POPUP_TO_DISPLAY_TEXTLIST'
    EXPORTING
      titel      = 'F1 HELP'
    TABLES
      text_table = gt_text.

AT SELECTION-SCREEN ON HELP-REQUEST FOR ck_show.

  REFRESH : gt_text[].
  CLEAR : gs_text.

  gs_text-tdformat = 'U1'.
  gs_text-tdline = 'F1 HELP FOR CHECKBOX SHOW'.
  APPEND gs_text TO gt_text.
  CLEAR gs_text.

  CALL FUNCTION 'COPO_POPUP_TO_DISPLAY_TEXTLIST'
    EXPORTING
      titel      = 'F1 HELP'
    TABLES
      text_table = gt_text.

AT SELECTION-SCREEN ON HELP-REQUEST FOR p_row.

  REFRESH : gt_text[].
  CLEAR : gs_text.

  gs_text-tdformat = 'U1'.
  gs_text-tdline = 'F1 HELP FOR PARAMETER ROW'.
  APPEND gs_text TO gt_text.
  CLEAR gs_text.

  CALL FUNCTION 'COPO_POPUP_TO_DISPLAY_TEXTLIST'
    EXPORTING
      titel      = 'F1 HELP'
    TABLES
      text_table = gt_text. 
Output :
SAP ABAP
SAP ABAP






Now, put the cursor on rb_great – radiobutton and press F1.
SAP ABAP
SAP ABAP











Put the cursor on checkbox and press F1
SAP ABAP
SAP ABAP











You can also assign F1 help for elementary data type such as I , p , f , c , n etc.
PARAMETERS p_row    TYPE i.
SAP ABAP
SAP ABAP









Thanks a lot again friends for reading this tutorial. If you find this is useful and helpful to you, please consider it sharing to your friends using the social buttons below. 
Thank you and I invite everyone to connect with me on my facebook page ABAP TOPICS or follow me on goole plus. You can subscribe also to keep updated with latest posts. Enjoy reading this blog .
Please mail all your contributions to roushan.c.kumar@gmail.com . We request you to mention your Name & Organization you are working for. Your posts will be verified and posted in this site with your name.



No comments:

Post a Comment