cancel
Showing results for 
Search instead for 
Did you mean: 

REUSE_ALV_HIERSEQ_LIST_DISPLAY

Former Member
0 Kudos

hi,

I am not able to get the output using this function module REUSE_ALV_HIERSEQ_LIST_DISPLAY.

In my program i even wanted to add new columns to the output table.

i am not getting the correct output.

I have even compared my code with your code but there is no error in my code. Still no correct output.

I want to know about the input parameters in this function module.

plz reply me its urgent..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

<b>Hierarchical display is used for displaying data that are related. Like sales order and item details. Here sales order details can be the header data whereas them items in the sales order can be the item data</b>

<b>Export:</b>

a. I_CALLBACK_PROGRAM

b. I_CALLBACK_PF_STATUS_SET

c. I_CALLBACK_USER_COMMAND

d. IS_LAYOUT

e. <b>It_fieldcat</b>

f. <b> It_events</b>

g. <b>I_tabname_header</b> : Name of the internal table in the program

containing the output data of the highest hierarchy level.

h. <b>I_tabname_item</b> : Name of the internal table in the program containing

the output data of the lowest hierarchy level.

i. <b> Is_keyinfo</b> : This structure contains the header and item table field

names which link the two tables (shared key).

<b>Tables </b>

a. t_outtab_header : Header table with data to be output

b. t_outtab_item : Name of the internal table in the program containing

the output data of the lowest hierarchy level.

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Answers (8)

Answers (8)

Former Member
0 Kudos

Hi,

Plz compare your code with the following code and increase fields in your field catalouge to increase the fields in field catalogue.

&----


*& Report ZTEST_HIRERACHY_NEW *

*& *

&----


*& *

*& *

&----


report ztest_hirerachy_new .

tables : stko,stpo,makt,mast.

type-pools : slis.

data : begin of istko occurs 0,

stlnr like stko-stlnr,

datuv like stko-datuv,

matnr like mast-matnr,

bmeng like stko-bmeng,

bmein like stko-bmein,

end of istko.

data : begin of istpo occurs 0,

stlnr like stpo-stlnr,

idnrk like stpo-idnrk,

menge like stpo-menge,

meins like stpo-meins,

maktx like makt-maktx,

end of istpo.

data : begin of imakt occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of imakt.

data : begin of imast occurs 0,

matnr like mast-matnr,

stlnr like mast-stlnr,

end of imast.

data : ifieldcat type slis_t_fieldcat_alv,

wfieldcat type slis_fieldcat_alv,

ilayout type slis_layout_alv,

ikeyinfo type slis_keyinfo_alv,

ievent type slis_t_event,

wevent type slis_alv_event,

isort type slis_t_sortinfo_alv,

wsort type slis_sortinfo_alv.

parameters : p_num type i default 10.

start-of-selection.

perform getdata.

perform getheadermat.

perform get_mat_desc.

perform build_fcat_head.

perform build_fcat_item.

perform build_keyinfo.

perform build_event_tab.

perform build_sort_tab.

perform build_layout.

perform display_data.

&----


*& Form GETDATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form getdata .

select stlnr datuv bmeng bmein into corresponding fields of table

istko

from stko up to p_num rows.

if not istko[] is initial.

select stlnr idnrk menge meins into table istpo from stpo for all

entries in istko

where stlnr = istko-stlnr and postp = 'L'.

endif.

endform. " GETDATA

&----


*& Form BUILD_FCAT_HEAD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fcat_head .

wfieldcat-tabname = 'ISTKO'.

wfieldcat-fieldname = 'STLNR'.

wfieldcat-seltext_l = 'BOM no'.

wfieldcat-outputlen = 15.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTKO'.

wfieldcat-fieldname = 'DATUV'.

wfieldcat-seltext_l = 'BOM date'.

wfieldcat-outputlen = 15.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTKO'.

wfieldcat-fieldname = 'MATNR'.

