cancel
Showing results for 
Search instead for 
Did you mean: 

Logic to get 2 print copies separately

Former Member
0 Kudos

Hi All,

We have a req on check printing to add logic to take care of 2 print copies (check and office copy)separately and save them in a PDF file in a location thru pop-up.

Pls. provide your valuable pointer.

Thanks,

Deepti.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Refer to the following code. it will be helpful for u.

REPORT ZPRACSCRIPT.

TABLES: likp, lips,itcpo.

Data: struct type itcpo,

pdftab type standard TABLE OF tline,

datab TYPE standard TABLE OF itcoo.

DATA: BINFILe type I,

filename type string,

filepath type string,

fullpath type string.

struct-tddest = 'LP-01'.

struct-tdnoprev = 'X'.

itcpo-tdgetotf = 'X'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'Z_PRAC'

LANGUAGE = SY-LANGU

  • OPTIONS = itcpo

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 'CLOSE_FORM'

  • TABLES

  • OTFDATA = datab

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SEND_ERROR = 3

SPOOL_ERROR = 4

CODEPAGE = 5

OTHERS = 6

.

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 'CONVERT_OTF'

EXPORTING

FORMAT = 'PDF'

IMPORTING

BIN_FILESIZE = BINFILE

    • TABLES

    • otf = datab

    • lines = pdftab

    • EXCEPTIONS

    • ERR_MAX_LINEWIDTH = 1

    • ERR_FORMAT = 2

    • ERR_CONV_NOT_POSSIBLE = 3

    • ERR_BAD_OTF = 4

    • OTHERS = 5

    • .

    • 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 METHOD cl_gui_frontend_services=>file_save_dialog

    • CHANGING

    • filename = filename

    • path = filepath

    • fullpath = fullpath

**

    • EXCEPTIONS

    • CNTL_ERROR = 1

    • ERROR_NO_GUI = 2

    • NOT_SUPPORTED_BY_GUI = 3

    • others = 4

    • .

    • 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 'GUI_DOWNLOAD'

    • EXPORTING

    • BIN_FILESIZE = binfile

    • filename = 'D:\MYFILE.PDF'

    • FILETYPE = 'BIN'

**

    • tables

    • data_tab = pdftab

    • EXCEPTIONS

    • FILE_WRITE_ERROR = 1

    • NO_BATCH = 2

    • GUI_REFUSE_FILETRANSFER = 3

    • INVALID_TYPE = 4

    • NO_AUTHORITY = 5

    • UNKNOWN_ERROR = 6

    • HEADER_NOT_ALLOWED = 7

    • SEPARATOR_NOT_ALLOWED = 8

    • FILESIZE_NOT_ALLOWED = 9

    • HEADER_TOO_LONG = 10

    • DP_ERROR_CREATE = 11

    • DP_ERROR_SEND = 12

    • DP_ERROR_WRITE = 13

    • UNKNOWN_DP_ERROR = 14

    • ACCESS_DENIED = 15

    • DP_OUT_OF_MEMORY = 16

    • DISK_FULL = 17

    • DP_TIMEOUT = 18

    • FILE_NOT_FOUND = 19

    • DATAPROVIDER_EXCEPTION = 20

    • CONTROL_FLUSH_ERROR = 21

    • OTHERS = 22

    • .

    • IF sy-subrc <> 0.

      • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

      • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    • ENDIF.

Regards

Rajesh Kumar

Edited by: Rajesh Kumar on May 4, 2009 8:43 AM

former_member205763
Active Contributor
0 Kudos

R u using script for check printing or smartform?

also the two copies that u need, are they identical?

If u r looking for some help here at sdn please explain ur question clearly

Former Member
0 Kudos

Hi,

We are using SAP Scripts.

The check prints are identical.

Here is the complete req.- At present when the user fires the printout MFGPro(need to know more) sends data to 3rd party.This interface is responsible for drawing layout of form and also prints the check and office copy at same time.So the pre-printed page and A4 page will be kept in a different trays of printer.

Since sap will fire spool fire directly we need to add logic to take care of 2 prints separately.

Print the actual check and asve a PDF file in the location mentioned thru pop-up.All checks can be saved i same folder so user can select them and check them once.

former_member205763
Active Contributor
0 Kudos

To get the pdf, check the parameter getotf in the output options as X this will give u the output as an otf internal table use this otf table to convert into pdf using fm convert_otf, now u ll have a pdf internal table as output now use th class CL_GUI_FRONTENDSERVICES, it has two methods FILE_SAVE_DIALOG and GUI_DOWNLOAD use these to get a popup and save the pdf at appropriate locations.

since u already have to otf data u can use the fm print_otf to trigger the spool print.

Edited by: Kartik Tarla on May 3, 2009 12:12 PM