You are on page 1of 72

Web Services

(A). What is web services?

Answer : Web services are client and server applications that communicate over the World Wide Web's (www)
Hypertext Transfer Protocol (HTTP).

(B). What you should already know?

Answer : Before you study web services you should have a basic understanding of XML.

(C). How many kinds of web services are there?

Answer : There are two kinds of web services are there.

SOAP (Simple Object Access protocol) : It's a protocol specification for exchanging structured information in the
implementation of web services in computer networks.

REST (Representational state transfer) : It's an abstraction of the architecture of the World Wide Web. More precisely,
REST is an architectural style consisting of a coordinated set of architectural constraints applied to components,
connectors, and data elements, within a distributed hypermedia system.

(D). What is the use of web services?

Answer : A web service is a software system designed to support interoperable machine-to-machine interaction
over a network. The basic web services platform is XML + HTTP(S). XML provides a language which can be used
between different platforms and programming languages and still express complex messages and functions. Now a
days, JSON (JavaScript Object Notation) also used in web services.

(E). What is WSDL?

Answer : WSDL stands for Web Services Description Language. WSDL is an XML-based language fro describing
Web Services and it's recomended by WWW.

In SAP Business ByDesign system we are able to Create and Consume SOAP and REST web services.

From the next page onward you can have the step wise description with screenshots to perform create and consume
web services in SAP Business ByDesign system.

Table of Contents :

Create Web Services External Web Services Integration


Create Inbound Web Services Create External Web Service Integration
Create Communication Scenario for Inbound Services Create Communication Scenario for Outbound Services
Create Communication System for Inbound Services Create Communication System for Outbound Services
Create Communication Arrangement for Inbound Create Communication Arrangement for Outbound
Testing of Web Services using SOAP UI Web Services Trigger Operations
Examples of Request and Response XML Testing of External Web Services Integration

BODL and ABSL Codes of Sample Business Objects

Business Object StudentDB Codes Business Object CloneStudentDB Codes


Create Web Services on any Business Object in SAP Business ByDesign

Step – 1 : Login to the SAP Business ByDesign SDK with PDI Access Credentials and open the Solution.

Step – 2 : Right Click on a folder or solution and click on Add > New Item.

Step – 3 : In the Add New wizard click on the Service Integration from the left and then click on Web Service.
Then Assign a name for the web service (Logically understandable) and click on Add button.
Step – 4 : Define the web service namespace and business object and click on the Next button.

Step – 5 : Select the elements in the Business Object View and click on Next Button.
Step – 6 : Select the elements in the Service Operations (Create, Read, Update, Query and Actions) and click Next
Button.
Step – 7 : Click on the Add Button of the Add Work Center View wizard and click on the radio button Create New
View and define the Work Center View Name and Click on the Add Button.
Instead of creating a New Work Center View, already created Work Center View(s) can also be assigned.
For that, click on the radio button Use Existing View and select the Work Center View from the list.

Step – 8 : After adding the Work Center View, select the work center view and check the service operations you
want to assign and then click on the Next Button.
Step – 9 : In the web service creating final wizard click on the Finish Button to generate the web service.
Step – 10 : After successfully generating the web service, right click on the web service and click on the Check In
Content and then Activate to Check In and Activate the web service.
(If error occurs, then please shorten the erroneous names within 120 characters and then follow the process)
Step – 11 : After Successfully Activation of the web service, right click on that and Download WSDL File in the local
system.

Move to Table of Contents


Create Communication Scenario for Inbound Services in SAP Business ByDesign

Step – 1 : Right Click on a folder or solution and click on Add > New Item.

Step – 2 : In the Add New wizard click on the Service Integration from the left and then click on Communication
Scenario. Then Assign a name for the Communication Scenario (Logically understandable) and click on Add button.
Step – 3 : Click on the Radio Buttons for Web Service Type as SOAP and Communication Type as Application
Integration (A2X). But don't check the checkbox for "Allow Non-Secure URLs (HTTP)". Click Next Button.

Step – 4 : Select the Web Services and Service Operations from the respective lists and click on Next Button.
Step – 5 : In the final wizard of the Communication Scenario Click on the Finish Button to generate.

Step – 6 : After generating the Communication Scenario, Right Click on that and click on Check In Content and then
Activate it.

Move to Table of Contents


Create Communication System for Inbound Services in SAP Business ByDesign

Step – 1 : Login to the SAP Business ByDesign system in web browser with credentials and the navigate to the
Application and User Management Work Center and then Communication Systems and click there.

Step – 2 : Click on the New Button and it will navigate to the New Communication System UI screen.
Step – 3 : In the New Communication System UI Screen fill all the details and click on Save Button.
After saving the Communication System click on Actions – Set to Active and then Save and Close Button.
Step – 4 : Click on the Go Button to see the Newly created Communication System in the List.

Move to Table of Contents


Create Communication Arrangement for Inbound Services in SAP Business ByDesign

Step – 1 : Login to the SAP Business ByDesign system in web browser with credentials and the navigate to the
Application and User Management Work Center and then Communication Arrangements and click there.

Step – 2 : Click on the Communication Arrangements New Button.


Step – 3 : Select the Communication Scenario and click on the Next Button.

Step – 4 : Select the system instance ID from the OVS (Object Value Selector) and click Next Button.
Step – 5 : The Inbound Communication Enabled checkbox should be checked. The Applictaion Protocol should be
"Web Service" and the Authentication Method should be selected as "User ID and Password".
Then Click on the Edit Credentials button. Set the Web Service Access password and click on OK Button.
In the Password atleast one Capital Letter and one Numeric Value should be there.
Step – 6 : Click on the Edit Advanced Settings Button.

