cancel
Showing results for 
Search instead for 
Did you mean: 

Printing sapscript directly from Z program

Former Member
0 Kudos

Hi everyone! I just need to know if there's some way, using a FM or otherwise, to directly print a SAPscript from my Z program. I'd also need to set the printing parameters in the code too.

Thanks a lot,

Fernando.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

U can get something from the following code

report  z_script.

call function 'OPEN_FORM'
 exporting
*   APPLICATION                       = 'TX'
*   ARCHIVE_INDEX                     =
*   ARCHIVE_PARAMS                    =
*   DEVICE                            = 'PRINTER'
*   DIALOG                            = 'X'
   form                              = 'Z_SCRIPT'
   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
          .

call function 'WRITE_FORM'
 exporting
   element                        = 'ORIGINAL'
*   FUNCTION                       = 'SET'
*   TYPE                           = 'BODY'
   window                         = 'PAGE'
* IMPORTING
*   PENDING_LINES                  =
* EXCEPTIONS
*   ELEMENT                        = 1
*   FUNCTION                       = 2
*   TYPE                           = 3
*   UNOPENED                       = 4
*   UNSTARTED                      = 5
*   WINDOW                         = 6
*   BAD_PAGEFORMAT_FOR_PRINT       = 7
*   SPOOL_ERROR                    = 8
*   CODEPAGE                       = 9
          .
call function 'WRITE_FORM'
 exporting
   element                        = 'WINDOW'
*   FUNCTION                       = 'SET'
*   TYPE                           = 'BODY'
   window                         = 'INVOCE'
* IMPORTING
*   PENDING_LINES                  =
* EXCEPTIONS
*   ELEMENT                        = 1
*   FUNCTION                       = 2
*   TYPE                           = 3
*   UNOPENED                       = 4
*   UNSTARTED                      = 5
*   WINDOW                         = 6
*   BAD_PAGEFORMAT_FOR_PRINT       = 7
*   SPOOL_ERROR                    = 8
*   CODEPAGE                       = 9
          .



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
          .

REWARD POINTS IF USEFUL

Edited by: ankit harjai on Feb 8, 2008 5:06 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Yes Fernando that is possible.

Do it just like other standard programs do it.

The only difference is that you cannot use the output determination flexibilty that SAP provides.(NACE)

You can use a selection screen to accept the printng parameters or hard code them accordingly

.