Why and when to use Screen and apex class to pass data? #
We always need to pass the sObject Id to select the data from the database. Here requirement is that user doesn’t want to select data from the database. The data is coming from a screen and they want to make a call to SAP with that data. We have to pass the data which user enters into a screen to invokeCallout2()
They don’t want to have the data to be written into a table in Salesforce. Just whatevere user enters in the screen need to be put a request for the HTTP callout through the SFDC2SAPPI or other adapters. They would use customer class in the outbound interface, so they can extract data themselves.
Steps to use the API invokeCallout2() to pass data from the apex class: #
User want to pass data when s/he executes callout api, so only api invokeCallout2 can handle this scenario. here we are using SFDC2SAPPI adapter for outbound processing.
Step1: Create SFDC2SAPPI adapter.
Step2: Create Integration.
Step2: Create Outbound Interface
Step3: Do mapping
Step4: Push data with apex class
- Go to set up
- Click on developer console
- Open Anonymous Window and enter following apex code.
Map<String, String> m=new Map<String, String>();
m.put(‘Name’, ‘AC1’);
m.put(‘BillingCity’,’City1′);
m.put(‘BillingCountry’,’DE’);
m.put(‘BillingState’,’State1′);
m.put(‘ERP_DEBTOR_ID__c’,’AC1′);
m.put(‘SAP_Division__c’,’00’);
m.put(‘SAP_Sales_Org__c’,’00’);
c.setPayLoad(m);
skyvvasolutions.IServices.invokeCallout2(‘Shweta’, ‘Account’, null, ‘SYNC’, c);
[/aux_code]
Step5: check result on message board