Highlighting the visited record on the basic list (ALV) on pressing BACK button in the secondary list using 'REUSE_ALV_LIST_DISPLAY'.

By Haritha

REPORT ZALV_LIST3.

TABLES:
  SPFLI,
  SFLIGHT,
  SBOOK.

TYPE-POOLS:
  SLIS.

DATA:
  BEGIN OF T_SPFLI OCCURS 0,
    CHECKBOX,
    COLOR(3).
        INCLUDE STRUCTURE SPFLI.
DATA:  END OF T_SPFLI.

DATA:
  T_SSPFLI LIKE STANDARD TABLE OF T_SPFLI .

DATA:
  FS_SPFLI LIKE LINE OF T_SSPFLI.

DATA:
  BEGIN OF T_SFLIGHT OCCURS 0,
    CHECKBOX,
    COLOR(3).
        INCLUDE STRUCTURE SFLIGHT.
DATA:  END OF T_SFLIGHT.

DATA:
  T_SSFLIGHT LIKE STANDARD TABLE OF T_SFLIGHT.

DATA:
  FS_SFLIGHT LIKE LINE OF T_SSFLIGHT.

DATA:
  BEGIN OF T_SBOOK OCCURS 0.
        INCLUDE STRUCTURE SBOOK.
DATA:  END OF T_SBOOK.

DATA:
  FS_LAYOUT TYPE  SLIS_LAYOUT_ALV,
  W_PROGRAM TYPE SY-REPID.

SELECT *
  FROM SPFLI
  INTO CORRESPONDING FIELDS OF TABLE T_SPFLI.

FS_LAYOUT-INFO_FIELDNAME = 'COLOR'.
FS_LAYOUT-BOX_FIELDNAME = 'CHECKBOX'.

W_PROGRAM = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
 EXPORTING
   I_CALLBACK_PROGRAM             = W_PROGRAM
   I_CALLBACK_PF_STATUS_SET       = 'FLIGHT'
   I_CALLBACK_USER_COMMAND        = 'SPFLI_INFO'
   I_STRUCTURE_NAME               = 'SPFLI'
   IS_LAYOUT                      = FS_LAYOUT
  TABLES
    T_OUTTAB                       = T_SPFLI
 EXCEPTIONS
   PROGRAM_ERROR                  = 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.

*&--------------------------------------------------------------------*
*&      Form  FLIGHT
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->RT_EXTAB   text
*---------------------------------------------------------------------*

FORM FLIGHT    USING RT_EXTAB TYPE SLIS_T_EXTAB..
  SET PF-STATUS 'FLIGHT' EXCLUDING RT_EXTAB.
ENDFORM.                    "FLIGHT

*&--------------------------------------------------------------------*
*&      Form  SPFLI_INFO
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->UCOMM      text
*      -->SELFIELD   text
*---------------------------------------------------------------------*
FORM SPFLI_INFO USING UCOMM LIKE SY-UCOMM
                       SELFIELD TYPE SLIS_SELFIELD.

  SELFIELD-REFRESH = 'X'.
  CASE UCOMM.
    WHEN 'FLIGHT'.
      LOOP AT T_SPFLI.
        IF T_SPFLI-CHECKBOX = 'X'.
          T_SPFLI-CHECKBOX = ' '.
          T_SPFLI-COLOR = 'C51'.
          MODIFY T_SPFLI TRANSPORTING CHECKBOX COLOR.
          FS_SPFLI = T_SPFLI.
          APPEND FS_SPFLI TO T_SSPFLI.
        ENDIF.
      ENDLOOP.

      LOOP AT T_SSPFLI INTO FS_SPFLI.
        SELECT *
          FROM SFLIGHT
     APPENDING CORRESPONDING FIELDS OF TABLE T_SFLIGHT
         WHERE CARRID EQ FS_SPFLI-CARRID
           AND CONNID EQ FS_SPFLI-CONNID.
      ENDLOOP.

  ENDCASE.
  REFRESH T_SSPFLI.
  CLEAR FS_SPFLI.

  FS_LAYOUT-INFO_FIELDNAME = 'COLOR'.
  FS_LAYOUT-CONFIRMATION_PROMPT = 'X'.
  FS_LAYOUT-KEY_HOTSPOT = 'X'.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM             = W_PROGRAM
     I_STRUCTURE_NAME               = 'SFLIGHT'
     IS_LAYOUT                      = FS_LAYOUT
    TABLES
      T_OUTTAB                       = T_SFLIGHT
   EXCEPTIONS
     PROGRAM_ERROR                  = 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.
  REFRESH T_SFLIGHT.

ENDFORM.                    "SPFLI_INFO

The Basic List will be as follows. 

 

If we check any of the flights and click on the flight icon present on the application toolbar as displayed above, the Secondary List will be displayed as follows. 

 

 When we press back button it will ask for confirmation whether to exit that screen or not. 

 

 When we go back to the Basic list, the list would appear as follows. 

 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image