cancel
Showing results for 
Search instead for 
Did you mean: 

script doubt

Former Member
0 Kudos

Dear experts,

i have a question in script printing.

can we print first page in potrait and secong page in landscape ?

is it possible in script? if so how can accomplish this task.

can anyone cpls explain on this

thanks

karthik

Accepted Solutions (0)

Answers (6)

Answers (6)

former_member480923
Active Contributor
0 Kudos

Hi

Yes it is possible in SAPScript.

Please look at the following program

CALL FUNCTION 'OPEN_FORM'
* EXPORTING
*   APPLICATION                       = 'TX'
*   ARCHIVE_INDEX                     =
*   ARCHIVE_PARAMS                    =
*   DEVICE                            = 'PRINTER'
*   DIALOG                            = 'X'
*   FORM                              = 'ZSCRIPT1'
*   LANGUAGE                          = SY-LANGU
*   OPTIONS                           =
*   MAIL_SENDER                       =
*   MAIL_RECIPIENT                    =
*   MAIL_APPL_OBJECT                  =
*   RAW_DATA_INTERFACE                = '*'
*   SPONUMIV                          =
* IMPORTING
*   LANGUAGE                          =
*   NEW_ARCHIVE_PARAMS                =
*   RESULT                            =
 EXCEPTIONS
   CANCELED                          = 1
   DEVICE                            = 2
   FORM                              = 3
   OPTIONS                           = 4
   UNCLOSED                          = 5
   MAIL_OPTIONS                      = 6
   ARCHIVE_ERROR                     = 7
   INVALID_FAX_NUMBER                = 8
   MORE_PARAMS_NEEDED_IN_BATCH       = 9
   SPOOL_ERROR                       = 10
   CODEPAGE                          = 11
   OTHERS                            = 12
          .
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'START_FORM'
EXPORTING
*   ARCHIVE_INDEX          =
   FORM                   = 'ZFORM1'
*   LANGUAGE               = ' '
*   STARTPAGE              = 'X'
   PROGRAM                = 'ZSCRIPT1'
*   MAIL_APPL_OBJECT       =
* IMPORTING
*   LANGUAGE               =
* EXCEPTIONS
*   FORM                   = 1
*   FORMAT                 = 2
*   UNENDED                = 3
*   UNOPENED               = 4
*   UNUSED                 = 5
*   SPOOL_ERROR            = 6
*   CODEPAGE               = 7
*   OTHERS                 = 8
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'WRITE_FORM'
 EXPORTING
*   ELEMENT                        = ' '
*   FUNCTION                       = 'SET'
*   TYPE                           = 'BODY'
   WINDOW                         = 'HEADER'
* IMPORTING
*   PENDING_LINES                  =
 EXCEPTIONS
   ELEMENT                        = 1
   FUNCTION                       = 2
   TYPE                           = 3
   UNOPENED                       = 4
   UNSTARTED                      = 5
   WINDOW                         = 6
   BAD_PAGEFORMAT_FOR_PRINT       = 7
   SPOOL_ERROR                    = 8
   OTHERS                         = 9
          .
IF SY-SUBRC <> 0.
write:/ 'ERROR IN HEADER'.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'WRITE_FORM'
 EXPORTING
*   ELEMENT                        = ' '
*   FUNCTION                       = 'SET'
*   TYPE                           = 'BODY'
   WINDOW                         = 'MAIN'
* IMPORTING
*   PENDING_LINES                  =
 EXCEPTIONS
   ELEMENT                        = 1
   FUNCTION                       = 2
   TYPE                           = 3
   UNOPENED                       = 4
   UNSTARTED                      = 5
   WINDOW                         = 6
   BAD_PAGEFORMAT_FOR_PRINT       = 7
   SPOOL_ERROR                    = 8
   OTHERS                         = 9
          .
IF SY-SUBRC <> 0.
write:/ 'ERROR IN HEADER'.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'WRITE_FORM'
 EXPORTING
*   ELEMENT                        = ' '
*   FUNCTION                       = 'SET'
*   TYPE                           = 'BODY'
   WINDOW                         = 'FOOTER'
* IMPORTING
*   PENDING_LINES                  =
 EXCEPTIONS
   ELEMENT                        = 1
   FUNCTION                       = 2
   TYPE                           = 3
   UNOPENED                       = 4
   UNSTARTED                      = 5
   WINDOW                         = 6
   BAD_PAGEFORMAT_FOR_PRINT       = 7
   SPOOL_ERROR                    = 8
   OTHERS                         = 9
          .
IF SY-SUBRC <> 0.
write:/ 'ERROR IN HEADER'.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'END_FORM'
* IMPORTING
*   RESULT                         =
* EXCEPTIONS
*   UNOPENED                       = 1
*   BAD_PAGEFORMAT_FOR_PRINT       = 2
*   SPOOL_ERROR                    = 3
*   CODEPAGE                       = 4
*   OTHERS                         = 5
          .

CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
*   RESULT                         =
*   RDI_RESULT                     =
* TABLES
*   OTFDATA                        =
* EXCEPTIONS
*   UNOPENED                       = 1
*   BAD_PAGEFORMAT_FOR_PRINT       = 2
*   SEND_ERROR                     = 3
*   SPOOL_ERROR                    = 4
*   CODEPAGE                       = 5
*   OTHERS                         = 6
          .

Here the 2 forms have different layouts to work

Thanks

Anirban M.

Former Member
0 Kudos

HI,

This is possible. For each page use Start_form/end_form function modules and pass the print parameters.

Your program would like this...

open_form

start_form

write_form : page1

end_form

start_form

write_form : page2

end_form

close_form

Former Member
0 Kudos

hi,

it is not possible in scripts it is possible in smartforms.

santhosh

sridhar_k1
Active Contributor
0 Kudos

Yes, In smartforms you can define page orientation when you create pages node in output options.

Regards

Sridhar

sridhar_k1
Active Contributor
0 Kudos

Not possible with the available options in sapscript, but you can do it by sendig PCL command to the printer.

Add the following sapscript commands in the main window after main text element.

Works only when PCL device type used in the printer definition in SPAD

/: IF &PAGE& = '2'

/: HEX TYPE PCL

/= 1B2661393050

/: ENDHEX

/: ENDIF

Regards

Sridhar

Former Member
0 Kudos

i dont think it is possible. It is one the disadavntages of scripts.

former_member181962
Active Contributor
0 Kudos

Hi,

I doubt if that is possible. Because, the setting we do is a header level, static one in se71 . We cannot alter the header level properties of a form on the fly.

What i can think of is to create two forms one with potrait and the other with landscape format and call each of these layouts in your driver program conditionally using start_form and end_form.

Regards,

ravi