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

Selection screen navigation

0 Likes
1,015

Hi Collegue,

I have 1st selection screen where Iinput some value and navigate to 2nd selection screen where i can give selection parameter values and execute and get an alv. now if I press back button i have to navigate to second selection screen and the values in 2nd selection screen should be preserved.

Any suggestion how can I do it.

Regards,

Saurabh

5 REPLIES 5
Read only

Former Member
0 Likes
938

Hi ,

please note to do this properly

You can achieve this by creating two screens ( dynpro ) and to implement the corresponding PBO and PAI

in the PAI of the second screen module user_command should handle a PF Status with the button 'BACK' ,( add a pf_status to your screen and give code fonction 'BACK' to the button back )

Module USER_COMMADE using sy-ucomm .

.....

.....

case sy-ucomm .

when 'BACK'.

set screen 0.

when ...

......

Endcase.

ENDMODULE.

all inputs will be still there in defined strcutures , if clear statements arn't within the PAI/PBO of your screens .

Best Regards .


Read only

0 Likes
938

Hi Kassa,

Thanks for suggestion.

My scenario is little different.

The 1st and 2nd screen are designed by select-options .

So i dont have PBO and PAI here.

Also in some place I am using dynamic report where again i have select-option for that scenario also I have to retain the value on back.

Regards,

Saurabh

Read only

0 Likes
938

Hi Saurbh

