Tuesday, April 28, 2020

Integration of SAP Hybris with Procurement System

Introduction

This kind of integration is also known as "punchout integration". For SAP Hybris eCommerce platform, it has given a B2BPunchOutAddon out of the box to support standard punchout operations.

Before getting ahead, just a bit about the term "punchout", if you check the Wikipedia explanation from here,

PunchOut is a protocol for interactive sessions managed across the Internet, a communication from one application to another, achieved through a dialog of real-time, synchronous cXML messages, which support user interaction at a remote site. This protocol is most commonly used today in the form of Procurement PunchOut, which specifically supports interactions between a procurement application and a supplier’s eCommerce web site and possibly includes an intermediary for authentication and version matching. The buyer leaves or "punches out" of their company's system and goes to the supplier's web-based catalog to locate and add items to their shopping cart, while their application transparently maintains connection with the web site and gathers pertinent information. A vendor catalog, enhanced for this process, is known as a punchout catalog. PunchOut enables communication between the software and the web site so that relevant information about the transaction is delivered to the appropriate channels. 

Which in simple words, can be explained by the example of let say there is an ERP system of a large dairy plant.Now this plant may have different suppliers for all sorts of products being used in the plant e.g. Computers & related accessories, mechanical equipment, stationary. Let say the Computers are being provided by the supplier who has the punchout-ready e-commerce website. So now when dairy staff opens the procurement system (i.e SAP Ariba, Coupa etc) and there user can see the logo of the supplier, and to order the computers s/he clicks on the logo/link and redirects/punches out of the ERP  system and logs in to the supplier system.So this scenario is know as PunchOut scenario.



The following standard cXML transactions are supported by the hybris. More information about these transactions can be found at cxml.org.
Type
cXML Documents
Profile
           - ProfileRequest
           - ProfileResponse
PunchOut Session
           - PunchOutSetupRequest
           - PunchOutSetupResponse
           - PunchOutOrderMessage
Purchase Order
     - OrderRequest


Following diagram explains the typical sequence of this requests, here we are using Coupa as a sample procurement system,

Integration Sequence Diagram
Integration Sequence Diagram


Steps to enable the punchout feature in Hybris


I. Enable the Punchout addon and extension.

  1. Ensure that b2bpunchoutaddon is listed in config/localextensions.xml and that the entry is not commented out, as shown in the following example:
    ...
    <extension name="b2bpunchoutaddon" />
    ...
  2. Run the following ant task:
    ant addoninstall -Daddonnames="b2bpunchoutaddon" -DaddonStorefront.yacceleratorstorefront="yacceleratorstorefront"
  3. If you renamed your storefront extension, add the following line to the config/local.properties file, as shown in the following example (substitute mystorefrontextensionname with your storefront extension name):
    ...
    [mystorefrontextensionname].additionalWebSpringConfigs.b2bpunchoutaddon=classpath:/b2bpunchoutaddon/web/spring/b2bpunchoutaddon-web-spring.xml,classpath:/b2bpunchoutaddon/web/spring/b2bpunchoutaddon-spring-security-config.xml
    ...
  4. Property related to Security Channel
    Defines whether all content is served securely (https instead of http). Possible values: httphttpsany.
    • When set to https, all content is served securely.
    • When set to http, most content is forced to http. Certain content like logins are still served as https.
    • When set to any, content security is not changed one way or another and is served as requested by the browser. If the main page is requested as https, for example, then all the elements of that page will be served as https. This should be recommended option.
    Default: http
    So add the following setting to config/local.properties.
    storefront.security.default.required.channel=any
  5. Rebuild the system (ant all).
  6. Update the system as follows:
    1. Log on the SAP Commerce Administration Console (localhost:9001).
    2. Select Platform  Update.
    3. Select the Toggle all switch (under the Project data settings section of the Update page for the newly added addon and extension).
    4. Click the Update button.

II. Set the Customers, B2BUnit and permissions.

Once the server is up and running, go to the hac, and run below impex,

#
# Import a Sample B2B Organization for Punchout
#
$passwordEncoding=md5
$defaultPassword=12341234
$setPassword=@password[translator=de.hybris.platform.impex.jalo.translators.ConvertPlaintextToEncodedUserPasswordTranslator][default='$passwordEncoding:$defaultPassword']
$b2bCustomer=B2BCustomer(uid); 

