Call

Purpose With Call you can call a function from a GuiXT script or from an InputScript.

The function can either be a local dll-function (on the frontend PC), implemented in VC++ or a similar language, or an R/3 function module on the R/3 application server, implemented in ABAP. In this case SAP’s RFC (Remote Function Call) technology is used.

Please observe that the Call-command via RFC requires the component “InputAssistant”.

Examples
Call “ImgName” dll=“guiexits” In=“&F[Material]“ Out=“Matfilename”

Call “ImgName” In=“&F[Material]“ Out=“Matfilename”

In the first case the dll-function ImgName is called locally. In the second case the R/3 function module ImgName is called via RFC.

Format RFC call 

old format:
Call "funcname" In=par1" In=par2" ... Out=par1" Out=par2" ...

new format:
Call
"funcname" In.Name1=par1" In.Name2=par2" ... Out.Name1=par1" Out.Name2=par2" ... Table.Name1=“tab1" Table.Name2=“tab2" ...   

Call "funcname" Destination="dest" In.Name1="par1" In.Name2="par2" ... Out.Name1="par1" Out.Name2="par2" ...  ... Table.Name1=“tab1" Table.Name2=“tab2" ...   

dll call:
Call
"funcname" dll="dllname" In="par1" In="par2" ... Out="par1" Out="par2" ...

Please observe that only up to 20 parameters (In+Out+Tables) are currently possible.

Additional options
-try In case of RFC. Please specify the option immediately after the function name.

If the function ends with an “exception”, no error message is shown to the user. Instead, the system variable V[_exception] obtains the name of the exception. With  if Q[ok] you can query, after  call, if the function ended normally. Example:

Call “RPY_TABLE_READ”  -try  in.TABLE_NAME=”&V[structid]” .. 
if not Q[OK]
  Return “E: Structure &V[structid] not found in data dictionary” -statusline
endif

How to use
the output parameters in your script
The output parameters of a Call can be used in the format &[name] in all subsequent script lines.

Example:

Call “ImgName” In=“&F[Material]“ Out=“MatFileName”
Image (16,81) (24,100) “&[MatFileName]“ Start=“&[MatFileName]“ “-NoStretch”

Calling a dll function The function declaration is as follows (example with 2 IN parameters and 3 OUT parameters):

__declspec(dllexport) int funcname(char* p1, char*p2, char* p3, char* p4, char* p5)

All parameters (IN and OUT) are passed in the order specified in the script. The maximum length of each string is 255 characters. Please specify all parameters in your script, otherwise the dll-function gets an address exception.

You can download some useful examples from our dll-download-page

Calling an R/3 function module Passing parameters
There are 2 variants for parameter passing. You can either use positional parameters, without specifying a name:

Call "funcname" In=par1" In=par2" ... Out=par1" Out=par2" ...      

In this case the importing parameters of the function must be named In1, In2, .., the exporting parameter  Out1, Out2,… (R/3 function library, transaction SE37).

Or you use named parameters:

Call "funcname" In.Name1=par1" In.Name2=par2" ... Out.Name1=par1" Out.Name2=par2" ... Table.Name1=“tab1" Table.Name2=“tab2" ...   

In this case there is no restriction on parameter names.

Restrictions

  • All parameters must be of type C (Character), maximum length 255. For example, you could use the reference field SY-LISEL
  • EXCEPTIONS are not supported. If any exception occurs, the user gets a message and the next script line is executed
  • Dialogs within the function require a “Call Function SYSTEM_ATTACH_GUI.“  in the called function.
  • Tables must consist of character-type fields as well. 
  • The maximum table width is 255. No restriction on the number of lines. If necessary, you can specify a different width t between 1 und 32000 for each table in the call statement:
    Table.Name1(width:4000)="tab1"

It is possible to call other function modules from your function module.

Handling of tables

  • Tables are handled in InputScripts like texts. For example, you can use the TextBox and CopyText statements.  
  • They are transferred in both directions
  • There is no possibility to use data dictionary based structures in InputScripts, you have to use substring notation in order to divide a table line into single fields

Example: Calling a BAPI
We use the method  “Get_Detail” of the  R/3 business object “User” to read the user group (User master record). 

Call  “BAPI_USER_GET_DETAIL”   In.Username=“&[_user]“   Out.LogonData=UserLogonData”
Set V[UserGroup] “&[UserLogonData](18-29)”

Now the variable &V[UserGroup] contains the R/3 user group.

Explanation (see also the interface definition in transaction SE37):

  • The system variable &[_user] is passed as importing parameter Username 
  • The variable &[UserLogonData]  obtains the value of the exporting parameter LogonData 
  • According to structure definition  BapiLogonE you find the user group as substring 18-29 

Example: Displaying additional data with RFC

Calling other systems You can call functions in other systems (R/3 or R/2) as well, using the parameter  Destination=…  The destination must be described in the file saprfc
.ini
; please see the SAP RFC documentation for details. The file saprfc.ini is either in the sapgui working directory “…\SAPworkdir”, or you use the environment RFC_INI to name the saprfc.ini file.

Using this technique you can easily integrate information from other systems into the R/3 screens.

Tips
& Tricks
  • If you want to implement the dll in some other language, e.g. Visual Basic, you might need additional tools in order to build the dll. Please ask the supplier of the corresponding programming language if you have any problems here.
  • It is a good idea to use the test environment of the ABAP workbench in order to test your function module before you use it in a GuiXT script. 
  • It is possible to switch into the R/3 debugging mode if you call the function module from the script, if you issue a “Call Function SYSTEM_ATTACH_GUI.” before the first Break-Point. 
  • You can specify the RFC user and password in the GuiXT profile. As default, GuiXT uses “SAPCPIC” and the corresponding standard password. The password is stored in the GuiXT profile in encrypted format.

Call