wfieldcat-seltext_l = 'Header mat no'.

wfieldcat-outputlen = 18.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTKO'.

wfieldcat-fieldname = 'BMENG'.

wfieldcat-seltext_l = 'Base qty'.

wfieldcat-outputlen = 15.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTKO'.

wfieldcat-fieldname = 'BMEIN'.

wfieldcat-seltext_l = 'UOM'.

wfieldcat-outputlen = 3.

append wfieldcat to ifieldcat.

clear wfieldcat.

endform. " BUILD_FCAT_HEAD

&----


*& Form BUILD_FCAT_ITEM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fcat_item .

wfieldcat-tabname = 'ISTPO'.

wfieldcat-fieldname = 'STLNR'.

wfieldcat-seltext_l = 'BOM no'.

wfieldcat-no_out = 'X'.

*WFIELDCAT-HOTSPOT = 'X'.

wfieldcat-outputlen = 10.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTPO'.

wfieldcat-fieldname = 'IDNRK'.

wfieldcat-seltext_l = 'Material no'.

*WFIELDCAT-HOTSPOT = 'X'.

wfieldcat-outputlen = 18.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTPO'.

wfieldcat-fieldname = 'MAKTX'.

wfieldcat-seltext_l = 'Material desc'.

wfieldcat-just = 'C'.

wfieldcat-outputlen = 30.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTPO'.

wfieldcat-fieldname = 'MENGE'.

wfieldcat-seltext_l = 'Item qty'.

wfieldcat-outputlen = 15.

wfieldcat-do_sum = 'X'.

append wfieldcat to ifieldcat.

clear wfieldcat.

wfieldcat-tabname = 'ISTPO'.

wfieldcat-fieldname = 'MEINS'.

wfieldcat-seltext_l = 'UOM'.

wfieldcat-outputlen = 3.

append wfieldcat to ifieldcat.

clear wfieldcat.

endform. " BUILD_FCAT_ITEM

&----


*& Form BUILD_KEYINFO

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_keyinfo .

ikeyinfo-header01 = 'STLNR'.

ikeyinfo-item01 = 'STLNR'.

endform. " BUILD_KEYINFO

&----


*& Form DISPLAY_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_data .

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 = 'USER_COM'

is_layout = ilayout

it_fieldcat = ifieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = isort

  • IT_FILTER =

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

it_events = ievent[]

  • IT_EVENT_EXIT =

i_tabname_header = 'ISTKO'

i_tabname_item = 'ISTPO'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = ikeyinfo

  • 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 = istko

t_outtab_item = istpo

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

&----


*& Form GET_MAT_DESC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_mat_desc .

if not istpo[] is initial.

select matnr maktx into table imakt from makt for all entries in

istpo

where matnr = istpo-idnrk.

endif.

loop at istpo.

read table imakt with key matnr = istpo-idnrk.

if sy-subrc = 0.

istpo-maktx = imakt-maktx.

endif.

modify istpo.

endloop.

endform. " GET_MAT_DESC

&----


*& Form BUILD_LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_layout .

ilayout-zebra = 'X'.

ilayout-colwidth_optimize = 'X'.

endform. " BUILD_LAYOUT

*FORM USER_COM USING PUCOM LIKE SY-UCOMM PSELFIELD TYPE SLIS_SELFIELD.

*

*CASE PUCOM.

*WHEN '&IC1'.

  • SET PARAMETER ID 'MAT' FIELD PSELFIELD-VALUE.

  • CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

*ENDCASE.

*

*ENDFORM.

&----


*& Form BUILD_EVENT_TAB

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_event_tab .

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = ievent

  • 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 ievent into wevent with key name = 'TOP_OF_PAGE'.

if sy-subrc = 0.

wevent-form = 'TOPOFPAGE'.

modify ievent from wevent index sy-tabix.

endif.

endform. " BUILD_EVENT_TAB

&----


*& Form TOPOFPAGE

