Application Development and Automation 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: 
Read only

Base64 decoded xString to PDF File

natashagarg
Explorer
12,469

Hello

Requirement: To create a PDF and attach it to Sales Order through GOS from a base64 encoded string (from PDF file) as Input. The input PDF file has only 'SAP' written in it.

Completed so far:

1. Able to convert the input string into xString using 'SCMS_BASE64_DECODE_STR'

2. Converted xString to Binary using 'SCMS_XSTRING_TO_BINARY'. Below is the Binary output from this step


3. In order to create PDF from this point, I am writing above content to Spool and then converting to PDF using 'CONVERT_ABAPSPOOLJOB_2_PDF'

4. Linked the PDF table from Step 3 to Sales Order GOS attachment successfully

Problem: PDF attached to the Sales Order has the exact data shown in the screenshot as I wrote it in the spool as well. Please guide me in understanding how can I generate the PDF with the original content 'SAP' from Binary data in Step 2 without the unwanted data.

8 REPLIES 8
Read only

Former Member
0 Likes
10,481

Hi natashagarg,

Out of curiosity, have you tried ADS_CREATE_PDF_SPOOLJOB?

Cheers,

Luis

Read only

natashagarg
Explorer
0 Likes
10,481

Thanks Luis for replying. I tried the suggested FM as well but I am getting an error 'File does not begin with %PDF' while trying to open it from spool

Read only

natashagarg
Explorer
10,481

I am getting below in the PDF that is getting generated. It is same as what I am getting as output from 'SCMS_XSTRING_TO_BINARY'.

Read only

0 Likes
10,481

Please use the COMMENT button. The button ANSWER is reserved to give the solution.

Read only

joltdx
Active Contributor
10,481

Hi!

Let me see if get this straight. I might miss something...

  1. Your get a PDF file as a base64. (That PDF file has only the word 'SAP' written in it)
  2. Then you use SCMS_BASE64_DECODE_STR to get that PDF file (as base64) to a PDF file (as xstring)
  3. Next you call SCMS_XSTRING_TO_BINARY to get that PDF file (as xstring) to a PDF file (as binary).
  4. ...Shouldn't you stop here? Isn't this the PDF file you want to attach to the sales order?
Read only

Sandra_Rossi
Active Contributor
0 Likes
10,481

I second Jörgen, you don't need spooling !! If you have the bytes of the PDF, then add the file to the sales order.

Read only

former_member744059
Discoverer
10,481

i want to convert Xstring to PDF file,could you tell me how to write Xstring to FDF file ,thanks .

Read only

0 Likes
10,481

Saying "convert xstring to ..." is the same as saying "convert bytes to ...", which doesn't mean a lot without the context, whatever the target is PDF or anything else. You must explain what the source bytes contain (XLSX file, etc. ?)