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

sy-ucomm not calling for selection-screen after using call selection-screen in main program.

Former Member
0 Likes
3,796

Dear Gurus,

I am using docking container.

I have come through a strange problem. I have been using Include programes for selection screen and variable decalaration and another include for the Reciver calsses. I have been using Reciver class for creating the toolbar and double click event. With in double click event and toolbar events I am using alot of bapis to fecth the data.

1. The problem is when I CAME back to selection screen using back functionality with statement call selection screen 1000.  Remeber (leave to screen 0 and leave to sreen 1000 is not working). when I use leave to screen 0 it exit from the program instead of leaving to selection screen. Now at selection screen when I press the back or exit button instead of going out of the programe it goes back to the last Run alv results. it is not leaving the programe at selection-screen back and exit funcitonality. any suggesstion how to handle this problem.

I have already used at selection screen event. in the 2nd inlude before class but than it is not executing whole progrme it stays on selection-screen instead of running the class and fetching me the result. Sequence of the includes are.

1. include for the global data and selection screen

2. include for Receiver class

3. include for subroutine used for receiver class.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,119

it should come back to previous screen if you are using leave to screen 0.

are you displaying alv grid on a custom screen and handling the toolbar and double click events on the grid?

is it possible for you to paste your code here...

12 REPLIES 12
Read only

Former Member
0 Likes
3,120

it should come back to previous screen if you are using leave to screen 0.

are you displaying alv grid on a custom screen and handling the toolbar and double click events on the grid?

is it possible for you to paste your code here...

Read only

0 Likes
3,119

Dear Tiki patra,

The code is too long.

I have been using the double click even on alv container the container is docking container at bottom.

at pf-status I have been using my own execute, back and exit funcitonality.

Regards,

Read only

0 Likes
3,119

HERE IS THE SAMPLE CODE.


PROGRAM ZBCALV_GRID_05.

*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

* Purpose:

* ~~~~~~~~

* Demonstrate the creation of an own toolbar button.

*-----------------------------------------------------------------

* To check program behavior

* ~~~~~~~~~~~~~~~~~~~~~~~~~

* The report shows a list of flights of one airline.

* Select one or more lines and press the 'Detail'-Button to popup

* a dialog window with related bookings.

*-------------------------------------------------------------------

* Essential steps (Search for '§')

* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* 1.Apply steps for event handling for events TOOLBAR and

*   USER_COMMAND (see example for print events)

* 2.In event handler method for event TOOLBAR: Append own functions

*   by using event parameter E_OBJECT.

* 3.In event handler method for event USER_COMMAND: Query your

*   function codes defined in step 2 and react accordingly.

* 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.

*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

TABLES: SPFLI.

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

   SELECT-OPTIONS: S_CARRID FOR SPFLI-CARRID.

SELECTION-SCREEN: END OF BLOCK B1.

INCLUDE <icon>.

*********

* Predefine a local class for event handling to allow the

* declaration of a reference variable before the class is defined.

CLASS lcl_event_receiver DEFINITION DEFERRED.

*

*********

DATA: ok_code LIKE sy-ucomm,

       gt_sflight TYPE TABLE OF sflight,

       gt_sbook TYPE TABLE OF sbook,

       g_repid LIKE sy-repid,

       g_max type i value 100,

       gs_layout   TYPE lvc_s_layo,

       cont_on_main   TYPE scrfname VALUE 'BCALVC_TOOLBAR_D100_C1',

       cont_on_dialog TYPE scrfname VALUE 'BCALVC_TOOLBAR_D101_C1',

       grid1  TYPE REF TO cl_gui_alv_grid,

       grid2  TYPE REF TO cl_gui_alv_grid,

       custom_container1 TYPE REF TO cl_gui_custom_container,

       custom_container2 TYPE REF TO cl_gui_custom_container,

       event_receiver TYPE REF TO lcl_event_receiver.

* Set initial dynpro

SET SCREEN 100.

****************************************************************

* LOCAL CLASSES: Definition

****************************************************************

*===============================================================

* class lcl_event_receiver: local class to

*                         define and handle own functions.

*

* Definition:

* ~~~~~~~~~~~

CLASS lcl_event_receiver DEFINITION.

   PUBLIC SECTION.

     METHODS:

     handle_toolbar

         FOR EVENT toolbar OF cl_gui_alv_grid

             IMPORTING e_object e_interactive,

     handle_user_command

         FOR EVENT user_command OF cl_gui_alv_grid

             IMPORTING e_ucomm.

   PRIVATE SECTION.

