Skip to Content
0
Former Member
Apr 22, 2008 at 10:27 AM

Convert to PDF in background processing

102 Views

Hi all experts,

Please help. I've been on it for days and I can't seem to find any solution. Here's the scenario,

1. I get all the finished status spool in table TBTCO.

2. Match with TBTCP to get the spool number.

3. Open the graphical display of the spool to get the office

code using FM RSPO_RETURN_ABAP_SPOOLJOB.

4. Create a folder in the presentation folder for that office

code.

5. Create a pdf output for that spool.

6. Save all pdf output with the same office codes in the

created the presentation folder.

My problem is that an error keeps popping out. It says "Error calling Data provider". Maybe it's because I do it in background process, but I have to because if I don't, I get an "ABAP Runtime error." O please help me. Below are the FMs I used.

LOOP AT itab.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = itab-sp_numb

no_dialog = c_no

dst_device = c_device

IMPORTING

pdf_bytecount = gd_bytecount

TABLES

pdf = it_pdf_output

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.

AT NEW sp_name.

CONCATENATE: p_file itab-sp_name '\' INTO p_file.

ENDAT.

AT NEW br_code.

PERFORM get_brcode.

CONCATENATE: p_file brc '\' INTO p_file.

ENDAT.

AT NEW dumon.

CONCATENATE: p_file itab-dumon '\' INTO p_file.

ENDAT.

IF sy-subrc = 0.

IF p_pres EQ 'X'.

MOVE p_file TO lv_file.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = lv_file

filetype = 'BIN'

TABLES

data_tab = it_pdf_output.

IF sy-subrc 0.

MESSAGE e398(00) WITH 'Error creating file' p_file.

ELSE.

MESSAGE i398(00) WITH 'File Created' p_file.

ENDIF.

ELSE.

APPEND LINES OF it_pdf_output TO lt_conv.

IF lt_conv[] IS NOT INITIAL.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

LOOP AT lt_conv INTO lv_string.

TRANSFER lv_string TO p_file.

ENDLOOP.

CLOSE DATASET p_file.

IF sy-subrc EQ 0.

MESSAGE i398(00) WITH 'File Created' p_file.

ELSE.

MESSAGE e398(00) WITH 'Error closing file' p_file.

ENDIF.

ELSE.

MESSAGE e398(00) WITH 'Error creating file' p_file.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

<REMOVED BY MODERATOR>

Anna

Edited by: Alvaro Tejada Galindo on Apr 22, 2008 5:44 PM