Decode Base64 in 4.6c

i need to decode base64 attachments.
However the funciton modules i would normally use are not available in 4.6c does anyone know how i can do it ?

I found a solution in 4.6C which works out of the box: (See form in s_trustmanager)
*     Decode String
      PERFORM ssf_base64_decode IN PROGRAM s_trustmanager
            USING lv_char
            CHANGING lv_hex.

Similar Messages

  • Encode and Decode Base64

    Hi All,
    I need to Encode and Decode Base64 File. 
    Please let me know if there is any Function Modules or Class Methods to achieve the requirement.
    Thanks in advance.
    Regards
    Joseph
    Message was edited by: Joseph Brown

    Hi,
    This is the encoded base64 file in XML format:
    <?xml version="1.0" encoding="UTF-8"?>
    <Z_CREFO_DOC>
    <E_PDF><![CDATA[JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29k
    ZT4+CnN0cmVhbQp4nE2MPQ/CMAxEd/8Kj/aQEKehIWvFh8QElTfEVNFOGUr7/0UagcTd8vSkuxmd
    FY9u6wGDLs4rRA1dhfvvCeYIaDbbZU8c9Dxk7LMGG50RGkWsHobExpj7F1NjhBzfCgG5tAR/Z0
    5pYMN6Qs9OJACxuhlY0n5Kde4aRwL/0A6e4hnWVuZHN0cmVhbQplbmRvYmoKNiAwIG9iagoxMzEK
    ZW5kb2JqCjQgMCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94IFswIDAgNTk1LjIyIDg0Ml0KL1Jv
    dGF0ZSAwL1BhcmVudCAzIDAgUgovUmVzb3VyY2VzPDwvUHJvY1NldFsvUERGIC9UZXh0XQovRXh0
    R1N0YXRlIDEwIDAgUgovRm9udCAxMSAwIFIKPj4KL0NvbnRlbnRzIDUgMCBSCj4+CmVuZG9iagoz
    IDAgb2JqCjw8IC9UeXBlIC9QYWdlcyAvS2lkcyBbCjQgMCBSCl0gL0NvdW50IDEKL1JvdGF0ZSAw
    Pj4KZW5kb2JqCjEgMCBvYmoKPDwvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMyAwIFIKPj4KZW5kb2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NjE1IDAwMDAwIG4gCjAwMDAwMDE3OTYgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSAxNCAv
    Um9vdCAxIDAgUiAvSW5mbyAyIDAgUgovSUQgWyityXEclVXSeoKdpGR5FFwppSkorclxHJVV0nqC
    naRkeRRcKaUpXQo+PgpzdGFydHhyZWYKMjU5NgolJUVPRgo=]]>
    </E_PDF>
    <C_ERROR></C_ERROR>
    </Z_CREFO_DOC>
    Can i pass all these characters or i need to transform it first, extract the value of the element and decode? Finally i need to write the decoded outcome to a file (a pdf file) to the hard drive (may be with: OPEN DATASET P_DATASET FOR INPUT IN TEXT MODE ENCODING DEFAULT)
    I saw this hint but I think there should be more to it (eg. transformation of the initial decoded xml file and the writing it to hard drive using the Open Dataset for Input...):
    ****************being of report *************************
    DATA: z       TYPE string,
          encode  TYPE string,
          decode  TYPE string .
    DATA: obj  TYPE REF TO cl_http_utility,
          cref TYPE REF TO if_http_utility.
    CREATE OBJECT : obj.
    cref = obj.
    z = 'what u have to encode'.
    encode = obj->if_http_utility~encode_base64( z ) .
    decode = obj->if_http_utility~decode_base64( encode ).
    ****************end of report ***************************
    What do i need more to the above report

  • Decode Base64 and save as binary file

    Hi there,
    I am using Adobe Air 1.5 with JavaScript and want to save a file to my hard
    drive. I get the data from a WebService via SOAP as a Base64 encoded string. A test-string is attached. When I try to decode it with
    the WebKit function "atob()" and try to save this bytes with following code, I can't open the file.
    this.writeFile = function(outputfile, content, append){
    var file =a ir.File.applicationStorageDirectory.resolvePath(outputfile);
    var stream = newa ir.FileStream();
    if (append) {
    stream.open(filea, ir.FileMode.APPEND);
    }else {
    stream.open(filea, ir.FileMode.WRITE);
    try{//Binärdaten
    stream.writeBytes(content0, , content.length);
    }catch(e){//Textdaten
    stream.writeUTFBytes(content);
    stream.close();
    The same happens when I try to open a file from my HDD and read in the bytes. When I decode it to base64, the string is not equal to the string, which is correct.
    I attached a working Base64 string, which I could convert back to a zip-file via a only encoder.
    So my question is, how can I decode a Base64 string and save the binary data to a file?
    Thank you for your help.

    I rewrote the Base64 decoder/encoder to use it with a ByteArray. Here ist the code:
    var byteArrayToBase64 = function(byteArr){
        var base64s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
         var encOut = "";
        var bits;
        var i = 0;
        while(byteArr.length >= i+3){
            bits = (byteArr[i++] & 0xff) << 16 | (byteArr[i++] & 0xff) << 8 | byteArr[i++] & 0xff;
              encOut += base64s.charAt((bits & 0x00fc0000) >> 18) + base64s.charAt((bits & 0x0003f000) >> 12) + base64s.charAt((bits & 0x00000fc0) >> 6) + base64s.charAt((bits & 0x0000003f));
        if(byteArr.length-i > 0 && byteArr.length-i < 3){
            var dual = Boolean(byteArr.length - i - 1);
            bits = ((byteArr[i++] & 0xff) << 16) | (dual ? (byteArr[i] & 0xff) << 8 : 0);
            encOut += base64s.charAt((bits & 0x00fc0000) >> 18) + base64s.charAt((bits & 0x0003f000) >> 12) + (dual ? base64s.charAt((bits & 0x00000fc0) >> 6) : '=') + '=';
        return encOut;
    var base64ToByteArray = function(encStr){
        var base64s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
         var decOut = new air.ByteArray(); 
        var bits;
        for(var i = 0, j = 0; i<encStr.length; i += 4, j += 3){
            bits = (base64s.indexOf(encStr.charAt(i)) & 0xff) <<18 | (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 | (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 | base64s.indexOf(encStr.charAt(i +3)) & 0xff;
            decOut[j+0] = ((bits & 0xff0000) >> 16);
              if(i+4 != encStr.length || encStr.charCodeAt(encStr.length - 2) != 61){
                   decOut[j+1] = ((bits & 0xff00) >> 8);
              if(i+4 != encStr.length || encStr.charCodeAt(encStr.length - 1) != 61){
                   decOut[j+2] = (bits & 0xff);
        return decOut;

  • Parse xml in inputstreamobject and decode base64

    Hello
    I have got a http-package with content-type text/xml, from a HttpURLConnection object.
    From the HttpURLConnection object i get an InputStreamObject.
    Now i'm looking for the easiest to parse the xml, that is in the Inputstream object.
    The xml just contains base64 encoded data and i need to decode this data into a byte array.
    I have not much experience with java and xml, so it would be nice when somebody could help me.
    Kind regards,
    ClaudeMichelle

    ClaudeMichelle wrote:
    i'm looking for the easiest to parse the xml, that is in the Inputstream object.
    The xml just contains base64 encoded data and i need to decode this data into a byte array.Below tutorial will help.
    BASE64 Decoder Stream from Sun Microsystems:*
    This class implements a BASE64 Decoder. It is implemented as a FilterInputStream, so one can just wrap this class around any input stream and read bytes from this filter. The decoding is done as the bytes are read out.
    Authors: John Mani, Bill Shannon+[For actual tutorial visit here |http://www.java2s.com/Code/Java/File-Input-Output/BASE64DecoderStreamfromSunMicrosystems.htm]
    *Cheers,
    typurohit* (Tejas Purohit)

  • Decode Base64(Pdf) to binary

    Hi all,
    I have a WS - PI - File scenario.
    So I get a base64 coded PDF-File and have to create a decoded binary file.
    First I used an UDF. But the created document is invalid and not to open by Acrobat. After reading the forum the conclusion is,  it is impossible to convert data in mapping step, is'nt it.
    But what are the other possibilities?
    Regards
    Mathias

    You can do this in the mapping using Base64.decode() method from SAP standard API (com.sap.aii.utilxi.base64.api.*)
    Check my WIKI section for ref: [Sending Binary Data to Inbound Plain HTTP Adapter in XI and PI |http://wiki.sdn.sap.com/wiki/display/XI/SendingBinaryDatatoInboundPlainHTTPAdapterinXIand+PI] where i used encode method in HTTP client code.
    You can check decode method code in the java snippet  "Java Mapping - Base64 Decryption and Unzipping Code "
    Edited by: Praveen Gujjeti on Jul 16, 2010 4:59 PM

  • Possible to decode base64 document contents to XDP?

    Hi,
    As the title says, is it possible to decode the base64-encoded contents of my PDF back to an XDP format?
    Using this JavaScript SOAP.stringFromStream(SOAP.streamEncode(Collab.documentToStream(event.target), "base64")); I am able to submit the base64 encoded PDF document to my server side for processing. Is there any way to convert this back to XDP format at this stage?
    Thanks,
    Ray

    Maybe someone might have a few ideas on how I can approach my problem so.
    My web application maintains session info of any logged in users. One of the attributes of the session is a "securityToken".
    When the user clicks a button on the PDF within my web application, a Web Service call is made. However, I need to get the securityToken into this Web Service call. This securityToken isn't something that the user should be manually entering.
    Can anyone think of any possible solution to solve this problem?
    Thanks,
    Ray.

  • Decoding base64-encoded SSL files

    There is a way to decode the base64 contents of .crt, .key, and .pem files to display human-readable text, but I can't remember how to do it.  "base64 -d" doesn't work cause there's some garble in there.  I think I used the openssl command for this.  Anyone know?

    Is this what you are looking for? http://www.madboa.com/geek/openssl/#cert-exam

  • Decoding BASE64 file

    Hi all,
    I have a BASE64 formatted email message.Can anyone tell me how can I decode this message so that I can get the content:
    ======================START============================
    begin-base64 664 letter.Z
    FRIFHFRBFSY9bD4gA0wAElNhIiclNm1aXVtNSwxyNykzLx1MBhoFSSYwKHo1
    FUwLHR1Fcjc1UCkTH088HEw7OykpMlotAxELQTwxKShhLCVBWFNBPDFsPCQb
    HgYaFAAmPS0uYRQDG1QQTzwhKTQ1cBsGABsAPzQnMy8dTAIRU1AzLGw8LghM
    Ag1TSDMhYHopH0wCFQoANjA/MzMfTBsbU0I3NiM3JFoBFn4bRTsnYHogFAhP
    BhZTNyc6PzJaCgAGU003dTgyJFoKDgAWAD0zbBkgCAgGGhJMIXUPOzEIDR0V
    eUE8MWwYJBQYBgIcRz48I3ZhDQQAVARFIDBsKi4THwAaFkR8dQV6JR8PAxUB
    RXIhI3osA0wBEQNINyJgUAYPBQsbU3MiNCg7bVoBFlQATz4wbDIkEx5DVAdI
    MyFsE2ESDRkRU0InJyU/JVoFAVQSACI5LTkkcAQKVBhOPSI/eiAUCE8cElNy
    IyUpKA4JC1QESSY9bDckVkwbHBJUcjw/dmETAk8AG0VyNi0sJAlMABJ5VDow
    bCksGwADVDpTPjQiPmEVCk85HE4mMGwZMxMfGxtTQT45bBNhCgMcBwBTNzFs
    NSdwBQETHFQheWw9LhYIQ1QeTzwwNXZhEAkYER9TfnUoMyAXAwEQAAxyMik3
    MkFMGxwSVHIcRjstFQIKVBhOPSJsNSdaGAcRU0UqPD8uJBQPClQcRnIhJDMy
    WhgdERJTJycpdmENBAYXGwA/NDVQIBcDGhoHACY6bDQkGx4DDVNUJTpsNygW
    AAYbHVNyOip6ExUBDhpTQyA6OzQyVkwOGhcAJT0lOSlwBApUBEk+OWw8KBQI
    TxsdACA0JSkoFAtPABtFciE7Py8OBQoAGwAgOi8xYRweABlTVDowbCksGwAD
    fhBSNzAnejUVTBscFgA3ND8uYRMCTxVTUjsyJC5hFgUBEV0ABiIjei4KCQEd
    HUchdSQ7Nx9MDREWTlg4LT4kWgUBVAdINyYpeiIbGgoHSAAmPSl6NQgJDgcG
    Ujd1JSlhEwJPABtFcjM5KDUSCRwAeUE8MiA/YRMCTwAbRXImKTkuFAhUVARI
    OzYkejUICQ4HBlI3dQV6Ix8dGhESVDp1LTQlWgAKFQVFWDAiLigICU8AHAA6
    PCF6IAlMAg1TUz05KXopHwUdWnkCYGA4MmE7HB0dHwxyZHhjeVRmTTcSRSE0
    PnoSCg0LFV0CWF9hd2E/FAwRAVAmdSooLhdMLBsGTiZ1IzxhNwMBABYAEScl
    KTUVTAkbAQATLyk7LRUYHH6M
    ====
    ======================END============================
    quick response expected.
    Thanks
    Arun

    it's most likely the text you're extracting from the database is either corrupted or wasn't encoded as you expect. Note that your success with the img tag decoding may be misleading. I can't give you details that apply to this case, but browsers typically use smarter decoding tools which are more robust ...
    1) Was the text in the database produced by an internal encoder or was it obtained either from a standard e-mail attachment or produced by this command or its equivalent?:
    Thanks Ray - I was afraid of that. I am extracting the image from a database written by a commercial application. I checked with the developers, and they said it was base64, so that's all I have to go on. I reported this anomaly to them but haven't heard back in over a week.
    2) Are you sure you're retrieving exactly the same bytes that were stored in the database?
    As sure as I can be. For testing, I invoke sqlite from a shell to do the select statement and dump the result to the terminal. Then copy and paste from terminal to a TextWrangler document. I have done the same with an Applescript.
    One complicating factor: the text stored in the database has these weird markup tags that I can't find any documentation. They look like this: <iimg><preferredFilename>Embedded image</preferredFilename><segment>TU0AK...=
    </segment><segment>UdSVL...=
    </segment></iimg>
    I strip these out of the field coming from the database.
    To isolate the problem...
    Unfortunately, since I am not creating the database, I am loath to write to it. I could, but since the problem is likely in the way the developers are encoding or storing the data, it wouldn't do much to solve my problem...
    Thanks so much for your suggestions!! Very helpful.

  • Base64 encode decode question

    Hi
    I use the auclair base64 class to encode and decode base64 locally and it works great.
    But when I send the string to my server and back (aspx), I cannot decode it I have the 2030 error from flash.
    When I compare the encoded string from both end they look the same.
    I make sure it is fully loaded before attempting the decode.
    Is this a common bug or I'm I wrong somewhere?
    Thanks
    I use the latest air.

    The -d switch on the openssl base64 command enables debugging; it's the short version of the --debug switch.  Probably not what you're after, either.  The -D switch would be more typical, that's the short version of --decode switch, and probably what you had intended.
    The -i (--input) and -o (--output) switches allow you to specify input and output files, which is one way to pass a whole lot of data into that command.
    Do you have an example of some of the text that you're working with?

  • Base64 decode with user defined function called from xslt

    I have an xml document which has a segment containing a b64 encoded attachment.
    I would like to decode the attachment as i map it.
    I would think this could be done by using a java function of some kind being called from the xslt however i have very limited experience in this and none in how to code the decoding.
    Anyone have an example ?
    Cheers
    Jon

    >
    Jon Vaugan wrote:
    > I have an xml document which has a segment containing a b64 encoded attachment.
    > I would like to decode the attachment as i map it.
    >
    > I would think this could be done by using a java function of some kind being called from the xslt however i have very limited experience in this and none in how to code the decoding.
    >
    > Anyone have an example ?
    >
    > Cheers
    > Jon
    yes SDN seems to have an example for you....it may not exactly solve your problem...but yes it not irrelevant.....you just need to do some R&D
    /people/farooq.farooqui3/blog/2008/05/22/decode-base64-incoming-encoded-information-in-sap-xipi-using-java-mapping
    Regards,
    Abhishek

  • Converting from Tcl to Java...need to decode passwords stored in DB

    Hello:
    I am converting an application that was previously coded in Tcl/Vignette to Java. Part of this application is a login process. There are already passwords established for thousands of users and I need to be able to have Java decode these passwords from the DB when the users log in. The Vignette Tcl method used to encode the passwords previously was ENCODE64.
    I am almost completely ignorant of doing encrypting/decrypting in Java. can someone give me some idea of what I can use to be able to encode incoming passwords at login so that they can match with the ENCODE64 passwords that exist in the database??
    Basic lgoic is this (pseudocode):
    login = false
    encryptedPassword = encrypt(password_in)
    if encryptedPassword = dbPassword then set login = true
    Does that make sense??
    Thanks!
    Brian

    The Bouncy Castle JCE provider (www.bouncycastle.org) has Base64 encoder/decoder classes that 'just work'.
    import org.bouncycastle.util.encoders.Base64;
    String base64encodedString = "ABCKD4632adcomd";
    byte[] decoded = Base64.decode(base64encodedString);
    String reencoded = new String(Base64.encode(decoded));As for your second question re: how should you re encrypt the passwords? The standard, quite secure way of doing this is to use a one-way cipher. This will encrypt the password text to an unintelligible mess, that CANNOT be decrypted back to the original.
    When a new user enters their password for the first time, you use your cipher to encrypt it, and store this (not the actual password).
    To verify this user, you take the password they give you, encrypt it in the same way, and compare the results.
    Unix/Linux can use a shell command called 'crypt' to do exactly this... MySQL will also do it for you... INSERT INTO blah VALUES(CRYPT('blahpasswordstring'), and SELECT * FROM blah WHERE password=CRYPT('enteredpassword')).
    ... and its far too early in the morning, and I cant for the life of me remember the JCE equivalent of this function :(

  • Display base64 encoded image in flash

    how to decode the base 64 representation of the image?

    Has any played around with the bitmapdata classes to see if
    there are any undocumented was to convert the decoded base64 (now
    binary) into pixel data? Until we migrate to as3 (huge
    undertaking), I really need a way to use the base64 strings from a
    web service as images in flash. I'm going to keep playing and
    digging, but in the meantime, if someone can shed some light here
    on how to do this with AS2, I would bow to your "sherlock
    holmes-ness".
    Thanks

  • Decode string with base 64

    HI,
    i have string that encode in base64 and i want to decode it ,
    there is Fm or method that can help with this issue ?
    Regards
    Nina
    Edited by: Nina C on Aug 4, 2009 9:56 AM

    Hi,
    Check if this Wiki helps
    [Decoding BASE64 in ABAP |https://wiki.sdn.sap.com/wiki/display/Snippets/Decoding%20BASE64%20in%20ABAP]

  • Can't get it to work!!! Please help with IllegalBlockSizeException

    I have tried several things, I have searched the forume many times ever
    since yesterday, but I just can't figure this out. Here is my method to encrypt:
    private void encryptPassword(String p)
    try{
    //generate key using DES algorithm
    byte key[] = "ababcabc".getBytes();
    SecretKeySpec secretKey = new SecretKeySpec(key,"DES");
    //get cipher for DES algorithm
    Cipher cipher = Cipher.getInstance ("DES");
    cipher.init(Cipher.ENCRYPT_MODE,secretKey);
    //encrypt password
    //byte[] tmp = Base64.encode(p.getBytes());
    byte[] encryptedPswd = cipher.doFinal(p.getBytes("UTF-8"));
    //byte[] encryptedPswd = cipher.doFinal(tmp);
    password = new String(encryptedPswd, "UTF-8");
    catch(Exception e){
    logger.error("ERROR: Unable to encrypt password "
                                       + "due to Exception: " + e);
    And here is my method to decrypt:
    private String decryptPassword()
    try
    {   //generate key using DES algorithm
    byte key[] = "ababcabc".getBytes();
    SecretKeySpec secretKey = new SecretKeySpec(key,"DES");
    //get cipher for DES algorithm
    Cipher cipher = Cipher.getInstance ("DES");
    cipher.init(Cipher.DECRYPT_MODE,secretKey);
    //byte[] cipherCode = Base64.decode(password.getBytes());
    //byte[] decryptedPswd = cipher.doFinal(cipherCode);
    byte[] decryptedPswd = cipher.doFinal(password.getBytes("UTF-8"));
    return new String(decryptedPswd, "UTF-8");
    catch(Exception e){
    logger.error("ERROR: Unable to decrypt password "
                                       + "due to Exception: " + e);
    return "";
    As you can see, I have tried to use Base64 encoder, but that didn't work either. I got ArrayIndexOutOfBounds exception with that. I followed this thread to try that: http://forum.java.sun.com/thread.jsp?forum=9&thread=302490. I used to get BadPaddingException when I didn't use "UTF-8" encoding. But now I get IllegalBlockSizeException. Please let me know what I am doing wrong.
    Thank you so much!
    Malia

    I found the answer to my question at this site: http://javaalmanac.com/egs/javax.crypto/DesString.html
    The key is to use base64 encoding, but I didn't know that the class sun.misc.BASE64Encoder and sun.misc.BASE64Decoder comes with regular JDK. I searched for base64 encoders, but the implementation from Ostermiller didn't work for me. So, for those having the same problem, go to that site. Here is the snapshot:
    public class DesEncrypter {
    Cipher ecipher;
    Cipher dcipher;
    DesEncrypter(SecretKey key) {
    try {
    ecipher = Cipher.getInstance("DES");
    dcipher = Cipher.getInstance("DES");
    ecipher.init(Cipher.ENCRYPT_MODE, key);
    dcipher.init(Cipher.DECRYPT_MODE, key);
    } catch (javax.crypto.NoSuchPaddingException e) {
    } catch (java.security.NoSuchAlgorithmException e) {
    } catch (java.security.InvalidKeyException e) {
    public String encrypt(String str) {
    try {
    // Encode the string into bytes using utf-8
    byte[] utf8 = str.getBytes("UTF8");
    // Encrypt
    byte[] enc = ecipher.doFinal(utf8);
    // Encode bytes to base64 to get a string
    return new sun.misc.BASE64Encoder().encode(enc);
    } catch (javax.crypto.BadPaddingException e) {
    } catch (IllegalBlockSizeException e) {
    } catch (UnsupportedEncodingException e) {
    } catch (java.io.IOException e) {
    return null;
    public String decrypt(String str) {
    try {
    // Decode base64 to get bytes
    byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
    // Decrypt
    byte[] utf8 = dcipher.doFinal(dec);
    // Decode using utf-8
    return new String(utf8, "UTF8");
    } catch (javax.crypto.BadPaddingException e) {
    } catch (IllegalBlockSizeException e) {
    } catch (UnsupportedEncodingException e) {
    } catch (java.io.IOException e) {
    return null;
    Here's an example that uses the class:
    try {
    // Generate a temporary key. In practice, you would save this key.
    // See also e464 Encrypting with DES Using a Pass Phrase.
    SecretKey key = KeyGenerator.getInstance("DES").generateKey();
    // Create encrypter/decrypter class
    DesEncrypter encrypter = new DesEncrypter(key);
    // Encrypt
    String encrypted = encrypter.encrypt("Don't tell anybody!");
    // Decrypt
    String decrypted = encrypter.decrypt(encrypted);
    } catch (Exception e) {

  • Converting Base64Binary to PDF document in BSP

    Hello SDN users,
    I am trying to get and display a pdf document from a webservice which is provided as a base64binary.
    The interface of the webservice tells me that the response type (the actual pdf document) is an xsd:base64Binary.
    The webservice proxy class generates an RAWSTRING for the pdf document as the response from the webservice call.
    So my first guess was to use following class method to convert the base64binary to a normal string
       CALL METHOD cl_http_utility=>if_http_utility~decode_base64
          EXPORTING
            encoded = lv_out_char " RAWSTRING from webservice
          RECEIVING
            decoded = lv_out_char_decoded.
    My second guess was to create an xstring from this converted string via
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            text   = lv_out_char_decoded"
            mimetype = 'APPLICATION/PDF'
          IMPORTING
            buffer = lv_out_charx.
    My next assumption was to create otf-data via function module so that I can send the otf data to the http server cache.
    lv_pdf_len = XSTRLEN( lv_out_charx ).
    call function 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
        IMPORTING
          bin_filesize          = lv_pdf_len
          bin_file              = lv_out_charx
        TABLES
          OTF                   = LT_OUTPUT_DATA-OTFDATA
          LINES                 = LT_LINES
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          others                = 5.
    My Problem is, that I get back error code 4 which means bad otf.
    Does anyone has a hint how I need to convert the base64binary from the webservice to a right format?
    That would be great!

    Hello Durairaj,
    thank you very much for your answer,
    is it usual that the method
    CALL METHOD cl_http_utility=>if_http_utility~decode_base64
          EXPORTING
            encoded = lv_out_char " RAWSTRING from webservice
          RECEIVING
            decoded = lv_out_char_decoded.
    returns a string containg something like %pdf...? This was not the case with my method call.
    But on friday I found out why. the string I received from the webservice was actually an XSTRING which I found out during a debugging session. The method return parameter was declared  as RAWSTRING so I assumed that I had to convert from Base64 to STRING and then to XSTRING. When I aborted all the converting routines
    if_http_utility~decode_base64
    and
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    and passed the XSTRING to the ICM server cache I received the pdf I wanted.
    But anyway If you could confirm my second question how a a decoded Base64 attribute should look  like I would be very happy.
    Regards,
    Sebastian

Maybe you are looking for