Skip to Content
avatar image
Former Member

ALV

Hi,

how to diplay hierarchical list item data in alv tree format

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 02, 2008 at 06:58 AM

    Hi Surendra,

    Please check these threads

    tree-format-in-hierarchical-alv-display

    alv-hierarchical-display

    hierarchical-list-in-alv

    Check the standard programs BCALV_TEST_HIERSEQ_LIST and BCALV_TEST_HIERSEQ_LIST_EVENTS

    Hope this would help you.

    Good luck

    Narin

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06:58 AM

    Hi

    Go through the link given below :

    alv

    With Regards

    Nikunj Shah

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06:59 AM

    Just go through the following link:

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

    Hope this will help you.

    Thanks,

    Sriram Ponna.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 07:03 AM

    hii

    refer to follwoing link

    [ALV TREE DISPLAY|alv]

    in above link refer saptechnical site link given in that

    regards

    twinkal

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 07:04 AM

    Hi,

    I hope the below link will help you.

    alv tree

    Thanks,

    Khsuhboo.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 07:20 AM

    this is complete program for hierarichal alv in report

    run this code

    u will get the ans

    TABLES : t001w, "Table for Plants/Branches data.

    mska, "Table for Sales Order Stock.

    mchb, "Batch stock data.

    vbak. "sales document header detail.

    *Internal table declaration of Plants/Branches data .

    DATA : BEGIN OF it_t001w OCCURS 0,

    werks LIKE t001w-werks, "Plant

    name1 LIKE t001w-name1, "name1

    kunnr LIKE t001w-kunnr, "Customer Number

    lifnr LIKE t001w-lifnr, "Vendor Number

    ekorg LIKE t001w-ekorg, "Sales Organization

    expand TYPE xfeld, "Check box.

    END OF it_t001w,

    *Inernal table for sales order stock data.

    BEGIN OF it_mska OCCURS 0,

    werks LIKE mska-werks, "Plant

    matnr LIKE mska-matnr, "Material Number

    lgort LIKE mska-lgort, "Storage Location

    charg LIKE mska-charg, "Batch Number

    vbeln LIKE mska-vbeln, "Sales document number

    posnr LIKE mska-posnr, "Item Number

    kaspe LIKE mska-kaspe, "Blocked stock

    END OF it_mska,

    *Internal table for batch stock data.

    BEGIN OF it_mchb OCCURS 0,

    werks LIKE mchb-werks, "Plant

    matnr LIKE mchb-matnr, "Material Number

    lgort LIKE mchb-lgort, "Storage Location

    clabs LIKE mchb-clabs, "Valuated stock with unrestricted use

    cumlm LIKE mchb-cumlm, "Stock in transfer(from one storage location to another)

    cspem LIKE mchb-cspem, "Blocked stock

    END OF it_mchb,

    *Internal table for sales document header detail.

    BEGIN OF it_vbak OCCURS 0,

    vbeln LIKE vbak-vbeln, "Sales document number

    erdat LIKE vbak-erdat, "Document creation date

    auart LIKE vbak-auart, "Order type

    netwr LIKE vbak-netwr, "Net value of order

    waerk LIKE vbak-waerk, "SD document currency

    vkorg LIKE vbak-vkorg, "sales organization

    vtweg LIKE vbak-vtweg, "Distribution chanel

    spart LIKE vbak-spart, "Division

    END OF it_vbak.

    *Variable for program-id.

    DATA : v_repid LIKE sy-repid.

    *Constant declaratin.

    CONSTANTS c_x VALUE 'X'.

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

    *Data declaration for alv.

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

    TYPE-POOLS slis.

    *Variable declaration used in alv.

    DATA: i_tabname_header TYPE slis_tabname,

    i_tabname_item TYPE slis_tabname,

    is_keyinfo TYPE slis_keyinfo_alv,

    is_layout TYPE slis_layout_alv.

    *Fieldcatalog declaration for alv output.

    DATA : fldcat_plant TYPE slis_t_fieldcat_alv WITH HEADER LINE,

    fldcat_vbak TYPE slis_t_fieldcat_alv WITH HEADER LINE.

    *Selection screen for plant selection.

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

    SELECT-OPTIONS : s_werks FOR t001w-werks OBLIGATORY.

    PARAMETERS : p_expand AS CHECKBOX DEFAULT c_x.

    SELECTION-SCREEN END OF BLOCK plant.

    *Start data extraction.

    START-OF-SELECTION.

    *Get genral Plants/Branches data.

    SELECT werks

    name1

    kunnr

    lifnr

    ekorg

    FROM t001w INTO TABLE it_t001w

    WHERE werks IN s_werks.

    *Get batch stock data based on plant genral data.

    IF NOT it_t001w[] IS INITIAL.

    SELECT werks

    matnr

    lgort

    charg

    vbeln

    posnr

    kaspe

    FROM mska INTO TABLE it_mska

    FOR ALL ENTRIES IN it_t001w

    WHERE werks = it_t001w-werks.

    ENDIF.

    *If plant is not available for batch stock data then delete plant from it_t001w table.

    LOOP AT it_t001w.

    READ TABLE it_mska WITH KEY werks = it_t001w-werks.

    IF sy-subrc <> 0.

    DELETE it_t001w.

    ENDIF.

    ENDLOOP.

    *Call subroutine routine for fill fiedlcat.

    PERFORM fldcat_plant.

    *Call subroutine for relation between plant master and batch stock data.

    PERFORM fill_keyinfo.

    *Code for give expander in alv.

    IF p_expand = c_x.

    is_layout-expand_fieldname = 'EXPAND'.

    ENDIF.

    v_repid = sy-repid.

    *call function module for hierarical output.

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    i_callback_program = v_repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    i_callback_user_command = 'USER_COMMAND_VBAK'

    is_layout = is_layout

    it_fieldcat = fldcat_plant[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    • IT_EVENTS =

    • IT_EVENT_EXIT =

    i_tabname_header = 'IT_T001W'

    i_tabname_item = 'IT_MSKA'

    is_keyinfo = is_keyinfo

    TABLES

    t_outtab_header = it_t001w

    t_outtab_item = it_mska

    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 fldcat_plant

    &----


    • text-Form for fill fieldcatlog.

    ----


    FORM fldcat_plant.

    PERFORM fill_fldcat_plant USING :

    'WERKS' 'IT_T001W' 'WERKS' 'T001W',

    'NAME1' 'IT_T001W' 'NAME1' 'T001W',

    'KUNNR' 'IT_T001W' 'KUNNR' 'T001W',

    'LIFNR' 'IT_T001W' 'LIFNR' 'T001W',

    'EKORG' 'IT_T001W' 'EKORG' 'T001W',

    'MATNR' 'IT_MSKA' 'MATNR' 'MSKA',

    'LGORT' 'IT_MSKA' 'LGORT' 'MSKA',

    'CHARG' 'IT_MSKA' 'CHARG' 'MSKA',

    'VBELN' 'IT_MSKA' 'VBELN' 'MSKA',

    'POSNR' 'IT_MSKA' 'POSNR' 'MSKA',

    'KASPE' 'IT_MSKA' 'KASPE' 'MSKA'.

    ENDFORM. "fldcat_plant

    &----


    *& Form fill_fldcat_plant

    &----


    • text

    ----


    • -->P_FLDNAME text

    • -->P_TABNAME text

    • -->P_REF_FIELDtext

    • -->P_REF_TABNAtext

    ----


    FORM fill_fldcat_plant USING p_fldname

    p_tabname

    p_ref_fieldname

    p_ref_tabname.

    fldcat_plant-fieldname = p_fldname.

    fldcat_plant-tabname = p_tabname.

    fldcat_plant-ref_fieldname = p_ref_fieldname.

    fldcat_plant-ref_tabname = p_ref_tabname.

    APPEND fldcat_plant.

    CLEAR fldcat_plant.

    ENDFORM. "fill_fldcat_plant

    &----


    *& Form fill_keyinfo

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fill_keyinfo .

    is_keyinfo-header01 = 'WERKS'.

    is_keyinfo-item02 = 'MATNR'.

    ENDFORM. " FILL_KEYINFO

    &----


    *& Form USER_COMMAND_mchb

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->RS_SELFIELDtext

    ----


    FORM user_command_vbak USING r_ucomm LIKE sy-ucomm

    rs_selfield TYPE slis_selfield.

    IF rs_selfield-fieldname = 'VBELN'.

    CLEAR it_mska.

    *Read table it_mska with index.

    READ TABLE it_mska INDEX rs_selfield-tabindex.

    IF sy-subrc = 0.

    SELECT vbeln

    erdat

    auart

    netwr

    waerk

    vkorg

    vtweg

    spart

    FROM vbak INTO TABLE it_vbak

    WHERE vbeln = it_mska-vbeln .

    ENDIF.

    *If sales document doesn't available.

    IF it_vbak[] IS INITIAL.

    message I310(ZVIKALP).

    CALL TRANSACTION 'VA01'.

    EXIT.

    ENDIF.

    *Call subroutine for display sales order detail.

    IF fldcat_vbak[] IS INITIAL.

    PERFORM fldcat_vbak.

    ENDIF.

    *Call function for display material stock detail.

    v_repid = sy-repid.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = v_repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_STRUCTURE_NAME =

    • IS_LAYOUT =

    it_fieldcat = fldcat_vbak[]

    TABLES

    t_outtab = it_vbak

    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.

    CLEAR fldcat_vbak[].

    ENDIF.

    ENDFORM. "USER_COMMAND_vbak

    &----


    *& Form fldcat_VBAK

    &----


    • text

    ----


    FORM fldcat_vbak.

    PERFORM fill_fldcat_vbak USING :

    'VBELN' 'IT_VBAK' 'VBELN' 'VBAK',

    'AUART' 'IT_VBAK' 'AUART' 'VBAK',

    'NETWR' 'IT_VBAK' 'NETWR' 'VBAK',

    'WAERK' 'IT_VBAK' 'WAERK' 'VBAK',

    'VKORG' 'IT_VBAK' 'VKORG' 'VBAK',

    'VTWEG' 'IT_VBAK' 'VTWEG' 'VBAK',

    'SPART' 'IT_VBAK' 'SPART' 'VBAK'.

    ENDFORM. "fldcat_vbak

    &----


    *& Form fill_fldcat_vbak

    &----


    • text

    ----


    • -->P_FLDNAME text

    • -->P_TABNAME text

    • -->P_REF_FIELD text

    • -->P_REF_TABNA text

    ----


    FORM fill_fldcat_vbak USING p_fldname

    p_tabname

    p_ref_fieldname

    p_ref_tabname.

    fldcat_vbak-fieldname = p_fldname.

    fldcat_vbak-tabname = p_tabname.

    fldcat_vbak-ref_fieldname = p_ref_fieldname.

    fldcat_vbak-ref_tabname = p_ref_tabname.

    APPEND fldcat_vbak.

    CLEAR fldcat_vbak.

    ENDFORM.

    Add comment
    10|10000 characters needed characters exceeded