‎2007 May 30 3:45 PM
Hello,
I have developed a script and the problem is after 18 lines items on the first page the 19th should print on the second page and the 37th on the third page and so on.
I have written this piece of code in the print program within the LOOP ENDLOOP for the line items.
count = count + 1.
IF count GT 18.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'NEW_PAGE'
function = 'APPEND'
EXCEPTIONS
window = 1
element = 2.
ENDIF.
CLEAR count.IN the script layout I have,
/E NEW_PAGE
/: &NEW-PAGE&But after 18 line items it still prints on the same page.
Please suggest.
Ster.
‎2007 May 30 3:56 PM
Try to use Control_form instead of write_form.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'NEW-PAGE'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
‎2007 May 30 3:55 PM
The CLEAR count statement should be within your IF/ENDIF statement.
You only want to clear count when it reaches 18.
‎2007 May 30 3:56 PM
Try to use Control_form instead of write_form.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command = 'NEW-PAGE'
EXCEPTIONS
unopened = 1
unstarted = 2
OTHERS = 3.
‎2007 May 30 4:01 PM
‎2007 May 30 4:06 PM
Hey Ster,
Your count variable will get cleared at each loop pass so it will never attain the value 18.
the clear should happen inside the IF -- ENDIF.
also the correct format for the NEW-PAGE is
/: NEW-PAGE
if you use &NEW-PAGE& it will treat the NEW-PAGE as a Variable .
also as an alternative ,CONTROL_FORM can be used effiectively within the loop between the IF -- ENDIF.
Kindly reward points if useful
Regards,
gaurav
‎2007 May 30 4:11 PM
Thanks Seshu,
It works for the first page but I see some problems from the second page and the third page.
The first line on the second page is balance carried forward so from here onwards i need to print only 17 line items instead of the 18 line items.
Is there a way I can do this.
Ster.
‎2007 May 30 4:15 PM
Hi,
Use an IF Statement again
in the SAP SCRIPT
if &PAGE& = 1
& count = 18
new-page
else.
count = 17
new-page
endif.
Regards,
Gaurav