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: 

Subheadings in ALV Grid Display

Former Member
0 Kudos
408

Hi All,

I want to display display the subheadings in alv grid display using function modules.

My output some wat should be like this.

-


| PPE|25/10/2007|26/10/2007|27/10/2007

-


VBELN | POSNR|ERDAT|ERNAM|ANGDT |BNDDT|25/10/2007|26/10/2007|27/10/2007

__________________________________________________________________

This i want to display in using alv grid display.

How can i do this can any body help me this please.this is very urgent.

I shurely reward points.please.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
132

hi,

in normal ALV GRID DISPLAY... it is not possible to display sud-headings....

still if u need that, then go for Hierarchial ALV..

reply back.

With Rgds,

S.Barani

5 REPLIES 5

Former Member
0 Kudos
133

hi,

in normal ALV GRID DISPLAY... it is not possible to display sud-headings....

still if u need that, then go for Hierarchial ALV..

reply back.

With Rgds,

S.Barani

Former Member
0 Kudos
132

this is not possible

what you can do is display the header part in TOP OF PAGE

chk this blog for that

/people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid

display the heading in last row of top of page

and then display the sub headings as the headers of ALV report

Former Member
0 Kudos
132

Hi Swapna,

suppose ur internal table is it_final.

create one more internal table it_final1 with same structure and one extra field as subtotal.

now write the following logic.

loop at final table.

at end of field for which u want subtotal.

sum.

subtotal = field sum.

append it_final1.

endloop.

Pass it_final1 to internal table.

cheers

Lalit

Former Member
0 Kudos
132

hi

good

pls check this code

REPORT ZMK_SHIPMENT_ALV

no standard page heading

line-size 105

line-count 50(5)

message-id zz.

**********************************

  • TABLES *

**********************************

tables : vttk, "Shipment Header

vttp, " Shipment Item

lips. " Delivary Item

**********************************

***TYPE-POOLS *

**********************************

type-pools : slis.

**********************************

*WORK AREAS *

**********************************

  • Work area for field catalog table

data : wa_fldcat type slis_fieldcat_alv.

  • Work area for Events table

data : wa_events type slis_alv_event.

  • Work area for layout.

data : wa_layout type slis_layout_alv.

***********************************

*INTERNAL TABLES *

***********************************

  • Shimpment Details

data : begin of itab occurs 0,

tknum like vttk-tknum,

shtyp like vttk-shtyp,

tpnum like vttp-tpnum,

vbeln like vttp-vbeln,

end of itab.

data : begin of itab1 occurs 0,

vbeln like lips-vbeln,

posnr like lips-posnr,

matnr like lips-matnr,

lfimg like lips-lfimg,

meins like lips-meins,

end of itab1.

  • For field catalog table

data : it_fldcats type slis_t_fieldcat_alv.

  • For Events table

data : it_event type slis_t_event.

  • For layout.

data : it_layout type slis_layout_alv.

  • For field catalog table

data : it_fldcats1 type slis_t_fieldcat_alv.

  • For Events table

data : it_event1 type slis_t_event.

data : v_repid like sy-repid.

*Data Declaration

******************

data: v_index type sy-index,

v_vbeln like lips-vbeln.

*SELECT-OPTIONS

****************

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

select-options : s_tknum for vttk-tknum .

selection-screen end of block b.

*INITIALIZATION

****************

initialization.

v_repid = sy-repid.

*START-OF-SELCTION

********************

start-of-selection.

perform populate-data.

sort itab by tknum.

top-of-page.

write : 'Shipment wise Delivary Report'.

end-of-selection.

perform build-fieldcatalog.

perform modify-fieldcatalog.

perform build-events.

perform modify-events.

perform set-layout.

  • perform set-pfstatus.

perform list-display.

&----


*& Form populate-data

  • Retrives the Shipment data depending on the selection criteria *

&----


FORM populate-data.

select vttk~tknum

vttk~shtyp

vttp~tpnum

vttp~vbeln

into table itab

from vttk

join vttp

on vttptknum = vttktknum

where vttk~tknum in s_tknum.

if sy-subrc <> 0.

message e999 with 'NO DATA FOUND'.

exit.

endif.

ENDFORM. " populate-data

&----


*& Form build-fieldcatalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build-fieldcatalog.

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

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.

endform. " BUILD-FIELDCATALOG

&----


*& Form build-events

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build-events.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = it_event

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-events

&----


*& Form set-layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM set-layout.

wa_layout-zebra = 'X'.

wa_layout-colwidth_optimize = 'X'.

wa_layout-no_colhead = space.

wa_layout-no_vline = space.

ENDFORM. " set-layout

&----


*& Form list-display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM list-display.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

IS_LAYOUT = wa_layout

IT_FIELDCAT = it_fldcats

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = it_event

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

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

TABLES

T_OUTTAB = itab

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. " list-display

&----


*& Form modify-fieldcatalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM modify-fieldcatalog.

loop at it_fldcats into wa_fldcat.

case wa_fldcat-fieldname.

when 'TKNUM'.

wa_fldcat-seltext_l = 'Ship No.'.

wa_fldcat-col_pos = 1.

wa_fldcat-ddictxt = 'L'.

when 'SHTYP'.

wa_fldcat-seltext_l = 'Ship Type'.

wa_fldcat-col_pos = 2.

wa_fldcat-ddictxt = 'L'.

when 'TPNUM'.

wa_fldcat-seltext_l = 'Item No.'.

wa_fldcat-col_pos = 3.

wa_fldcat-ddictxt = 'L'.

when 'VBELN'.

wa_fldcat-seltext_l = 'Delivary No.'.

wa_fldcat-hotspot = 'X'.

wa_fldcat-col_pos = 4.

wa_fldcat-ddictxt = 'L'.

endcase.

modify it_fldcats from wa_fldcat.

endloop.

ENDFORM. " modify-fieldcatalog

&----


*& Form modify-events

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form modify-events.

read table it_event with key name =

slis_ev_top_of_page into wa_events.

if sy-subrc = 0.

wa_events-form = 'HEADER-OF-REPORT'.

modify it_event from wa_events index sy-tabix.

clear wa_events.

endif.

read table it_event with key name =

slis_ev_end_of_page into wa_events.

if sy-subrc = 0.

wa_events-form = 'FOOTER-OF-REPORT'.

modify it_event from wa_events index sy-tabix.

clear wa_events.

endif.

endform. " modify-events

&----


*& Form HEADER-OF-REPORT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM HEADER-OF-REPORT.

write : 'Shipment Wise Delivary Report'.

ENDFORM. " HEADER-OF-REPORT

&----


*& Form FOOTER-OF-REPORT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FOOTER-OF-REPORT.

write : 'End of Report'.

ENDFORM. " FOOTER-OF-REPORT

&----


*& Form USER_COMMAND

&----


  • User command for Calling Transaction VT03N, Execute and Refresh

----


FORM user_command USING p_ucomm LIKE sy-ucomm

p_selfield TYPE slis_selfield.

V_INDEX = P_SELFIELD-TABINDEX. " holds the selected table index

CASE p_ucomm.

WHEN '&IC1'.

IF p_selfield-fieldname eq 'VBELN'.

perform secondary_list.

ENDIF.

ENDCASE.

ENDFORM. " USER_COMMAND

&----


*& Form secondary_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM secondary_list.

perform get_data1.

perform build-fieldcatalog1.

perform modify-fieldcatalog1.

perform build-events1.

perform modify-events1.

  • perform set-layout.

  • perform set-pfstatus.

perform list-display1.

ENDFORM. " secondary_list

&----


*& Form build-fieldcatalog1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build-fieldcatalog1.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'ITAB1'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = it_fldcats1

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.

ENDFORM. " build-fieldcatalog1

&----


*& Form modify-fieldcatalog1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM modify-fieldcatalog1.

loop at it_fldcats into wa_fldcat.

case wa_fldcat-fieldname.

when 'VBELN'.

wa_fldcat-seltext_l = 'Delivary No.'.

wa_fldcat-col_pos = 1.

wa_fldcat-ddictxt = 'L'.

when 'POSNR'.

wa_fldcat-seltext_l = 'Item No'.

wa_fldcat-col_pos = 2.

wa_fldcat-ddictxt = 'L'.

when 'MATNR'.

wa_fldcat-seltext_l = 'Material'.

wa_fldcat-col_pos = 3.

wa_fldcat-ddictxt = 'L'.

when 'LFIMG'.

wa_fldcat-seltext_l = 'Quantity'.

wa_fldcat-col_pos = 4.

wa_fldcat-ddictxt = 'L'.

when 'MEINS'.

wa_fldcat-seltext_l = 'Unit of Measure'.

wa_fldcat-col_pos = 5.

wa_fldcat-ddictxt = 'L'.

endcase.

modify it_fldcats from wa_fldcat.

endloop.

ENDFORM. " modify-fieldcatalog1

&----


*& Form build-events1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build-events1.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = it_event1

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-events1

&----


*& Form modify-events1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM modify-events1.

read table it_event1 with key name =

slis_ev_top_of_page into wa_events.

if sy-subrc = 0.

wa_events-form = 'HEADER_OF_REPORT_2'.

modify it_event1 from wa_events index sy-tabix.

clear wa_events.

endif.ENDFORM. " modify-events1

&----


*& Form list-display1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM list-display1.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

IS_LAYOUT = wa_layout

IT_FIELDCAT = it_fldcats1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = it_event1

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

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

TABLES

T_OUTTAB = itab1

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. " list-display1

&----


*& Form get_data1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data1.

READ TABLE itab INDEX V_INDEX.

v_vbeln = itab-vbeln.

select vbeln

posnr

matnr

lfimg

meins

from lips

into table itab1

where vbeln eq v_vbeln.

ENDFORM. " get_data1

&----


*& Form header_of_report_2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM header_of_report_2.

write: 'Delivary item list'.

ENDFORM. " header_of_report_2

*

**-- callling a transaction code by passing the initial screen value.

*

*

**&----


**

**& Form USER_COMMAND

**&----


**

*form user_command using p_ucomm like sy-ucomm

  • p_selfield type slis_selfield.

  • data : l_index like sy-index,

  • l_refbn like cooi-refbn.

  • l_index = p_selfield-tabindex. " holds the selected table index

  • clear l_refbn.

  • case p_ucomm.

*

  • when '&IC1'.

  • clear l_refbn.

  • read table it_outtab index l_index.

  • if sy-subrc eq 0.

  • l_refbn = it_outtab-refbn.

  • if not l_refbn is initial.

  • set parameter id 'BES' field l_refbn.

  • call transaction 'ME23' and skip first screen.

*

  • endif.

  • else.

  • message e999 with text-014.

  • endif.

  • endcase.

*endif.

reward point if helpful.

thanks

mrutyun^

Former Member
0 Kudos
132

Hi

FORM TOP_OF_PAGE.

DATA: T_HEADER TYPE SLIS_T_LISTHEADER,

W_HEADER TYPE SLIS_LISTHEADER.

W_HEADER-TYP = 'H'.

W_HEADER-INFO = 'WELCOME HEADER LIST'.

APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.

W_HEADER-KEY = 'REPORT:'.

W_HEADER-INFO = SY-REPID.

APPEND W_HEADER TO T_HEADER.

W_HEADER-TYP = 'S'.

W_HEADER-KEY = 'DATE:'.

CONCATENATE SY-DATUM4(2) ' / ' SY-DATUM6(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.

APPEND W_HEADER TO T_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = T_HEADER.

ENDFORM.

and activate I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

in function module REUSE_ALV_GRID_DISPLAY

it wl b helpfull