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

alv

Hi,

please let me know the mandatory fields in hierarchy alv?

Regards,

kb

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 29, 2007 at 12:05 PM

    thank u

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 29, 2007 at 07:02 AM

    Hi,

    For better understanding on ALV refer to

    http://www.sapgenie.com/abap/controls/alvgrid.htm

    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox

    http://www.sapfans.com/forums/viewtopic.php?t=58286

    http://www.sapfans.com/forums/viewtopic.php?t=76490

    http://www.sapfans.com/forums/viewtopic.php?t=20591

    http://www.sapfans.com/forums/viewtopic.php?t=66305

    http://www.sapfans.com/forums/viewtopic.php?t=11601

    http://www.sapfans.com/forums/viewtopic.php?t=23010

    http://www.sapfans.com/forums/viewtopic.php?t=20386

    http://www.sapfans.com/forums/viewtopic.php?t=85191

    http://www.sapfans.com/forums/viewtopic.php?t=88401

    http://www.sapfans.com/forums/viewtopic.php?t=17335

    http://www.sapfans.com/forums/viewtopic.php?t=58775

    http://www.sapfans.com/forums/viewtopic.php?t=60550

    http://www.sapfans.com/forums/viewtopic.php?t=16629

    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

    http://www.sapfans.com/forums/viewtopic.php?t=64320

    http://www.sapfans.com/forums/viewtopic.php?t=44477

    http://www.sapfans.com/forums/viewtopic.php?t=52107

    http://www.sapfans.com/forums/viewtopic.php?t=81149

    http://www.sapfans.com/forums/viewtopic.php?t=35498

    http://www.sapfans.com/forums/viewtopic.php?t=5013

    http://www.sapfans.com/forums/viewtopic.php?t=84933

    http://www.sapfans.com/forums/viewtopic.php?t=69878

    http://www.sapfans.com/forums/viewtopic.php?t=83243

    http://www.sapfans.com/forums/viewtopic.php?t=19224

    http://www.sapfans.com/forums/viewtopic.php?t=79424

    http://www.sapfans.com/forums/viewtopic.php?t=24512

    http://www.sapfans.com/forums/viewtopic.php?t=88376

    http://www.sapfans.com/forums/viewtopic.php?t=40968

    http://www.sapfans.com/forums/viewtopic.php?t=6919

    Regards

    Bala

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 29, 2007 at 07:03 AM

    hi

    <<<<<<<<<<<< are mandatory fields...

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    I_CALLBACK_PROGRAM = SY-CPROG <<<<<<<<<

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    • IS_LAYOUT = IS_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT[] <<<<<<<<<

    • IT_EXCLUDING = IT_EXCLUDING

    • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

    • IT_SORT = IT_SORT

    • IT_FILTER = IT_FILTER

    • IS_SEL_HIDE = 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 = IS_VARIANT

    • IT_EVENTS = IT_EVENTS

    • IT_EVENT_EXIT = IT_EVENT_EXIT

    I_TABNAME_HEADER = I_HEADERTAB <<<<<<<<<<<

    I_TABNAME_ITEM = I_ITEMTAB <<<<<<<<<<<<

    • I_STRUCTURE_NAME_HEADER = I_STRUCTURE_NAME_HEADER

    • I_STRUCTURE_NAME_ITEM = I_STRUCTURE_NAME_ITEM

    IS_KEYINFO = IS_KEYINFO <<<<<<<<<<<<

    • IS_PRINT = IS_PRINT

    • IS_REPREP_ID = IS_REPREP_ID

    • I_BYPASSING_BUFFER = I_BYPASSING_BUFFER

    • I_BUFFER_ACTIVE = I_BUFFER_ACTIVE

    • IR_SALV_HIERSEQ_ADAPTER = IR_SALV_HIERSEQ_ADAPTER

    • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

    • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

    • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

    TABLES

    T_OUTTAB_HEADER = IT_MARC <<<<<<<<<<<<

    T_OUTTAB_ITEM = IT_MARD <<<<<<<<<<<<

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 29, 2007 at 06:58 AM

    hi,

    The mandatory fields are

    callback program,

    fieldcatalog,

    outtab.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 29, 2007 at 07:04 AM

    HI,

    see this code.

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

    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.

    rgds,

    bharat.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 29, 2007 at 07:09 AM

    hi,

    mandatory fields are layout keyinfo and fieldcat

    LS_LAYOUT TYPE SLIS_LAYOUT_ALV,

    LS_KEYINFO TYPE SLIS_KEYINFO_ALV,

    LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

    EX:

    REPORT ZSR_ALV_HIERSEQ_LIST.

    TYPE-POOLS: SLIS. " ALV Global types

    ----


    CONSTANTS :

    C_X VALUE 'X',

    C_GT_VBAP TYPE SLIS_TABNAME VALUE 'GT_VBAP',

    C_GT_VBAK TYPE SLIS_TABNAME VALUE 'GT_VBAK'.

    ----


    SELECTION-SCREEN :

    SKIP,

    BEGIN OF LINE,COMMENT 5(27) V_1 FOR FIELD P_MAX. "#EC NEEDED

    PARAMETERS P_MAX(02) TYPE N DEFAULT '10' OBLIGATORY.

    SELECTION-SCREEN END OF LINE.

    SELECTION-SCREEN :

    SKIP, BEGIN OF LINE,COMMENT 5(27) V_2 FOR FIELD P_EXPAND. "#EC NEEDED

    PARAMETERS P_EXPAND AS CHECKBOX DEFAULT C_X.

    SELECTION-SCREEN END OF LINE.

    ----


    TYPES :

    • 1st Table

    BEGIN OF TY_VBAK,

    VBELN TYPE VBAK-VBELN, " Sales document

    KUNNR TYPE VBAK-KUNNR, " Sold-to party

    NETWR TYPE VBAK-NETWR, " Net Value of the Sales Order

    ERDAT TYPE VBAK-ERDAT, " Creation date

    WAERK TYPE VBAK-WAERK, " SD document currency

    EXPAND TYPE XFELD,

    END OF TY_VBAK,

    • 2nd Table

    BEGIN OF TY_VBAP,

    VBELN TYPE VBAP-VBELN, " Sales document

    POSNR TYPE VBAP-POSNR, " Sales document

    MATNR TYPE VBAP-MATNR, " Material number

    NETWR TYPE VBAP-NETWR, " Net Value of the Sales Order

    WAERK TYPE VBAP-WAERK, " SD document currency

    END OF TY_VBAP.

    ----


    DATA :

    • 1st Table

    GT_VBAK TYPE TABLE OF TY_VBAK,

    • 2nd Table

    GT_VBAP TYPE TABLE OF TY_VBAP.

    ----


    INITIALIZATION.

    V_1 = 'Maximum of records to read'.

    V_2 = 'With ''EXPAND'' field'.

    ----


    START-OF-SELECTION.

    • Read Sales Document: Header Data

    SELECT VBELN KUNNR NETWR WAERK ERDAT

    FROM VBAK

    UP TO P_MAX ROWS

    INTO CORRESPONDING FIELDS OF TABLE GT_VBAK.

    IF NOT GT_VBAK[] IS INITIAL.

    • Read Sales Document: Item Data

    SELECT VBELN POSNR MATNR NETWR WAERK

    FROM VBAP

    INTO CORRESPONDING FIELDS OF TABLE GT_VBAP

    FOR ALL ENTRIES IN GT_VBAK

    WHERE VBELN = GT_VBAK-VBELN.

    ENDIF.

    PERFORM F_DISPLAY.

    ----


    • Form F_DISPLAY

    ----


    FORM F_DISPLAY.

    • Macro definition

    DEFINE M_FIELDCAT.

    LS_FIELDCAT-TABNAME = &1.

    LS_FIELDCAT-FIELDNAME = &2.

    LS_FIELDCAT-REF_TABNAME = &3.

    LS_FIELDCAT-CFIELDNAME = &4. " Field with currency unit

    APPEND LS_FIELDCAT TO LT_FIELDCAT.

    END-OF-DEFINITION.

    DEFINE M_SORT.

    LS_SORT-TABNAME = &1.

    LS_SORT-FIELDNAME = &2.

    LS_SORT-UP = C_X.

    APPEND LS_SORT TO LT_SORT.

    END-OF-DEFINITION.

    DATA:

    LS_LAYOUT TYPE SLIS_LAYOUT_ALV,

    LS_KEYINFO TYPE SLIS_KEYINFO_ALV,

    LS_SORT TYPE SLIS_SORTINFO_ALV,

    LT_SORT TYPE SLIS_T_SORTINFO_ALV," Sort table

    LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

    LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV." Field catalog

    LS_LAYOUT-GROUP_CHANGE_EDIT = C_X.

    LS_LAYOUT-COLWIDTH_OPTIMIZE = C_X.

    LS_LAYOUT-ZEBRA = C_X.

    LS_LAYOUT-DETAIL_POPUP = C_X.

    LS_LAYOUT-GET_SELINFOS = C_X.

    IF P_EXPAND = C_X.

    LS_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.

    ENDIF.

    • Build field catalog and sort table

    M_FIELDCAT C_GT_VBAK 'VBELN' 'VBAK' ''.

    M_FIELDCAT C_GT_VBAK 'KUNNR' 'VBAK' ''.

    M_FIELDCAT C_GT_VBAK 'NETWR' 'VBAK' 'WAERK'.

    M_FIELDCAT C_GT_VBAK 'WAERK' 'VBAK' ''.

    M_FIELDCAT C_GT_VBAK 'ERDAT' 'VBAK' ''.

    M_FIELDCAT C_GT_VBAP 'POSNR' 'VBAP' ''.

    M_FIELDCAT C_GT_VBAP 'MATNR' 'VBAP' ''.

    M_FIELDCAT C_GT_VBAP 'NETWR' 'VBAP' 'WAERK'.

    M_FIELDCAT C_GT_VBAP 'WAERK' 'VBAP' ''.

    M_SORT C_GT_VBAK 'KUNNR'.

    M_SORT C_GT_VBAP 'NETWR'.

    LS_KEYINFO-HEADER01 = 'VBELN'.

    LS_KEYINFO-ITEM01 = 'VBELN'.

    LS_KEYINFO-ITEM02 = 'POSNR'.

    • Dipslay Hierarchical list

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-CPROG

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    IS_LAYOUT = LS_LAYOUT

    IT_FIELDCAT = LT_FIELDCAT

    IT_SORT = LT_SORT

    I_TABNAME_HEADER = C_GT_VBAK

    I_TABNAME_ITEM = C_GT_VBAP

    IS_KEYINFO = LS_KEYINFO

    TABLES

    T_OUTTAB_HEADER = GT_VBAK

    T_OUTTAB_ITEM = GT_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.

    ENDFORM. " F_LIST_DISPLAY

    ----


    • Form USER_COMMAND *

    ----


    FORM USER_COMMAND USING I_UCOMM TYPE SY-UCOMM

    IS_SELFIELD TYPE SLIS_SELFIELD. "#EC CALLED

    DATA LS_VBAK TYPE TY_VBAK.

    CASE I_UCOMM.

    WHEN '&IC1'. " Pick

    CASE IS_SELFIELD-TABNAME.

    WHEN C_GT_VBAP.

    WHEN C_GT_VBAK.

    READ TABLE GT_VBAK INDEX IS_SELFIELD-TABINDEX INTO LS_VBAK.

    IF SY-SUBRC EQ 0.

    • Sales order number

    SET PARAMETER ID 'AUN' FIELD LS_VBAK-VBELN.

    • Display Sales Order

    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. " USER_COMMAND

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 29, 2007 at 07:12 AM

    HI.

    refer this ..

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    i_interface_check = 'I'

    i_callback_program = gv_repid

    • i_callback_pf_status_set = 'STATUS_DATA'

    i_callback_user_command = 'COMMAND_DATA'

    • is_layout = gs_layout

    it_fieldcat = gt_fieldcat

    i_default = ' '

    i_save = 'A'

    i_tabname_header = v_headers_itable

    i_tabname_item = v_items_itable

    i_structure_name_header = v_headers_table

    i_structure_name_item = v_items_table

    is_keyinfo = gs_keyinfo

    i_bypassing_buffer = 'X'

    TABLES

    t_outtab_header = i_headers

    • t_outtab_item = i_result

    t_outtab_item = i_report

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    The field cat creation worked like this :

    FORM fieldcat.

    DATA: ls_fieldcat TYPE slis_fieldcat_alv.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    i_internal_tabname = v_items_itable

    i_structure_name = v_items_table

    CHANGING

    ct_fieldcat = gt_fieldcat.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    i_internal_tabname = v_headers_itable

    i_structure_name = v_headers_table

    CHANGING

    ct_fieldcat = gt_fieldcat.

    ENDFORM.

    and of course you need to tell the thing what is key and item

    gs_keyinfo-header01 = 'PA'.

    gs_keyinfo-item01 = 'PA'.

    gs_keyinfo-item02 = 'SAPDOC'.

    PERFORM fieldcat.

    Reward all helpfull answers.

    Regards.

    Jay

    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.