ENDCLASS.

*

* lcl_event_receiver (Definition)

*===============================================================

****************************************************************

* LOCAL CLASSES: Implementation

****************************************************************

*===============================================================

* class lcl_event_receiver (Implementation)

*

*

CLASS lcl_event_receiver IMPLEMENTATION.

   METHOD handle_toolbar.

* § 2.In event handler method for event TOOLBAR: Append own functions

*   by using event parameter E_OBJECT.

     DATA: ls_toolbar  TYPE stb_button.

*....................................................................

* E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.

* This class has got one attribute, namly MT_TOOLBAR, which

* is a table of type TTB_BUTTON. One line of this table is

* defined by the Structure STB_BUTTON (see data deklaration above).

*

* A remark to the flag E_INTERACTIVE:

* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*         'e_interactive' is set, if this event is raised due to

*         the call of 'set_toolbar_interactive' by the user.

*         You can distinguish this way if the event was raised

*         by yourself or by ALV

*         (e.g. in method 'refresh_table_display').

*         An application of this feature is still unknown... 🙂

* append a separator to normal toolbar

     CLEAR ls_toolbar.

     MOVE 3 TO ls_toolbar-butn_type.

     APPEND ls_toolbar TO e_object->mt_toolbar.

* append an icon to show booking table

     CLEAR ls_toolbar.

     MOVE 'BOOKINGS' TO ls_toolbar-function.

     MOVE icon_employee TO ls_toolbar-icon.

     MOVE 'Show Bookings'(111) TO ls_toolbar-quickinfo.

     MOVE 'Detail'(112) TO ls_toolbar-text.

     MOVE ' ' TO ls_toolbar-disabled.

     APPEND ls_toolbar TO e_object->mt_toolbar.

   ENDMETHOD.

*-------------------------------------------------------------------

   METHOD handle_user_command.

* § 3.In event handler method for event USER_COMMAND: Query your

*   function codes defined in step 2 and react accordingly.

     DATA: lt_rows TYPE lvc_t_row.

     CASE e_ucomm.

       WHEN 'BOOKINGS'.

         CALL METHOD grid1->get_selected_rows

                  IMPORTING et_index_rows = lt_rows.

         CALL METHOD cl_gui_cfw=>flush.

         IF sy-subrc ne 0.

* add your handling, for example

           CALL FUNCTION 'POPUP_TO_INFORM'

                EXPORTING

                     titel = g_repid

                     txt2  = sy-subrc

                     txt1  = 'Error in Flush'(500).

         else.

                   perform show_booking_table tables lt_rows.

         ENDIF.

     ENDCASE.

   ENDMETHOD.                           "handle_user_command

*-----------------------------------------------------------------

ENDCLASS.

*

* lcl_event_receiver (Implementation)

*===================================================================

*---------------------------------------------------------------------*

*       FORM EXIT_PROGRAM                                             *

*---------------------------------------------------------------------*

FORM exit_program.

* The instance grid2 is freed not until the program exits from the

* main screen.

* (It is created only once during the first selection of SBOOK,

* no matter how many times the second window is called).

*

   CALL METHOD custom_container1->free.

   IF not custom_container2 is initial.

     CALL METHOD custom_container2->free.

   ENDIF.

   CALL METHOD cl_gui_cfw=>flush.

   IF sy-subrc ne 0.

* add your handling, for example

     CALL FUNCTION 'POPUP_TO_INFORM'

          EXPORTING

               titel = g_repid

               txt2  = sy-subrc

               txt1  = 'Error in Flush'(500).

   ENDIF.

   LEAVE PROGRAM.

ENDFORM.

*&---------------------------------------------------------------------*

*&      Module  PBO_100  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE pbo_100 OUTPUT.

   SET PF-STATUS 'MAIN100'.

   SET TITLEBAR 'MAIN100'.

   g_repid = sy-repid.

   IF custom_container1 is initial.

* select data from table SFLIGHT

     PERFORM select_table_sflight CHANGING gt_sflight.

* create a custom container control for our ALV Control

     CREATE OBJECT custom_container1

         EXPORTING

             container_name = cont_on_main

         EXCEPTIONS

             cntl_error = 1

             cntl_system_error = 2

             create_error = 3

             lifetime_error = 4

             lifetime_dynpro_dynpro_link = 5.

     IF sy-subrc ne 0.