INSERT_UPDATE B2BUnit; description; uid[unique=true]; name; locName[lang=en]; groups(uid); reportingOrganization(uid); Addresses(&addId); &B2BUnitID; accountManager(uid); creditLimit(code); approvalProcessCode; 
; Hierarchical; PunchOut Organization; PunchOut Organization; PunchOut Organization;; PunchOut Organization; PunchOutAddrID; PunchOutID;;;; 
INSERT_UPDATE Address; streetname[unique=true]; postalcode[unique=true]; town; country(isocode); billingAddress; contactAddress; shippingAddress; unloadingAddress; firstname; lastname; email; title(code); &addId; owner(&B2BUnitID)[unique=true]; 
; 999 South Wacker Drive; 60606; Chicago; US; TRUE; TRUE; TRUE; TRUE; PunchOut; Customer; punchout.customer@punchoutorg.com; mr; PunchOutAddrID; PunchOutID; 

INSERT_UPDATE B2BCustomer; description; uid[unique=true]; originalUid; email; name; title(code); groups(uid); permissionGroups(uid); sessionCurrency(isocode)[default='USD']; $setPassword; 
; PunchOut Sample Customer; punchout.customer@punchoutorg.com; punchout.customer@punchoutorg.com; punchout.customer@punchoutorg.com; PunchOut Customer; mr; PunchOut Organization, b2bcustomergroup;;;;;; 
; PunchOut Sample Customer 2; punchout.customer2@punchoutorg.com; punchout.customer2@punchoutorg.com; punchout.customer2@punchoutorg.com; PunchOut Customer 2; mr; PunchOut Organization, b2bcustomergroup;;;;;; 
INSERT_UPDATE B2BCostCenter; code[unique=true]; name[lang=en]; Unit(uid); budgets(code); currency(isocode)[default='USD']
; PunchOut Organization; PunchOut Organization; PunchOut Organization;; 

INSERT_UPDATE B2BOrderThresholdTimespanPermission; code[unique=true]; Unit(uid); threshold; currency(isocode); range(code,itemtype(code));
; PunchOut Org Unlimited Timespan; PunchOut Organization; 999999999; USD; MONTH:B2BPeriodRange; 
INSERT_UPDATE B2BBudgetExceededPermission; code[unique=true]; Unit(uid); 
; PunchOut Org Budget Exceeded; PunchOut Organization;
INSERT_UPDATE B2BOrderThresholdPermission; code[unique=true]; Unit(uid); threshold; currency(isocode)[default='USD'];
; PunchOut Org Unlimited USD ORDER; PunchOut Organization; 999999999;

UPDATE B2BCustomer; originalUid[unique=true]; uid[unique=true]; permissions(code,Unit(uid)); 
; punchout.customer@punchoutorg.com; punchout.customer@punchoutorg.com; PunchOut Org Unlimited USD ORDER:PunchOut Organization,PunchOut Org Unlimited Timespan:PunchOut Organization,PunchOut Org Budget Exceeded:PunchOut Organization;
INSERT_UPDATE PunchOutCredential;code[unique=true]; domain[unique=true]; identity[unique=true]; sharedsecret
; NetworkId1; NetworkID; AN01000002779-T; VerySecret1234       
; DUNS1; DUNS; 123456789; VerySecret1234
; AribaNetworkUserId1; AribaNetworkUserId; sysadmin@ariba.com; VerySecret1234
; DUNS2; DUNS; 123; VerySecret1234
                               
INSERT_UPDATE B2BCustomerPunchOutCredentialMapping; $b2bCustomer[unique=true]; credentials(code)
; punchout.customer@punchoutorg.com; NetworkId1,DUNS1
; punchout.customer2@punchoutorg.com; AribaNetworkUserId1

Please note, this values are related to out of the box powertools shop, you may need to change this steps according to your setup.


III. Test using REST client.

Use your favorite REST client, and follow below steps to test the setup,

1. PunchOut setup request

  • Request Type: Post
  • URL: https://powertools.local:9002/yb2bacceleratorstorefront/punchout/cxml/setup?site=powertools
  • Content-Type: application/xml
  • Payload:


If the authentication succeeded, the expected response should resemble the following example.


Now, using the URL under tag, Procurement system user can automatically logged into the hybris system. Once user selects the products and go to the cart page, user will able to see the cart page like,




Once user clicks on the "RETURN TO REQUISITION" button, the cart details will be send to procurement system in the cXML fomat but in the encoded into base64. This cart will be deleted from the hybris.

2. PunchOut Order request

Once the cart/order details has been sent to the procurement system, user can either review or edit the order. After the approval process user can place an order from the procurement system. To place an order in the supplier's system (hybris storefont) below request being posted,

  • Request Type: Post
  • URL: https://powertools.local:9002/yb2bacceleratorstorefront/punchout/cxml/order
  • Content-Type: application/xml
  • Payload:

If everything goes well, you will get the response like below,



That completes the order flow.

References: