Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

SAP Screen Personas


 

 

How to call Remote Enabled ABAP Function Modules in Personas 3.0


SAP SCREEN PERSONAS KNOWLEDGE BASE - by Sushant Priyadarshi , Clemens Gantert , Regina Sheynblat , Sebastian Steinhauer , Cristiano Hansen

Purpose

This page provides an overview of using ABAP Function Modules from Personas 3.0 scripts.

Overview

In Personas 3.0, you can use script to call a Function Module which is "Remote Enabled" and "Whitelisted" by personas admin. Below, you will find 3 different examples of how to send/receive data from some standard BAPIs.

Checklist before using any Function

  1. Check whether the existing function is Remote Enabled. Go to transaction SE37 and enter the function module name. The highlighted radio button should be selected:


  2. Personas admin has to make the Function Module as WHITELISTED.
    Go to transaction SM30 and display the table/view "/PERSONAS/C_RFCW".
    You can also access to this view from Personas Admin Menu:

    The maintenance screen displayed, with a sample FM already set:


3. Every RFC call made out of a SAP Screen Personas script runs and finishes it own Logical Unit of Work (LUW). In other words, if you want to run a "writing" RFC, such as changing the name of a business partner, you have to make sure that the chosen RFC function module finishes with a commit (  ABAP statement 'COMMIT WORK' ). Many standard RFCs come with a parameter that tells the RFC whether or not to commit (see for instance parameter 'WITHOUT_COMMIT' of sales order creation RFC 'BAPI_SALESORDER_CREATEFROMDAT1'). Others require subsequent call of RFC "BAPI_TRANSACTION_COMMIT". The latter group of non-committing RFC cannot be directly called from a script, or - to be precise - they can be called, but they will not work because the changes they perform will be rolled back at the end of the RFC call. Our suggestion for such non-committing RFCs is to create a custom, "wrapper" RFC that calls the desired RFC and then commits. See the example "Changing an Equipment Record" below.


Example 1 : Export/Import simple data parameter from "BAPI_USER_GET_DETAIL"

 

Sample Script:

Example 1
var rfc = session.createRFC("BAPI_USER_GET_DETAIL");
rfc.setParameter("USERNAME", "PRIYADARSHIS");
rfc.requestResults(JSON.stringify(["ADDRESS", "RETURN"]));
rfc.send();
var address = JSON.parse(rfc.getResult("ADDRESS"));
session.utils.log(address.FULLNAME);

 

Example 2 : Export/Import table parameter from "SEPM_GWS_SALES_ORDERS_GET"

Sample Script:

Example 2
var rfc = session.createRFC("SEPM_GWS_SALES_ORDERS_GET");
var orderSearch1 = { SIGN: 'I', OPTION: "EQ",LOW: '500000001'};
var orderSearch2 = { SIGN: 'I', OPTION: "EQ",LOW: '500000005'};
rfc.setParameter("IT_SO_ID_RANGE", JSON.stringify([orderSearch1, orderSearch2])); 
rfc.requestResults('["ET_SO_HEADER", "ET_RETURN"]');
rfc.send();
var soJ = rfc.getResult("ET_SO_HEADER");
session.utils.log(soJ);
var so = JSON.parse(soJ);
for(var i=0; i<so.length; i++){
	session.utils.log(so[i].SO_ID+" : "+so[i].GROSS_AMOUNT);
}

 

 

Example 3 : Changing an Equipment Record

The used custom RFC "ZBAPI_EQUI_CHANGE" calls standard RFC 'BAPI_EQUI_CHANGE' and then performs a "COMMIT WORK". ZBAPI_EQUI_CHANGE only has BAPI_EQUI_CHANGE's mandatory parameters.

  

 

Sample Script:

Example 3
var oRFC = session.createRFC("ZBAPI_EQUI_CHANGE");
oRFC.setParameter("EQUIPMENT", "000000000010000005");
oRFC.setParameter("DATA_GENERAL", {"DESCRIPT": "changed description"});
oRFC.setParameter("DATA_GENERALX", {"DESCRIPT":"X"});
oRFC.setParameter("DATA_SPECIFIC", {});
oRFC.setParameter("DATA_SPECIFICX", {});
oRFC.requestResults(["RETURN"]);
oRFC.send();
var _RETURN = oRFC.getResultObject("RETURN");

 

 

 

 

 

 

 

Important News

This knowledge base is not solely SAP provided content - but community driven. Please also check on SMP and help.sap.com for SAP released information and notes on SAP Screen Personas.

Create New Article

Compare SAP Screen Personas versions

Search the KB

How to Open OSS Message

 What information is needed for creating OSS message?

  1. Make Sure you are on the latest patches and notes.
  2. Kernel Patch Level
  3. Two Types of connections to your environment: HTTP and R/3
  4. All the connections should be tested with proper credentials provided
  5. Steps to re-create the issue
  6. Attach related logs
  7. File tickets against BC_PER