Application Development and Automation 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: 
Read only

Displaying Hierarchical sequential ALV

Former Member
0 Likes
728

Hi Guru's,

I have the following requirement.

A group header should be added above the material for product hierarchy. All materials within each product hierarchy should then display below the product hierarchy group header. Materials within the group hierarchy should be sorted by material number. Exp.

Product-1

-


marteial-1.1

Details-

-


marteial-1.2

Details-

====================

Product-2

-


marteial-2.1

Details

-


marteial-2.2

Details

-


marteial-2.2

Details

-


marteial-2.3

Details

like the above product hierarchy, I need to display the fields.

Please help me out.

Thanks in advance,

Amit varlani

Hi Guru's,

I have the following requirement.

A group header should be added above the material for product hierarchy. All materials within each product hierarchy should then display below the product hierarchy group header. Materials within the group hierarchy should be sorted by material number. Exp.

Product-1

-


marteial-1.1

Details-

-


marteial-1.2

Details-

====================

Product-2

-


marteial-2.1

Details

-


marteial-2.2

Details

-


marteial-2.2

Details

-


marteial-2.3

Details

like the above product hierarchy, I need to display the fields.

Please help me out.

Thanks in advance,

Amit varlani

4 REPLIES 4
Read only

former_member386202
Active Contributor
0 Likes
627

Hi,

refer these standard programs

BCALV_TEST_HIERSEQ_LIST Program BCALV_TEST_HIERSEQ_LIST

BCALV_TEST_HIERSEQ_LIST_EVENTS Program BCALV_TEST_HIERSEQ_LIST_EVENTS

BCALV_TREE_01 ALV tree control: build up the hierarchy tree

BCALV_TREE_DND ALV tree control: Drag & Drop within a hierarchy

BCALV_TREE_DND_MULTIPLE ALV tree control: Drag & Drop within a hierarchy'

Regards,

Prashant

Read only

0 Likes
627

Hi,

thanks for quick reply but all the programs don't solve the problem.

I required the exactly the same manner as I mentioned.

Thanks A lot,

Amit varlani

Read only

Former Member
0 Likes
627

Hi

Main Steps to create ALV Tree(Using Objects)

The ALV tree report produces uses OBJECT METHOD functionality in-order to produce a

tree structured ALV output.

The creation of an ALVtree report first requires the creation of a simple program to build the ALV

details such as the fieldcatalog and to call a screen which will be used to display the ALVTree.

The screen should be created with a 'custom control' where you wish the ALVtree report to appear.

For the following example it will have the name 'SCREEN_CONTAINER'.

Creation of Main Program code, Data declaration and screen call

Creation of 'INCLUDES' to store ALVtree code

Create Screen along with PBO and PAI modules for screen

Define OK CODE(SY-UCOMM) variable

Add screen control to PAI module(INCLUDE Z......I01)

Create pf-status

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

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

<b>Reward if usefull</b>

Read only

Former Member
0 Likes
627

hi,

I think 3 level hierarchy is not possible...

Only two level possible..

Like this

TYPE-POOLS : slis.

TABLES : mseg.

DATA : BEGIN OF itab_head OCCURS 0,

matnr LIKE mseg-matnr,

werks LIKE mseg-werks,

END OF itab_head.

DATA : BEGIN OF itab_item OCCURS 0,

matnr LIKE mseg-matnr,

werks LIKE mseg-werks,

mblnr LIKE mseg-mblnr,

menge LIKE mseg-menge,

END OF itab_item.

DATA : t_fcat TYPE slis_t_fieldcat_alv,

key_info TYPE slis_keyinfo_alv,

t_eve TYPE slis_t_event,

gt_subtot TYPE slis_t_sortinfo_alv,

subtot LIKE LINE OF gt_subtot,

t_listhead TYPE slis_t_listheader,

st_line TYPE slis_listheader.

DATA : t_mtdoc LIKE mseg-mblnr.

SELECT-OPTIONS : mat FOR mseg-matnr.

INITIALIZATION.

PERFORM build_cat USING t_fcat.

PERFORM build_eve.

START-OF-SELECTION.

PERFORM get_data.

PERFORM dis_data.

&----


*& Form build_cat

&----


  • text

----


  • -->TEMP_FCAT text

----


FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.

DATA : wa_fcat TYPE slis_fieldcat_alv.

wa_fcat-tabname = 'ITAB_HEAD'.

wa_fcat-fieldname = 'MATNR'.

wa_fcat-seltext_m = 'Material'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

wa_fcat-tabname = 'ITAB_HEAD'.

wa_fcat-fieldname = 'WERKS'.

wa_fcat-seltext_m = 'Plant'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

wa_fcat-tabname = 'ITAB_ITEM'.

wa_fcat-fieldname = 'MBLNR'.

wa_fcat-seltext_m = 'Material Doc.'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

wa_fcat-tabname = 'ITAB_ITEM'.

wa_fcat-fieldname = 'MENGE'.

wa_fcat-seltext_m = 'Quantity'.

  • wa_fcat-do_sum = 'Y'.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

  • subtot-spos = 1.

  • subtot-fieldname = 'MATNR'.

  • subtot-tabname = 'ITAB_HEAD'.

  • subtot-up = 'X'.

  • subtot-group = 'X'.

  • subtot-subtot = 'X'.

  • subtot-expa = 'X'.

  • APPEND subtot TO gt_subtot.

ENDFORM. "build_cat

&----


*& Form build_eve

&----


  • text

----


FORM build_eve.

DATA : wa_eve TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = t_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.

ENDFORM. "build_eve

&----


*& Form get_data

&----


  • text

----


FORM get_data.

SELECT matnr werks mblnr menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab_item

WHERE matnr IN mat.

ENDFORM. "get_data

&----


*& Form dis_data

&----


  • text

----


FORM dis_data.

key_info-header01 = 'MATNR'.

key_info-item01 = 'MATNR'.

key_info-header02 = 'WERKS'.

key_info-item02 = 'WERKS'.

REFRESH itab_head.

LOOP AT itab_item.

ON CHANGE OF itab_item-matnr OR itab_item-werks.

MOVE-CORRESPONDING itab_item TO itab_head.

APPEND itab_head.

ENDON.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

i_callback_program = 'ZHEIRALV_PRDS'

it_fieldcat = t_fcat

it_sort = gt_subtot

it_events = t_eve[]

i_tabname_header = 'ITAB_HEAD'

i_tabname_item = 'ITAB_ITEM'

is_keyinfo = key_info

TABLES

t_outtab_header = itab_head

t_outtab_item = itab_item

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

reward if useful..