&----


  • text

----


form topofpage.

data : ilisthead type slis_t_listheader,

wlisthead type slis_listheader.

wlisthead-info = 'Its a test hierarchical sequential alv dispaly'.

wlisthead-typ = 'H'.

append wlisthead to ilisthead.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = ilisthead

  • I_LOGO = ''

  • I_END_OF_LIST_GRID =

.

endform. "TOPOFPAGE

&----


*& Form GETHEADERMAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form getheadermat .

if not istko[] is initial.

select matnr stlnr into table imast from mast for all entries in istko

where stlnr = istko-stlnr.

endif.

loop at istko.

read table imast with key stlnr = istko-stlnr.

if sy-subrc = 0.

istko-matnr = imast-matnr.

endif.

modify istko.

endloop.

endform. " GETHEADERMAT

&----


*& Form BUILD_SORT_TAB

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_sort_tab .

wsort-fieldname = 'STLNR'.

wsort-tabname = 'ISTPO'.

wsort-up = 'X'.

wsort-subtot = 'X'.

wsort-group = 'UL'.

append wsort to isort.

endform. " BUILD_SORT_TAB

regards,

Ruchika saini

former_member198270
Active Contributor
0 Kudos

Hi Geetika ,

Please find the piece of code.

&----


*& Report Z8AS_PROGRAM_ALV

*&

&----


*&

*&

&----


REPORT Z8AS_PROGRAM_ALV.

TABLES : STKO,STPO,MAKT,MAST.

TYPE-POOLS : SLIS.

DATA : BEGIN OF ISTKO OCCURS 0,

STLNR LIKE STKO-STLNR,

DATUV LIKE STKO-DATUV,

MATNR LIKE MAST-MATNR,

BMENG LIKE STKO-BMENG,

BMEIN LIKE STKO-BMEIN,

END OF ISTKO.

DATA : BEGIN OF ISTPO OCCURS 0,

STLNR LIKE STPO-STLNR,

IDNRK LIKE STPO-IDNRK,

MENGE LIKE STPO-MENGE,

MEINS LIKE STPO-MEINS,

MAKTX LIKE MAKT-MAKTX,

END OF ISTPO.

DATA : BEGIN OF IMAKT OCCURS 0,

MATNR LIKE MAKT-MATNR,

MAKTX LIKE MAKT-MAKTX,

END OF IMAKT.

DATA : BEGIN OF IMAST OCCURS 0,

MATNR LIKE MAST-MATNR,

STLNR LIKE MAST-STLNR,

END OF IMAST.

DATA : IFIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WFIELDCAT TYPE SLIS_FIELDCAT_ALV,

ILAYOUT TYPE SLIS_LAYOUT_ALV,

IKEYINFO TYPE SLIS_KEYINFO_ALV,

IEVENT TYPE SLIS_T_EVENT,

WEVENT TYPE SLIS_ALV_EVENT.

PARAMETERS : P_NUM TYPE I .

START-OF-SELECTION.

PERFORM GETDATA.

PERFORM GETHEADERMAT.

PERFORM GET_MAT_DESC.

PERFORM BUILD_FCAT_HEAD.

PERFORM BUILD_FCAT_ITEM.

PERFORM BUILD_KEYINFO.

PERFORM BUILD_EVENT_TAB.

PERFORM BUILD_LAYOUT.

PERFORM DISPLAY_DATA.

&----


*& Form GETDATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GETDATA .

SELECT STLNR DATUV BMENG BMEIN INTO CORRESPONDING FIELDS OF TABLE ISTKO

FROM STKO UP TO P_NUM ROWS.

IF NOT ISTKO[] IS INITIAL.

SELECT STLNR IDNRK MENGE MEINS INTO TABLE ISTPO FROM STPO FOR ALL ENTRIES IN ISTKO

WHERE STLNR = ISTKO-STLNR AND POSTP = 'L'.

ENDIF.

