‎2011 Nov 02 1:45 PM
Hello all,
I've a program which converts the spool to a pdf file and drops that pdf to the Application server. This process apparently works fine. The issue here is, while trying to download the same pdf file using CG3Y or using another FM from the App.server, which will be in the binary format and was save as PDF file. However I'm NOT able to open that PDF file using Adobe. While try to open the pdf file, The message says "Adobe reader could not open <file>, because it is either not a supported file type or because the file has been damaged;.
Do I need to do conversion of this binary file in the App.server?
The objective is, I should be able to open the pdf file using Adobe after I've downloaded from the App.server.
Looking forward to hear back from the experts...
Here's the code which does the download of pdf to App.Server.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = LV_RQIDENT
NO_DIALOG = 'X'
DST_DEVICE =
NO_BACKGROUND =
GET_SIZE_FROM_FORMAT =
IMPORTING
PDF_bytecount = GV_pdf_bytecount
PDF_spoolid = GV_pdf_spoolid
BTC_jobname = GV_btc_jobname
BTC_jobcount = GV_btc_jobcount
TABLES
PDF = GT_pdftab
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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Concatenate: L_OFILE '/' L_Repid '_' Sy-datum '_' Sy-uzeit '.pdf' into GV_Ofile.
If NOT GT_pdftab[] is initial.
OPEN DATASET GV_Ofile FOR OUTPUT IN BINARY MODE. "TEXT MODE encoding default.
If Sy-subrc is initial.
Loop at GT_pdftab into WA_pdftab.
Move: WA_pdftab-TDLINE to GV_output.
Transfer GV_output to GV_Ofile.
Endloop.
CLOSE DATASET GV_Ofile.
Write:/ 'PDF file created:' color 5,
GV_Ofile color 4.
Else.
Write:/ 'Could not open file:', GV_ofile.
Endif.
Thanks,
G
‎2011 Nov 02 2:22 PM
Hi
Try to use the exporting parameter BIN_FILE instead of tables PDF
Max
‎2011 Nov 02 2:22 PM
Hi
Try to use the exporting parameter BIN_FILE instead of tables PDF
Max
‎2011 Nov 02 2:58 PM
Hi Max,
Thanks for your feedback.
I've used the BIN_FILE field in the Importing section...However it came back with blank...I guess we still have to rely upon the pdf table. I've also found out that the first bytes of the pdf data were in the 'tdformat' field. Now I've concatenated that field with 'tdline' before sending it to the App.server.... But the issue is still not solved....
G
‎2011 Nov 02 4:04 PM
Hi
I use this code and it works fine:
PARAMETERS: P_FILE(200) LOWER CASE OBLIGATORY.
PARAMETERS: RQIDENT LIKE TSP01-RQIDENT OBLIGATORY.
DATA RQ TYPE TSP01.
DATA T_DUMMY TYPE TABLE OF RSPOATTR.
DATA: BIN_FILESIZE TYPE I,
BIN_FILE TYPE XSTRING.
DATA PDF_CONTENT TYPE SOLIX_TAB.
DATA: L_PDF TYPE SOLIX.
DATA: L_KO TYPE FLAG,
L_OPEN TYPE FLAG..
INITIALIZATION.
P_FILE = '<.....>.pdf'.
START-OF-SELECTION.
CALL FUNCTION 'RSPO_GET_ATTRIBUTES_SPOOLJOB'
EXPORTING
RQIDENT = RQIDENT
IMPORTING
RQ = RQ
TABLES
ATTRIBUTES = T_DUMMY
EXCEPTIONS
NO_SUCH_JOB = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE I208(00) WITH 'Spool non trovato'(001).
STOP.
ENDIF.
CASE RQ-RQDOCTYPE.
WHEN 'OTF' OR 'SMART'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = RQ-RQIDENT
NO_DIALOG = 'X'
PDF_DESTINATION = 'X'
NO_BACKGROUND = 'X'
IMPORTING
PDF_BYTECOUNT = BIN_FILESIZE
BIN_FILE = BIN_FILE
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 I208(00) WITH 'Error in CONVERT_OTFSPOOLJOB_2_PDF'(002).
ENDIF.
WHEN 'LIST'.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = RQ-RQIDENT
NO_DIALOG = 'X'
PDF_DESTINATION = 'X'
NO_BACKGROUND = 'X'
IMPORTING
PDF_BYTECOUNT = BIN_FILESIZE
BIN_FILE = BIN_FILE
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 <> 0.
MESSAGE I208(00) WITH 'Error in CONVERT_ABAPSPOOLJOB_2_PDF'(003).
ENDIF.
ENDCASE.
IF SY-SUBRC <> 0. STOP. ENDIF.
PDF_CONTENT = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX( BIN_FILE ).
DESCRIBE TABLE PDF_CONTENT LINES SY-TABIX.
IF SY-TABIX > 0.
CLEAR BIN_FILE.
OPEN DATASET P_FILE FOR OUTPUT IN BINARY MODE.
IF SY-SUBRC = 0.
L_OPEN = 'X'.
LOOP AT PDF_CONTENT INTO L_PDF.
TRANSFER L_PDF TO P_FILE.
ENDLOOP.
CLOSE DATASET P_FILE.
ENDIF.
ELSE.
L_KO = 'X'.
ENDIF.
IF L_KO IS INITIAL.
IF L_OPEN = 'X'.
MESSAGE S208(00) WITH 'File pdf scaricato con successo'(004).
ELSE.
MESSAGE S208(00) WITH 'Scarico file pdf fallito'(006).
ENDIF.
ELSE.
IF L_OPEN = 'X'.
DELETE DATASET P_FILE.
ENDIF.
MESSAGE S208(00) WITH 'Nessun dato da scaricare'(005).
ENDIF.Max
‎2011 Nov 02 4:59 PM
Excellent example Max...
PDF_CONTENT = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX( BIN_FILE ).
This is what did the trick...Since I was doing both pdf table and bin_file, my bin_file was never populated...
I removed the pdf table and used the just the bin_file during the 'CONVERT_ABAPSPOOLJOB_2_PDF' call.
Problem solved...
Rewarded with points.
Thanks very much Max...Really appreciated...
G