* add your handling, for example

       CALL FUNCTION 'POPUP_TO_INFORM'

            EXPORTING

                 titel = g_repid

                 txt2  = sy-subrc

                 txt1  = 'The control could not be created'(510).

     ENDIF.

* create an instance of alv control

     CREATE OBJECT grid1

            EXPORTING i_parent = custom_container1.

*

* Set a titlebar for the grid control

*

     gs_layout-grid_title = 'Flights'(100).

* allow to select multiple lines

     gs_layout-sel_mode = 'A'.

     CALL METHOD grid1->set_table_for_first_display

          EXPORTING i_structure_name = 'SFLIGHT'

                    is_layout        = gs_layout

          CHANGING  it_outtab        = gt_sflight.

********

* ->Create Object to receive events and link them to handler methods.

* When the ALV Control raises the event for the specified instance

* the corresponding method is automatically called.

*

     CREATE OBJECT event_receiver.

     SET HANDLER event_receiver->handle_user_command FOR grid1.

     SET HANDLER event_receiver->handle_toolbar FOR grid1.

*

********

* § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.

     CALL METHOD grid1->set_toolbar_interactive.

   ENDIF.                               "IF grid1 IS INITIAL

   CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid1.

ENDMODULE.                             " PBO_100  OUTPUT

*&---------------------------------------------------------------------*

*&      Module  PAI_100  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE pai_100 INPUT.

OK_CODE = SY-UCOMM.

   CASE ok_code.

     WHEN 'EXIT'.

       PERFORM exit_program.

       WHEN 'BACK'.

         CALL SELECTION-SCREEN 1000.

*         LEAVE TO SCREEN 0.

   ENDCASE.

   CLEAR ok_code.

ENDMODULE.                             " PAI_100  INPUT

*&---------------------------------------------------------------------*

*&      Module  PBO_0101  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE pbo_0101 OUTPUT.

   IF custom_container2 is initial.

* (the data from sbook is already selected)

* create a custom container control for our ALV Control

     CREATE OBJECT custom_container2

         EXPORTING

             container_name = cont_on_dialog

         EXCEPTIONS

             cntl_error = 1

             cntl_system_error = 2

             create_error = 3

             lifetime_error = 4

             lifetime_dynpro_dynpro_link = 5.

     IF sy-subrc ne 0.

* add your handling, for example

       CALL FUNCTION 'POPUP_TO_INFORM'

            EXPORTING

                 titel = g_repid

                 txt2  = sy-subrc

                 txt1  = 'The control could not be created'(510).

     ENDIF.

* create an instance of alv control

     CREATE OBJECT grid2

            EXPORTING i_parent = custom_container2.

*

* change title

*

     gs_layout-grid_title = 'Bookings'(101).

     gs_layout-sel_mode = ' '.

     CALL METHOD grid2->set_table_for_first_display

          EXPORTING i_structure_name = 'SBOOK'

                    is_layout        = gs_layout

          CHANGING  it_outtab        = gt_sbook.

   ELSE.

     CALL METHOD grid2->refresh_table_display.

   ENDIF.                               "IF custom_container2 IS INITIAL.

   CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid2.

   CALL METHOD cl_gui_cfw=>flush.

   IF sy-subrc ne 0.

* add your handling, for example

     CALL FUNCTION 'POPUP_TO_INFORM'

          EXPORTING

               titel = g_repid

               txt2  = sy-subrc

               txt1  = 'Error in Flush'(500).

   ENDIF.

ENDMODULE.                             " PBO_0101  OUTPUT

*&---------------------------------------------------------------------*

*&      Form  SELECT_TABLE_SFLIGHT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      <--P_GT_SFLIGHT  text

*----------------------------------------------------------------------*

FORM select_table_sflight CHANGING p_gt_sflight LIKE gt_sflight[].

   SELECT * FROM sflight INTO TABLE p_gt_sflight WHERE CARRID IN S_CARRID.

ENDFORM.                               " SELECT_TABLE_SFLIGHT

*&---------------------------------------------------------------------*

*&      Form  SELECT_TABLE_SBOOK

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->P_LS_SFLIGHT  text

*      <--P_GT_SBOOK  text

*----------------------------------------------------------------------*

