2023 Oct 26 5:13 PM
I have a requirement to pull a PDF file from an FTP server and then write the exact same file to a folder in the SAP AL11 directory.
I am successfully connecting to and getting the date from the FTP server using several SAP standard function modules including FTP_SERVER_TO_R3.
That returns a BLOB table.
What I am having trouble is writing that BLOB data out to AL11 in a valid file that can then be opened.
The blob table returned by the FTP_SERVER_TO_R3 function is in GT_DATA
OPEN DATASET p_file2 FOR OUTPUT IN BINARY MODE.I have also tried using the following function to convert the BLOB to XSTRING.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = gv_len
IMPORTING
BUFFER = X_CONTENT
tables
binary_tab = gt_data
EXCEPTIONS
FAILED = 1
OTHERS = 2.
Then I transfer the X_CONENT to the file and close the file.
Neither approach seems to work.
Any suggestions would be appreciated.
Jay
2023 Oct 26 8:30 PM
You may simplify a lot !
Take your blob table of type SOLIX_TAB, then convert to XSTRING via
xstring = CL_BCS_CONVERT=>solix_to_xstring( IT_SOLIX = blob_table IV_SIZE = blob_length ).
Write the XSTRING, don't loop:
OPEN DATASET file FOR OUTPUT IN BINARY MODE.
TRANSFER xstring TO file.
CLOSE DATASET file.