Skip to Content
0
Former Member
Feb 13, 2009 at 10:59 AM

Moving from One screen to another.

1241 Views

Moved to correct forum by moderator

hi,

In my code given below, what i am trying is at Screen 100 i am showing an ALV display .

This screen has some buttons (delete, refresh, change) at the Application Tool Bar.

On pressing Change i called another Screen ie Screen No 200, where i have a button on it.

But what is happning is , when I execute its showing mw the same ALV display after pressing the change button on the tool bar without the the buttons of screen 100 on the Application Tool Bar.

I want the Screen to show me the Button (modify) that I have on this screen 200 and not the display that is there in screen 100.

What is going wrong ?

******DEFINATION OF CLASSS**********
CLASS for_hotspot DEFINITION.
  PUBLIC SECTION.
    METHODS hand_click FOR EVENT hotspot_click OF cl_gui_alv_grid
                                IMPORTING e_row_id e_column_id.
ENDCLASS.

*******IMPLEMENTATION OF CLASS***********SN71245
CLASS for_hotspot IMPLEMENTATION.
  METHOD hand_click.
    PERFORM hand_click_form USING e_row_id e_column_id.
  ENDMETHOD.
ENDCLASS.

DATA: i_zempl TYPE STANDARD TABLE OF zempl,
      wa_zempl LIKE LINE OF i_zempl,
      s_grid              TYPE REF TO cl_gui_alv_grid,
      s_custom_container  TYPE REF TO cl_gui_custom_container,
      s_count(12)     TYPE c   VALUE 'S_CONTAINER',

      i_fieldcat            TYPE lvc_t_fcat,
      wa_fieldcat           TYPE lvc_s_fcat,
      g_event_receiver      TYPE REF TO for_hotspot.


SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
SELECT-OPTIONS s_empno FOR wa_zempl-empno.
SELECTION-SCREEN END OF BLOCK a.

START-OF-SELECTION.
  SELECT * FROM zempl INTO TABLE i_zempl
           WHERE empno IN s_empno.
  SORT i_zempl BY empno.

  CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  PAI  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pai INPUT.
  CASE sy-ucomm.
    WHEN 'DELETE'.
      DELETE FROM zempl WHERE empno = wa_zempl-empno.

    WHEN 'REFERESH'.
      SELECT * FROM zempl INTO TABLE i_zempl
               WHERE empno IN s_empno.

      CALL METHOD s_grid->set_table_for_first_display
         EXPORTING i_structure_name = 'ZEMPL'
         CHANGING  it_outtab        = i_zempl
                   it_fieldcatalog   = i_fieldcat.

    WHEN 'CHANGE'.
      CALL SCREEN 200.


    WHEN 'EXIT'.
      LEAVE PROGRAM.

    WHEN OTHERS.
  ENDCASE.
ENDMODULE.                 " PAI  INPUT

*&---------------------------------------------------------------------*
*&      Module  PBO  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'ASSIG_10'.
  SET TITLEBAR 'employe informatin table'.
* build field catalog
  wa_fieldcat-tabname    = 'I_EMPL'.
  wa_fieldcat-hotspot    = 'X'.
  wa_fieldcat-col_pos      = '1'.
  wa_fieldcat-fieldname    = 'EMPNO'.
*   wa_fieldcat-key          = 'X'.
  wa_fieldcat-outputlen    = '10'.
  wa_fieldcat-scrtext_s    = 'Emp Number'.
  APPEND wa_fieldcat TO i_fieldcat.
  CLEAR wa_fieldcat.

  IF s_custom_container IS INITIAL.
    CREATE OBJECT s_grid
          EXPORTING i_parent = s_custom_container.

    CREATE OBJECT s_custom_container
          EXPORTING container_name = s_count.


    CREATE OBJECT g_event_receiver.
    SET HANDLER g_event_receiver->hand_click
                             FOR s_grid.

    CALL METHOD s_grid->set_table_for_first_display
         EXPORTING i_structure_name = 'ZEMPL'
         CHANGING  it_outtab        = i_zempl
                   it_fieldcatalog   = i_fieldcat.
  ENDIF.

ENDMODULE.                 " PBO  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  hand_click_form
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_E_ROW_ID  text
*      -->P_E_COLUMN_ID  text
*----------------------------------------------------------------------*
FORM hand_click_form USING    p_e_row_id TYPE lvc_s_row
                              p_e_column_id TYPE lvc_s_col.
  READ TABLE i_zempl INTO wa_zempl
                     INDEX p_e_row_id-index.

ENDFORM.                    " hand_click_form

*&---------------------------------------------------------------------*
*&      Module  STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0200 OUTPUT.
  SET PF-STATUS 'ASSIG'.
ENDMODULE.                 " STATUS_0200  OUTPUT


*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0200  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0200 INPUT.

  CASE sy-ucomm.
    WHEN 'EXIT'.
      LEAVE TO SCREEN 0.

    WHEN 'MODIFY'.
      CLEAR wa_zempl.
      wa_zempl-empno      =  wa_zempl-empno.
      wa_zempl-name       =  wa_zempl-name.
      wa_zempl-country    =  wa_zempl-country.
      wa_zempl-department =  wa_zempl-department.
      wa_zempl-salary     =  wa_zempl-salary.
      wa_zempl-unit       =  wa_zempl-unit.

      APPEND wa_zempl TO i_zempl.
      MODIFY zempl FROM TABLE i_zempl.

      SELECT * FROM zempl INTO TABLE i_zempl
                     WHERE empno IN s_empno.     .

      CALL METHOD s_grid->set_table_for_first_display
         EXPORTING i_structure_name = 'ZEMPL'
         CHANGING  it_outtab        = i_zempl
                   it_fieldcatalog   = i_fieldcat.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0200  INPUT

Edited by: Matt on Feb 13, 2009 12:08 PM - please surround any ABAP you write with - I've done it for you this time.