ENDFORM. " GETDATA

&----


*& Form BUILD_FCAT_HEAD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FCAT_HEAD .

WFIELDCAT-TABNAME = 'ISTKO'.

WFIELDCAT-FIELDNAME = 'STLNR'.

WFIELDCAT-SELTEXT_L = 'BOM no'.

WFIELDCAT-OUTPUTLEN = 15.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

WFIELDCAT-TABNAME = 'ISTKO'.

WFIELDCAT-FIELDNAME = 'DATUV'.

WFIELDCAT-SELTEXT_L = 'BOM date'.

WFIELDCAT-OUTPUTLEN = 15.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

WFIELDCAT-TABNAME = 'ISTKO'.

WFIELDCAT-FIELDNAME = 'MATNR'.

WFIELDCAT-SELTEXT_L = 'Header mat no'.

WFIELDCAT-OUTPUTLEN = 18.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

WFIELDCAT-TABNAME = 'ISTKO'.

WFIELDCAT-FIELDNAME = 'BMENG'.

WFIELDCAT-SELTEXT_L = 'Base qty'.

WFIELDCAT-OUTPUTLEN = 15.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

WFIELDCAT-TABNAME = 'ISTKO'.

WFIELDCAT-FIELDNAME = 'BMEIN'.

WFIELDCAT-SELTEXT_L = 'UOM'.

WFIELDCAT-OUTPUTLEN = 3.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

ENDFORM. " BUILD_FCAT_HEAD

&----


*& Form BUILD_FCAT_ITEM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FCAT_ITEM .

WFIELDCAT-TABNAME = 'ISTPO'.

WFIELDCAT-FIELDNAME = 'IDNRK'.

WFIELDCAT-SELTEXT_L = 'Material no'.

*WFIELDCAT-HOTSPOT = 'X'.

WFIELDCAT-OUTPUTLEN = 18.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

WFIELDCAT-TABNAME = 'ISTPO'.

WFIELDCAT-FIELDNAME = 'MAKTX'.

WFIELDCAT-SELTEXT_L = 'Material desc'.

WFIELDCAT-JUST = 'C'.

WFIELDCAT-OUTPUTLEN = 30.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

WFIELDCAT-TABNAME = 'ISTPO'.

WFIELDCAT-FIELDNAME = 'MENGE'.

WFIELDCAT-SELTEXT_L = 'Item qty'.

WFIELDCAT-OUTPUTLEN = 15.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

WFIELDCAT-TABNAME = 'ISTPO'.

WFIELDCAT-FIELDNAME = 'MEINS'.

WFIELDCAT-SELTEXT_L = 'UOM'.

WFIELDCAT-OUTPUTLEN = 3.

APPEND WFIELDCAT TO IFIELDCAT.

CLEAR WFIELDCAT.

ENDFORM. " BUILD_FCAT_ITEM

&----


*& Form BUILD_KEYINFO

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_KEYINFO .

IKEYINFO-HEADER01 = 'STLNR'.

IKEYINFO-ITEM01 = 'STLNR'.

ENDFORM. " BUILD_KEYINFO

&----


*& Form DISPLAY_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_DATA .

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 = 'USER_COM'

IS_LAYOUT = ILAYOUT

IT_FIELDCAT = IFIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

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

IT_EVENTS = IEVENT[]

  • IT_EVENT_EXIT =

I_TABNAME_HEADER = 'ISTKO'

I_TABNAME_ITEM = 'ISTPO'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

IS_KEYINFO = IKEYINFO

  • 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 = ISTKO

T_OUTTAB_ITEM = ISTPO

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

&----


*& Form GET_MAT_DESC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_MAT_DESC .

IF NOT ISTPO[] IS INITIAL.

SELECT MATNR MAKTX INTO TABLE IMAKT FROM MAKT FOR ALL ENTRIES IN ISTPO

WHERE MATNR = ISTPO-IDNRK.

