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: 

In ALV GRID, when pressing BACK button go back to selection-screen.

aris_hidalgo
Contributor
0 Kudos

Hello experts,

Where will I put the code that if a user presses back in ALV grid display, it will go back to either selection screen 500 or 1500?

Again, thank you guys and have a nice day!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Viraylab,

Include Function Code: BACK, EXIT, or CANC with Function Type 'E' in Standard Toolbar.

At the PAI module, include this:

CASE sy-ucomm.

WHEN 'BACK' OR 'EXIT' OR 'CANC'.

LEAVE TO SCREEN 500. "or screen 1500

ENDCASE.

Thanks and cheers,

Patrick

9 REPLIES 9

Former Member
0 Kudos

In the USER_COMMAND routine which will be trigged if you have set the parameter I_CALLBACK_USER_COMMAND.

Try writing the code in this rotuine to trigger the BACK user action.

Cheers

VJ

0 Kudos

Hi Vijayendra,

Thanks for the helpful reply. But another question(sorry if i'm stubborn), How do I do that when displaying a normal report? example, i'm displayng the files that was selected by the user?

Again, thank you and have a nice day!

0 Kudos

Hi viray,

You need to first call the EVENTS FM to get the events

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
   EXPORTING
     i_list_type           = 2
   IMPORTING
     et_events             = it_events
*  EXCEPTIONS
*    LIST_TYPE_WRONG       = 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.

then modify the events table which is obtained by the above FM

  READ TABLE it_events INTO wa_event WITH KEY name = 'USER_COMMAND'.
  IF sy-subrc EQ 0.
    wa_event-form = 'USER_COMMAND'.
    MODIFY it_events FROM wa_event TRANSPORTING form
    WHERE name = wa_event-name.
  ENDIF.

And finally in the routine write the code for what you need to process.

FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

  CASE r_ucomm.

    WHEN '&BACK_PRO'. 
         Your code to do what ever u want.
  ENDCASE.
ENDFORM.                    "user_command

0 Kudos

Hi,

If its a normal report then it will come back on the previous screen as the status is already set...

But if u want it to come back on a particular screen then create ur own status and write in PAI-

case sy-ucomm.

when 'BACK'.

leave to screen <screen no>

endcase.

Hope this helps!!!

Seema.

0 Kudos

Hi guys,

It still doesn't work. Thanks again!

0 Kudos

Viray,

Probably you could try this logic. I created a program roughly under standing your entire requirement. I suggest you to merge this logic with the one which suggested you in

Check the code below. Before executing just create the pf status with Func code.

rgds,

TM.

REPORT z_ALV_TEST_TM MESSAGE-ID zz.

* Data definition
TABLES: nast,  " Message status
        usr02, " User
        t685.  " Output Types

DATA: BEGIN OF wa_nast ,
       objky LIKE nast-objky,    " Object key
       kschl LIKE nast-kschl,    " Output Type
       spras LIKE nast-spras,    " Lamguage
       datvr LIKE nast-datvr,    " Processed date
       uhrvr LIKE nast-uhrvr,    " Processed time
       usnam LIKE nast-usnam,    " User name
       vstat LIKE nast-vstat,    " Status
       icon TYPE icon-id, "traffic lights
      END OF wa_nast.
DATA: itab_nast LIKE wa_nast OCCURS 0.
DATA i_repid LIKE sy-repid.

* Data for ALV display
TYPE-POOLS: slis.
DATA: wa_layout TYPE slis_layout_alv,
      wa_fieldcat TYPE slis_fieldcat_alv,
      it_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_event TYPE slis_alv_event,
    rt_events LIKE ls_event OCCURS 0.

SELECT-OPTIONS: s_datvr FOR nast-datvr, " Date
                s_usnam FOR usr02-bname," User
                s_kschl FOR t685-kschl. " Output type

PARAMETERS: pr_upld RADIOBUTTON GROUP grp2 USER-COMMAND ucomm1.
PARAMETERS: pr_upld2 RADIOBUTTON GROUP grp2.

SELECTION-SCREEN BEGIN OF SCREEN 1500.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_datvr1 FOR nast-datvr. " Date
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_dcode LIKE vbak-kunnr,
            p_name1 LIKE kna1-name1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN END OF SCREEN 1500.


START-OF-SELECTION.
* read data into table itab_nast
  SELECT objky kschl spras datvr uhrvr usnam vstat
         FROM nast INTO TABLE itab_nast WHERE kschl IN s_kschl AND
         datvr IN s_datvr AND usnam IN s_usnam.
  IF sy-subrc NE 0.
    MESSAGE e000 WITH 'Data not found'.
  ELSE.
    SORT  itab_nast BY datvr uhrvr.
    wa_nast-icon = '@08@'. " Green
    MODIFY itab_nast FROM wa_nast TRANSPORTING icon WHERE vstat = '1'.
    wa_nast-icon = '@0A@'. " Red
    MODIFY itab_nast FROM wa_nast TRANSPORTING icon WHERE vstat = '2'.
    wa_nast-icon = '@09@'. " Yellow
    MODIFY itab_nast FROM wa_nast TRANSPORTING icon WHERE vstat = '0'.
    wa_nast-uhrvr = ''.
    MODIFY itab_nast FROM wa_nast TRANSPORTING uhrvr
           WHERE datvr = '00000000' AND uhrvr = '000000'.
  ENDIF.



END-OF-SELECTION.

  MOVE sy-repid TO i_repid.
  wa_layout-colwidth_optimize = 'X'.

  DEFINE m_fieldcat.
    add 1 to wa_fieldcat-col_pos.
    wa_fieldcat-fieldname = &1.
    wa_fieldcat-ref_tabname = 'NAST'.
    wa_fieldcat-icon = &2.
    wa_fieldcat-seltext_l = &3.
    append wa_fieldcat to it_fieldcat.
  END-OF-DEFINITION.

  m_fieldcat 'ICON' 'X' 'Status'.
  m_fieldcat 'OBJKY' '' ''.
  m_fieldcat 'KSCHL' '' ''.
  m_fieldcat 'SPRAS' '' ''.
  m_fieldcat 'DATVR' '' ''.
  m_fieldcat 'UHRVR' '' ''.
  m_fieldcat 'USNAM' '' ''.


* Create ALV Display
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            i_callback_program       = i_repid
            it_fieldcat              = it_fieldcat
            is_layout                = wa_layout
            i_callback_user_command  = 'USER_COMMAND'
            i_callback_pf_status_set = 'PF_STATUS'
            it_events                = rt_events[]
            i_save                   = 'A'
       TABLES
            t_outtab                 = itab_nast
       EXCEPTIONS
            program_error            = 1
            OTHERS                   = 2.
  IF sy-subrc <> 0.
    WRITE: /'Return Error ', sy-subrc, 'REUSE_ALV_LIST_DISPLAY'.
  ENDIF.

*---------------------------------------------------------------------*
*       FORM PF_STATUS                                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  GIT_EXTAB                                                     *
*---------------------------------------------------------------------*
FORM pf_status       USING git_extab TYPE slis_t_extab.

  SET PF-STATUS 'STANDARD' .

ENDFORM.

*---------------------------------------------------------------------*
*       FORM user_command                                             *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  UCOMM                                                         *
*  -->  RS_SELFIELD                                                   *
*---------------------------------------------------------------------*
FORM user_command USING ucomm LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.

  CASE ucomm.
    WHEN 'BACK_SCR'.
      CALL SELECTION-SCREEN '1500'.
  ENDCASE.
ENDFORM.                    "user_command

0 Kudos

Hi,

If you are using Function Module for ALV, then you can use <b>I_CALLBACK_PF_STATUS_SET</b> import parameter.

You create the PF status with required code for BACK button.

Go thru the documentation for this parameter.

Hope it helps.

Regards,

Shashank

0 Kudos

viraylab,

in an abap-report simply use:

   WHEN 'BACK' OR '%EX' OR 'RW' OR 'EXIT'.
      CALL METHOD grid->free.
      <b>SET SCREEN 0</b>.

regards Andreas

Former Member
0 Kudos

Hi Viraylab,

Include Function Code: BACK, EXIT, or CANC with Function Type 'E' in Standard Toolbar.

At the PAI module, include this:

CASE sy-ucomm.

WHEN 'BACK' OR 'EXIT' OR 'CANC'.

LEAVE TO SCREEN 500. "or screen 1500

ENDCASE.

Thanks and cheers,

Patrick