Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Hierarchial

Former Member
0 Kudos

Hi,

I have a requirement like, when we click on one of the records in the grid display (first screen) I have to call a screen with 2 alv screens in the same screen. Among this 2 screens one is Hierarchial alv. I am using 'REUSE_ALV_GRID_DISPLAY' in the first screen and when double click I am calling a screen with 2 custom containers in it. For the first custom container I am using 'CL_GUI_ALV_GRID' to fill the data. Now I have to fill second container with Hierarchial alv. I have tried to find a class for hierarchial ALV. If anybody know how to do this, Please suggest me.

Thanks,

Ram

6 REPLIES 6

Former Member
0 Kudos

Hi Ram,

I don't think Hierarchial ALV is possible in controls. Instead try tree display.

Sample program BCALV_GRID_DND_TREE_SIMPLE.

Here also you will see two containers. The left most container uses the tree display. You can refer to the program.

Regards

Rajesh

0 Kudos

the class for hierarchical ALV is

<b>cl_gui_alv_tree</b> and the demo program is

<b>BCALV_TREE_DEMO</b>

Regards

Raja

former_member181959
Contributor
0 Kudos

hi...

i am giving an example program for ALV hierarchical reports. i hope it helpful to u.

it is working will. try it.

REPORT ZABAP_EX1 .

*TYPEPOOLS DECLARATION

  • for field catalog

TYPE-POOLS SLIS.

*TABLE DECLARATION

TABLES : KNA1,VBAK.

*INTERNAL TABLES DECLAREATION

DATA ITAB_KNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA ITAB_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.

*FIELD CATALOG DECLARATION

DATA FCAT_HIRC TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

*EVENTS DECLARATION

DATA EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE.

*LAYOUT DECLARATION

DATA LAYOUT TYPE SLIS_LAYOUT_ALV .

*FIELD CATLOG INTIALIZATION FOR CUSTOMER INFORMATION

FCAT_HIRC-COL_POS = 1.

FCAT_HIRC-FIELDNAME = 'KUNNR'.

FCAT_HIRC-REF_TABNAME = 'KNA1'.

FCAT_HIRC-TABNAME = 'ITAB_KNA1'.

APPEND FCAT_HIRC.

FCAT_HIRC-COL_POS = 2.

FCAT_HIRC-FIELDNAME = 'NAME1'.

FCAT_HIRC-REF_TABNAME = 'KNA1'.

FCAT_HIRC-TABNAME = 'ITAB_KNA1'.

APPEND FCAT_HIRC.

FCAT_HIRC-COL_POS = 3.

FCAT_HIRC-FIELDNAME = 'ORT01'.

FCAT_HIRC-REF_TABNAME = 'KNA1'.

FCAT_HIRC-TABNAME = 'ITAB_KNA1'.

APPEND FCAT_HIRC.

*FIELD CATLOG INTIALIZATION FOR SALES DOCUMENT HEADER

FCAT_HIRC-COL_POS = 1.

FCAT_HIRC-FIELDNAME = 'VBELN'.

FCAT_HIRC-REF_TABNAME = 'VBAK'.

FCAT_HIRC-TABNAME = 'ITAB_VBAK'.

APPEND FCAT_HIRC.

FCAT_HIRC-COL_POS = 2.

FCAT_HIRC-FIELDNAME = 'VKBUR'.

FCAT_HIRC-REF_TABNAME = 'VBAK'.

FCAT_HIRC-TABNAME = 'ITAB_VBAK'.

APPEND FCAT_HIRC.

FCAT_HIRC-COL_POS = 3.

FCAT_HIRC-FIELDNAME = 'NETWR'.

FCAT_HIRC-REF_TABNAME = 'VBAK'.

FCAT_HIRC-TABNAME = 'ITAB_VBAK'.

APPEND FCAT_HIRC.

DATA KEYINFO TYPE SLIS_KEYINFO_ALV.

SELECT * FROM KNA1 INTO TABLE ITAB_KNA1.

SELECT * FROM VBAK INTO TABLE ITAB_VBAK.

**

EVENTS-FORM = 'TOP_FORM'.

EVENTS-NAME = 'TOP_OF_PAGE'.

APPEND EVENTS.

*

*Customer's account number with credit limit reference

KEYINFO-HEADER01 = 'KUNNR'.

KEYINFO-ITEM01 = 'KUNNR'.

KEYINFO-HEADER02 = 'KNKLI'.

KEYINFO-ITEM02 = 'KNKLI'.

*

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

I_CALLBACK_PROGRAM = SY-CPROG

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IT_EXCLUDING =

.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_HS_APPEND'

EXPORTING

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FCAT_HIRC[]

IS_KEYINFO = KEYINFO

I_HEADER_TABNAME = 'ITAB_KNA1'

I_ITEM_TABNAME = 'ITAB_VBAK'

IT_EVENTS = EVENTS[]

  • IT_SORT =

  • I_TEXT = ' '

TABLES

T_OUTTAB_HEADER = ITAB_KNA1

T_OUTTAB_ITEM = ITAB_VBAK

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • MAXIMUM_OF_APPENDS_REACHED = 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_BLOCK_LIST_DISPLAY'

  • EXPORTING

  • I_INTERFACE_CHECK = ' '

  • IS_PRINT =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

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

WRITE :/25 'CUSTOMER WISE SALES ORDER INFORMATION ' COLOR 3.

ENDFORM.

Former Member
0 Kudos

The above example does not serve the requirement. Moreover, the example user the block list display. For hierarchical there is a different FM. Anyway that FM won't help.

For this requirment you will have to stick to tree display.

Former Member
0 Kudos

Hi Rambabu,

For the hierachical alv, you can use 'cl_gui_custom_container' container to fill the data and the tree as reference to 'cl_gui_list_tree'.

The demo Program 'BCALV_TREE_DEMO' can also be reffered for the usage.

Greetings,

Kiruthika

Former Member
0 Kudos

Hi,

U can have a look at this sample program

In essence, this is a call in one of my ABAPs

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.