ENDIF.

LOOP AT ISTPO.

READ TABLE IMAKT WITH KEY MATNR = ISTPO-IDNRK.

IF SY-SUBRC = 0.

ISTPO-MAKTX = IMAKT-MAKTX.

ENDIF.

MODIFY ISTPO.

ENDLOOP.

ENDFORM. " GET_MAT_DESC

&----


*& Form BUILD_LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_LAYOUT .

ILAYOUT-ZEBRA = 'X'.

ILAYOUT-COLWIDTH_OPTIMIZE = 'X'.

ENDFORM. " BUILD_LAYOUT

*FORM USER_COM USING PUCOM LIKE SY-UCOMM PSELFIELD TYPE SLIS_SELFIELD.

*

*CASE PUCOM.

*WHEN '&IC1'.

  • SET PARAMETER ID 'MAT' FIELD PSELFIELD-VALUE.

  • CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

*ENDCASE.

*

*ENDFORM.

&----


*& Form BUILD_EVENT_TAB

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_EVENT_TAB .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IEVENT

  • 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 IEVENT INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.

IF SY-SUBRC = 0.

WEVENT-FORM = 'TOPOFPAGE'.

MODIFY IEVENT FROM WEVENT INDEX SY-TABIX.

ENDIF.

ENDFORM. " BUILD_EVENT_TAB

&----


*& Form TOPOFPAGE

&----


  • text

----


FORM TOPOFPAGE.

DATA : ILISTHEAD TYPE SLIS_T_LISTHEADER,

WLISTHEAD TYPE SLIS_LISTHEADER.

WLISTHEAD-INFO = 'Its a test hierarchical sequential alv dispaly'.

WLISTHEAD-TYP = 'H'.

APPEND WLISTHEAD TO ILISTHEAD.

WLISTHEAD-INFO = 'hellozzzz'.

WLISTHEAD-TYP = 'S'.

APPEND WLISTHEAD TO ILISTHEAD.

WLISTHEAD-INFO = 'Action'.

WLISTHEAD-TYP = 'A'.

APPEND WLISTHEAD TO ILISTHEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = ILISTHEAD

  • I_LOGO = ''

  • I_END_OF_LIST_GRID =

.

ENDFORM.

&----


*& Form GETHEADERMAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GETHEADERMAT .

IF NOT ISTKO[] IS INITIAL.

SELECT MATNR STLNR INTO TABLE IMAST FROM MAST FOR ALL ENTRIES IN ISTKO

WHERE STLNR = ISTKO-STLNR.

ENDIF.

LOOP AT ISTKO.

READ TABLE IMAST WITH KEY STLNR = ISTKO-STLNR.

IF SY-SUBRC = 0.

ISTKO-MATNR = IMAST-MATNR.

ENDIF.

MODIFY ISTKO.

ENDLOOP.

ENDFORM. " GETHEADERMAT

Reward points if helpful .

Regards ,

Amber S

Former Member
0 Kudos

ALV (Abap List Viewer)

We can easily implement basic features of reports like Sort, Allign, Filtering, Totals-Subtotals etc... by using ALV. Three types of reports we can do by ALV as 1. Simple Report, 2. Block Reprot and 3. Hierarchical Sequential Report.

alv grid types

1) list/ grid

these are having rows and columns

function modules for this type are

REUSE_ALV_LIST_DISPLAY

REUSE_ALV_GRID_DISPLAY2)

2) HIERARCHY

this will have header and line items

function module for this type

REUSE_ALV_HIERSEQ_LIST_DISPLAY

3) tree

this will nodes and child type structure

function module for this type

REUSE_ALV_TREE_DISPLAY

4) APPEND

this can append all the different types of lists where each list has different number of columns

events associated with alvs

1) top of page

2) end of page

3) top of list

4) end of list

5) on double click

6) on link click

7) on user command

some useful links:

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

http://help.sap.com/saphelp_nw04/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm

Examples:

REPORT Z_ALV__ITEM .

TYPE-POOLS : slis.

*----

-


Data

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : flag tyPE c,

END OF itab.

*

*DATA: itab like t001 occurs 0 with header line.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

data v_repid like sy-repid.

*----

-


Select Data

v_repid = sy-repid.

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = alvfc[] .

*----

-


Display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc[]

i_callback_program = v_repid

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

In very detail it's not easy, i believe it's better for you to test the function modules to work with ALV :

REUSE_ALV_FIELDCATALOG_MERGE to create the fieldcatalogue

REUSE_ALV_GRID_DISPLAY - to display the ALV in grid format

REUSE_ALV_LIST_DISPLAY - to display the ALV in list format

Anyone, here's one exemple of creating ALV reports :

REPORT ZALV_SLAS_GDF .

  • Declaração de Dados

TABLES: ZSLA_NIV_SAT.

selection-screen begin of block b1 with frame title text-001.

select-options DATA for ZSLA_NIV_SAT-DATA. " Data

select-options LIFNR for ZSLA_NIV_SAT-LIFNR. " Nº de conta fornecedor

select-options WERKS for ZSLA_NIV_SAT-WERKS. " Centro

select-options EBELN for ZSLA_NIV_SAT-EBELN. " Nº contrato

selection-screen end of block b1.

DATA: BEGIN OF itab1 OCCURS 100.

include structure ZSLA_NIV_SAT.

data: END OF itab1.

*----


*

  • Outros dados necessários:

  • Campo para guardar o nome do report

DATA: i_repid LIKE sy-repid.

  • Campo para verificar o tamanho da tabela

DATA: i_lines LIKE sy-tabix.

*----


*

  • Dados para mostrar o ALV

TYPE-POOLS: SLIS.

*DATA: int_fcat type SLIS_T_FIELDCAT_ALV with header line.

DATA: int_fcat type SLIS_T_FIELDCAT_ALV.

DATA: l_key TYPE slis_keyinfo_alv.

START-OF-SELECTION.

  • Ler dados para dentro da tabela imat

SELECT * FROM ZSLA_NIV_SAT

INTO CORRESPONDING FIELDS OF TABLE itab1

WHERE data in data

and lifnr in lifnr

and ebeln in ebeln

and werks in werks.

CLEAR: i_lines.

DESCRIBE TABLE itab1 LINES i_lines.

IF i_lines lt 1.

WRITE: / 'Não foram seleccionadas entradas.'.

EXIT.

ENDIF.

END-OF-SELECTION.

*----


*

  • Agora, começa-se o ALV

*

*----


*

  • Para usar o ALV, nós precisamos de uma estrutura do dicionário de

*dados DDIC ou de uma coisa chamada “Fieldcatalogue”.

  • Existe 2 maneiras de preencher a coisa referida acima:

*Automaticamente e Manualmente

  • Como preencher Automaticamente?

  • O fieldcatalouge pode ser gerado pela Função

*'REUSE_ALV_FIELDCATALOG_MERGE' a partir de uma tabela de qualquer fonte

  • Para que se possa utilizar esta função tabela tem que ter campos do

*dicionário de dados, como é o caso da tabela ITAB1

*----


*

  • Guardar o nome do programa

i_repid = sy-repid.

  • Create Fieldcatalogue from internal table

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME =

i_repid

I_INTERNAL_TABNAME =

'ITAB1' "LETRAS GRANDES

I_INCLNAME =

i_repid

CHANGING

CT_FIELDCAT =

int_fcat[]

EXCEPTIONS

INCONSISTENT_INTERFACE =

1

PROGRAM_ERROR =

2

OTHERS =

3.

IF SY-SUBRC <> 0.

WRITE: / 'Returncode', sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

ENDIF.

*Isto era o Fieldcatalogue

*----


*

  • E agora estamos preparados para executar o ALV

  • Chama o ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = i_repid

