Submitted by Anonymous (not verified) on Tue, 02/05/2013 - 00:00
Forums

Hi,

I have a Soap web serve using ILOBS and I want to save the contents to a stream file on the IFS.

What am I doing wrong in this program:

    PPutDocument      B                   export

    DPutDocument      pi

… Lines removed

    D*************************************************************************

     /free

     SetContentType('text/xml; charset=utf-8');


     ilobdokout = sesgetilob('filedata');
     ilobdok = sesgetilob('filedata2');

     ilob_clear(ilobdokout);

     filename = %trim(root) + 'test.pdf';

     ILOB_SetWriteBinary(ilobdokout:*on);
     ILOB_Base64Decode(ilobdokout:ilobdok);
     ILOB_SaveToBinaryStream(ilobdokout:filename);

     *inlr = *on;

     /end-free

    PPutDocument      E

Regards,
Thomas

Niels Liisberg

Tue, 02/05/2013 - 00:00

Hi Thomas;

Typically it is a CCSID problem: the Base64Decode needs the input to be in some kind of ASCII. And my guess is your ilob is already converted into EBCDIC.

So my version of the programs use the ILOB_Xlate to bring the ilob from EBCDICto ASCII

   ILOB_Xlate (ilobdok: 0 : 1252);

Where:
Zero denotes the jobs current CCSID which is in some kind of EBCDIC.
1252 is just some ASCII codepage, in this case windows-1252. base64 only uses a-z A-Z and 0-9 so any CCSID will do.

Here is my modifications:

   PPutDocument      B                   export

    DPutDocument      pi

… Lines removed

    D*************************************************************************

     /free

     SetContentType('text/xml; charset=utf-8');


     ilobdokout = sesgetilob('filedata');
     ilobdok = sesgetilob('filedata2');
     ILOB_Xlate (ilobdok: 0 : 1252);

     filename = %trim(root) + 'test.pdf';

     ILOB_SetWriteBinary(ilobdokout:*on);
     ILOB_Base64Decode(ilobdokout:ilobdok);
     ILOB_SaveToBinaryStream(ilobdokout:filename);

     *inlr = *on;

     /end-free

    PPutDocument      E 

Best regards,
Niels Liisberg