cancel
Showing results for 
Search instead for 
Did you mean: 

Convert OTF to PDF and print PDF from Spool

Former Member
0 Kudos

Hi,

I have searched all the forums and service market place but could not find solution to my problem.

I am using Function module



  CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid              = p_spool
      no_dialog                = 'X'
      dst_device               = 'ISJB'
      pdf_destination          = 'S'
    IMPORTING
      pdf_bytecount            = lv_bytecount
      pdf_spoolid              = lv_spoolid
      otf_pagecount            = lv_pagecount
      btc_jobname              = lv_jobname
      btc_jobcount             = lv_jobcount
    TABLES
      pdf                      = gt_pdf
    EXCEPTIONS
      err_no_otf_spooljob      = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_dstdevice        = 5
      user_cancelled           = 6
      err_spoolerror           = 7
      err_temseerror           = 8
      err_btcjob_open_failed   = 9
      err_btcjob_submit_failed = 10
      err_btcjob_close_failed  = 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.

this generates spool in SP01. Ideally it should generate a PDF spool file but it generates a BIN file of Format G_RAW. When I display the spool it displays all kinds of japanese characters which does not make sense,.

I setup printer ISJB with device type JPPDF (PDF converted for Japanese characters). Does any one know where the problem could be? Why I could not print the Spool in PDF?

Thank you,

Jagadish

Accepted Solutions (0)

Answers (4)

Answers (4)

SandySingh
Active Contributor
0 Kudos

Attaching the Invoice Smartforms to Dunning Letter Smartform

Hello Mr Jagdish,

Could you please help me with a Enhancement to Dunning Smart form. I am using a Custom Smart form for Dunning and i have a requirement that I need to print all the respective customer invoice smart forms/Sap scripts along with the Dunning Letter smartform.

For this, I tried putting the logic in custom Dunning Smart form for printing all the invoices but some of the invoices have landscape format and I am getting a runtime error. I think it is not a good idea from even maintenance point of view.

So now I am trying to open and customize the standard print program SAPF150D2 and calling my invoice smartforms from print program. I have TWO problems:

1. How the Dunning Statement printed from Transaction - F150 different from what printed from standard print program SAPF150D2 ?

2. How to get a single spool for both print outs. If not, how to create a spool for second form with all the Invoices form attached in single PDF.

Could anyone please help me in this. Does anyone had such requirement of Attaching the Invoice Smartforms to Dunning Letter Smartform.

Much Appreciated.

Regards

Sam

former_member196280
Active Contributor
0 Kudos

<u>Taken from OSS Note</u>

How can Thai ABAP lists be converted to PDF via the SAP spool?

Other terms

Thai, ABAP list, PDF1, ZPDF1, THPDF, ZTHPDF

Reason and Prerequisites

Up to now, PDF output via spools (as in note 317851) for Thai was not supported.

Solution

The following prerequisites apply to the PDF conversion of ABAP lists in Thai via the SAP spool:

1. SAP Release 4.6C or higher

2. The ZTHPDF device type must be installed in the system (see attachment)

3. As the Acrobat standard fonts do not support Thai characters, you must use the RSTXPDF2 report to install a PDF substitute font that is embedded (font embedding) in the generated PDF files during the conversion to PDF. The "Angsana New" TrueType font (file name Angsan.ttf) is a suitable font for this:

SAP font name: TrueType font:

THDRAFT Angsana New

4. The system must contain the Support Package listed with this note.

5. The system must contain the following kernel patch:

4.6D patch level 1304

6.10 patch level -> use 6.20 kernel

6.20 patch level 508

A THPDF device type for PDF conversion is delivered as of SAP Release 6.40.

Regards,

SaiRam

Former Member
0 Kudos

Hi,

check out this program which will convert spool to pdf

REPORT zsmartform_spool_g.

*************Types Declaration ****************************

TYPES : BEGIN OF gty_tab, " Spool Requests

rqident TYPE tsp01-rqident, " Spool request number

rqdoctype TYPE tsp01-rqdoctype, " Spool: document type

rqo1name TYPE tsp01-rqo1name, " TemSe object name

END OF gty_tab.

*********Work Area ****************************************

DATA: form_name TYPE rs38l_fnam, " Used to get the function module of Smartform

wa_outopt TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer) options

gs_tab TYPE gty_tab. " Spool Requests

*******Internal Table Declarations ************************

DATA: gt_tab TYPE STANDARD TABLE OF gty_tab, " Spool Requests

gt_pdf TYPE STANDARD TABLE OF tline, " SAPscript: Text Lines

gt_spoolid TYPE tsfspoolid, " Table with Spool IDs

gt_otfdata TYPE ssfcrescl. " Smart Forms: Return value at end of form prnt

*********Variable Declarations ****************************

DATA: gv_bytecount TYPE i, "#EC NEEDED " PDF Byte Count

gv_file_name TYPE string, " File name

gv_file_path TYPE string, " File Path

gv_full_path TYPE string, " Path

gv_binfilesize TYPE i, " Bin File size

gv_rqident TYPE tsp01-rqident, " Spool request number

gv_name TYPE tst01-dname, " TemSe object name

gv_objtype TYPE rststype-type, " TemSe: Object type name

gv_type TYPE rststype-type. " TemSe: Object type name

START-OF-SELECTION.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZPDF_G'

IMPORTING

fm_name = form_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*Get Spool IDs

wa_outopt-tdnewid = 'X'.

wa_outopt-tddest = 'LP01'.

CALL FUNCTION form_name

EXPORTING

output_options = wa_outopt

user_settings = 'X'

IMPORTING

job_output_info = gt_otfdata

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 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.

*Assign the spool id

gt_spoolid = gt_otfdata-spoolids.

  • Generate spool and pdf for the output of the form

PERFORM sub_generate_spool_pdf.

END-OF-SELECTION.

&----


*& Form sub_generate_spool_pdf

&----


  • Generate Spool and PDF output

----


FORM sub_generate_spool_pdf .

DATA: ls_spoolid LIKE LINE OF gt_spoolid.

*----Get the Spool Number

CLEAR ls_spoolid.

READ TABLE gt_spoolid INTO ls_spoolid INDEX 1.

IF sy-subrc = 0.

gv_rqident = ls_spoolid.

ENDIF.

CLEAR gt_tab.

SELECT rqident rqdoctype rqo1name INTO TABLE gt_tab

FROM tsp01 WHERE rqident = gv_rqident.

IF sy-subrc = 0.

CLEAR gs_tab.

  • Get the TemSe: Object name into variable gv_name

READ TABLE gt_tab INTO gs_tab INDEX 1.

IF sy-subrc = 0.

gv_name = gs_tab-rqo1name.

ENDIF.

ENDIF.

CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

EXPORTING

authority = 'SP01'

client = sy-mandt

name = gv_name

part = 1

IMPORTING

type = gv_type

objtype = gv_objtype

EXCEPTIONS

fb_error = 1

fb_rsts_other = 2

no_object = 3

no_permission = 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.

  • Check if temse object name type is 'OTF' or 'LIST'

IF gv_objtype(3) = 'OTF'.

PERFORM get_otf_spool_in_pdf.

ELSE.

PERFORM get_abap_spool_in_pdf.

ENDIF.

  • Generate F4 functionality from spool to pdf

PERFORM write_pdf_spool_to_pc.

ENDFORM. " sub_generate_spool_pdf

&----


*& Form get_abap_spool_in_pdf

&----


  • Generate the Spool number

----


FORM get_abap_spool_in_pdf .

REFRESH gt_pdf.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gv_rqident

IMPORTING

pdf_bytecount = gv_bytecount

TABLES

pdf = gt_pdf

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

OTHERS = 12.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " get_abap_spool_in_pdf

&----


*& Form get_otf_spool_in_pdf

&----


  • Generate OTF data from the Spool Number

----


FORM get_otf_spool_in_pdf .

REFRESH gt_pdf.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gv_rqident

IMPORTING

pdf_bytecount = gv_bytecount

TABLES

pdf = gt_pdf

EXCEPTIONS

err_no_otf_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_dstdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 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.

ENDFORM. " get_otf_spool_in_pdf

&----


*& Form write_pdf_spool_to_pc

&----


  • Generate PDF format

----


FORM write_pdf_spool_to_pc .

CALL METHOD cl_gui_frontend_services=>file_save_dialog

CHANGING

filename = gv_file_name

path = gv_file_path

fullpath = gv_full_path

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.

----


DOWNLOADING THE PDF DATA***

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = gv_binfilesize

filename = gv_full_path

filetype = 'BIN'

TABLES

data_tab = gt_pdf

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.

ENDFORM. " write_pdf_spool_to_pc

Former Member
0 Kudos

Thanks for your prompt reply.

But, what I need is not download after converting to PDF. I want to <b>create a spool in PDF format and automatically print the spool.</b>

SAP now provides different output devices like ZPDF1 in order to print a SAPscript or Smartform in PDF. I am using those output devices but not getting the spool in PDF format.

Did any face this problem before?

Thank you,

Jagadish

former_member196280
Active Contributor
0 Kudos

Follow this examples with screen shots, it will help you to close your issue.

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df8244556">Example 1</a>

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d937ec90-0201-0010-0ca8-b6cb3b6dd1ef">Example2</a>

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df8244556">Example3(download from spool)</a>

Close the thread once your question is answered.

Regards,

Sairam