IT_FIELDCAT = int_fcat[]

I_DEFAULT = ' '

I_SAVE = ' ' "'A'

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

WRITE: /

'Returncode', sy-subrc, 'from FUNCTION REUSE_ALV_GRID_DISPLAY'.

ENDIF.

REPORT YMS_HIERSEQLISTDISPLAY .

*----


*

  • Program with FM REUSE_ALV_HIERSEQ_LIST_DISPLAY *

*----


*

*----


*

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

                                    • END OF PROGRAM Z_ALV_HIERSEQ_LIST ******************

Thanks,

Former Member
0 Kudos

Hi,

see if this details can help u of coming out of problem:

Hierarchical display is possible only in LIST display. A typical example where such a display would be required will be

Header of the display would be the PO header details

And items of the display would be line item details of the specific PO.

For getting the hierarchical display use the FM

REUSE_ALV_HIERSEQ_LIST_DISPLAY

The interface of this FM is very much similar to that of the normal list display function module. This FM has some extra parameters which are related to the hierarchical display. The new parameters to be passed to this FM are

1. I_TABNAME_HEADER (Export Parameter)

Name of the internal table in the program containing the output data of the highest

hierarchy level.

2. I_TABNAME_ITEM (Export Parameter)

Name of the internal table in the program containing the output data of the lowest

hierarchy level.

3. I_STRUCTURE_NAME_HEADER (Export Parameter)

Same as the I_STRUCTURE_NAME of the FM REUSE_ALV_LIST_DISPLAY. (for the internal table containing the output data of the highest hierarchy level).

4. I_STRUCTURE_NAME_ITEM (Export Parameter)

Same as the I_STRUCTURE_NAME of the FM REUSE_ALV_LIST_DISPLAY. (for the internal table containing the output data of the lowest hierarchy level).

5. IS_KEYINFO (Export Parameter)

For the hierarchical display, the two tables should be linked using key fields. The key fields should be present in both the tables. These fields defined as the key, will be displayed both in the header level and the item level and cannot be suppressed.

The parameters IS_KEYINFO contains the field names which link the two tables. Enter the foreign key field names in the fields KEYINFO-HEADERxx and KEYINFO-ITEMxx.

6. T_OUTTAB_HEADER (Export Parameter)

The internal table in the program containing the output data of the highest hierarchy level.

7. T_OUTTAB_ITEM (Export Parameter)

The internal table in the program containing the output data of the lowest hierarchy level.

____________________________________________________________________

Export:

a. I_CALLBACK_PROGRAM

b. I_CALLBACK_PF_STATUS_SET

c. I_CALLBACK_USER_COMMAND

d. IS_LAYOUT

e. It_fieldcat

f. It_events

g. I_tabname_header : Name of the internal table in the program

containing the output data of the highest hierarchy level.

h. I_tabname_item : Name of the internal table in the program containing

the output data of the lowest hierarchy level.

i. Is_keyinfo : This structure contains the header and item table field

names which link the two tables (shared key).

Tables

a. t_outtab_header : Header table with data to be output

b. t_outtab_item : Name of the internal table in the program containing

the output data of the lowest hierarchy level.

Former Member
0 Kudos

hi

check the parameters:

<b>I_INTERFACE_CHECK:</b> - (Interface consistency check log output.)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_CALLBACK_PROGRAM:</b> - (Name of the calling program.)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_CALLBACK_PF_STATUS_SET: -</b>

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_CALLBACK_USER_COMMAND:</b> - (Exit routine for command handling.)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IS_LAYOUT:</b> - (List layout specifications)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IT_FIELDCAT: -</b> (Field catalog with field descriptions)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IT_EXCLUDING: -</b> (Table of inactive function codes)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IT_SPECIAL_GROUPS: -</b> (Grouping fields for column selection)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IT_SORT:</b> -(Sort criteria for first list display)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IT_FILTER:</b> -(Filter criteria for first list output)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IS_SEL_HIDE:</b> - (Selection information modification)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_SCREEN_START_COLUMN:</b> -(Coordinates for list in dialog box)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_SCREEN_START_LINE:</b> - -(Coordinates for list in dialog box)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_SCREEN_END_COLUMN:</b> -(Coordinates for list in dialog box)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_SCREEN_END_LINE:</b> - -(Coordinates for list in dialog box)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_DEFAULT:</b> - (Initial variant active/inactive logic)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_SAVE</b>: -(Variants can be saved)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IS_VARIANT</b>: -(Variant information)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IT_EVENTS:</b> - (Table of events to perform)

