Skip to Content
Technical Articles

SAP Cloud Platform Integration (CPI) || Fetching Report’s data from ECC to C4C via CPI (Alternative for Mashups in C4C/ Integration fo ECC, CPI, and C4C)

Dear Reader,

To read my series of blog posts on CPI, you can click on the links below: 

  • My adventure in learning CPI || Part 1 || All about SAP Cloud
  • My adventure in learning CPI || Part 2 || Deployment Models
  • My adventure in learning CPI || Part 3 || Cloud Security
  • SAP Cloud Platform Integration (CPI) || Part 4 || Know your tool
  • SAP Cloud Platform Integration (CPI) || Part 5 || Content Modifier
  • SAP Cloud Platform Integration (CPI) || Part 6 || Configuring Mail Adapter
  • SAP Cloud Platform Integration (CPI) || Part 7 || Maintaining logs by using “Groovy Scripts”, even if the IFlow is not on trace mode.
  • SAP Cloud Platform Integration (CPI) || Part 8 || Working with Request Reply

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – 

SCENARIO: 

There is a report in ECC, and the idea is to show the report’s data in C4C. Now, the C4C experts will say that you can create Webservices in ECC and they can be displayed in the “HTML Mashups”which has been provided by SAP, out-of-the-box i.e. by standard.

Now I will tell you what is the problem with Mashups. In the configuration for Mashups you maintain the link to access the report, and the credentials to ECC. Your client’s ECC runs in their private network, and hence, the moment the end-user is outside the company’s network, these reports won’t run. To run these reports you shall need VPN. But, isn’t it much of a trouble for the client, and their end-users? The idea should always be to provide ease to the end-users while transacting.

So what should be done?

 

SOLUTION:

  1. [ABAP] Create a webservice
  2. [CPI] Generate an end-point URL, and share it with [ABAP]. Maintain the Connection details as shown below, and Deploy the IFlow to generate the end-points.
  3.  [ABAP] Share the structure in the form of abcd.wsdl to [CPI], otherwise, the [CPI] person can extract the structure from SE80 from the package in which the [ABAP] has created the Service defination.
  4.  [ABAP] Create a proxy program to send the report’s data. [ABAP/ CPI]Please take a note of the Logical Port name maintained in the program.
  5.  [ABAP /CPI] Enter the TCode, SOAMANAGER. Typically this TCODE when entered, opens in your webbrowser. Now, go to Web Service Configuration.
  6.  [ABAP/ CPI] Search for the consumer proxy program as show below:
  7.  [ABAP/ CPI] By Manual Configuration, create Logical Ports using the same Logical Port, as mention in the proxy program (refer point number 4).
  8.  [ABAP/ CPI] Below is the configuration details for the Logical Port created:
  9.  [ABAP/ CPI] Execute the program in SE80 to send the report data to CPI, so that you can see the incoming Payload which is to be shared with the [C4C] consultant.
  10.  [CPI] Below is the Payload which you can see in the TRACE mode.
  11. [C4C] Create a custom Business Object in SDK. 
  12.  [C4C] Here is the code for the Business Object, which you can creting seeing the payload shared by the [CPI]. Basically, the elements decalred are going to be the columns of the Data Store which you are going to 
    import AP.Common.GDT as apCommonGDT;
    
    [WithAdministrativeData][ChangeHistory] businessobject SaleOrder_Report {
    
    [Label ("Report Name")]		element ZReportName : LANGUAGEINDEPENDENT_LONG_Text;
    [Label ("External ID")]		element ZExternalID : ID;
    [Label ("Internal ID")]		element ZInternalID : BusinessPartnerInternalID;
    [Label ("Sales Order Number")]	element ZSONumber	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Sales Order Item Number")]	element ZSOItem		: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Purchase Order Number")]	element ZPONumber	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Purchase Order Date")]		element ZPODate		: Date;
    [Label ("Quality")]		element ZQuality	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Grade")]		element ZGrade		: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Thickness")]		element ZThickness	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Width")]		element ZWidth		: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Length")]		element ZLength		: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Finish")]		element ZFinish		: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Edge Condition")]	element ZEdgeCon	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Document Date")]	element ZDocDate	: Date;
    [Label ("Quantity")]		element ZQuantity	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Basic Rate")]		element ZBasicRate	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Product Type")]	element ZProdType	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Reason for Rejection")] element ZROR		: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Part Weight Min")]	element ZPWtMin		: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Part Weight Max")]	element ZPwWtMax	: LANGUAGEINDEPENDENT_MEDIUM_Text;
    [Label ("Creation Date")]	element ZCreationDate : Date;
    }
  13.  [C4C] A script (.absl) for the “Event-BeforeSave” to be created, and below is the script for it.
    import ABSL;
    import AP.FO.BusinessPartner.Global;
    
    foreach (var each5 in this)
    {
    if (each5.SAP_SystemAdministrativeData.CreationDateTime == each5.SAP_SystemAdministrativeData.LastChangeDateTime)
            {
    		each5.ZCreationDate = each5.SAP_SystemAdministrativeData.CreationDateTime.ConvertToDate();
    	}
    }
    foreach (var each2 in this)
    {
    	var QueryUpdate = SaleOrder_Report.QueryByElements;
    	var SelUpdate = QueryUpdate.CreateSelectionParams();
    	var CurrentDate = Context.GetCurrentSystemDate();
    	var CurrentDate1 = Context.GetCurrentGlobalDateTime().ConvertToDate();
    	SelUpdate.Add(QueryUpdate.ZCreationDate, "E", "EQ", CurrentDate);
    	var ResultUdpate = QueryUpdate.Execute(SelUpdate);
    
    	if (ResultUdpate.Count() > 0)
    	{
    		ResultUdpate.Delete();
    
    	}
    }
    foreach (var each in this)
    {
    	var Query = Customer.QueryByBusinessObjectCustomer;
    	var SelectionPar = Query.CreateSelectionParams();
    	SelectionPar.Add(Query.ExternalID.content, "I", "EQ", each.ZExternalID.RemoveLeadingZeros());
    	var result = Query.Execute(SelectionPar);
    	if (result.Count() > 0)
    	{
    		foreach (var custinfo in result)
    			each.ZInternalID = custinfo.InternalID;
    	}
    }
  14.  [C4C] Create a Data Source on the custom Business Object created. Follow the screeshots below
  15.  [C4C] Create a custom OData Service. Select the Business Object, Select the elements/ fields, Assign the workcenter, Save the OData Service, and Activate it. Share the link with [CPI] Consultant.
  16. [CPI] Connect the End event to the Receiver using an OData adapter.
  17. [CPI] In the Message Mapping, maintain the .xsd file generated in the Target, and seeing the incoming payload from ECC, create a structure for the source.
  18. [CPI] Make the necessary mapping as per the Mapping Sheet shared by Business Team.
  19. [ABAP/ CPI] Now run the program in SE38, and this will do the following:
    •  From SE38, the consumer proxy program will send the data from the ERP to CPI, bases on the Transport Settings mainted in SOAMANGER.
    •  The Data comes to CPI, and gets consumed by the Receiver i.e. C4C on the basis of the OData Adapter Connection setting, and hits C4C.
    •  In C4C, you may create a report on top of the Data Source created in step number 14, and view the data.

 

Hope you had a good read.

If you wish to know more, or have any queries on this blog, then please feel free to drop a comment.

 

Thanks & Regards,

Sookriti Mishra

Be the first to leave a comment
You must be Logged on to comment or reply to a post.