Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom control in module pool

Former Member
0 Kudos

Hi gurus,

actually in custom control can we write messages and second thing is that if there r 2 notification no it should display 2 and if 10 then it should display 10.

1 ACCEPTED SOLUTION

former_member212653
Active Contributor
0 Kudos

are you talking about system messges like error message or warning message, if yes, then to tell you custom control has nothing to do with messages. they are displayed in status bar or a popup(information message).

If you want write some text on the custom control then you have to use dynamic documents.

3 REPLIES 3

former_member212653
Active Contributor
0 Kudos

are you talking about system messges like error message or warning message, if yes, then to tell you custom control has nothing to do with messages. they are displayed in status bar or a popup(information message).

If you want write some text on the custom control then you have to use dynamic documents.

former_member212653
Active Contributor
0 Kudos

check out this code:



*&---------------------------------------------------------------------*
*& Report  ZTEST_DYNAMIC_DOCUMENT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztest_dynamic_document.
TYPE-POOLS: sdydo.

DATA:
container TYPE REF TO cl_gui_docking_container,
doc TYPE REF TO cl_dd_document,
ok_code TYPE syucomm.
DATA form1 TYPE REF TO cl_dd_form_area.
DATA text TYPE sdydo_text_element.
DATA value TYPE sdydo_value.
DATA button1 TYPE REF TO cl_dd_button_element.
DATA input1 TYPE REF TO cl_dd_input_element.
DATA first_display VALUE 'X'.
DATA opt_tab TYPE sdydo_option_tab.
DATA select1 TYPE REF TO cl_dd_select_element.
*----------------------------------------------------------------------*
*       CLASS cl_my_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_my_event_handler DEFINITION.
  PUBLIC SECTION.
    METHODS:
 handle_input FOR EVENT  entered OF cl_dd_input_element
                                                       IMPORTING sender,
 handle_submit_buttons FOR EVENT clicked OF cl_dd_button_element
                                                       IMPORTING sender,
  use_new_resources FOR EVENT resources_changed OF cl_gui_resources.
ENDCLASS.                    "cl_my_event_handler DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_my_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_my_event_handler IMPLEMENTATION.
  METHOD handle_input.
    MESSAGE i001(00) WITH input1->value.
  ENDMETHOD.                    "handle_submit_buttons
  METHOD handle_submit_buttons.
    MESSAGE i001(00) WITH input1->value.
  ENDMETHOD.                    "handle_submit_buttons
  METHOD use_new_resources.
    IF first_display IS INITIAL.
* initialize documents
      CALL METHOD doc->initialize_document.
* merge documents
      CALL METHOD doc->merge_document.
* display documents
      CALL METHOD doc->display_document
        EXPORTING
          reuse_control      = 'X'
          reuse_registration = 'X'.
    ENDIF.
  ENDMETHOD.                    "use_new_resources
ENDCLASS.                    "cl_my_event_handler IMPLEMENTATION

START-OF-SELECTION.

  DATA: my_handler TYPE REF TO cl_my_event_handler.
  CREATE OBJECT my_handler .

END-OF-SELECTION.

  CALL SCREEN 100.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS '0100'.
*  SET TITLEBAR 'xxx'.
  SET HANDLER my_handler->use_new_resources.
  CREATE OBJECT doc
     EXPORTING
*    style  =
     background_color = cl_dd_area=>col_background_level2
*    bds_stylesheet =
*    no_margins =
      .
  PERFORM add_html_code.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE ok_code.
    WHEN 'BACK'.
      SET SCREEN 00.
      LEAVE SCREEN.


  ENDCASE.


ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  add_html_code
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM add_html_code .
  IF first_display = 'X'.
    text = 'Hi' &
           'Babes'.
    CALL METHOD doc->add_text
       EXPORTING
         text          = text
*    text_table    =
*    fix_lines     =
     sap_style     = cl_dd_document=>heading
*    sap_color     = cl_dd_document=>LIST_POSITIVE_INT
     sap_fontsize  = cl_dd_document=>medium
