Author |
Message
|
ghoshly |
Posted: Wed Dec 18, 2024 3:42 pm Post subject: SAP OData service call to send BASE64 data |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Hello,
I am trying to call a SAP OData service from ACE 12 message flow and within the payload one field is actually an attachment in Base64 format.
The field is defined as string in SAP and through the service invocation, SAP developer is only getting first 255 characters, hence the complete file is not received. I tried to send the field as BLOB after decoding it, but it didn't help.
What is the best way to handle this scenario which appears to be very common. I would be thankful for any pointer to resolve this.
Best Regards.. |
|
Back to top |
|
 |
timber |
Posted: Wed Jan 01, 2025 10:08 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Please provide details of the input message tree and the code that you have tried. |
|
Back to top |
|
 |
ghoshly |
Posted: Tue Jan 07, 2025 12:46 pm Post subject: |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Hello Tim,
Thanks for responding, the input message is a SOAP message which is received from IBM Maximo. I am just selecting few fields and generating JSON message payload to call SAP Odata service.
DOCUMENTDATA is the field in the source message tree which contains the Base64 format of an attachment to an work order which I should share with SAP.
Code: |
DECLARE NS_Max NAMESPACE 'http://www.sodexo.com/maximo';
DECLARE RF_Output REFERENCE TO OutputRoot;
DECLARE RF_Doclinks REFERENCE TO InputRoot.SOAP.Body.NS_Max:*[<].NS_Max:*[<].NS_Max:DOCLINKS;
DECLARE RF_WorkOrder REFERENCE TO RF_Doclinks.NS_Max:WORKORDER;
CREATE LASTCHILD OF OutputRoot AS RF_Output DOMAIN 'JSON' NAME 'JSON';
CREATE LASTCHILD OF RF_Output AS RF_Output NAME 'Data';
IF RF_Doclinks.Action = 'Delete' THEN
SET RF_Output.Function = 'D'; -- Check RF_Doclinks.Action and assign values based on that
ELSE
SET RF_Output.Function = 'C';
END IF;
SET RF_Output.MaximoWO = RF_WorkOrder.NS_Max:WONUM;
IF LENGTH(COALESCE(RF_WorkOrder.NS_Max:WOJO6, '')) > 0 THEN
SET RF_Output.SAPWOrder = RF_WorkOrder.NS_Max:WOJO6;
END IF;
SET RF_Output.MaximoWOID = RF_Doclinks.NS_Max:OWNERID;
SET RF_Output.FileName = RF_Doclinks.NS_Max:URLNAME;
SET RF_Output.FileDesc = RF_Doclinks.NS_Max:DESCRIPTION;
SET RF_Output.DocType = RF_Doclinks.NS_Max:DOCTYPE;
SET RF_Output.Content = RF_Doclinks.NS_Max:DOCUMENTDATA; -- CAST(BASE64DECODE(RF_Doclinks.NS_Max:DOCUMENTDATA) AS BLOB);
|
|
|
Back to top |
|
 |
timber |
Posted: Thu Jan 09, 2025 3:39 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
The input field is base64. So you need to
- decode the base64 to get a BLOB (base64decode) and then
- encode the BLOB as a character stream ( CAST blob AS CHARACTER CCSID <choose ccsid carefully to match what the receiver expects> |
|
Back to top |
|
 |
ghoshly |
Posted: Thu Jan 09, 2025 5:50 pm Post subject: Resolved` |
|
|
Partisan
Joined: 10 Jan 2008 Posts: 333
|
Well, thanks for your response Tim.
my code worked when SAP developer decoded the base 64 and converted into Hex.
I would try the character stream for a Odata service where the output field type is STREAM. |
|
Back to top |
|
 |
|