Same as in REUSE_ALV_LIST_DISPLAY

IT_EVENT_EXIT: - (Standard fcode exit requests table)

Same as in REUSE_ALV_LIST_DISPLAY

<b>I_TABNAME_HEADER:</b> -(Header Table Name)

Name of the internal table in the program containing the output data of the highest hierarchy level.

<b>I_TABNAME_ITEM:</b> - (Item Table Name)

Name of the internal table in the program containing the output data of the lowest hierarchy level.

<b>I_STRUCTURE_NAME_HEADER:-</b> (Internal output table (header) structure name)

Same as I_STRUCTURE_NAME in REUSE_ALV_LIST_DISPLAY

<b>I_STRUCTURE_NAME_ITEM:</b> -(Internal output table (posit.) structure name)

Same as I_STRUCTURE_NAME in REUSE_ALV_LIST_DISPLAY

<b>IS_KEYINFO:</b> - (Header/posit. table field links)

This structure contains the header and item table field names, which link the two tables (shared key).

Enter the foreign key field names in the fields KEYINFO-HEADERxx and

<b>KEYINFO-ITEMxx.</b> The foreign key field names of the header and item tables are usually identical.

The item table has other key fields as well as the header table foreign key. These other key fields should also be named in this structure. The corresponding header table field (HEADERxx) must be SPACE.

Naming the other key fields guarantees a stable item table sort sequence.

<b>IS_PRINT:</b> - (Print information)

Same as in REUSE_ALV_LIST_DISPLAY

<b>IS_REPREP_ID: -</b> (Initialization key for Re/Re interface)

<b>E_EXIT_CAUSED_BY_CALLER:</b> -(Delete list in CALLBACK_USER_COMMAND)

Same as in REUSE_ALV_LIST_DISPLAY

<b>ES_EXIT_CAUSED_BY_USER:</b> -(How the user left the list)

Same as in REUSE_ALV_LIST_DISPLAY

<b>T_OUTTAB_HEADER:</b> -(Header table with data to be output)

Same as T_OUTTAB in REUSE_ALV_LIST_DISPLAY

<b>T_OUTTAB_ITEM:</b> - (Position table with data to be output)

Same as T_OUTTAB in REUSE_ALV_LIST_DISPLAY

reward points for useful help

regards

vivek

Former Member
0 Kudos

> hi,

> I am not able to get the output using this function

> module REUSE_ALV_HIERSEQ_LIST_DISPLAY.

> In my program i even wanted to add new columns to the

> output table.

> i am not getting the correct output.

> I have even compared my code with your code but there

> is no error in my code. Still no correct output.

>

> I want to know about the input parameters in this

> function module.

>

> plz reply me its urgent..

 " The  below are the combination  of 2  Function  modules  to be  utilised ..

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.

reward points if it is usefull ....

Girish

Former Member
0 Kudos

hi,

there is a sequence that need to be followed for using this.

Intially 1) init and 2) append and 3)display

and also check wether the select statement your are using is fetching data

into internal table or not.

if possible send us the code that you have tried

Regards,

Srinivas

Former Member
0 Kudos

hi,

1. chk the field catalog and internal atbel.

2. Also debug the itab with repect to the select query

after that pls revert back.

Rgds

Reshma