*    sap_fontstyle = cl_dd_document=>SANS_SERIF
*    sap_emphasis  = cl_dd_document=>
*    style_class   = cl_dd_document=>WARNING
*  CHANGING
*    document      =
        .


    CALL METHOD doc->new_line
      EXPORTING
        repeat = 1.

    text = 'You r cool...'.
    CALL METHOD doc->add_text
       EXPORTING
         text          = text
*    text_table    =
*    fix_lines     =
     sap_style     = cl_dd_document=>heading
*    sap_color     = cl_dd_document=>LIST_POSITIVE_INT
     sap_fontsize  = cl_dd_document=>medium
*    sap_fontstyle = cl_dd_document=>SANS_SERIF
*    sap_emphasis  = cl_dd_document=>
*    style_class   = cl_dd_document=>WARNING
*  CHANGING
*    document      =
        .


    CALL METHOD doc->add_form
       IMPORTING
         formarea         = form1
*      main_url         =
*      alv_offline_info =
        .
    CALL METHOD form1->line_with_layout
      EXPORTING
        start = 'X'.
    CALL METHOD form1->add_input_element
       EXPORTING
       value         = value
         name          = 'INP1'
         size          = '10'
         maxlength     = '10'
*    sub_area      =
*    tooltip       =
*    tabindex      =
*    hotkey        =
*    a11y_label    =
       IMPORTING
         input_element = input1   .


    SET HANDLER my_handler->handle_input FOR input1.

    CALL METHOD form1->add_gap
      EXPORTING
        width = 1.


    CALL METHOD form1->add_button
      EXPORTING
        sap_icon = 'ICON_EXECUTE_OBJECT'
        tooltip  = 'Hello'
        name     = 'BUT1'
      IMPORTING
        button   = button1.
    SET HANDLER my_handler->handle_submit_buttons FOR button1.

    CALL METHOD form1->line_with_layout
      EXPORTING
        end = 'X'.

    text = 'kasgsjdh'.
    CALL METHOD form1->add_text
      EXPORTING
        text = text.
    CALL METHOD form1->line_with_layout
      EXPORTING
        start = 'X'.
    PERFORM fill_opt_tab CHANGING opt_tab.
    CALL METHOD form1->add_select_element
      EXPORTING
        OPTIONS        = opt_tab
        value          = 'P'
      IMPORTING
        select_element = select1.

    CALL METHOD form1->line_with_layout
      EXPORTING
        end = 'X'.

    CALL METHOD doc->merge_document
      .



    CALL METHOD doc->display_document
       EXPORTING
*      reuse_control      = 'X'
*      reuse_registration = 'X'
         container          = 'CONT'
*    parent             =
      EXCEPTIONS
        html_display_error = 1
        OTHERS             = 2
            .

    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CLEAR first_display.
  ENDIF.
ENDFORM.                    " add_html_code
*&---------------------------------------------------------------------*
*&      Form  fill_opt_tab
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_OPT_TAB  text
*----------------------------------------------------------------------*
FORM fill_opt_tab  CHANGING p_opt_tab TYPE sdydo_option_tab.
  DATA opt TYPE sdydo_option.
  opt-value = 'DER'.
  opt-text  = 'DER'.                                        "#EC NOTEXT
  APPEND opt TO p_opt_tab.
  opt-value = 'SCR'.
  opt-text  =  'SCR'.                                       "#EC NOTEXT
  APPEND opt TO p_opt_tab.
  opt-value = 'TPR'.
  opt-text  = 'TPR'.
  APPEND opt TO p_opt_tab.
  opt-value = 'WIRR'.
  opt-text  = 'WIRR'.
  APPEND opt TO p_opt_tab.
  opt-value = 'CDF'.
  opt-text  = 'CDF'.
  APPEND opt TO p_opt_tab.
ENDFORM.                    " fill_opt_tab

Former Member
0 Kudos

Thanks

But i need notification number thing and about messages i got that pgm thanks for that but please see about notification no