Step – 7 : Select the web services from the Inbound List and click on Check Service Button.
Step – 8 : If the Check Successful, the click on Check Completeness Button.

Step – 9 : If the Check Successful, then click on the Next Button.


Step – 10 : Click on Finish Button and then Close Button. The newly created Communication Arrangement can be
found in the list of Communication Arrangements.

Move to Table of Contents


Testing of Web Services (WSDL) using SOAP UI

Step – 1 : Download the latest version of SOAP UI ( http://www.soapui.org/Downloads/latest-release.html )

Step – 2 : Install the SOAP UI (If not installed already) and execute that to test the WSDL File.

Step – 3 : Click on File – New soapUI Project (CTRL + N) or click on the icon to create a new SOAP UI Project.

Step – 4 : Browse the WSDL File from the local system. Select the WSDL File and click on Open Button.
Step – 5 : In the "New soapUI Project" wizard check the Create Requests checkbox and then click on OK Button.

Step – 6 : Expand the soapUI project and double click on any service operations (Create, Read, Update, Query, etc.)
Step – 7 : Identify the Request XML and fill with data along with the Web Service Access credentials (On Left side).
All the un-used XML tag(s) should be removed completely and XML tag opening and closing should be performed
perfectly, otherwise web service execution error will occur at the time of executing the web services.

After filling all the data to the corresponding Request XML tag(s) and the web service credentials, click on the Run
Button (Shown in the screenshot). After completion of the web service execution, the Response XML will generate on
the right hand side of the SOAP UI application.
Step – 8 : After successfully testing of the web services operations, save the Request XML and Response XML in
separate files in XML Format. These XML Files will help to perform the web service consume process.
Save the soapUI Project also to check the web services functionality again at any time without creating the projects.

Examples of XML :

Request XML for Create Service Operation :

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
<soap:Header/>
<soap:Body>
<glob:StudentDBWebServiceStudentDBCreateRequest_sync>
<StudentDB>
<StudentID>2</StudentID>
<StudentName>John Hall</StudentName>
<Gender>1</Gender>
<ContactNo>
<SubscriberID>1234567890</SubscriberID>
</ContactNo>
<DateOfBirth>1980-12-31</DateOfBirth>
<EmailID>john@gmail.com</EmailID>
<FatherName>Johny Hall</FatherName>
<PermanentAddress>123, USA</PermanentAddress>
<DepartmentName>Mechanical Engineering</DepartmentName>
<DepartmentRollNo>MECH/2000/17</DepartmentRollNo>
<UniversityRegistrationNo>UNIVREG002</UniversityRegistrationNo>
<UniversityRollNo>UNIVROLL8137</UniversityRollNo>
</StudentDB>
</glob:StudentDBWebServiceStudentDBCreateRequest_sync>
</soap:Body>
</soap:Envelope>
Response XML for Create Service Operation :

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
<n0:StudentDBWebServiceStudentDBCreateConfirmation_sync
xmlns:n0="http://sap.com/xi/SAPGlobal20/Global"
xmlns:prx="urn:sap.com:proxy:KGL:/1SAI/TAS2489CBD1191B26AE723D:804">
<StudentDB>
<SAP_UUID>00163e04-c86b-1ee4-98fd-8bb891dc426b</SAP_UUID>
<StudentID>2</StudentID>
</StudentDB>
<Log>
<MaximumLogItemSeverityCode>1</MaximumLogItemSeverityCode>
<Item>
<TypeID>007(/CSG_RUNTIME/)</TypeID>
<SeverityCode>1</SeverityCode>
<Note>Create operation was successful</Note>
</Item>
</Log>
</n0:StudentDBWebServiceStudentDBCreateConfirmation_sync>
</env:Body>
</env:Envelope>

Request XML for Read Service Operation :

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
<soap:Header/>
<soap:Body>
<glob:StudentDBWebServiceStudentDBReadByIDQuery_sync>
<StudentDB>
<StudentID>2</StudentID>
</StudentDB>
</glob:StudentDBWebServiceStudentDBReadByIDQuery_sync>
</soap:Body>
</soap:Envelope>

Response XML for Read Service Operation :

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
<n0:StudentDBWebServiceStudentDBReadByIDResponse_sync
xmlns:n0="http://sap.com/xi/SAPGlobal20/Global"
xmlns:prx="urn:sap.com:proxy:KGL:/1SAI/TAS6FA6AA8385E57B3D0CFF:804">
<StudentDB>
<SAP_UUID>00163e04-c86b-1ee4-98fd-8bb891dc426b</SAP_UUID>
<StudentID>2</StudentID>
<StudentName>John Hall</StudentName>
<Gender>1</Gender>
<GenderName>Male</GenderName>
<ContactNo>
<SubscriberID>1234567890</SubscriberID>
</ContactNo>
<DateOfBirth>1980-12-31</DateOfBirth>
<EmailID>john@gmail.com</EmailID>
<FatherName>Johny Hall</FatherName>
<PermanentAddress>123, USA</PermanentAddress>
<DepartmentName>Mechanical Engineering</DepartmentName>
<DepartmentRollNo>MECH/2000/17</DepartmentRollNo>
<UniversityRegistrationNo>UNIVREG002</UniversityRegistrationNo>
<UniversityRollNo>UNIVROLL8137</UniversityRollNo>
<SystemAdminData>
<CreationDateTime>2014-11-04T06:32:35Z</CreationDateTime>
<CreationIdentityUUID>00163e04-c86b-1ee4-98ed-123f7af37456</CreationIdentityUUID>
<LastChangeDateTime>2014-11-04T06:32:35Z</LastChangeDateTime>
</SystemAdminData>
</StudentDB>
<Log/>
</n0:StudentDBWebServiceStudentDBReadByIDResponse_sync>
</env:Body>
</env:Envelope>

Request XML for Update Service Operation :

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
<soap:Header/>
<soap:Body>
<glob:StudentDBWebServiceStudentDBUpdateRequest_sync>
<StudentDB>
<StudentID>2</StudentID>
<StudentName>John Hall</StudentName>
<Gender>1</Gender>
<ContactNo>
<SubscriberID>1234567899</SubscriberID>
</ContactNo>
<DateOfBirth>1980-12-30</DateOfBirth>
<EmailID>john@gmail.com</EmailID>
<FatherName>Johny Hall</FatherName>
<PermanentAddress>123, USA</PermanentAddress>
<DepartmentName>Mechanical Engineering</DepartmentName>
<DepartmentRollNo>MECH/2000/17</DepartmentRollNo>
<UniversityRegistrationNo>UNIVREG002</UniversityRegistrationNo>
<UniversityRollNo>UNIVROLL8137</UniversityRollNo>
</StudentDB>
</glob:StudentDBWebServiceStudentDBUpdateRequest_sync>
</soap:Body>
</soap:Envelope>

Response XML for Update Service Operation :

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
<n0:StudentDBWebServiceStudentDBUpdateConfirmation_sync
xmlns:n0="http://sap.com/xi/SAPGlobal20/Global"
xmlns:prx="urn:sap.com:proxy:KGL:/1SAI/TAS33C3372FC564423874DB:804">
<Log>
<MaximumLogItemSeverityCode>1</MaximumLogItemSeverityCode>
<Item>
<TypeID>013(/CSG_RUNTIME/)</TypeID>
<SeverityCode>1</SeverityCode>
<Note>Update operation was successful</Note>
</Item>
</Log>
</n0:StudentDBWebServiceStudentDBUpdateConfirmation_sync>
</env:Body>
</env:Envelope>
Request XML for QueryByElements Service Operation :

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
<soap:Header/>
<soap:Body>
<glob:StudentDBWebServiceStudentDBQueryByElementsSimpleByRequest_sync>
<StudentDBSimpleSelectionBy>
<SelectionBySystemAdminDataLastChangeDateTime>
<InclusionExclusionCode>I</InclusionExclusionCode>
<IntervalBoundaryTypeCode>7</IntervalBoundaryTypeCode>
<LowerBoundaryLastChangeDateTime>2014-11-05T00:00:00Z</LowerBoundaryLastChangeDateTime>
</SelectionBySystemAdminDataLastChangeDateTime>
</StudentDBSimpleSelectionBy>
<ProcessingConditions>
<QueryHitsUnlimitedIndicator>true</QueryHitsUnlimitedIndicator>
</ProcessingConditions>
</glob:StudentDBWebServiceStudentDBQueryByElementsSimpleByRequest_sync>
</soap:Body>
</soap:Envelope>

Response XML for QueryByElements Service Operation :

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
<n0:StudentDBWebServiceStudentDBQueryByElementsSimpleByConfirmation_sync
xmlns:n0="http://sap.com/xi/SAPGlobal20/Global"
xmlns:prx="urn:sap.com:proxy:KGL:/1SAI/TASDF2F277B093F98C43E0F:804">
<StudentDB>
<SAP_UUID>00163e04-c86b-1ee4-98fd-8bb891dc426b</SAP_UUID>
<StudentID>2</StudentID>
<StudentName>John Hall</StudentName>
<Gender>1</Gender>
<GenderName>Male</GenderName>
<ContactNo>
<SubscriberID>1234567890</SubscriberID>
</ContactNo>
<DateOfBirth>1980-12-31</DateOfBirth>
<EmailID>john@gmail.com</EmailID>
<FatherName>Johny Hall</FatherName>
<PermanentAddress>123, USA</PermanentAddress>
<DepartmentName>Mechanical Engineering</DepartmentName>
<DepartmentRollNo>MECH/2000/17</DepartmentRollNo>
<UniversityRegistrationNo>UNIVREG002</UniversityRegistrationNo>
<UniversityRollNo>UNIVROLL8137</UniversityRollNo>
<SystemAdminData>
<CreationDateTime>2014-11-04T06:32:35Z</CreationDateTime>
<CreationIdentityUUID>00163e04-c86b-1ee4-98ed-123f7af37456</CreationIdentityUUID>
<LastChangeDateTime>2014-11-04T06:32:35Z</LastChangeDateTime>
</SystemAdminData>
</StudentDB>
<StudentDB>
<SAP_UUID>00163e05-b54c-1ed4-98eb-5248bc11f55d</SAP_UUID>
<StudentID>1</StudentID>
<StudentName>Susanta Dey Sarkar</StudentName>
<Gender>1</Gender>
<GenderName>Male</GenderName>
<DateOfBirth>1988-10-01</DateOfBirth>
<EmailID>deysarkar.susanta@gmail.com</EmailID>
<FatherName>Sadhan Dey Sarkar</FatherName>
<PermanentAddress>Debinagar, Maynaguri, Jalpaiguri, West Bengal, India</PermanentAddress>
<DepartmentName>Information Technology</DepartmentName>
<DepartmentRollNo>IT/07/16</DepartmentRollNo>
<UniversityRegistrationNo>UNIVREG001</UniversityRegistrationNo>
<UniversityRollNo>UNIVROLL001</UniversityRollNo>
<CreatedBy>Susanta Sarkar</CreatedBy>
<ChangedBy>Susanta Sarkar</ChangedBy>
<SystemAdminData>
<CreationDateTime>2014-11-03T13:22:39Z</CreationDateTime>
<CreationIdentityUUID>00163e04-c86b-1ed3-9eba-2afb3ea2c97e</CreationIdentityUUID>
<LastChangeDateTime>2014-11-03T13:23:23Z</LastChangeDateTime>
<LastChangeIdentityUUID>00163e04-c86b-1ed3-9eba-2afb3ea2c97e</LastChangeIdentityUUID>
</SystemAdminData>
</StudentDB>
<ProcessingConditions>
<ReturnedQueryHitsNumberValue>2</ReturnedQueryHitsNumberValue>
<MoreHitsAvailableIndicator>false</MoreHitsAvailableIndicator>
</ProcessingConditions>
<Log>
<MaximumLogItemSeverityCode>1</MaximumLogItemSeverityCode>
<Item>
<TypeID>009(/CSG_RUNTIME/)</TypeID>
<SeverityCode>1</SeverityCode>
<Note>Query returned 2 records</Note>
</Item>
</Log>
</n0:StudentDBWebServiceStudentDBQueryByElementsSimpleByConfirmation_sync>
</env:Body>
</env:Envelope>

InclusionExclusionCode Values in Query Service Operation Request XML(s) :

Code Value Description


E Excluding
I Including

IntervalBoundaryTypeCode Values in Query Service Operation Request XML(s) :

Code Value Description


1 Equal To
2 Between (excl. upper boundary)
3 Between
4 Between (excl. both boundaries)
5 Between (excl. Lower boundary)
6 Less Than
7 Less Than or Equal to
8 Greater Than
9 Greater Than or Equal to

Move to Table of Contents


Create External Web Service Integration in SAP Business ByDesign

Step – 1 : Login to the SAP Business ByDesign SDK with PDI Access Credentials and open the Solution.

Step – 2 : Right Click on a folder or solution and click on Add > New Item.

Step – 3 : In the Add New wizard click on the Service Integration from the left and then click on External Web
Service Integration. Then Assign the name (Logically understandable) and click on Add button.
Step – 4 : In the wizard select the Web Service Type (either SOAP or REST), depending upon the WSDL type and
click on Next Button.

Step – 5 : If the Web Service type is SOAP, then browse the WSDL File or if the Web Service type is REST, then
enter the web service service URL and then click on Next Button and then Finish.
Step – 6 : After generating the External Web Service Integration, right click on that and Check In Content and then
Activate it.

Move to Table of Contents


Create Communication Scenario for Outbound Services in SAP Business ByDesign

Step – 1 : Right Click on a folder or solution and click on Add > New Item.

Step – 2 : In the Add New wizard click on the Service Integration from the left and then click on Communication
Scenario. Then Assign a name for the Communication Scenario (Logically understandable) and click on Add button.
Step – 3 : Click on the Radio Buttons for Web Service Type as SOAP and Communication Type as Application
Integration (A2X). But don't check the checkbox for "Allow Non-Secure URLs (HTTP)". Click Next Button.

Step – 4 : Select the Web Services and Service Operations from the respective lists and click on Next Button.
Step – 5 : In the final wizard of the Communication Scenario Click on the Finish Button to generate.

Step – 6 : After generating the Communication Scenario, Right Click on that and click on Check In Content and
then Activate it.

Move to Table of Contents


Create Communication System for Outbound Services in SAP Business ByDesign

Step – 1 : Login to the SAP Business ByDesign system in web browser with credentials and the navigate to the
Application and User Management Work Center and then Communication Systems and click there.

Step – 2 : Click on the New Button and it will navigate to the New Communication System UI screen.
Step – 3 : In the New Communication System UI Screen fill all the details and click on Save Button.
After saving the Communication System click on Actions – Set to Active and then Save and Close Button.
Step – 4 : Click on the Go Button to see the Newly created Communication System in the List.

Move to Table of Contents


Create Communication Arrangement for Inbound Services in SAP Business ByDesign

Step – 1 : Login to the SAP Business ByDesign system in web browser with credentials and the navigate to the
Application and User Management Work Center and then Communication Arrangements and click there.

Step – 2 : Click on the Communication Arrangements New Button.


Step – 3 : Select the Communication Scenario and click on the Next Button.

Step – 4 : Select the system instance ID from the OVS (Object Value Selector) and click Next Button.
Step – 5 : In the Outbound Communications : Basic Settings the Outbound Communication Enabled checkbox
should be checked, Application Protocol should be "Web Service", Authentication Method should be "User ID and
Password" and the Host Name must have an URL. Click on the Edit Credentials Button and assign the User ID and
Password for accessing the web services (Exactly same for the web services credentials).
Step – 6 : Click on the Edit Advanced Settings Button and then select the web services from the Outbound list and
click on Check Service Button. After successfull checking the web services, click on the Check Completeness Button.
Step – 7 : Click on the Next Button. Then Click on Finish Button and Close Button.
Step – 8 : Click on the GO Button of the Communication Arrangement List and then select the newly created
Communication Arrangement and click on the Edit Button.
Step – 9 : Click on the Edit Advanced Settings Button. In the Outbound list select the web services and click on
Check Service Button.
Step – 10 : Open the WSDL File in a browser (Preferably Internet Explorer) and scroll to the end.
Copy (CTRL + C) the SOAP Address Location URL from the WSDL (Shown in the screenshot) and Paste (CTRL + V)
the URL in the corresponding Path field of each of the web services respectively.
Step – 11 : Click on the Check Service Button for each of the web services in the Outbound List, after entering the
values in Path field from the corresponfing WSDL Files.
Step – 12 : Click on the Check Connection Button for each of the web services in the Outbound List, after entering
the values in Path field from the corresponfing WSDL Files. Either "Checking connection failed" or "Checking
Successful" message will raise. If the "Checking connection failed" message arises, then click on the Edit Basic
Settings Button for changing the web service access credentials.
Step – 13 : Click on the Edit Credentials Button to chnage the Web Services Access User ID and Password (If it's
not correctly mentioned). Then assign the Web Services access User ID and Password and click on OK Button.
Step – 14 : Click on the Edit Advanced Settings Button. In the Outbound List select each of the web services and
Click on Check Service and Check Connection Buttons. For each of the cases if the messages raises as "Check
Successful" and "Ping Successful" respectively, then click on the Check Completeness Button to check the
Completeness of the entire process (See the screenshots).
Step – 15 : Click on the Save and Reactivate Button and then Click on the Close Button.

Now the web services has been created and ready for being consumed by the SAP Business ByDesign.

Move to Table of Contents


Create BO and ABSL Scripts for Web Services Trigger Operations in SAP Business ByDesign

Step – 1 : Create a Business Object named as "TriggerStudentBackup" and insert the below mentioned BODL codes.

BODL Codes :

import AP.Common.GDT as apCommonGDT;


import BASIS.Global as basisGlobal;

businessobject TriggerStudentBackup raises GeneralInfo


{
// General Message Declaration
message GeneralInfo text "&1" : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Alternative Key for the BO


[AlternativeKey] element TriggerStudentBackupID : BusinessTransactionDocumentID;

// Selection Last Changed Date And Time


element SelectionByLastChangeDateTime : basisGlobal:GLOBAL_DateTime;

// Returned Query Hits Number Value


element ReturnedQueryHitsNumberValue : IntegerValue;

// Created By
element CreatedBy : apCommonGDT:Name;

// Changed By
element ChangedBy : apCommonGDT:Name;

// System Administrative Data


element SystemAdminData : SystemAdministrativeData;

// Action - Trigger the Web Services


action TriggerWS;
}
Step – 2 : After inserting the BODL Code to the Business Object, Check In the Business Object and Activate it.

Step – 3 : After Successful Activation of the Business Object, right Click on that and Generate the Script Files.
In the Script files only "Event-BeforeSave.absl" and "Action-TriggerWS.absl" should be there.

Step – 4 : In the "Action-TriggerWS.absl" script, insert the following code. Then Save, Check In and Activate it.

ABSL Codes :

import ABSL;

/***** Run the Query on Student DB [Using Last Changed Date and Time] : Start *****/

// Set up QueryByElement Request Object


var qry_student_db_request_object : Library::ConsumeWebServiceStudentDB.QueryByElements.Request;

// Setup Processing Conditions object


var qry_student_db_processing_condition_object :
Library::ConsumeWebServiceStudentDB.QueryByElements.Request.StudentDBWebServiceStudentDBQueryByElementsSimpleByRequest_sync.Proce
ssingConditions;
qry_student_db_processing_condition_object.QueryHitsUnlimitedIndicator = true;

// Assign the Objects to the request Object


qry_student_db_request_object.StudentDBWebServiceStudentDBQueryByElementsSimpleByRequest_sync.ProcessingConditions =
qry_student_db_processing_condition_object;

// Response object of the Query


var qry_student_db_response_object = Library::ConsumeWebServiceStudentDB.QueryByElements(qry_student_db_request_object, "",
"ConsumeStudentCSD");

// Query returns number of values


var qry_student_db_response_return_no_value =
qry_student_db_response_object.StudentDBWebServiceStudentDBQueryByElementsSimpleByConfirmation_sync.ProcessingConditions.ReturnedQue
ryHitsNumberValue;

/***** Run the Query on Student DB [Using Last Changed Date and Time] : End *****/

/***** Get the ID(s) of Student DB [List of StudentID] : Start *****/

// If the QueryByElements returns number of values more than Zero, then get the values
if(qry_student_db_response_return_no_value > 0)
{
// For Navigating each of the StudentDB Instances
foreach(var all_student_db_instances in
qry_student_db_response_object.StudentDBWebServiceStudentDBQueryByElementsSimpleByConfirmation_sync.StudentDB)
{
var student_id_found = all_student_db_instances.StudentID.content;
var student_name_found = all_student_db_instances.StudentName.content;
var gender_found = all_student_db_instances.Gender;
var contact_no_found = all_student_db_instances.ContactNo.SubscriberID;
var email_id_found = all_student_db_instances.EmailID.content;
var dob_found = all_student_db_instances.DateOfBirth;
var father_name_found = all_student_db_instances.FatherName.content;
var permanent_address_found = all_student_db_instances.PermanentAddress;
var department_name_found = all_student_db_instances.DepartmentName;
var department_roll_no_found = all_student_db_instances.DepartmentRollNo;
var university_reg_no_found = all_student_db_instances.UniversityRegistrationNo;
var university_roll_no_found = all_student_db_instances.UniversityRollNo;

/***** Read on Clone Student DB [Using StudentID] : Start *****/

// Set up Read Request Object


var read_clone_student_db_request_object : Library::ConsumeWSCloneStudentDB.Read.Request;

// Set up Clone Student ID for Read operation


var read_clone_student_db_id_object :
Library::ConsumeWSCloneStudentDB.Read.Request.CloneStudentDBWSCloneStudentDBReadByIDQuery_sync.CloneStudentDB;
read_clone_student_db_id_object.StudentID.content = student_id_found;

// Assign the Objects to the request Object

read_clone_student_db_request_object.CloneStudentDBWSCloneStudentDBReadByIDQuery_sync.CloneStudentDB =
read_clone_student_db_id_object;

// Response object of the Read


var read_clone_student_db_response_object =
Library::ConsumeWSCloneStudentDB.Read(read_clone_student_db_request_object, "", "ConsumeStudentCSD");

/***** If it's not yet been created, then Create on Clone Student DB : Start *****/

// If the StudentID is initial, then proceed to Create the existing instance

if(read_clone_student_db_response_object.CloneStudentDBWSCloneStudentDBReadByIDResponse_sync.CloneStudentDB.StudentID.content.IsIniti
al())
{
// Set up Create Request Object
var create_clone_student_db_request_object :
Library::ConsumeWSCloneStudentDB.Create.Request;

// Set up Clone Student Object for Create operation


var create_clone_student_db_id_object :
Library::ConsumeWSCloneStudentDB.Create.Request.CloneStudentDBWSCloneStudentDBCreateRequest_sync.CloneStudentDB;

// Assign the Data to the corresponding objects


create_clone_student_db_id_object.StudentID.content =
student_id_found;
create_clone_student_db_id_object.StudentName.content =
student_name_found;
create_clone_student_db_id_object.Gender =
gender_found;
create_clone_student_db_id_object.ContactNo.SubscriberID =
contact_no_found;
create_clone_student_db_id_object.EmailID.content =
email_id_found;
create_clone_student_db_id_object.DateOfBirth =
dob_found;
create_clone_student_db_id_object.FatherName.content =
father_name_found;
create_clone_student_db_id_object.PermanentAddress =
permanent_address_found;
create_clone_student_db_id_object.DepartmentName =
department_name_found;
create_clone_student_db_id_object.DepartmentRollNo =
department_roll_no_found;
create_clone_student_db_id_object.UniversityRegistrationNo =
university_reg_no_found;
create_clone_student_db_id_object.UniversityRollNo =
university_roll_no_found;

// Assign the Objects to the request Object

create_clone_student_db_request_object.CloneStudentDBWSCloneStudentDBCreateRequest_sync.CloneStudentDB =
create_clone_student_db_id_object;

// Response object of the Create


var create_clone_student_db_response_object =
Library::ConsumeWSCloneStudentDB.Create(create_clone_student_db_request_object, "", "ConsumeStudentCSD");
}
// End If the StudentID is initial, then proceed to Create the existing instance

/***** If it's not yet been created, then Create on Clone Student DB : End *****/

/***** If it's already created, then Update on Clone Student DB Instance : Start *****/

// If the StudentID is not initial, then proceed to Update the existing instance
if(!
read_clone_student_db_response_object.CloneStudentDBWSCloneStudentDBReadByIDResponse_sync.CloneStudentDB.StudentID.content.IsInitial(
))
{
// Set up Update Request Object
var update_clone_student_db_request_object :
Library::ConsumeWSCloneStudentDB.Update.Request;

// Set up Clone Student Object for Update operation


var update_clone_student_db_id_object :
Library::ConsumeWSCloneStudentDB.Update.Request.CloneStudentDBWSCloneStudentDBUpdateRequest_sync.CloneStudentDB;

// Assign the Data to the corresponding objects


update_clone_student_db_id_object.StudentID.content =
student_id_found;
update_clone_student_db_id_object.StudentName.content =
student_name_found;
update_clone_student_db_id_object.Gender =
gender_found;
update_clone_student_db_id_object.ContactNo.SubscriberID =
contact_no_found;
update_clone_student_db_id_object.EmailID.content =
email_id_found;
update_clone_student_db_id_object.DateOfBirth =
dob_found;
update_clone_student_db_id_object.FatherName.content =
father_name_found;
update_clone_student_db_id_object.PermanentAddress =
permanent_address_found;
update_clone_student_db_id_object.DepartmentName =
department_name_found;
update_clone_student_db_id_object.DepartmentRollNo =
department_roll_no_found;
update_clone_student_db_id_object.UniversityRegistrationNo =
university_reg_no_found;
update_clone_student_db_id_object.UniversityRollNo =
university_roll_no_found;

// Assign the Objects to the request Object

update_clone_student_db_request_object.CloneStudentDBWSCloneStudentDBUpdateRequest_sync.CloneStudentDB =
update_clone_student_db_id_object;

// Response object of the Update


var update_clone_student_db_response_object =
Library::ConsumeWSCloneStudentDB.Update(update_clone_student_db_request_object, "", "ConsumeStudentCSD");
}
// End If the StudentID is not initial, then proceed to Update the existing instance

/***** If it's already created, then Update on Clone Student DB Instance : End *****/

/***** Read on Clone Student DB [Using StudentID] : End *****/


}
}

/***** Get the ID(s) of Student DB [List of StudentID] : End *****/

// Assign the number of Returned Values Count


this.ReturnedQueryHitsNumberValue = qry_student_db_response_return_no_value;
Step – 5 : In the "Event-BeforeSave.absl" script, insert the following code. Then Save, Check In and Activate it.

ABSL Codes :

import ABSL;
import AP.PC.IdentityManagement.Global;
import AP.FO.BusinessPartner.Global;

/***** Start of Generating Alternative Key ID *****/

if(this.TriggerStudentBackupID.content.IsInitial())
{
var triggerID : TriggerStudentBackup.TriggerStudentBackupID;
var triggerQuery = TriggerStudentBackup.QueryByElements;
var triggerParameter = triggerQuery.CreateSelectionParams();

triggerParameter.Add(triggerQuery.TriggerStudentBackupID.content, "I", "GE", "0");


var triggerResults = triggerQuery.Execute();

var triggerCount = triggerResults.Count();

if(triggerCount == 0)
{
triggerCount = 1;
}

else
{
triggerCount = triggerCount + 1;
}

this.TriggerStudentBackupID.content = triggerCount.ToString();
}

/***** End of Generating Alternative Key ID *****/

/***** Start of System Administrative Data *****/

var current_emp_uuid = Context.GetCurrentIdentityUUID();


var bupa_uuid = Identity.Retrieve(current_emp_uuid).BusinessPartnerUUID;
if(!bupa_uuid.content.IsInitial())
{
var current_employee_name;
var employee = Employee.Retrieve(bupa_uuid);

if (employee.IsSet())
{
var current_common = employee.CurrentCommon;

if (current_common.IsSet())
{
current_employee_name = current_common.BusinessPartnerFormattedName;
}

this.ChangedBy.content = current_employee_name;
this.CreatedBy.content = current_employee_name;
}

this.SystemAdminData.LastChangeIdentityUUID = current_emp_uuid;
}

var currentDateTime = Context.GetCurrentSystemDateTime();

if(this.SystemAdminData.CreationIdentityUUID.content.IsInitial())
{
this.SystemAdminData.CreationDateTime = currentDateTime.ConvertToGlobalDateTime();
this.SystemAdminData.CreationIdentityUUID = current_emp_uuid;
}

this.SystemAdminData.LastChangeDateTime = currentDateTime.ConvertToGlobalDateTime();

/***** End of System Administrative Data *****/

this.TriggerWS(); // Trigger the Action

Step – 6 : Check In the entire BO and Scripts and Activate it. And then Generate the UI Screens for the BO.

Move to Table of Contents


Testing of External Web Services Integration in SAP Business ByDesign

Step – 1 : Login to SAP Business ByDesign system in browser and SDK using PDI development credentials.

Step – 2 : In the SDK right click on the "StudentDB_OWL.OWL.uicomponent" and click Preview Screen. Apply the
same procedure for "CloneStudentDB_OWL.OWL.uicomponent" and "TriggerStudentBackup_OWL.OWL.uicomponent".
Step – 3 : In the browser login, go to the "List of Students" tab and click on New Button to create New Students.

Step – 4 : Fill all the mandatory data and other data of a Student and click on the Save Button.

Step – 5 : After saving the student data, click on the Close Button.

Step – 6 : Click on the GO Button of the "List of Students" tab and Edit any existing data and Save and Close.
Step – 7 : In the browser login, go to the "List of Clonned Students" tab and click on GO Button and check records.

Step – 8 : In the browser login, go to the "Trigger Student Backup" tab and click on New Button.

Step – 9 : Fill the necessary information and the click on Save Button and then Close Button.
Step – 10 : In the browser login, go to the "Trigger Student Backup" tab and click on GO Button to check whether
the new entry is populating or not.

Step – 11 : In the browser login, go to the "List of Clonned Students" tab and click on GO Button to check whether
the new and updated entries are populating or not. And then Edit those entries to check data is proper or not.
Move to Table of Contents

 Conclusion :

From the initial to the last module and steps we have successfully created Web Services and consumed
External Web Services in SAP Business ByDesign system. Using the SOAP Method we have performed different kinds
of service operations like Create, Read, Update and QueryByElements.
Sample Business Object Codes :
StudentDB.bo :

import AP.Common.GDT as apCommonGDT;

businessobject StudentDB raises GeneralInfo


{
// Message Declaration
message GeneralInfo text "&1" : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Alternative Key Declaration


[AlternativeKey] element StudentID : BusinessTransactionDocumentID;

// Student Name (Mandatory)


element StudentName : Name;

// Student Gendar (Mandatory)


element Gender : GenderCode;

// Contact Number
element ContactNo : PhoneNumber;

// Email ID
element EmailID : EmailURI;

// Date Of Birth (Mandatory)


element DateOfBirth : Date;

// Father Name
element FatherName : Name;

// Permanent Address
element PermanentAddress : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Department Name
element DepartmentName : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Department Roll Number


element DepartmentRollNo : LANGUAGEINDEPENDENT_EXTENDED_Text;

// University Registration Number


element UniversityRegistrationNo : LANGUAGEINDEPENDENT_EXTENDED_Text;

// University Roll Number


element UniversityRollNo : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Created By
element CreatedBy : Name;

// Changed By
element ChangedBy : Name;

// System Administrative Data


element SystemAdminData : SystemAdministrativeData;
}

StudentDB > Event-BeforeSave.absl :

import ABSL;
import AP.PC.IdentityManagement.Global;
import AP.FO.BusinessPartner.Global;

/***** Start of Generating Alternative Key ID *****/

if(this.StudentID.content.IsInitial())
{
var studentID : StudentDB.StudentID;
var studentQuery = StudentDB.QueryByElements;
var studentParameter = studentQuery.CreateSelectionParams();

studentParameter.Add(studentQuery.StudentID.content, "I", "GE", "0");


var studentResults = studentQuery.Execute();

var studentCount = studentResults.Count();


if(studentCount == 0)
{
studentCount = 1;
}

else
{
studentCount = studentCount + 1;
}

this.StudentID.content = studentCount.ToString();
}

/***** End of Generating Alternative Key ID *****/

/***** Start of System Administrative Data *****/

var current_emp_uuid = Context.GetCurrentIdentityUUID();


var bupa_uuid = Identity.Retrieve(current_emp_uuid).BusinessPartnerUUID;

if(!bupa_uuid.content.IsInitial())
{
var current_employee_name;
var employee = Employee.Retrieve(bupa_uuid);

if (employee.IsSet())
{
var current_common = employee.CurrentCommon;

if (current_common.IsSet())
{
current_employee_name = current_common.BusinessPartnerFormattedName;
}

this.ChangedBy.content = current_employee_name;
this.CreatedBy.content = current_employee_name;
}

this.SystemAdminData.LastChangeIdentityUUID = current_emp_uuid;
}

var currentDateTime = Context.GetCurrentSystemDateTime();

if(this.SystemAdminData.CreationIdentityUUID.content.IsInitial())
{
this.SystemAdminData.CreationDateTime = currentDateTime.ConvertToGlobalDateTime();
this.SystemAdminData.CreationIdentityUUID = current_emp_uuid;
}

this.SystemAdminData.LastChangeDateTime = currentDateTime.ConvertToGlobalDateTime();

/***** End of System Administrative Data *****/

StudentDB > Validation-OnSave.absl :

import ABSL;

if(this.StudentName.content.IsInitial())
{
raise GeneralInfo.Create("E", "Student Name is mandatory");
}

if(this.Gender.IsInitial())
{
raise GeneralInfo.Create("E", "Gender is mandatory");
}

if(this.DateOfBirth.IsInitial())
{
raise GeneralInfo.Create("E", "Date of Birth is mandatory");
}

else
{
return true;
}
CloneStudentDB.bo :

import AP.Common.GDT as apCommonGDT;

businessobject CloneStudentDB raises GeneralInfo


{
// Message Declaration
message GeneralInfo text "&1" : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Alternative Key Declaration


[AlternativeKey] element StudentID : BusinessTransactionDocumentID;

// Student Name (Mandatory)


element StudentName : Name;

// Student Gendar (Mandatory)


element Gender : GenderCode;

// Contact Number
element ContactNo : PhoneNumber;

// Email ID
element EmailID : EmailURI;

// Date Of Birth (Mandatory)


element DateOfBirth : Date;

// Father Name
element FatherName : Name;

// Permanent Address
element PermanentAddress : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Department Name
element DepartmentName : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Department Roll Number


element DepartmentRollNo : LANGUAGEINDEPENDENT_EXTENDED_Text;

// University Registration Number


element UniversityRegistrationNo : LANGUAGEINDEPENDENT_EXTENDED_Text;

// University Roll Number


element UniversityRollNo : LANGUAGEINDEPENDENT_EXTENDED_Text;

// Created By
element CreatedBy : Name;

// Changed By
element ChangedBy : Name;

// System Administrative Data


element SystemAdminData : SystemAdministrativeData;
}

CloneStudentDB > Event-BeforeSave.absl :

import ABSL;
import AP.PC.IdentityManagement.Global;
import AP.FO.BusinessPartner.Global;

/***** Start of System Administrative Data *****/

var current_emp_uuid = Context.GetCurrentIdentityUUID();


var bupa_uuid = Identity.Retrieve(current_emp_uuid).BusinessPartnerUUID;

if(!bupa_uuid.content.IsInitial())
{
var current_employee_name;
var employee = Employee.Retrieve(bupa_uuid);

if (employee.IsSet())
{
var current_common = employee.CurrentCommon;

if (current_common.IsSet())
{
current_employee_name = current_common.BusinessPartnerFormattedName;
}

this.ChangedBy.content = current_employee_name;
this.CreatedBy.content = current_employee_name;
}

this.SystemAdminData.LastChangeIdentityUUID = current_emp_uuid;
}

var currentDateTime = Context.GetCurrentSystemDateTime();

if(this.SystemAdminData.CreationIdentityUUID.content.IsInitial())
{
this.SystemAdminData.CreationDateTime = currentDateTime.ConvertToGlobalDateTime();
this.SystemAdminData.CreationIdentityUUID = current_emp_uuid;
}

this.SystemAdminData.LastChangeDateTime = currentDateTime.ConvertToGlobalDateTime();

/***** End of System Administrative Data *****/

Move to Table of Contents

Document Title Web Services in SAP Business ByDesign - Training Document


Document Version 1
Organization Name ERP LOGIC (INDIA) PRIVATE LIMITED, Bangalore, India
Document Created By SUSANTA DEY SARKAR (Senior Developer)
Document Creation Date 7th November, 2014

You might also like