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

hierarchical ALV list in expended mode (Collapsed) in default

I am looking for help to display the hierarchical ALV list in expended mode (Collapsed

) . I had take expended in the structure for the same.

TYPES : BEGIN OF ty_icdhdr,

CHANGENR type CDCHANGENR,

PLANCHNGNR type PLANCHNGNR,

UDATE type UDATE,

UTIME type UTIME,

USERNAME type USERNAME,

aetxt TYPE aetxt,

aegru TYPE aegru, " Reason for change

expand.

TYPES END OF ty_icdhdr.

But while setting values for lay out it_layout-expand_fieldname = 'EXPAND' will not gives the collapsed view rather gives the hotspot to collapse the list.

*----


  • Complete program is as

*&----


*& Report ZTEST_MAT_CHG_HIERARCHYLIST *

*&----


*& RM : hierarchical sequential list display of material change *

*&----


REPORT ZTEST_MAT_CHG_HIERARCHYLIST .

  • type-pools declarations for alv and icon

TYPE-POOLS: slis,icon.

*structure declaration for table details

TYPES : BEGIN OF ty_icdhdr,

CHANGENR type CDCHANGENR,

PLANCHNGNR type PLANCHNGNR,

UDATE type UDATE,

UTIME type UTIME,

USERNAME type USERNAME,

aetxt TYPE aetxt,

aegru TYPE aegru, " Reason for change

expand.

TYPES END OF ty_icdhdr.

  • cdhdr

*internal table and wa decln for table details

DATA : it_cdhdr TYPE TABLE OF ty_icdhdr,

wa_cdhdr TYPE ty_icdhdr.

TYPES : BEGIN OF ty_ausg,

CHANGENR type CDCHANGENR,

PLANCHNGNR type PLANCHNGNR,

FTEXT type FTEXT,

  • FNAME type FNAME,

CDSHWIND type CDSHWIND,

F_OLD type CDFLDVALO,

F_NEW type CDFLDVALN.

  • INCLUDE STRUCTURE cdshw.

TYPES END OF ty_ausg.

*Internal table and wa decln for field details

DATA : it_ausg TYPE STANDARD TABLE OF ty_ausg,

wa_ausg TYPE ty_ausg.

DATA: BEGIN OF ausg OCCURS 50.

INCLUDE STRUCTURE cdshw.

DATA: END OF ausg.

DATA: BEGIN OF icdhdr OCCURS 50.

INCLUDE STRUCTURE CDHDR.

DATA: END OF icdhdr.

data : ls_cdhdr like CDHDR.

  • ls_cdshw like CDSHW.

DATA: BEGIN OF export OCCURS 0,

head LIKE cdhdr,

pos LIKE cdshw OCCURS 10,

END OF export.

*Mat Detata

DATA: objekt LIKE cdhdr-objectclas,

objektid LIKE cdhdr-objectid .

*data declarations for ALV

DATA : it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

it_layout TYPE slis_layout_alv,

key TYPE slis_keyinfo_alv.

*Input the tables.User cannot enter a range but can enter any number

*of tables one by one in this select-options

SELECT-OPTIONS : s_table FOR objektid NO INTERVALS.

*initializatin event

INITIALIZATION.

*start-of-selection event

START-OF-SELECTION.

*subroutine to fetch the data from the tables

  • PERFORM fetch_tabledata.

perform getdata.

*subroutine to build alv hierarchy output

PERFORM hierarchyalv_build.

&----


*& Form hierarchyalv_build

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form hierarchyalv_build .

*fieldcatalogue

perform build_fieldcat.

*layout

perform build_layout.

*key information for hierarchy

perform build_key.

*output

perform list_display.endform. " hierarchyalv_build

&----


*& Form build_fieldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fieldcat .

*Header DATA

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'PLANCHNGNR'.

wa_fieldcat-tabname = 'IT_CDHDR'.

wa_fieldcat-seltext_m = 'Change Number'.

wa_fieldcat-key = 'X'.

wa_fieldcat-emphasize = 'C110'. APPEND wa_fieldcat TO it_fieldcat.

*PLANCHNGNR CHANGENR

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 2.

wa_fieldcat-fieldname = 'UDATE'.

wa_fieldcat-tabname = 'IT_CDHDR'.

wa_fieldcat-seltext_m = 'Updating Date'.

wa_fieldcat-emphasize = 'C110'. APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 3.

wa_fieldcat-fieldname = 'UTIME'.

wa_fieldcat-tabname = 'IT_CDHDR'.

wa_fieldcat-seltext_m = 'Time'.

wa_fieldcat-emphasize = 'C110'. APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 4.

wa_fieldcat-fieldname = 'USERNAME'.

wa_fieldcat-tabname = 'IT_CDHDR'.

wa_fieldcat-seltext_m = 'User Name'.

wa_fieldcat-emphasize = 'C110'. APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 5.

wa_fieldcat-fieldname = 'AETXT'.

wa_fieldcat-tabname = 'IT_CDHDR'.

wa_fieldcat-seltext_m = 'Reason'.

  • wa_fieldcat-reptext_ddic = 'Reason'.

  • wa_fieldcat-outputlen = 50.

wa_fieldcat-emphasize = 'C110'. APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 6.

wa_fieldcat-fieldname = 'AEGRU'.

wa_fieldcat-tabname = 'IT_CDHDR'.

wa_fieldcat-seltext_m = 'Origin'.

