Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
Error rendering macro 'code': Invalid value specified for parameter 'lang'
*  -----------------------------------------------------------------------------*
*     Here is the code for alv with page nos and subtotals....
*     if you click any one of the line it will displays the list .
*  -----------------------------------------------------------------------------*
REPORT ZTESTS .
TYPE-POOLS: SLIS.
*--------------------------------------------------------------------
* G L O B A L I N T E R N A L T A B L E S
*--------------------------------------------------------------------
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_EVENTS TYPE SLIS_T_EVENT.
DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV ,
WA_SORT TYPE SLIS_SORTINFO_ALV .
DATA: GS_PRINT TYPE SLIS_PRINT_ALV.
DATA: BEGIN OF IT_SFLIGHT OCCURS 0,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID,
FLDATE LIKE SFLIGHT-FLDATE,
PRICE LIKE SFLIGHT-PRICE,
PLANETYPE LIKE SFLIGHT-PLANETYPE,
SEATSMAX LIKE SFLIGHT-SEATSMAX,
SEATSOCC LIKE SFLIGHT-SEATSOCC,
PAYMENTSUM LIKE SFLIGHT-PAYMENTSUM,
END OF IT_SFLIGHT.
DATA: G_REPID LIKE SY-REPID.
DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: V_TOTAL(5).
START-OF-SELECTION.
  G_REPID = SY-REPID.
  PERFORM INIT_FIELDCAT USING GT_FIELDCAT[].
  PERFORM BUILD_EVENTTAB USING GT_EVENTS[].
  PERFORM BUILD_COMMENT USING GT_LIST_TOP_OF_PAGE[].
  PERFORM GET_DATA.
  PERFORM SET_LAYOUT USING GS_LAYOUT.* SORTINGCLEAR WA_SORT.
  WA_SORT-FIELDNAME = 'CARRID'.
  WA_SORT-UP = 'X'.
  WA_SORT-GROUP = '*'.
  WA_SORT-SUBTOT = 'X'.
  APPEND WA_SORT TO IT_SORT.
  CLEAR WA_SORT.
  WA_SORT-FIELDNAME = 'CONNID'.
  WA_SORT-UP = 'X'.
  WA_SORT-GROUP = 'UL'.
  WA_SORT-SUBTOT = 'X'.
  APPEND WA_SORT TO IT_SORT.
* DISPLAY LIST
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK       = ' '
      I_CALLBACK_PROGRAM      = G_REPID
      I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
      IS_LAYOUT               = GS_LAYOUT
      IT_FIELDCAT             = GT_FIELDCAT[]
      IT_SORT                 = IT_SORT[]
      IT_EVENTS               = GT_EVENTS
      IS_PRINT                = GS_PRINT
    TABLES
      T_OUTTAB                = IT_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.
*&---------------------------------------------------------------------*
*& Form INIT_FIELDCAT
*&---------------------------------------------------------------------*
FORM INIT_FIELDCAT USING P_GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
  DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
  L_INDEX TYPE SY-TABIX.
  DATA :REP LIKE SY-REPID.
  REP = SY-REPID.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_PROGRAM_NAME         = REP
      I_INTERNAL_TABNAME     = 'IT_SFLIGHT'
      I_INCLNAME             = REP
    CHANGING
      CT_FIELDCAT            = GT_FIELDCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      OTHERS                 = 3.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-SUBRC.
  ENDIF.
  SORT GT_FIELDCAT BY COL_POS.
  LOOP AT GT_FIELDCAT INTO LS_FIELDCAT.
    L_INDEX = SY-TABIX.
    IF LS_FIELDCAT-FIELDNAME = 'PRICE'.
      LS_FIELDCAT-DO_SUM = 'X'.
      LS_FIELDCAT-SP_GROUP = 'X'.
      MODIFY GT_FIELDCAT FROM LS_FIELDCAT INDEX L_INDEX .
    ENDIF.
  ENDLOOP.
ENDFORM. " INIT_FIELDCAT
*&---------------------------------------------------------------------*
*& Form BUILD_EVENTTAB
*&---------------------------------------------------------------------*
FORM BUILD_EVENTTAB USING P_GT_EVENTS TYPE SLIS_T_EVENT.
  DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
  CLEAR LS_EVENT.
  LS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
  LS_EVENT-FORM = 'XTOP_OF_PAGE'.
  APPEND LS_EVENT TO P_GT_EVENTS.
  CLEAR LS_EVENT.
  LS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
  LS_EVENT-FORM = 'XTOP_OF_LIST'.
  APPEND LS_EVENT TO P_GT_EVENTS.
  CLEAR LS_EVENT.
  LS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
  LS_EVENT-FORM = 'XEND_OF_PAGE'.
  APPEND LS_EVENT TO P_GT_EVENTS.
  CLEAR LS_EVENT.
  LS_EVENT-NAME = SLIS_EV_END_OF_LIST.
  LS_EVENT-FORM = 'XEND_OF_LIST'.
  APPEND LS_EVENT TO P_GT_EVENTS.
  CLEAR LS_EVENT.
ENDFORM. " BUILD_EVENTTAB
*&---------------------------------------------------------------------*
*& Form BUILD_COMMENT
*&---------------------------------------------------------------------*
FORM BUILD_COMMENT USING P_GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
  DATA: LS_LINE TYPE SLIS_LISTHEADER.
  LS_LINE-TYP = 'H'." = Header, S = Selection, A = Action
  LS_LINE-KEY = 'KEY'.
  LS_LINE-INFO = 'INFO'.
  APPEND LS_LINE TO P_GT_LIST_TOP_OF_PAGE.
ENDFORM. " BUILD_COMMENT
*&---------------------------------------------------------------------*
*& Form SELECTION
*&---------------------------------------------------------------------*
FORM GET_DATA..
  DATA: L_ROWS TYPE I VALUE 3.
* Read data from table SFLIGHT
  SELECT CARRID
  CONNID
  FLDATE
  PRICE
  PLANETYPE
  SEATSMAX
  SEATSOCC
  PAYMENTSUM
  FROM SFLIGHT
  INTO TABLE IT_SFLIGHT.
  SORT IT_SFLIGHT.
ENDFORM. " SELECTION
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT
*&---------------------------------------------------------------------*
FORM SET_LAYOUT USING P_GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
  P_GS_LAYOUT-ZEBRA = 'X'.
  P_GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  P_GS_LAYOUT-NO_INPUT = 'X'.
  P_GS_LAYOUT-NO_COLHEAD = SPACE.
  P_GS_LAYOUT-TOTALS_TEXT = 'Total Price'.
  P_GS_LAYOUT-SUBTOTALS_TEXT = 'Sub Total'.
  P_GS_LAYOUT-TOTALS_ONLY = 'X'.
  P_GS_LAYOUT-KEY_HOTSPOT = 'X'.
  P_GS_LAYOUT-DETAIL_POPUP = 'X'.
  P_GS_LAYOUT-NO_SUBTOTALS = SPACE.
  P_GS_LAYOUT-EXPAND_ALL = 'X'.
  P_GS_LAYOUT-GROUP_BUTTONS = 'X'."space.
ENDFORM. " SET_LAYOUT
*---------------------------------------------------------------------*
* FORM XTOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM XTOP_OF_PAGE.
  DATA : LV_PAGE(5),
  LV_TEXT(20).
  MOVE SY-PAGNO TO LV_PAGE.
  WRITE:/ 'X_TOP_OF_PAGE'.
ENDFORM. "xtop_of_page
*---------------------------------------------------------------------*
* FORM XTOP_OF_LIST *
*---------------------------------------------------------------------*
FORM XTOP_OF_LIST.
  WRITE:/ 'X_TOP_OF_LIST'.
ENDFORM. "xtop_of_list
*---------------------------------------------------------------------*
* FORM XEND_OF_PAGE *
*---------------------------------------------------------------------*
FORM XEND_OF_PAGE.
  WRITE:/ 'X_END_OF_PAGE'.
ENDFORM. "xend_of_page
*---------------------------------------------------------------------*
* FORM XEND_OF_LIST *
*---------------------------------------------------------------------*
FORM XEND_OF_LIST.
  WRITE:/ 'X_END_OF_LIST'.
  DATA : LV_PAGE(5),
  LV_TEXT(20).
  DATA : L_LINES TYPE I,
  L_LINE TYPE I.
  CLEAR V_TOTAL.
  WRITE SY-PAGNO TO V_TOTAL LEFT-JUSTIFIED.
  DO SY-PAGNO TIMES.
    LV_PAGE = SY-INDEX.
    CONCATENATE 'Page' LV_PAGE 'of' V_TOTAL
    INTO LV_TEXT SEPARATED BY SPACE.
    IF SY-INDEX = 1.
      READ LINE 2 OF PAGE SY-INDEX.
    ELSE.
      READ LINE 1 OF PAGE SY-INDEX.
    ENDIF.
    SY-LISEL+60(20) = LV_TEXT.
    MODIFY CURRENT LINE .
  ENDDO.
ENDFORM. "xend_of_list
*---------------------------------------------------------------------*
* USER_COMMAND *
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
  CASE R_UCOMM.
    WHEN 'EXIT'.
      LEAVE TO SCREEN 0.
    WHEN '&IC1'.
      DATA: TEXT(256),TEXT1(6),TEXT2(5).
      MOVE RS_SELFIELD-TABINDEX TO TEXT1.
      MOVE RS_SELFIELD-SUMINDEX TO TEXT2.
      CONCATENATE 'Double clicked on (field:'
      RS_SELFIELD-FIELDNAME
      'Value:'
      RS_SELFIELD-VALUE
      ','
      TEXT1
      ','
      TEXT2
      ' ) '
      INTO TEXT
      SEPARATED BY SPACE.
      CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
        EXPORTING
          TEXTLINE1 = TEXT.
  ENDCASE.
ENDFORM. "user_command
  • No labels