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

ALV grid Tree

Hi All,

I am new to ABAP and was just working on ALV grid, can you please guide me through ALV TREE functionality. It will be great if you can please guide me through using simple program.

Thanks,

Rajeev !!!!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

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

    Hi Gupta,

    I think the following example will helpful to u,just have a look.

    HIERARCHICAL ALV REPORT.

    TYPE-POOLS: SLIS.

    DATA: BEGIN OF I_VBAK OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    ERNAM LIKE VBAK-ERNAM,

    ERDAT LIKE VBAK-ERDAT,

    AUDAT LIKE VBAK-AUDAT,

    VAR1,

    END OF I_VBAK.

    DATA: BEGIN OF I_VBAP OCCURS 0,

    VBELN LIKE VBAP-VBELN,

    POSNR LIKE VBAP-POSNR,

    MATNR LIKE VBAP-MATNR,

    CHARG LIKE VBAP-CHARG,

    END OF I_VBAP.

    DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

    LAYOUT TYPE SLIS_LAYOUT_ALV,

    KEY TYPE SLIS_KEYINFO_ALV.

    SELECT VBELN ERNAM ERDAT AUDAT FROM VBAK

    INTO CORRESPONDING FIELDS OF TABLE I_VBAK

    UP TO 20 ROWS.

    SELECT VBELN POSNR MATNR CHARG FROM VBAP

    INTO CORRESPONDING FIELDS OF TABLE I_VBAP

    UP TO 20 ROWS.

    FLDCAT-FIELDNAME = 'VBELN'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'VBELN'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'SALES DOC.'.

    FLDCAT-COL_POS = 0.

    FLDCAT-KEY = 'X'.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'ERNAM'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'ERNAM'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'NAME OF PERSON'.

    FLDCAT-COL_POS = 1.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'ERDAT'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'ERDAT'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'RECORD DATE'.

    FLDCAT-COL_POS = 2.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'AUDAT'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'AUDAT'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'DOCUMENT DATE'.

    FLDCAT-COL_POS = 3.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'POSNR'.

    FLDCAT-TABNAME = 'I_VBAP'.

    FLDCAT-REF_FIELDNAME = 'POSNR'.

    FLDCAT-REF_TABNAME = 'VBAP'.

    FLDCAT-SELTEXT_M = 'SALES DOC ITEM'.

    FLDCAT-COL_POS = 4.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'MATNR'.

    FLDCAT-TABNAME = 'I_VBAP'.

    FLDCAT-REF_FIELDNAME = 'MATNR'.

    FLDCAT-REF_TABNAME = 'VBAP'.

    FLDCAT-SELTEXT_M = 'MATERIAL NO'.

    FLDCAT-COL_POS = 5.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'CHARG'.

    FLDCAT-TABNAME = 'I_VBAP'.

    FLDCAT-REF_FIELDNAME = 'CHARG'.

    FLDCAT-REF_TABNAME = 'VBAP'.

    FLDCAT-SELTEXT_M = 'BATCH NUMBER'.

    FLDCAT-COL_POS = 6.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    LAYOUT-EXPAND_FIELDNAME = 'VAR1'.

    KEY-HEADER01 = 'VBELN'.

    KEY-ITEM01 = 'VBELN'.

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    I_CALLBACK_PROGRAM = SY-REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    IS_LAYOUT = LAYOUT

    IT_FIELDCAT = FLDCAT[]

    • 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 = 'I_VBAK'

    I_TABNAME_ITEM = 'I_VBAP'

    • I_STRUCTURE_NAME_HEADER =

    • I_STRUCTURE_NAME_ITEM =

    IS_KEYINFO = KEY

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    • IR_SALV_HIERSEQ_ADAPTER =

    • IT_EXCEPT_QINFO =

    • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB_HEADER = I_VBAK

    T_OUTTAB_ITEM = I_VBAP

    • 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.

    reward points,if it is helpful.

    Thanks

    chandu.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 31, 2008 at 01:26 AM

    Hi,

    You can type in ALV or SALV*TREE in SE38 and press F4 to see ALV examples. Hope this helps...

    P.S. Please award points if it helps...

    Add a comment
    10|10000 characters needed characters exceeded

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

    Hi Rajeev ,

    Check this program.

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

    Reward If useful.

    Regards,

    Chitra

    Add a comment
    10|10000 characters needed characters exceeded

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

    Hi Rajeev,

    check this code, will be of some help.

    REPORT ZBHALV_GRID.

    TABLES:LFA1,EKKO.

    SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.

    DATA:BEGIN OF ITAB OCCURS 0,

    LIFNR LIKE LFA1-LIFNR,

    NAME1 LIKE LFA1-NAME1,

    LAND1 LIKE LFA1-LAND1,

    ORT01 LIKE LFA1-ORT01,

    REGIO LIKE LFA1-REGIO,

    SORTL LIKE LFA1-SORTL,

    END OF ITAB.

    *DATA:BEGIN OF JTAB OCCURS 0,

    • LIFNR LIKE EKKO-LIFNR,

    • EBELN LIKE EKKO-EBELN,

    • BUKRS LIKE EKKO-BUKRS,

    • BSTYP LIKE EKKO-BSTYP,

    • BSART LIKE EKKO-BSART,

    *END OF JTAB.

    DATA:JTAB LIKE EKKO OCCURS 0 WITH HEADER LINE.

    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR

    IN LIFNR.

    SELECT * FROM EKKO INTO CORRESPONDING FIELDS OF TABLE JTAB WHERE LIFNR

    IN LIFNR.

    TYPE-POOLS:SLIS.

    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.

    DATA:KINFO TYPE SLIS_KEYINFO_ALV.

    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.

    DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.

    DATA:HEAD TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

    LAYOUT-ZEBRA = 'X'.

    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

    LAYOUT-WINDOW_TITLEBAR = 'VENDORS AND PURCHASE DOCCUMENTS

    DETAILS'.

    LAYOUT-numc_sum = 'X'.

    KINFO-HEADER01 = 'LIFNR'.

    KINFO-ITEM01 = 'LIFNR'.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = EVE[]

    EXCEPTIONS

    LIST_TYPE_WRONG = 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.

    READ TABLE EVE WITH KEY NAME = 'TOP_OF_PAGE'.

    EVE-FORM = 'TOPOFPAGE'.

    MODIFY EVE TRANSPORTING FORM WHERE NAME = 'TOP_OF_PAGE'.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = SY-REPID

    I_INTERNAL_TABNAME = 'ITAB'

    • I_STRUCTURE_NAME =

    • I_CLIENT_NEVER_DISPLAY = 'X'

    I_INCLNAME = SY-REPID

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    CHANGING

    CT_FIELDCAT = FCAT

    • EXCEPTIONS

    • INCONSISTENT_INTERFACE = 1

    • PROGRAM_ERROR = 2

    • OTHERS = 3

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    I_CALLBACK_PROGRAM = SY-REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    IS_LAYOUT = LAYOUT

    IT_FIELDCAT = FCAT

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_SCREEN_START_COLUMN = 5

    • I_SCREEN_START_LINE = 5

    • I_SCREEN_END_COLUMN = 120

    • I_SCREEN_END_LINE = 25

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = EVE[]

    • IT_EVENT_EXIT =

    I_TABNAME_HEADER = 'ITAB'

    I_TABNAME_ITEM = 'JTAB'

    I_STRUCTURE_NAME_HEADER = 'LFA1'

    I_STRUCTURE_NAME_ITEM = 'EKKO'

    IS_KEYINFO = KINFO

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB_HEADER = ITAB[]

    T_OUTTAB_ITEM = JTAB[]

    • 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 TOPOFPAGE.

    REFRESH HEAD.

    HEAD-TYP = 'H'.

    HEAD-INFO = 'VENDORS & PURCHASE DOCC. DETAILS'.

    APPEND HEAD.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = HEAD[]

    • I_LOGO = ' '

    • I_END_OF_LIST_GRID =

    .

    ENDFORM.

    cheers,

    Hema.

    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.