2013 Jan 23 3:49 PM
Hello guys.
I'm converting a spool to a pdf, after that the pdf should be download using FTP. The convert tp PDF is ok, i checked by download the pdf using GUI and the file is opened fine. The problem is when i try to download the PDF using FTP, the pdf file is prueba001.pdf around 47 KB. So, it contains data. But i can't opening, the acrobat says error.
This is what i have done until now.
{code}
REPORT ztest006.
PARAMETERS: spoolno LIKE tsp01-rqident.
DATA pdf LIKE tline OCCURS 100 WITH HEADER LINE.
DATA: numbytes TYPE i,
pdfspoolid LIKE tsp01-rqident,
jobname LIKE tbtcjob-jobname,
jobcount LIKE tbtcjob-jobcount.
DATA: client LIKE tst01-dclient,
name LIKE tst01-dname,
objtype LIKE rststype-type,
type LIKE rststype-type.
TABLES: tsp01.
DATA: mc_password(20) TYPE c,
mi_key TYPE i VALUE 26101957,
mi_pwd_len TYPE i,
mi_handle TYPE i,
cmd(120),
l_rfc LIKE rfcdes-rfcdest.
CONSTANTS: c_key TYPE i VALUE 26101957.
SELECT SINGLE * FROM tsp01 WHERE rqident = spoolno.
client = tsp01-rqclient.
name = tsp01-rqo1name.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = client
name = name
part = 1
IMPORTING
type = type
objtype = objtype.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolno
no_dialog = ' '
IMPORTING
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
TABLES
pdf = pdf.
mc_password = 'xxx'.
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = mc_password "Actual password
sourcelen = '10'
key = c_key
IMPORTING
destination = mc_password. "Encyrpted Password
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = 'xxx'
password = mc_password
host = '192.xxx'
rfc_destination = 'SAPFTPA'
IMPORTING
handle = mi_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
CHECK sy-subrc = 0.
CONCATENATE 'prueba001' '.pdf' INTO cmd.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = mi_handle
fname = cmd
character_mode = 'X'
TABLES
text = pdf[]
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = mi_handle
EXCEPTIONS
OTHERS = 1.
{code}
Please, any ideas how to solve this problem???
Regards
2013 Jan 23 4:01 PM
I'm not 100% sure, but it may be the character mode flag in the FTP_R3_TO_SERVER call.
With a PDF, it will more then likely need to be sent in binary mode. I'm not 100% familiar with the above FM (I use some other FTP functions, like FTP_CONNECT, FTP_COMMAND, etc); so this is just a educated guess at best.