Ariba is one of the SAP products which is used in my organization (Oil & Gas Industry) as part of the Demand to Deliver (D2D) domain. A new module Ariba Guided Buying (AGB) was introduced and we need master data to be updated on Ariba portal as part of requirement. CIG is being used to connect our SAP ECC system to read the master data file and consume the data.
Use case
SAP provides a program which extracts master data from SAP ECC, but our DevOps team wants to sync some additional master data records in Ariba. Due to limitations in the standard approach and after initial investigation it was determined that to upload file on Ariba portal, we need to:
- Zip the CSV file generated by a program on SAP ECC.
- Zipped file must be encoded with Base64 encoding.
- cXML file (to be uploaded) must be in specific format along with Name & value parameter.
We (as an Integration specialist) during our career might have come across point 1 or 2 to support business requirement. Trickiest part was to find the right combination for all 3 points, to generate valid file which can be consumed by Ariba. I would like to admit that I enjoyed the time spent to solve this puzzle, searching for right combination.
Solution
For Point 1 we used Standard Bean “PayloadZipBean” with mode as “ZIPALL” on sender communication channel to zip the file.
Below are the configuration details applied on communication channel:
The Zip file content should be encoded (base64) and passed on as an input to content field in the target cXML file format. For this we used Java Mapping to address the point 2.
Reference Java code used, where we are creating cXML file format:
package com.encode;
import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import java.util.Base64;
public class Encoder extends AbstractTransformation {
@Override
public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException {
String encodedString = null;
String initialxml = null;
String endxml = null;
String completexml = null;
try {
InputStream inputStream = in.getInputPayload().getInputStream();
OutputStream outputStream = out.getOutputPayload().getOutputStream();
byte[] b = new byte[inputStream.available()];
inputStream.read(b);
encodedString = Base64.getEncoder().encodeToString(b);
initialxml = "<?xml version="1.0" encoding="UTF-8"?><ns0:MT_UploadFile xmlns:ns0="urn:slb.com:SUP:CustomerNumberDetails">";
endxml = "<Name></Name><Content>"+encodedString+"</Content></ns0:MT_UploadFile>";
completexml = initialxml+endxml;
//Derive output(target) xml message
outputStream.write((completexml).getBytes());
} catch (Exception exception) {
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}
}
}
The output of this java mapping is used as an input of the GUI mapping. We need to populate few Name & Value parameters on target structure, which are used to upload the data on Ariba portal along with content:
Target cXML file structure used:
GUI Message Mapping:
Once the cXML file format is prepared, we can then upload the file on Ariba portal.
Below are the configuration details related to receiver communication channel:
Conclusion
We were able to upload master data on Ariba portal via this approach. The details were validated by our Ariba team and data was available on the portal. I expect this approach can help to overcome existing limitation and may be another way of uploading data on Ariba.