Skip to Content
author's profile photo Former Member
Former Member

Hierarchical alv using oops

Can we get hierarchical alv display for grid not for the list using oops concept? if yes can anyone give me the sample code or any kind of help where i can get this information.

Thanks for the advance help.

Points will rewarded definitely

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 05:32 AM

    Hi

    Hope it will help you.

    Please reward if help.

    Code for Hierarchical alv using oops:-

    REPORT ZALV5_OBJECTS.

    TABLES : EKKO.

    TYPE-POOLS : SLIS.

    TYPES : BEGIN OF TY_EKKO,

    EBELN TYPE EKPO-EBELN,

    EBELP TYPE EKPO-EBELP,

    STATU TYPE EKPO-STATU,

    AEDAT TYPE EKPO-AEDAT,

    MATNR TYPE EKPO-MATNR,

    MENGE TYPE EKPO-MENGE,

    MEINS TYPE EKPO-MEINS,

    NETPR TYPE EKPO-NETPR,

    PEINH TYPE EKPO-PEINH,

    END OF TY_EKKO.

    DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

    IT_EKPO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

    IT_EMPTYTAB TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

    WA_EKKO TYPE TY_EKKO,

    WA_EKPO TYPE TY_EKKO.

    DATA: OK_CODE LIKE SY-UCOMM, "OK-Code

    SAVE_OK LIKE SY-UCOMM.

    *ALV data declarations

    DATA: FIELDCATALOG TYPE LVC_T_FCAT WITH HEADER LINE.

    DATA: GD_FIELDCAT TYPE LVC_T_FCAT,

    GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,

    GD_LAYOUT TYPE SLIS_LAYOUT_ALV.

    *ALVtree data declarations

    CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.

    CLASS CL_GUI_CFW DEFINITION LOAD.

    DATA: GD_TREE TYPE REF TO CL_GUI_ALV_TREE,

    GD_HIERARCHY_HEADER TYPE TREEV_HHDR,

    GD_REPORT_TITLE TYPE SLIS_T_LISTHEADER,

    GD_LOGO TYPE SDYDO_VALUE,

    GD_VARIANT TYPE DISVARIANT.

    *Create container for alv-tree

    DATA: GD_TREE_CONTAINER_NAME(30) TYPE C,

    GD_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

    ************************************************************************

    *Includes

    *INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules

    *INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules

    *INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)

    ************************************************************************

    *Start-of-selection.

    START-OF-SELECTION.

    • ALVtree setup data

    PERFORM DATA_RETRIEVAL.

    PERFORM BUILD_FIELDCATALOG.

    PERFORM BUILD_LAYOUT.

    PERFORM BUILD_HIERARCHY_HEADER CHANGING GD_HIERARCHY_HEADER.

    PERFORM BUILD_REPORT_TITLE USING GD_REPORT_TITLE GD_LOGO.

    PERFORM BUILD_VARIANT.

    • Display ALVtree report

    • CALL SCREEN 100.

    &----


    *& Form data_retrieval

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DATA_RETRIEVAL .

    SELECT EBELN

    UP TO 10 ROWS

    FROM EKKO

    INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.

    LOOP AT IT_EKKO INTO WA_EKKO.

    SELECT EBELN EBELP STATU AEDAT MATNR MENGE MEINS NETPR PEINH

    FROM EKPO

    APPENDING TABLE IT_EKPO

    WHERE EBELN EQ WA_EKKO-EBELN.

    ENDLOOP.

    ENDFORM. " data_retrieval

    &----


    *& Form build_fieldcatalog

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_FIELDCATALOG .

    • Please not there are a number of differences between the structure of

    • ALVtree fieldcatalogs and ALVgrid fieldcatalogs.

    • For example the field seltext_m is replace by scrtext_m in ALVtree.

    FIELDCATALOG-FIELDNAME = 'EBELN'. "Field name in itab

    FIELDCATALOG-SCRTEXT_M = 'Purchase Order'. "Column text

    FIELDCATALOG-COL_POS = 0. "Column position

    FIELDCATALOG-OUTPUTLEN = 15. "Column width

    FIELDCATALOG-EMPHASIZE = 'X'. "Emphasize (X or SPACE)

    FIELDCATALOG-KEY = 'X'. "Key Field? (X or SPACE)

    • fieldcatalog-do_sum = 'X'. "Sum Column?

    • fieldcatalog-no_zero = 'X'. "Don't display if zero

    APPEND FIELDCATALOG TO GD_FIELDCAT.

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'EBELP'.

    FIELDCATALOG-SCRTEXT_M = 'PO Iten'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 1.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'STATU'.

    FIELDCATALOG-SCRTEXT_M = 'Status'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 2.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'AEDAT'.

    FIELDCATALOG-SCRTEXT_M = 'Item change date'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 3.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'MATNR'.

    FIELDCATALOG-SCRTEXT_M = 'Material Number'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 4.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'MENGE'.

    FIELDCATALOG-SCRTEXT_M = 'PO quantity'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 5.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'MEINS'.

    FIELDCATALOG-SCRTEXT_M = 'Order Unit'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 6.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'NETPR'.

    FIELDCATALOG-SCRTEXT_M = 'Net Price'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 7.

    FIELDCATALOG-DATATYPE = 'CURR'.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    FIELDCATALOG-FIELDNAME = 'PEINH'.

    FIELDCATALOG-SCRTEXT_M = 'Price Unit'.

    FIELDCATALOG-OUTPUTLEN = 15.

    FIELDCATALOG-COL_POS = 8.

    APPEND FIELDCATALOG TO GD_FIELDCAT..

    CLEAR FIELDCATALOG.

    ENDFORM. " build_fieldcatalog

    &----


    *& Form build_layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_LAYOUT .

    GD_LAYOUT-NO_INPUT = 'X'.

    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

    GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).

    • gd_layout-totals_only = 'X'.

    • gd_layout-f2code = 'DISP'. "Sets fcode for when double

    • "click(press f2)

    • gd_layout-zebra = 'X'.

    • gd_layout-group_change_edit = 'X'.

    • gd_layout-header_text = 'helllllo'

    ENDFORM. " build_layout

    &----


    *& Form build_hierarchy_header

    &----


    • text

    ----


    • <--P_GD_HIERARCHY_HEADER text

    ----


    FORM BUILD_HIERARCHY_HEADER CHANGING

    P_HIERARCHY_HEADER TYPE TREEV_HHDR.

    P_HIERARCHY_HEADER-HEADING = 'Hierarchy Header'(013).

    P_HIERARCHY_HEADER-TOOLTIP = 'This is the Hierarchy Header !'(014).

    P_HIERARCHY_HEADER-WIDTH = 30.

    P_HIERARCHY_HEADER-WIDTH_PIX = ''.

    ENDFORM. " build_hierarchy_header

    &----


    *& Form build_report_title

    &----


    • text

    ----


    • -->P_GD_REPORT_TITLE text

    • -->P_GD_LOGO text

    ----


    FORM BUILD_REPORT_TITLE USING PT_REPORT_TITLE TYPE SLIS_T_LISTHEADER

    P_GD_LOGO TYPE SDYDO_VALUE.

    DATA: LS_LINE TYPE SLIS_LISTHEADER,

    LD_DATE(10) TYPE C.

    • List Heading Line(TYPE H)

    CLEAR LS_LINE.

    LS_LINE-TYP = 'H'.

    • ls_line-key "Not Used For This Type(H)

    LS_LINE-INFO = 'PO ALVTree Display'.

    APPEND LS_LINE TO PT_REPORT_TITLE.

    • Status Line(TYPE S)

    LD_DATE(2) = SY-DATUM+6(2).

    LD_DATE+2(1) = '/'.

    LD_DATE3(2) = SY-DATUM4(2).

    LD_DATE+5(1) = '/'.

    LD_DATE+6(4) = SY-DATUM(4).

    LS_LINE-TYP = 'S'.

    LS_LINE-KEY = 'Date'.

    LS_LINE-INFO = LD_DATE.

    APPEND LS_LINE TO PT_REPORT_TITLE.

    • Action Line(TYPE A)

    CLEAR LS_LINE.

    LS_LINE-TYP = 'A'.

    CONCATENATE 'Report: ' SY-REPID INTO LS_LINE-INFO SEPARATED BY SPACE.

    APPEND LS_LINE TO PT_REPORT_TITLE.

    ENDFORM. " build_report_title

    &----


    *& Form build_variant

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_VARIANT .

    • Set repid for storing variants

    GD_VARIANT-REPORT = SY-REPID.

    ENDFORM. " build_variant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 05:34 AM

    Hi,

    Yo can't have hierarchical alv display for grid. its possible only with ALV list.

    Check these demo programs for ALV List.

    BALVHD01

    BALVHD01_GROUP

    Regards,

    Pankaj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 05:35 AM

    Hi

    http://www.sapdev.co.uk/reporting/alv/alvtree/alvtree_basic.htm

    see this link

    you can learn very easily

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.