Application Development and Automation 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: 
Read only

script

Former Member
0 Likes
574

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
557

Try to use Control_form instead of write_form.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

command = 'NEW-PAGE'

EXCEPTIONS

unopened = 1

unstarted = 2

OTHERS = 3.

6 REPLIES 6
Read only

Former Member
0 Likes
557

The CLEAR count statement should be within your IF/ENDIF statement.

You only want to clear count when it reaches 18.

Read only

Former Member
0 Likes
558

Try to use Control_form instead of write_form.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

command = 'NEW-PAGE'

EXCEPTIONS

unopened = 1

unstarted = 2

OTHERS = 3.

Read only

0 Likes
557

Thanks, Will try and get back.

Ster.

Read only

0 Likes
557

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

Read only

0 Likes
557

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.

Read only

0 Likes
557

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