FORM select_table_sbook USING    p_ls_sflight LIKE LINE OF gt_sflight

                         CHANGING p_gt_sbook LIKE gt_sbook[].

   DATA: lt_sbook LIKE gt_sbook[].

* Select data from sbook according to a line of sflight

* and append that data to table p_gt_sbook

*

   SELECT * FROM  sbook INTO TABLE lt_sbook

          WHERE  carrid  = p_ls_sflight-carrid

          AND    connid  = p_ls_sflight-connid

          AND    fldate  = p_ls_sflight-fldate.

   APPEND LINES OF lt_sbook TO p_gt_sbook.

ENDFORM.                               " SELECT_TABLE_SBOOK

*&---------------------------------------------------------------------*

*&      Module  PAI_0101  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE pai_0101 INPUT.

   CASE ok_code.

     WHEN 'RETURN'.

       LEAVE TO SCREEN 0.

   ENDCASE.

   CLEAR ok_code.

ENDMODULE.                             " PAI_0101  INPUT

*&---------------------------------------------------------------------*

*&      Form  show_booking_table

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->P_ET_INDEX_ROWS  text

*----------------------------------------------------------------------*

FORM show_booking_table TABLES p_et_index_rows

                                 STRUCTURE lvc_s_row.

   DATA: ls_selected_line LIKE lvc_s_row,

         lf_row_index TYPE lvc_index,

         ls_sflight LIKE LINE OF gt_sflight.

   CLEAR gt_sbook[].

   LOOP AT p_et_index_rows INTO ls_selected_line.

     lf_row_index = ls_selected_line-index.

* read selected row from internal table gt_sflight

     READ TABLE gt_sflight INDEX lf_row_index INTO ls_sflight.

* select corresponding lines of table sbook

* and append new lines to global table

     PERFORM select_table_sbook USING ls_sflight

                                CHANGING gt_sbook.

   ENDLOOP.

* call dialog screen and display new alv control

   CALL SCREEN 101 STARTING AT 10 5.

ENDFORM.                               " show_booking_table

Read only

0 Likes
3,119

In your program, use leave to screen 0 instead of CALL SELECTION-SCREEN 1000.

*----------------------------------------------------------------------*

MODULE pai_100 INPUT.

OK_CODE = SY-UCOMM.

   CASE ok_code.

     WHEN 'EXIT'.

       PERFORM exit_program.

       WHEN 'BACK'.

         CALL SELECTION-SCREEN 1000.

*         LEAVE TO SCREEN 0.

   ENDCASE.

   CLEAR ok_code.

ENDMODULE.                             " PAI_100  INPUT


I tried same and it worked for me.


Let me know if you have any questions.

Read only

0 Likes
3,119

Dear Tiki Patra,

Try the sample code and than give me the answer.

Regards,

Read only

0 Likes
3,119

Off course I tried your sample code and then replied:)

Read only

0 Likes
3,119

Tiki Patra,

             But I have been facing the same issue. What will be the problem.

Regards,

Read only

0 Likes
3,119

Dear Tiki patra,

              first execute through selection. and then press the back button again press the back button at selection screen what is the behaviour than. In my case it is returning back to report. and even on exit it return back to the report instead of exiting.

Regards,

Read only

0 Likes
3,119

When using CALL SELECTION-SCREEN 1000 , it is returning back to the report, but when I used LEAVE TO SCREEN 0 it is properly navigating. I am not sure why LEAVE TO SCREEN 0 is not working for you but it should work.

you can also use:

CASE ok_code.

      WHEN 'BACK' OR 'EXIT'.

          LEAVE TO SCREEN 0.

    ENDCASE.

Read only

0 Likes
3,119

instead of  SET SCREEN 100. use CALL SCREEN 100 in START-OF-SELECTION event and then use

LEAVE TO SCREEN 0. it should work.

Read only

0 Likes
3,119

Tiki patra,

Thank you very much for All of you.

The problem is resolved I have use the LEAVE TO TRANSACTION SY-TCODE. It is working  fine now.  But remeber you have to create a  z t-code for the report to execute this leave to transaction event. I m closing the thread. Execute the report thruogh youir code. through se38 and se80 you might not get the desire result.

Regards,

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
3,119

How do you display this ALV: "...last Run alv results..."? With REUSE FM, SALV..?


With REUSE FM try set rs_selfield-exit = 'X' in user command.

With OO ALVs try destroy/free objects (ALV,container..) when you leave ALV.

-- Tomas --