Let`s say you have selection screen 100 and 200.

DATA: i_seltab LIKE STANDARD TABLE OF rsparams,
          v_program LIKE sy-repid.

In your start-of-selection event.

PERFROM f_get_selection_values.

When you click back button in user command.

PERFORM f_exit_program.

FORM f_get_selections_values.
  v_program = sy-repid.
  CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
      curr_report     = v_program  " Your program Name
    TABLES
      selection_table = i_seltab
    EXCEPTIONS
      not_found       = 1
      no_report       = 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.

ENDFORM.                    "f_get_selections_values

*&---------------------------------------------------------------------*
*&      Form  f_exit_program
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM f_exit_program.
  SUBMIT (v_program) USING SELECTION-SCREEN 200
        WITH SELECTION-TABLE i_seltab
   VIA SELECTION-SCREEN.
ENDFORM.

Regards,

Archer

Read only

0 Likes
938

hi Archer,

Thanks for a wonderful explanation for dynamic slection screen.

Here in my scenario I have 2 selection screen:-1st is standard selection screen of 1000 then i have selection screen 200 having many select-option field and if i input something i navigate to alv.

Now from alv if i press back i have to come back to selection screen 200 and if user input some more value the alv data should be changed based on new selection criteria.

Here from pai of alv on back button i am calling selection screen 200 and user can enter the data but my select query is unable to get this new select option because my control is still in PAI of alv.

Any suggestion is welcome.

Regards,

Saurabh

Read only

0 Likes
938

hi Saurabh

I wrote a test program as follow, when back to screen 200, To add new data to S_WERKS or S_LGORT, ALV data will also changed based on new selection entries.

*&---------------------------------------------------------------------*
*& Report  ZARCHER_0134
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zarcher_0134.

TYPE-POOLS slis.
TABLES: mard.
DATA: i_seltab LIKE STANDARD TABLE OF rsparams,
      v_program LIKE sy-repid.
DATA: BEGIN OF st_itab,
  matnr TYPE mard-matnr,
  werks TYPE mard-werks,
  lgort TYPE mard-lgort,
  labst TYPE mard-labst,
  END OF st_itab,
  it_itab LIKE STANDARD TABLE OF st_itab,
  it_alv_fieldcat TYPE slis_t_fieldcat_alv,
  st_alv_fieldcat LIKE LINE OF it_alv_fieldcat,
  st_alv_layout TYPE slis_layout_alv,
  i_sort TYPE  slis_t_sortinfo_alv,
  wa_sort TYPE slis_sortinfo_alv,
  wa_events         TYPE slis_alv_event,
  i_event TYPE slis_t_event.


SELECTION-SCREEN BEGIN OF BLOCK blk1.

SELECT-OPTIONS: s_matnr FOR mard-matnr.

SELECTION-SCREEN END OF BLOCK blk1.


SELECTION-SCREEN BEGIN OF SCREEN 200.

SELECT-OPTIONS: s_werks FOR mard-werks,
                s_lgort FOR mard-lgort.

SELECTION-SCREEN END OF SCREEN 200.


AT SELECTION-SCREEN OUTPUT .

START-OF-SELECTION.

  CALL SELECTION-SCREEN 200.

  PERFORM f_get_selections_values.

  SELECT matnr
           werks
           lgort
           labst
      INTO TABLE it_itab
      UP TO 100 ROWS
      FROM mard
      WHERE matnr IN s_matnr
       AND werks IN s_werks
       AND lgort IN s_lgort.

  PERFORM add_fieldcat USING 'IT_ITAB' 'MATNR' 'Material' '' '' ''
                              'X' ''.
  PERFORM add_fieldcat USING 'IT_ITAB' 'WERKS' 'Factory' '' '' '' ''
                              ''.
  PERFORM add_fieldcat USING 'IT_ITAB' 'LGORT' 'Location' '' '' ''
                              '' ''.
  PERFORM add_fieldcat USING 'IT_ITAB' 'LABST' 'Storage'
                             '' '' 'X' '' 'X'.

  st_alv_layout-colwidth_optimize = 'X'.
*  st_alv_layout-totals_text = 'Totals:'.
*  st_alv_layout-subtotals_text = 'SubTotals'.
*  st_alv_layout-edit_MODE = 'A'.
*
*  st_alv_layout-edit = 'X'.

* Sort on material
  wa_sort-spos = '01' .
  wa_sort-fieldname = 'MATNR'.
  wa_sort-tabname = 'I_EKPO'.
  wa_sort-up = 'X'.
  wa_sort-subtot = 'X'.
  APPEND wa_sort TO i_sort .
  CLEAR wa_sort.
* Sort on plant
  wa_sort-spos = '02'.
  wa_sort-fieldname = 'WERKS'.
  wa_sort-tabname = 'I_EKPO'.
  wa_sort-up = 'X'.
  wa_sort-subtot = 'X'.
  APPEND wa_sort TO i_sort .
  CLEAR wa_sort.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
*     I_INTERFACE_CHECK                 = ' '
*     I_BYPASSING_BUFFER                = ' '
*     I_BUFFER_ACTIVE                   = ' '
     i_callback_program                = sy-repid
     i_callback_pf_status_set          = 'PF_STATUS_SET'
     i_callback_user_command           = 'USER_COMMAND'
*     I_CALLBACK_TOP_OF_PAGE            = ' '
*     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*     I_CALLBACK_HTML_END_OF_LIST       = ' '
*     I_STRUCTURE_NAME                  =
*     I_BACKGROUND_ID                   = ' '
*     I_GRID_TITLE                      =
*     I_GRID_SETTINGS                   =
    is_layout                         = st_alv_layout
    it_fieldcat                       = it_alv_fieldcat
*     IT_EXCLUDING                      =
*     IT_SPECIAL_GROUPS                 =
     it_sort                           = i_sort
*     IT_FILTER                         =
*     IS_SEL_HIDE                       =
     i_default                         = 'X'
     i_save                            = 'A'
*     IS_VARIANT                        =
*      IT_EVENTS                         = i_event
*     IT_EVENT_EXIT                     =
*     IS_PRINT                          = gs_print
*     IS_REPREP_ID                      =
*     I_SCREEN_START_COLUMN             = 0
*     I_SCREEN_START_LINE               = 0
*     I_SCREEN_END_COLUMN               = 0
*     I_SCREEN_END_LINE                 = 0
*     I_HTML_HEIGHT_TOP                 = 0
*     I_HTML_HEIGHT_END                 = 0
*     IT_ALV_GRAPHICS                   =
*     IT_HYPERLINK                      =
*     IT_ADD_FIELDCAT                   =
*     IT_EXCEPT_QINFO                   =
*     IR_SALV_FULLSCREEN_ADAPTER        =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER           =
*     ES_EXIT_CAUSED_BY_USER            =
   TABLES
     t_outtab                          = it_itab
  EXCEPTIONS
    program_error                     = 1
    OTHERS                            = 2
           .
*&---------------------------------------------------------------------*
*&      Form  add_fieldcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ITABNAME   text
*      -->P_FIELDNAME  text
*      -->P_TEXT       text
*----------------------------------------------------------------------*
FORM add_fieldcat USING p_itabname TYPE string
                           p_fieldname TYPE string
                           p_text TYPE string
                           p_ref_tabname TYPE string
                           p_ref_fieldname TYPE string
                           p_do_sum TYPE c
                           p_hotspot TYPE c
                           p_edit TYPE c.
  CLEAR st_alv_fieldcat.
  st_alv_fieldcat-tabname   = p_itabname.
  st_alv_fieldcat-fieldname = p_fieldname.
  st_alv_fieldcat-seltext_s = p_text.
  st_alv_fieldcat-qtabname = p_ref_tabname.
  st_alv_fieldcat-qfieldname = p_ref_fieldname.
  st_alv_fieldcat-do_sum = p_do_sum.
  st_alv_fieldcat-hotspot = p_hotspot.
  st_alv_fieldcat-edit = p_edit.
  APPEND st_alv_fieldcat TO it_alv_fieldcat.

ENDFORM.                    "add_fieldcat
*&---------------------------------------------------------------------*
*&      Form  PF_STATUS_SET
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->EXTAB      text
*----------------------------------------------------------------------*
FORM pf_status_set USING extab TYPE slis_t_extab.
  SET PF-STATUS 'ZARCHER_0134'.
ENDFORM.                    "PF_STATUS_SET
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM    text
*      -->S_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command  USING r_ucomm LIKE sy-ucomm
                   s_selfield TYPE slis_selfield.
  CASE r_ucomm.
    WHEN '&BACK1'.
*      LEAVE to SCREEN 0.
      PERFORM f_exit_program.
  ENDCASE.
ENDFORM.                    "USER_COMMAND

*&---------------------------------------------------------------------*
*&      Form  f_get_selections_values
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM f_get_selections_values.
  v_program = sy-repid.
  CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
    EXPORTING
      curr_report     = v_program  " Your program Name
    TABLES
      selection_table = i_seltab
    EXCEPTIONS
      not_found       = 1
      no_report       = 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.

ENDFORM.                    "f_get_selections_values

*&---------------------------------------------------------------------*
*&      Form  f_exit_program
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM f_exit_program.
  SUBMIT zarcher_0134 USING SELECTION-SCREEN 200
        WITH SELECTION-TABLE i_seltab.
ENDFORM.                    "f_exit_program