Application Development and Automation 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: 
Read only

Capture Selection-screen events

Former Member
0 Likes
714

Dear SAP friends,

I have created OOP report.

At the runtime the program creates toolbar and adds pushbuttons to it.

Every button has fcode assigned.

On button click the below method is called.

The below statement "CALL SELECTION-SCREEN 1200 STARTING AT 10 10" calls selection screen as popup.

I need to capture when User closes the selection popup and when he clicks Cancel button located in the selection popup.

Please advise.

Regards

Tatyana.

METHOD  handle_pushbutton_click.
CASE fcode.
      WHEN 'CHECKS_EXP'.
        CALL SELECTION-SCREEN 1200 STARTING AT 10 10.
        PERFORM at_selection_1200.
        CHECK w_continue = abap_true.
        PERFORM build_options_range.
        PERFORM build_options_norange.
        PERFORM start_selection_1200.
        PERFORM fcat_init_1200.

        w_title = 'Checks -> Expenditures'.
        PERFORM set_layout USING w_title.
        PERFORM getdata_1200.

        DESCRIBE TABLE lt_rpt LINES w_count.      " Get number of records.
        PERFORM populate_selection USING w_count.

ENDDCASE.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
674

Hello Tatyana

The following sample report ZUS_SDN_OO_REPORT_SELSCREEN should simulate your scenario.

If you push the EXECUTE button you will find ok-code='CRET'.

If you close the popup or push the CANCEL button ok-code=' ' (space; empty). This way you know that the popup was closed by the user.


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_OO_REPORT_SELSCREEN
*&
*&---------------------------------------------------------------------*
*& Thread: Capture Selection-screen events
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1205127"></a>
*&---------------------------------------------------------------------*

REPORT  zus_sdn_oo_report_selscreen.


*----------------------------------------------------------------------*
*       CLASS lcl_myclass DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_myclass DEFINITION.

  PUBLIC SECTION.
    CLASS-DATA:
      md_okcode   TYPE ui_func.

    CLASS-METHODS:
      handle_pushbutton_click.

ENDCLASS.                    "lcl_myclass DEFINITION


*----------------------------------------------------------------------*
*       CLASS lcl_myclass IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_myclass IMPLEMENTATION.

  METHOD handle_pushbutton_click.
    DATA: ld_msg    TYPE bapi_msg.
    BREAK-POINT.

    CLEAR: lcl_myclass=>md_okcode.

    DO.
      CALL SELECTION-SCREEN 1200 STARTING AT 10 10.

      EXIT.
    ENDDO.

    CONCATENATE 'ok-code =' md_okcode INTO ld_msg
      SEPARATED BY space.
    MESSAGE ld_msg TYPE 'I'.

    MESSAGE 'Continue after SelScreen' TYPE 'S'.
  ENDMETHOD.                    "handle_pushbutton_click

ENDCLASS.                    "lcl_myclass IMPLEMENTATION



SELECTION-SCREEN BEGIN OF SCREEN 1200.
PARAMETERS:
  p_bukrs   TYPE bukrs.
SELECTION-SCREEN END OF SCREEN 1200.

AT SELECTION-SCREEN OUTPUT.
  BREAK-POINT.
  CLEAR: syst-ucomm.

AT SELECTION-SCREEN.
  BREAK-POINT.
  lcl_myclass=>md_okcode = syst-ucomm.


START-OF-SELECTION.

  lcl_myclass=>handle_pushbutton_click( ).


END-OF-SELECTION.

Regards

Uwe

Dear SAP friends,

I have created OOP report.

At the runtime the program creates toolbar and adds pushbuttons to it.

Every button has fcode assigned.

On button click the below method is called.

The below statement "CALL SELECTION-SCREEN 1200 STARTING AT 10 10" calls selection screen as popup.

I need to capture when User closes the selection popup and when he clicks Cancel button located in the selection popup.

Please advise.

Regards

Tatyana.

METHOD  handle_pushbutton_click.
CASE fcode.
      WHEN 'CHECKS_EXP'.
        CALL SELECTION-SCREEN 1200 STARTING AT 10 10.
        PERFORM at_selection_1200.
        CHECK w_continue = abap_true.
        PERFORM build_options_range.
        PERFORM build_options_norange.
        PERFORM start_selection_1200.
        PERFORM fcat_init_1200.

        w_title = 'Checks -> Expenditures'.
        PERFORM set_layout USING w_title.
        PERFORM getdata_1200.

        DESCRIBE TABLE lt_rpt LINES w_count.      " Get number of records.
        PERFORM populate_selection USING w_count.

ENDDCASE.

2 REPLIES 2
Read only

uwe_schieferstein
Active Contributor
0 Likes
675

Hello Tatyana

The following sample report ZUS_SDN_OO_REPORT_SELSCREEN should simulate your scenario.

If you push the EXECUTE button you will find ok-code='CRET'.

If you close the popup or push the CANCEL button ok-code=' ' (space; empty). This way you know that the popup was closed by the user.


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_OO_REPORT_SELSCREEN
*&
*&---------------------------------------------------------------------*
*& Thread: Capture Selection-screen events
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1205127"></a>
*&---------------------------------------------------------------------*

REPORT  zus_sdn_oo_report_selscreen.


*----------------------------------------------------------------------*
*       CLASS lcl_myclass DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_myclass DEFINITION.

  PUBLIC SECTION.
    CLASS-DATA:
      md_okcode   TYPE ui_func.

    CLASS-METHODS:
      handle_pushbutton_click.

ENDCLASS.                    "lcl_myclass DEFINITION


*----------------------------------------------------------------------*
*       CLASS lcl_myclass IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_myclass IMPLEMENTATION.

  METHOD handle_pushbutton_click.
    DATA: ld_msg    TYPE bapi_msg.
    BREAK-POINT.

    CLEAR: lcl_myclass=>md_okcode.

    DO.
      CALL SELECTION-SCREEN 1200 STARTING AT 10 10.

      EXIT.
    ENDDO.

    CONCATENATE 'ok-code =' md_okcode INTO ld_msg
      SEPARATED BY space.
    MESSAGE ld_msg TYPE 'I'.

    MESSAGE 'Continue after SelScreen' TYPE 'S'.
  ENDMETHOD.                    "handle_pushbutton_click

ENDCLASS.                    "lcl_myclass IMPLEMENTATION



SELECTION-SCREEN BEGIN OF SCREEN 1200.
PARAMETERS:
  p_bukrs   TYPE bukrs.
SELECTION-SCREEN END OF SCREEN 1200.

AT SELECTION-SCREEN OUTPUT.
  BREAK-POINT.
  CLEAR: syst-ucomm.

AT SELECTION-SCREEN.
  BREAK-POINT.
  lcl_myclass=>md_okcode = syst-ucomm.


START-OF-SELECTION.

  lcl_myclass=>handle_pushbutton_click( ).


END-OF-SELECTION.

Regards

Uwe

Read only

Former Member
0 Likes
674

Thank you Uwe!

Regards,

Tatyana