Monday, March 9, 2020

FBDI - Load data into ERP Cloud from SOA

Before proceeding with this blog, please go through Manual FBDI in Oracle ERP Cloud as a pre-requisite for better understanding. 

When we plan to load data into ERP cloud through SOA integration, one question for which we need to find the answer is, "what are the services available in ERP cloud to aid this functionality?"

Oracle Enterprise Repository:

Oracle provides Enterprise Repository for Fusion Applications in which all supported services are listed. 

This is the link for OER. In the page that opens, click on Cloud Applications. Choose the module that is relevant to you. Lets take an example of Financials.

REST APIs - On the left pane, you would find REST API -> Financials. On clicking this, you would find "You can view a list of all REST Endpoints". This link will show you all the REST services that are available for financial cloud. You can check for the ones applicable in your scenario and use them.

SOAP services - There are two ways of getting the list of services.

1. Service Catalog -
https://{cloud-instance}/fscmService/ServiceCatalogService?WSDL
Replace {cloud-instance} with your cloud url.
This service returns information about your cloud instances, any new services and also helps to programmatically find and retrieve the required data to invoke SOAP services.
This webservice exposes two operations - getAllServiceEndpoints and getServiceEndpoint. With getAllServiceEndpoints operation, you can find the list of all SOAP services (along with wsdl urls) supported by your cloud instance.

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ns0:getAllServiceEndPointsResponse xmlns:ns0="http://xmlns.oracle.com/oracle/apps/fnd/applcore/webservices/types/" xmlns:ns1="http://xmlns.oracle.com/oracle/apps/fnd/applcore/webservices/">
    <ns1:result>
      <ns0:qName>{http://xmlns.oracle.com/apps/scm/productCatalogManagement/advancedItems/custExtn/model/extnService/}EgoAdvancedItemsReferenceService</ns0:qName>
      <ns0:lbo>SCM-SCM : EGP-Product Model : EGP_ITEM-Item</ns0:lbo>
      <ns0:lifecycle>Deprecated</ns0:lifecycle>
      <ns0:xsdLocation>https://{cloud-instance}/fscmService/EgoAdvancedItemsReferenceService?XSD=/oracle/apps/scm/productCatalogManagement/advancedItems/custExtn/model/extnService/EgoAdvancedItemsReferenceService.xsd</ns0:xsdLocation>
      <ns0:wsdlAddress>https://{cloud-instance}/fscmService/EgoAdvancedItemsReferenceService?WSDL</ns0:wsdlAddress>
      <ns0:serviceType>BUSINESS_OBJECT</ns0:serviceType>
    </ns1:result>
    <ns1:result>
      <ns0:qName>{http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/}ErpIcsIntegrationService</ns0:qName>
      <ns0:lbo xsi:nil="true" />
      <ns0:lifecycle>Active</ns0:lifecycle>
      <ns0:xsdLocation>https://{cloud-instance}/fscmService/ErpIcsIntegrationService?XSD=/oracle/apps/financials/commonModules/shared/model/erpIntegrationService/ErpIcsIntegrationService.xsd</ns0:xsdLocation>
      <ns0:wsdlAddress>https://{cloud-instance}/fscmService/ErpIcsIntegrationService?WSDL</ns0:wsdlAddress>         
      <ns0:serviceType>BUSINESS_OBJECT</ns0:serviceType>
    </ns1:result>
    <ns1:result>
      <ns0:qName>{http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/}ErpIntegrationService</ns0:qName>
      <ns0:lbo xsi:nil="true" />
      <ns0:lifecycle>Active</ns0:lifecycle>
      <ns0:xsdLocation>https://{cloud-instance}/fscmService/ErpIntegrationService?XSD=/oracle/apps/financials/commonModules/shared/model/erpIntegrationService/ErpIntegrationService.xsd</ns0:xsdLocation>
      <ns0:wsdlAddress>https://{cloud-instance}/fscmService/ErpIntegrationService?WSDL</ns0:wsdlAddress>
      <ns0:serviceType>BUSINESS_OBJECT</ns0:serviceType>
    </ns1:result>
  </ns0:getAllServiceEndPointsResponse>
</soapenv:Body>

Note: Above example has only 3 services listed. But the actual response would have the list of all services.
2. Oracle Help Center - In the above OER link, go to Cloud Applications -> Financials -> Tasks -> Integrate -> Click on Learn about ERP Cloud Integrations.
It will redirect you to Oracle support page, where you can find the details of the services.

https://{cloud-instance}/fscmService/ErpIntegrationService?WSDL is the cloud webservice in which you would find operations to import data to cloud, export data from cloud, submitting jobs, etc.

For FBDI, we are interested in the operation importBulkData. The JobDetails sections in importBulkData operation carry the job parameters, job definition, package name, callback url, etc, which need to be populated while invoking the service.

Integration from SOA:

Before we call importBulkData operation from SOA, we need to ensure that all the steps taken care as part of Manual FBDI in Oracle ERP Cloud blog are handled programmatically in our SOA process.

Here are the steps and their explaination -

1. Write csv file in the format of RaInterfaceLinesAll.csv we saw in the previous blog.

   a. Using file adapter in BPEL, convert the csv file from the previous blog to a schema. From BPEL, transform the input into file schema format, and using a WriteFile operation, write the input into a file (in your local cloud domain) with name RaInterfaceLinesAll.csv.

Note: The name of the file should be exactly same as what got auto-generated in the previous blog.

The adapter configuration looks as follows - 

<adapter-config name="writeInvoiceFile" adapter="file" wsdlLocation="../WSDLs/writeInvoiceFile.wsdl">
   <connection-factory location="eis/FileAdapter"/>
   <endpoint-interaction portType="writeInvoiceCSV_ptt" operation="WriteCSV">
      <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
         <property name="PhysicalDirectory" value="/tmp/invoice"/>
         <property name="Append" value="false"/>
         <property name="FileNamingConvention" value="RaInterfaceLinesAll.csv"/>
      </interaction-spec>
   </endpoint-interaction>
</adapter-config>

2. Create a zip file of the above csv file(s) created.
You can use java code to take files from the above location, zip it and write back to the same location.

3. Convert the zip into base64 format.
Here as well, we can use java code to convert the above zip file into base64 format.

4. Hit ERPIntegrationService, importBulkData operation with the job parameters and above base64 content as input.

Lets see what input this operation takes -

<typ:importBulkData>    
   <typ:document>      
      <erp:Content>{content in base64 format}</erp:Content>     
      <erp:FileName>AutoInvoiceImport.zip</erp:FileName>
      <erp:ContentType>zip</erp:ContentType>        
      <erp:DocumentTitle/>
      <erp:DocumentAuthor/>
      <erp:DocumentSecurityGroup/>
      <erp:DocumentAccount/>
      <erp:DocumentName/>
      <erp:DocumentId/>
   </typ:document>
   <typ:jobDetails>       
      <erp:JobName>/oracle/apps/ess/financials/receivables/transactions/autoInvoices/,AutoInvoiceImportEss</erp:JobName>       
      <erp:ParameterList>8098090,CONTRACT INTERNAL INVOICES,2018-07-01,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL</erp:ParameterList>       
      <erp:JobRequestId/>
   </typ:jobDetails>    
   <typ:notificationCode/>
   <typ:callbackURL/>
   <typ:jobOptions/>
</typ:importBulkData>
Content - This is the base64 content that we converted in step 3.
FileName - The zip file name that we created in Step 2.
ContentType - zip
JobName - As per my previous blog, the job that we used is Import AutoInvoice. But for the job parameter, the exact name can be derived as follows.

Go to ERP Cloud console -> Setup and Maintenance -> Search for Financials in the Setup dropdown -> Search for Manage Custom Enterprise Scheduler Jobs for Financials and Supply Chain Management and Related Applications.

The page shows a list of all the jobs available under Financials and Supply Chain Management and Related Applications.

Search for Import AutoInvoice. The result would show you details about Import AutoInvoice job. 



Click on the job link. You would see two fields Name and Path. The concatenation of Job path and Job name with a comma separation should be given in the JobName parameter in the above service.




Eg:/oracle/apps/ess/financials/receivables/transactions/autoInvoices/,AutoInvoiceImportEss

ParameterList - For this field, please refer to any manually submitted job.
Referring to the manual job I submitted in the previous blog - 
Image 2.7 - Import AutoInvoice Submitted Job Parameters

As per the image above, there are 20 arguments that need to be passed as input (in the same sequence). Give input for whatever fields applicable. For rest of them, pass #NULL.

Note: Parameter list is very important. Else the job submission will fail.

This way we can invoke the importBulkData operation from SOA.

Testing and Validation of the service:

1. Once you test your BPEL process and if importBulkData operation is successful, open the instance and see. You should find a jobId/processId returned in response. Just getting the jobId in response doesnt mean that the process completed successfully. 

You should validate it in ERP Cloud console.

2. Go to ERP Console -> Tools -> Scheduled Processes -> Search for the above JobId.

3. For one call made to importBulkData with above parameters, you can find the following jobs created in Cloud.
  • Load Interface File to Import
  • Transfer File
  • Load File to Interface
  • Import AutoInvoice
  • Import AutoInvoice: Execution Report
Jobs starting bottom up from the above image.

First three steps ensure that the data from the file is loaded to Interface tables.
Fourth step ensures that the data is loaded from interface tables to base tables.
The last step will show the entire execution log and also errors if any.


1 comment: