Академический Документы
Профессиональный Документы
Культура Документы
So the execution first skips all the Final windows and completes the processing of other windows. Once all
the non final windows are processed, the Final windows are processed from top to bottom. For example if you
would like to have the total value of all the items on the first page but the value of this is known only at the end
of the form processing, we can use the Final window for displaying the total value. The sum of line items is
calculated in the MAIN window.
Recently I received the following requirement to produce an output for displaying items from the shipment.
These items are from multiple delivery documents and each delivery is associated with a ship-to-party.
Whenever the ship-to-party changes a page break is needed and the page number should reset. For example,
if the first ship-to-party has two pages the page number will be ‘Page 1 of 2’ and ‘Page 2 of
2’. Now for the next ship-to-party the page number again starts from 1 and the total number of pages will
be for that particular ship-to-party.
This cannot be done using the normal method. i.e. using the SFSY structure (SFSY-FORMPAGES and SFSYPAGE). In our example because the total number of pages for a particular ship-to-party is calculated only after
the processing of all its pages are completed. For such cases the ‘Final windows’ can be helpful.
The logic I have followed captures the page numbers for each ship-to-party and then uses the final window
‘PAGE’ to display that.
Step-1 (Make the window as a final window)
Double click on the window and in the ‘General Attributes’ tab select window type as ‘Final
Window’.
Note that once you have selected as final window, the icon changes.
A code is written just under the LOOP node to capture the page numbers for the ship to party.
The code for this program line node (GET_PAGE_NO) is given below and will capture pages for all the shipto-parties except the last one. Capturing pages for the final ship-to-party is explained in Step-3. The below
code will not work for the first ship-to-party (IF sfsy-formpages > 1) and will start from the second SHP.
DATA: wa_pageno(3),
wa_pagecnt(3).
* This code starts working from page 2 onwards
IF sfsy-formpages > 1.
wa_pageno = sfsy-formpages - wa_lastpage.
wa_pagecnt = 1.
DO wa_pageno TIMES.
wa_pages-pagefr = wa_pagecnt.
wa_pages-pageto = wa_pageno.
wa_pagecnt
= wa_pagecnt + 1.
wa_lastpage = sfsy-formpages.
Step-3 (Capture the pages for final ship to party and format page numbers)
Now we have one more program line node in the final window ‘PAGE’ and this is just before
the page output. Capturing pages for final ship-to-party is coded here because that is the final record in the
LOOP_SHP and the program line node GET_PAGE_NO will not be executed.
= sfsy-formpages - wa_lastpage + 1.
wa_pagecnt = 1.
DO wa_page TIMES.
wa_pages-pagefr = wa_pagecnt.
wa_pages-pageto = wa_page.
wa_pagecnt
= wa_pagecnt + 1.
CLEAR wa_pages.
READ TABLE wt_pages INTO wa_pages INDEX 1.
IF sy-subrc = 0.
CONDENSE: wa_pages-pagefr,
wa_pages-pageto.
CONCATENATE 'Page' wa_pages-pagefr 'of' wa_pages-pageto
INTO wa_pageno SEPARATED BY space.
DELETE wt_pages INDEX 1.
ENDIF.
The above will not work if you are on 4.6C or 4.6D version. But there is a work around suggested by SAP to
accomplish the same. But the support package level must be on SAPKB46C12 for 4.6C and SAPKB46D04 for
4.6D. This is described in the OSS note 359009.
In order to achieve late (Final) processing of windows do the following.
Create a secondary window that you want to process like FINAL window.
Now on the first page create another secondary window as the first node. In this create a program
line node and call the following subroutine for every window that you want to behave as a Final
window.
PERFORM set_late_window IN PROGRAM saplstxbc USING ‘FNL_WINDOW’
CHANGING l_subrc.
‘FNL_WINDOW’ is the name of the window. If you have several windows, you have to call
the subroutine for all the windows.
2232 Views
karthi keyan
Feb 25, 2008 5:23 AM
I am searching the solution for the page number problem for more than two days finally your blog helped me a
lot to solve the problem.
Thanks.