This website is not affiliated with, sponsored by, or approved by SAP AG.

How to write OPEN_FORM for new sapscript in the one spool

Development SAPscript/ Smartforms

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

How to write OPEN_FORM for new sapscript in the one spool

Postby Alicealice » Thu Oct 20, 2011 5:29 pm

Hi,
How to write OPEN_FORM for new sapscript in the one spool?
Currently the print program is already attach to one sapscript but now I have created second sapscript.
How can i write in the print program to call the second sapscript? where should I write the code?

Thanks.
Alicealice
 
Posts: 72
Joined: Sun Oct 02, 2011 11:52 pm

Re: How to write OPEN_FORM for new sapscript in the one spool

Postby Gothmog » Fri Oct 21, 2011 12:01 am

You use one OPEN_FORM call to start the spool, and close it with CLOSE_FORM.
Between these calls, you can use START_FORM and END_FORM to add several SAPscript form to the spool.

Have a look at the help on these function modules.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: How to write OPEN_FORM for new sapscript in the one spool

Postby Alicealice » Fri Oct 21, 2011 12:21 am

I have added the code for second sapscript after the CLOSE_FORM. What should I write for IMPORTING RESULT and
EXCEPTIONS UNOPENED.
Could you please check for me whether it is correct or not?


Code: Select all
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DIALOG = 'X'
DEVICE = 'PRINTER'
FORM = 'Z_PURCHASE_ORDER'
LANGUAGE = SY-LANGU
EXCEPTIONS
OTHERS = 1
.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM = 'Z_PURCHASE_ORDER'
LANGUAGE = SY-LANGU
EXCEPTIONS
FORM = 1
OTHERS = 7

CALL FUNCTION 'END_FORM'
IMPORTING RESULT =
EXCEPTIONS UNOPENED =
CALL FUNCTION 'CLOSE_FORM'
IMPORTING RESULT =
TABLES OTFDATA =
EXCEPTIONS UNOPENED =
Last edited by Gothmog on Fri Oct 21, 2011 12:36 am, edited 1 time in total.
Reason: code tags
Alicealice
 
Posts: 72
Joined: Sun Oct 02, 2011 11:52 pm

Re: How to write OPEN_FORM for new sapscript in the one spool

Postby Gothmog » Fri Oct 21, 2011 12:45 am

Alicealice wrote:I have added the code for second sapscript after the CLOSE_FORM.

No, your print program should have :
- call FM OPEN_FORM (no need to export the FORM parameter)
- call FM START_FORM for the first form
- call FM WRITE_FORM for each form element you need to print in the first form
- call FM END_FORM, ending the first form
- call FM START_FORM for the second form
- call FM WRITE_FORM for each form element you need to print in the second form
- call FM END_FORM, ending the second form
- call FM CLOSE_FORM
Alicealice wrote:What should I write for IMPORTING RESULT and EXCEPTIONS UNOPENED.
The same as in any function module call ? :?
The importing parameter for RETURN (if you want it) and the return code for the exceptions ?
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: How to write OPEN_FORM for new sapscript in the one spool

Postby Alicealice » Fri Oct 21, 2011 12:49 am

No, your print program should have :
- call FM OPEN_FORM (no need to export the FORM parameter)
- call FM START_FORM for the first form
- call FM WRITE_FORM for each form element you need to print in the first form
- call FM END_FORM, ending the first form
- call FM START_FORM for the second form
- call FM WRITE_FORM for each form element you need to print in the second form
- call FM END_FORM, ending the second form
- call FM CLOSE_FORM

Call Function 'OPEN_FORM'
EXPORTING
DIALOG = 'X'
DEVICE = 'PRINTER'

LANGUAGE = SY-LANGU
EXCEPTIONS
OTHERS = 1
Alicealice
 
Posts: 72
Joined: Sun Oct 02, 2011 11:52 pm

Re: How to write OPEN_FORM for new sapscript in the one spool

Postby Alicealice » Fri Oct 21, 2011 1:00 am

Hi,
Could you please check the code below. If wrong, could you change for me?


Code: Select all
Call Function 'OPEN_FORM'
     EXPORTING
     DIALOG = 'X'
     DEVICE = 'PRINTER'
     LANGUAGE = SY-LANGU
     EXCEPTIONS
     OTHERS = 1                    (What should I write for this?)

Call Function 'START_FORM'
      EXPORTING
      DIALOG = 'X'
      DEVICE = 'PRINTER'
      FORM = 'Z_PURCHASE_ORDER_1'
     LANGUAGE = SY-LANGU
     EXCEPTIONS
     OTHERS = 1

  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      element = 'NEXTPAGE'
      window  = 'NEXTPAGE'
    EXCEPTIONS
      OTHERS  = 01.

CALL FUNCTION 'END_FORM'
(What should I write?)

Call Function START_FORM
      EXPORTING
      DIALOG = 'X'
      DEVICE = 'PRINTER'
      FORM = 'Z_PURCHASE_ORDER_2'
     LANGUAGE = SY-LANGU
     EXCEPTIONS
     OTHERS = 1

  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      element = 'NEXTPAGE'
      window  = 'NEXTPAGE'
    EXCEPTIONS
      OTHERS  = 01.

CALL FUNCTION 'END_FORM'
(What should I write?)

CALL FUNCTION 'CLOSE_FORM'
(What should I write?)
Last edited by Gothmog on Fri Oct 21, 2011 1:03 am, edited 1 time in total.
Reason: code tags
Alicealice
 
Posts: 72
Joined: Sun Oct 02, 2011 11:52 pm

Re: How to write OPEN_FORM for new sapscript in the one spool

Postby Gothmog » Fri Oct 21, 2011 1:11 am

Did you at least look at the function modules I mentionned ? Because you're passing inexistant parameters to START_FORM... :evil:
Look at them, read the help, they're quite well documented.
And if you're confused about how function modules work (importing and exporting parameters, exception handling...), please take a basic ABAP course - or, once again, read the help ! F1 is your best friend.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1941
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home


Return to SAPscript/Smartforms

Who is online

Users browsing this forum: No registered users and 8 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.