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: 

Appending REUSE_ALV_HIERSEQ_LIST_DISPLAY

Former Member
0 Kudos
123

Hai all,

I am displaying some text like material details for 5 lines ,then i am displaying the header and item of that material using REUSE_ALV_HIERSEQ_LIST_DISPLAY.

for a specific material which is given as a parameter.

Now i am going to replace the Material (Parameter) to RANGE of materials (select-options)..So i need to..call the REUSE_ALV_HIERSEQ_LIST_DISPLAY number of times...how can this be achieved .............I am using F.M . and i dont want OOPS ...Do i need to set any Layout or will it get automtically appended.

Regards,

Dev

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos
57

It will display fine if you correctly fill IS_KEYINFO parameter.

Header 1
Line 1 1
Line 1 2
Header 2
Line 2 1..

.

Regards

Former Member
0 Kudos
57

Hi,

you just need to populate Header and Item tables and define the relation. List function module will take care of displaying Header data and corresponding item data.

Check these examples for details -

http://www.geocities.com/mpioud/Z_ALV_HIERSEQ_LIST.html

Hope this helps.

ashish

Former Member
0 Kudos
57

Hi

just execute the code below,


TABLES:LFA1,EKKO.

SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.


DATA:ITAB LIKE LFA1 OCCURS 0 WITH HEADER LINE.
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.

plz reward,if it is usefull to u.

Former Member
0 Kudos
57

hi,

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

READ TABLE t_eve INTO wa_eve WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc = 0.

wa_eve-form = 'TOP_OF_PAGE'.

MODIFY t_eve FROM wa_eve INDEX sy-tabix.

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'

  • i_callback_user_command = 'USER_COMMAND'

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

&----


*& Form user_Command

&----


  • text

----


  • -->U_COMM text

  • -->SELFIELD text

----


*FORM user_command USING u_comm TYPE sy-ucomm selfield TYPE slis_selfield.

*

  • CASE u_comm.

  • WHEN '&IC1'.

  • READ TABLE itab_item INDEX selfield-tabindex.

  • t_mtdoc = itab_item-mblnr.

  • SET PARAMETER ID 'MBN' FIELD t_mtdoc.

  • CALL TRANSACTION 'MIGO' AND SKIP FIRST SCREEN.

  • ENDCASE.

*ENDFORM. "user_Command

&----


*& Form top_of_page

&----


  • text

----


FORM top_of_page.

CLEAR st_line.

st_line-typ = 'H'.

st_line-info = 'Dhwani Shah'.

APPEND st_line TO t_listhead.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_listhead

  • I_LOGO =

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

ENDFORM. "top_of_page