SAP-CRM-WEBSHOP: How to call custom Function Modules #63

[It’s a little tricky – I really should re-write this.]
Pre-requisite: knowledge in J2EE, Struts, SAP CRM Webshop, HTML
What this article will provide? Just a very upper level description on how to call your own function modules, or SAP built-in function modules that are not called by the standard application/webshop.

What are function modules?

SAP provides many different function modules to execute different operations [back end operations]. You can also consider them as stored procedures in traditional DBMSs like Oracle, SQL Server, MySQL, and PostGreSQL. Usually, you call the backend stored procedures from the front end [say Java programs], supply some input parameters to the stored procedures, and collect outputs for further processing [or just display]. Same is true for SAP. In CRM Webshop, one strategy is that you can have backend objects in your applications and these backend objects can have functions that execute the function modules.

An example:

From a JSP page when the form is submitted, you want to execute a custom function module [written by you]. The JSp page will collect shopId from the user and display the shop description. Your function module will retrieve the shop description and pass it to the JSP/Java program for display.

Implementation Requirements: You will need to implement a business object, a backend object, a custom business object manager. Also, you will need to register these objects in the Internet Sales Framework (SAP-ISA).

Steps: In the JSP page create a text box to collect the shop id, and refer the form action to the custom action (z_test.do) as action=”z_test.do”. Map the action z_test.do to the action class Z_CustomAction in your configuration file named config.xml as follows:

When users will provide the shop id and click on the submit button the doPerform() method of the class Z_CustomAction will be executed. In the Z_CustomAction class, in the doPerform() method, you have to get a reference to the custom business object manager(bom) as

Z_CustomBusinessObjectManager myBOM = (Z_CustomBusinessObjectManager)userSessionData. getBOM(Z_CustomBusinessObjectManager.CUSTOM_BOM);
[you need to write this BOM class Z_CustomBusinessObjectManager also. userSessionData is the sap wrapped session object]

then use the custom BOM object (myBOM) to retrive the CustomBasket [Basket = shopping/order basket] as

myBOM.getCustomBasket()

where the CustomeBasket is of Z_CustomFunc type [i.e. myBOM.getCustomBasket() returns Z_CustomFunc type object, You need to write Z_CustomFunc class as well].

Then call the getShopDescription(id) method of the Z_CustomFunc class as

String shopDescr = myBOM.getCustomBasket().getShopDescription(shopId);

As mentioned that the custom basket is of type Z_CustomFunc class with methods such as getShopDescription(id) [getShopDescription of Z_CustomFunc eventually will go to the lowest level to call the function module]. In Z_CustomFunc class in getShopDescription(id), you will call the getShopDescription(id) method of the backend object Z_CustomFuncBackend [you have to write the interface] as

return getCustomBasketBackend().getShopDescription(shopId);

[In getShopDescription(id) method of Z_CustomFunc]
here through getCustomBasketBackend()[method of Z_CustomFunc] you get a reference to the backend object Z_CustomFuncBackend, then call the method getShopDescription of Z_CustomFuncBackend. In getCustomBasketBackend() method, you practically create the backend object Z_Custom of Z_CustomFuncBackend type. Then you map Z_Custom to Z_CustomFuncCRM class/object in the backendobject-config.xml file. Then, in Z_CustomFuncCRM, you need to define the method getShopDescription(id) where the actual/lowest level call to the function module will be done as follows:

JCO.Function func = getDefaultJCoConnection().getJCoFunction(“CRM_ISA_SHOP_GETLIST”);
func.getImportParameterList().setValue(“B2B”, “SCENARIO”);
getDefaultJCoConnection().execute(func);

CRM_ISA_SHOP_GETLIST is the name of the underlying custom function module. Also, in this method, you can write code to collect information from the function module for further processing or display.Configurations
backendobject-config.xml for Z_Custom backend object

Also, list your BOM in the config file bom-config.xml as

——————-Additional Information———————–

BOM class that have functions to get/point to the custom basket, bom gets reference to the custom basket through backend object manager as

mCustomBasket = new Z_CustomFunc();
assignBackendObjectManager(mCustomBasket);
mCustomBasket is the custom basket to be returned

—Z_CustomFunc has methods like

getShopDescription: that calls
getCustomBasketBackend().getShopDescription(shopId);

where getCustomBasketBackend() Returns a reference to the backend object Z_CustomFuncBackend that you also need to write. CustomFuncBackend is just an interface with method declaration such as getShopDescription(id)

Also, you need to write a class that handles the function module call and data retrieval say Z_CustomFuncCRM withgetShopDescription(id) function that may include:

JCO.Function func = getDefaultJCoConnection().getJCoFunction(“CRM_ISA_SHOP_GETLIST”);
func.getImportParameterList().setValue(“B2B”, “SCENARIO”);
getDefaultJCoConnection().execute(func);

—–Reference: SAP CRM ECommerce – Development and Extension Guide

From: http://sitestree.com/?p=5026
Categories:63
Tags:
Post Data:2013-03-24 12:36:42

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>