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: 

Page break and Subtotal display in alv

Former Member
0 Kudos
255

Kindly provide me the resolution for the following issue at your earliest

Issue:

I am sorting the alv list based on invoice payment date with subtotals.

and i need a page break for every new invoice payment date.I have achived

the same by following code but now subtotals are displaying in the new page

first line rather i need subtotals at end of each page.

Thanking you.

Regards

Ravishekar.Thallapally

Mobil:09866887298.

&----


*& Form sub_Build_sort_catalogue

&----


  • Building Sort Catalog

----


  • <-- L_T_SORT : Internal table for sort catalog

----


FORM sub_build_sort_catalogue CHANGING l_t_sort TYPE slis_t_sortinfo_alv.

DATA: l_v_sortcat TYPE slis_sortinfo_alv.

CLEAR l_v_sortcat.

  • Sort the fields with Planned Incoming Payment in alv

l_v_sortcat-spos = '1'.

l_v_sortcat-fieldname = 'FAEDT'.

l_v_sortcat-subtot = 'X'.

l_v_sortcat-up = 'X'.

APPEND l_v_sortcat TO l_t_sort.

CLEAR l_v_sortcat.

  • Sort the fields with Planned Incoming Payment in alv

l_v_sortcat-spos = '002'.

l_v_sortcat-fieldname = 'INV_REF'.

l_v_sortcat-subtot = 'X'.

l_v_sortcat-up = 'X'.

APPEND l_v_sortcat TO l_t_sort.

CLEAR l_v_sortcat.

ENDFORM. " sub_Build_sort_catalogue

&----


*& Form sub_after_line_output

&----


  • Appending another event 'AFTER_LINE_OUTPUT' to g_t_events

----


  • -->L_T_OUTPUT : Internal table with output data

  • <--L_T_EVENTS : Internal table with events

----


FORM sub_after_line_output USING l_t_output TYPE ty_t_output

CHANGING l_t_events TYPE slis_t_event.

DATA: l_v_event TYPE slis_alv_event.

l_v_event-name = 'AFTER_LINE_OUTPUT'.

l_v_event-form = 'SUB_AFTER_LINE_OUTPUT1'.

APPEND l_v_event TO l_t_events.

ENDFORM.

&----


*& Form after_line_output

&----


  • After line output event is handled via this form

----


  • L_V_LINE : Capturing line value for page break.

----


FORM SUB_after_line_output1 USING l_v_line TYPE slis_lineinfo. "#EC CALLED

DATA: l_index1 LIKE sy-tabix,

l_index2 LIKE sy-tabix.

FIELD-SYMBOLS: <l_fs_output1> TYPE ty_output,

<l_fs_output2> TYPE ty_output.

CLEAR l_index1.

l_index1 = l_v_line-tabindex.

READ TABLE g_t_output INDEX l_index1 ASSIGNING <l_fs_output1>.

IF sy-subrc = 0.

CLEAR l_index2.

l_index2 = l_index1 + 1.

READ TABLE g_t_output INDEX l_index2 ASSIGNING <l_fs_output2>.

IF sy-subrc = 0.

IF <l_fs_output1>-FAEDT <> <l_fs_output2>-FAEDT .

  • WRITE: sy-uline.

NEW-PAGE.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " after_line_output

&----


*& Form Sub_display_alv_list

&----


  • Displaying the ALV list

----


  • -->L_T_FIELDCATALOG : Itab with Field Catalog

  • -->L_T_LAYOUT : Itab with Layout Records

  • -->L_T_OUTPUT : Itab with Output Data

  • -->L_T_EVENT : Itab with Event Catalalog

----


FORM sub_display_alv_list USING l_t_fieldcatalog TYPE slis_t_fieldcat_alv

l_t_layout TYPE slis_layout_alv

l_t_sort TYPE slis_t_sortinfo_alv

CHANGING l_t_event TYPE slis_t_event

l_t_output TYPE ty_t_output .

*Set Report Title.

g_v_title = 'AR Clearing Doc. Details'.

*Perform for after line output

PERFORM sub_after_line_output USING l_t_output

CHANGING l_t_event .

*CALL TO FM REUSE ALV LIST DISPLAY

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

is_layout = l_t_layout

it_fieldcat = l_t_fieldcatalog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = l_t_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = l_t_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 = l_t_output[]

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF.

ENDFORM. " Sub_display_alv_list

3 REPLIES 3

Former Member
0 Kudos
72

Hi,

To do Subtotal, create the sort table for the order type.

IT_SORT_DATA-SPOS = L_SPOS.

IT_SORT_DATA-FIELDNAME = 'VBELN'.

IT_SORT_DATA-TABNAME = 'IT_DISPLAY'.

<b>IT_SORT_DATA-UP = 'X'.</b>

<b>IT_SORT_DATA-group = 'X'.</b>

<b>IT_SORT_DATA-subtot = 'X'.</b>

APPEND IT_SORT_DATA.

CLEAR IT_SORT_DATA.

and pass this info to FM(layout, sort table along with fieldcat)

Thanks,

Pramod

0 Kudos
72

Dear Friends,

I have got the solution from my technical lead for the below issue, I like to share this resolution with you all.

Best Regards,

Ravishekar.Thallapally

&----


*& Form after_line_output

&----


  • After line output event is handled via this form

----


  • L_V_LINE : Capturing line value for page break.

----


FORM sub_after_line_output1 USING l_v_line TYPE slis_lineinfo."#EC CALLED

DATA: l_v_int TYPE int1.

IF l_v_line-sumindex IS NOT INITIAL .

l_v_int = l_v_line-sumindex MOD 2 .

IF l_v_line-subtot = 'X' AND l_v_int = 0.

Write:/ sy-uline.

NEW-PAGE.

CLEAR:l_v_int.

ENDIF.

ENDIF.

ENDFORM. " after_line_output

Former Member
0 Kudos
72

Hi KCR,

Go through the below link:

http://www.saptechnical.com/Tutorials/ALV/PageBreaks.htm

<b>

Reward all helpful answers</b>

Thanks & Regards,

V.Raghavender.