wa_fieldcat-emphasize = 'C110'. APPEND wa_fieldcat TO it_fieldcat.

  • ITEM DATA

  • CLEAR wa_fieldcat. wa_fieldcat-col_pos = 7.

  • wa_fieldcat-fieldname = 'CDSHWIND'.

  • wa_fieldcat-tabname = 'IT_AUSG'.

  • wa_fieldcat-key = 'X'.

  • wa_fieldcat-seltext_m = 'Change type'.

  • wa_fieldcat-EMPHASIZE = 'C600'. APPEND wa_fieldcat TO it_fieldcat.

  • CLEAR wa_fieldcat. wa_fieldcat-col_pos = 8.

    wa_fieldcat-fieldname = 'FTEXT'.

    wa_fieldcat-tabname = 'IT_AUSG'.

    wa_fieldcat-key = 'X'.

    wa_fieldcat-seltext_m = 'Field Changed'.

    wa_fieldcat-EMPHASIZE = 'C400'. APPEND wa_fieldcat TO it_fieldcat.

    CLEAR wa_fieldcat. wa_fieldcat-col_pos = 9.

    wa_fieldcat-fieldname = 'F_OLD'.

    wa_fieldcat-tabname = 'IT_AUSG'.

    wa_fieldcat-seltext_m = 'Old Value'.

    wa_fieldcat-just = 'R'.

    wa_fieldcat-EMPHASIZE = 'C400'. APPEND wa_fieldcat TO it_fieldcat.

    CLEAR wa_fieldcat. wa_fieldcat-col_pos = 10.

    wa_fieldcat-fieldname = 'F_NEW'.

    wa_fieldcat-tabname = 'IT_AUSG'.

    wa_fieldcat-seltext_m = 'New Value'.

    wa_fieldcat-just = 'R'.

    wa_fieldcat-EMPHASIZE = 'C400'.

    APPEND wa_fieldcat TO it_fieldcat.

    • APPEND wa_fieldcat TO it_fieldcat.

    endform. " build_fieldcat

    &----


    *& Form build_layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form build_layout .

    *to expand the header table for item details

    *COLLAPSED

    it_layout-expand_fieldname = 'EXPAND'.

    CONCATENATE 'Material' s_table-low 'Change History' INTO it_layout-window_titlebar SEPARATED BY space.

    • it_layout-window_titlebar = 'Material Change History'.

    it_layout-lights_tabname = 'IT_AUSG'.

    it_layout-colwidth_optimize = 'X'.

    endform. " build_layout

    &----


    *& Form build_key

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form build_key .

    *key infomation for the header and item table

    key-header01 = 'CHANGENR'.

    key-item01 = 'CHANGENR'.

    endform. " build_key

    &----


    *& Form list_display

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form list_display .

    *ALV output

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-cprog

    is_layout = it_layout

    it_fieldcat = it_fieldcat

    i_tabname_header = 'IT_CDHDR'

    i_tabname_item = 'IT_AUSG'

    is_keyinfo = key

    TABLES

    t_outtab_header = it_cdhdr

    t_outtab_item = it_ausg.

    endform. " list_display

    &----


    *& Form fetch_tabledata

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    &----


    form getdata.

    DATA: ls_cdhdr type cdhdr.

    DATA archive.

    DATA: lv_return TYPE bapiret2 OCCURS 0,

    lv_address TYPE bapiaddr3.

    DATA: gv_first_name TYPE ad_namefir,

    gv_last_name TYPE ad_namelas.

    DATA: lt_aennr TYPE TABLE OF ccaennr with header line,

    lt_aenr TYPE TABLE OF aenr with header line.

    DATA: nummer LIKE cdhdr-changenr,

    tabname LIKE cdpos-tabname,

    tabkey LIKE cdpos-tabkey.

    objekt ='MATERIAL'.

    objektid = s_table-low .

    CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'

    EXPORTING

    objectclass = objekt

    objectid = objektid

    username = space

    TABLES

    i_cdhdr = icdhdr

    EXCEPTIONS

    no_position_found = 1

    OTHERS = 2.

    LOOP AT icdhdr.

    • move-corresponding icdhdr to wa_cdhdr.

    • get firstname and lastname for username

    CALL FUNCTION 'BAPI_USER_GET_DETAIL'

    EXPORTING

    username = icdhdr-username

    IMPORTING

    address = lv_address

    TABLES

    return = lv_return .

    gv_first_name = lv_address-firstname.

    gv_last_name = lv_address-lastname.

    CONCATENATE gv_first_name gv_last_name INTO icdhdr-username SEPARATED BY space.

    MODIFY icdhdr TRANSPORTING username WHERE username = icdhdr-username.

    CLEAR: gv_first_name , gv_last_name.

    lt_aennr-change_no = icdhdr-planchngnr.

    APPEND lt_aennr.

    CLEAR lt_aennr.

    *get reason n origin for change number

    CALL FUNCTION 'BU_CHANGE_NUMBER_TABLE_READ'

    TABLES

    t_i_aennr = lt_aennr

    t_o_aenr = lt_aenr.

    move-corresponding icdhdr to wa_cdhdr.

    wa_cdhdr-aegru = lt_aenr-aegru.

    wa_cdhdr-aetxt = lt_aenr-aetxt.

    append wa_cdhdr to it_cdhdr.

    CLEAR: wa_cdhdr,icdhdr.

    ENDLOOP.

    LOOP AT it_cdhdr into wa_cdhdr.

    refresh ausg.

    clear ls_cdhdr.

    nummer = wa_cdhdr-CHANGENR.

    • nummer = wa_cdhdr-PLANCHNGNR.

    move-corresponding wa_cdhdr to ls_cdhdr.

    CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'

    EXPORTING

    changenumber = nummer

    tablename = tabname

    tablekey = tabkey

    IMPORTING

    header = ls_cdhdr

    TABLES

    editpos = ausg

    EXCEPTIONS

    no_position_found = 1

    OTHERS = 2.

    loop at ausg.

    clear wa_ausg.

    move-corresponding ausg to wa_ausg.

    wa_ausg-CHANGENR = wa_cdhdr-CHANGENR.

    append wa_ausg to it_ausg.

    endloop.

    ENDLOOP.

    endform.

    *----


    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    1 Answer

    • author's profile photo Former Member
      Former Member
      Posted on Feb 24, 2009 at 11:29 AM

      Hi,

      Check the demo program

      BCALV_TEST_HIERSEQ_LIST_EVENTS

      BCALV_TEST_HIERSEQ_LIST

      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.