Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert spool to PDF if pages more than 100

Former Member
0 Kudos

Hi

I want to convert spool to PDF if pages more than 100 and send it to application server.

if pages are less than 99 then it is working fine.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = wv_rqident

no_dialog = wc_x1

TABLES

pdf = wt_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.

CONCATENATE '/expc_var//EGYPT/' ws_regup-laufd ws_regup-laufi '.PDF' INTO wv_file.

OPEN DATASET wv_file FOR OUTPUT IN BINARY MODE.

LOOP AT wt_pdf INTO ws_pdf. TRANSFER ws_pdf TO wv_file.

ENDLOOP.

CLOSE DATASET wv_file.

Please suggest me how to achieve it?

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

The note 1833550 - Creating or Converting Large PDF Files explains that if the PDF is more than 99 pages, it may go to a background job (and so nothing is returned by the function module); you may avoid this drawback by passing the parameter NO_BACKGROUND = 'X' which does not start a background job, and more than 99 pages may be returned by the function module.

8 REPLIES 8

raymond_giuseppi
Active Contributor

0 Kudos

Hi Raymond,

RSTXPDFT4 generated background job along with spool number which contains binary data and not able convert to PDF data using FM CONVERT_OTFSPOOLJOB_2_PDF.

Kindly let me know how to convert background job spool to PDF data?

0 Kudos

The background job generated spool (raw data) can be converted and downloaded with report RSTXPDFT5. (It's no longer required to convert otf/spool to pdf, already done by the job)

Regards,
Raymond

0 Kudos

Thanks Raymond..

Implemented logic as below to place the data into application server but taking around one min time to finish the background job if spool have morethan 100 pages. In this case I am not getting spool number until background job finished so program should wait one min after the calling FM'CONVERT_OTFSPOOLJOB_2_PDF' .

Can you please suggest me.

CONCATENATE '/expc_var/archive/emi/EGYPT/' ws_regup-laufd ws_regup-laufi '.PDF' INTO wv_file. IF wv_zbukr = '0845' .

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = wv_rqident

no_dialog = wc_x1

IMPORTING

btc_jobname = wv_jobname

btc_jobcount = wv_jobcount

TABLES pdf = wt_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.

IF wv_jobname IS NOT INITIAL AND wv_jobcount IS NOT INITIAL.

SELECT listident FROM tbtcp UP TO 1 ROWS INTO wv_spool_nr

WHERE jobname = wv_jobname AND jobcount = wv_jobcount.

ENDSELECT.

*REPORT TO DOWNLOAD PDF SPOOL TO GUI

SUBMIT zfi_rstxpdft5 WITH spoolid = wv_spool_nr with fs_serv = 'X' WITH serv_fn = wv_file AND RETURN.

ELSEIF wt_pdf[] IS NOT INITIAL.

OPEN DATASET wv_file FOR OUTPUT IN BINARY MODE.

LOOP AT wt_pdf INTO ws_pdf.

TRANSFER ws_pdf TO wv_file.

ENDLOOP.

CLOSE DATASET wv_file.

0 Kudos

You could use FM BP_JOB_STATUS_GET to check status of the background job, only get generated spool id when it successfuly end (type-pools TYBTC or include LBTCHDEF for status values)

Regards,
Raymond

0 Kudos

Thanks Raymond,

Done..

IF batch = 'X' AND wf_witem IS NOT INITIAL. DO.

CALL FUNCTION 'BP_JOB_STATUS_GET'

EXPORTING

jobcount = jobcount

jobname = jobname

IMPORTING

status = l_status

EXCEPTIONS

job_doesnt_exist = 1

unknown_error = 2

parent_child_inconsistency = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID 'FB' TYPE 'E' NUMBER 051.

EXIT.

ELSE.

IF l_status EQ 'F' OR l_status EQ 'A'. "Finished/Abgebrochen

EXIT.

ENDIF.

ENDIF.

WAIT UP TO 3 SECONDS.

ENDDO.

0 Kudos

You could just pass the parameter NO_BACKGROUND = 'X', because I don't see the advantage of running the pdf conversion in background if you're waiting for it.

Sandra_Rossi
Active Contributor

The note 1833550 - Creating or Converting Large PDF Files explains that if the PDF is more than 99 pages, it may go to a background job (and so nothing is returned by the function module); you may avoid this drawback by passing the parameter NO_BACKGROUND = 'X' which does not start a background job, and more than 99 pages may be returned by the function module.