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: 

Regarding top of page

Former Member
0 Kudos
314

Hi All,

Can anybody explain, how to use EXIT routine for Callback_top_of_page in RS_TREE_LIST_DISPLAY

to display the Heading of a tree in a output report.

Thanks.

2 REPLIES 2

former_member188685
Active Contributor
0 Kudos
84

It is similiar to normal ALV top of page please check the sample code.

REPORT  ZALV_TEST.

TABLES: KNVH.

TYPES: BEGIN OF WORKTYPE,
         LEVEL(2),
         HKUNNR LIKE KNVH-KUNNR,
         KUNNR  LIKE KNVH-HKUNNR,
       END OF WORKTYPE.

DATA: IT_KNVH TYPE TABLE OF WORKTYPE,
      WA_KNVH LIKE LINE OF IT_KNVH,
      IT_TEMP TYPE TABLE OF WORKTYPE,
      WA_TEMP LIKE LINE OF IT_TEMP,
      IT_WORK TYPE TABLE OF WORKTYPE,
      WA_WORK LIKE LINE OF IT_WORK.

DATA : BEGIN OF IT_NODES OCCURS 0.
        INCLUDE STRUCTURE SNODETEXT.
DATA : END OF IT_NODES.

CONSTANTS: NUMBER_OF_LEVELS TYPE I VALUE 6.
PARAMETER: P_HKUNNR LIKE KNVH-HKUNNR.

START-OF-SELECTION.

* Parent = 1. hierarchy node
WA_TEMP-KUNNR = P_HKUNNR.
APPEND WA_TEMP TO IT_TEMP.
WA_WORK-KUNNR = WA_TEMP-KUNNR.
WA_WORK-LEVEL = 1.
APPEND WA_WORK TO IT_WORK.

* Reading customer hierarchy (max. 6 level)
DO NUMBER_OF_LEVELS TIMES.

  CHECK NOT IT_TEMP IS INITIAL.

  SELECT KUNNR HKUNNR
    FROM KNVH
    INTO CORRESPONDING FIELDS OF TABLE IT_KNVH
    FOR ALL ENTRIES IN IT_TEMP
    WHERE HKUNNR = IT_TEMP-KUNNR.

  LOOP AT IT_KNVH INTO WA_KNVH.
    WA_KNVH-LEVEL = SY-INDEX + 1.
    APPEND WA_KNVH TO IT_WORK.
  ENDLOOP.

  IT_TEMP[] = IT_KNVH[].

ENDDO.

* Hierarchy nodes -> tree control
LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 1.
  PERFORM MAKE_NODE.
  LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 2 AND
                                     HKUNNR = WA_WORK-KUNNR.
    PERFORM MAKE_NODE.
    LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 3 AND
                                       HKUNNR = WA_WORK-KUNNR.
      PERFORM MAKE_NODE.
      LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 4 AND
                                         HKUNNR = WA_WORK-KUNNR.
        PERFORM MAKE_NODE.
        LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 5 AND
                                           HKUNNR = WA_WORK-KUNNR.
          PERFORM MAKE_NODE.
          LOOP AT IT_WORK INTO WA_WORK WHERE LEVEL = 6 AND
                                          HKUNNR = WA_WORK-KUNNR.
            PERFORM MAKE_NODE.
          ENDLOOP.
        ENDLOOP.
      ENDLOOP.
    ENDLOOP.
  ENDLOOP.
ENDLOOP.

* Making the tree control
CALL FUNCTION 'RS_TREE_CONSTRUCT'
       TABLES
            NODETAB      = IT_NODES
       EXCEPTIONS
            TREE_FAILURE = 1.

* Display the tree control
  DATA : F15 TYPE C.
  CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
       EXPORTING
            CALLBACK_PROGRAM      = SY-REPID
            CALLBACK_TOP_OF_PAGE  = 'TOP_OF_PAGE'
       IMPORTING
            F15                   = F15 .


FORM MAKE_NODE.
  IT_NODES-NAME = WA_WORK-KUNNR.
  IT_NODES-COLOR = 1.
  IT_NODES-INTENSIV = 1.
  IT_NODES-TEXT = WA_WORK-KUNNR.
  IT_NODES-TLENGTH = 16.
  IT_NODES-TLEVEL = WA_WORK-LEVEL.
  IT_NODES-TCOLOR = 1.
  IT_NODES-TINTENSIV = 1.
  APPEND IT_NODES.
ENDFORM.

FORM TOP_OF_PAGE.

WRITE 'THIS IS TOP OF PAGE'.

ENDFORM.

former_member216100
Participant
0 Kudos
84

you need to call the FB following:

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
     EXPORTING
          CALLBACK_PROGRAM       = 'YOURREPORT'
          CALLBACK_USER_COMMAND  = 'HANDLE_USER_COMMAND'
          CALLBACK_TEXT_DISPLAY  = 'HANDLE_TEXT_DISPLAY'
*         CALLBACK_COLOR_DISPLAY = 'HANDLE_COLOR_DISPLAY'
          CALLBACK_TOP_OF_PAGE   = 'HANDLE_TOP_OF_PAGE'
*         STATUS                 = 'IMPLICIT'
*         CHECK_DUPLICATE_NAME   = '1'
*         COLOR_OF_NODE          = '4'
*         COLOR_OF_MARK          = '3'
*         COLOR_OF_LINK          = '1'
*         LOWER_CASE_SENSITIVE   = ' '
*         MODIFICATION_LOG       = ' '
*         NODE_LENGTH            = 30
*         TEXT_LENGTH            = 75
*         TEXT_LENGTH1           = 0
*         TEXT_LENGTH2           = 0
*         RETURN_MARKED_SUBTREE  = ' '
*         SCREEN_START_COLUMN    = 0
*         SCREEN_START_LINE      = 0
*         SCREEN_END_COLUMN      = 0
*         SCREEN_END_LINE        = 0
*         SUPPRESS_NODE_OUTPUT   = ' '
*    IMPORTING
*         F15                    =
     EXCEPTIONS
          OTHERS                 = 1.

than you need to create a form in this abap

*---------------------------------------------------------------------*
*        FORM HANDLE_TOP_OF_PAGE                                      *
*---------------------------------------------------------------------*
*        Unterroutine für den Zeitpunkt TOP-OF_PAGE                   *
*---------------------------------------------------------------------*
FORM HANDLE_TOP_OF_PAGE.

   CHECK SY-PFKEY EQ 'DETAIL'.

   WRITE:   /01(89) SY-ULINE.
   FORMAT COLOR COL_GROUP INTENSIFIED.
   WRITE:
          /01 SY-VLINE,
           02 TEXT-004,
           89 SY-VLINE.
   FORMAT COLOR COL_HEADING INTENSIFIED.
   WRITE:
          /01 SY-VLINE,
           02 TEXT-005,
           89 SY-VLINE.

   IF LTAK-TANUM = SAV_TANUM.
     PERFORM WRITE_KOPFZEILE USING LTAK.
     MOVE LTAK-TANUM TO SAV_TANUM.
   ENDIF.
   WRITE:   /01(89) SY-ULINE.

ENDFORM.