Liquid UI - Documentation - 4.07 Calling BAPIs and using ABAP Packed Structures in WS

4.07 Calling BAPIs and using ABAP Packed Structures in WS


Purpose

WS now supports calling a BAPI type RFC.

When calling SAP defined BAPIs, often the return type is of a ‘Structure’. And when a ‘Component’ in the structure is ‘Packed BCD’, type ‘P’, the resulting return string will contain a ‘null’ which makes it an invalid WS string. Therefore, to properly receive the return value of this RFC, you have to declare a ‘structure definition’ to properly parse the return value.

Step 1: Prerequsite

The function module needs to be remote callable, or Liquid UI will not be able to execute it through RFC.

This article is to use call command to get the detail from native SAP function module.

ex: SAP_WAPI_COUNT_WORKITEMS
BAPI_MATERIAL_GET_ALL
ALM_ME_FUNCLOC_INSTALLED_EQUI
BAPI_ALM_ORDER_GET_DETAIL
BAPI_USER_GET_DETAIL
BAPISDORDER_GETDETAILEDLIST

By using the command with extra structure object, it is able to get different type of data from FM.

Note: valid from WS version 1.2.326.0 or Server version 3.5.563.0 and above


Step 2: Confirm ouput structure according to parameter

The structure of each output parameter needs to be specified individually. Its detail can be referenced from SAP in transaction SE37

Using transaction SE37, we look at a FM like following:


 

In the ‘Associated Type’, you can see ‘BAPI_MARA__GA’. That is the return type for the Parameter, CLIENTDATA. Double clicking on the BAPI_MARA_GA, will show you this:


 

This means, that the CLIENTDATA return value, will be returned in a stream of bytes, that corresponds to this ‘Structure’. Most of the ‘Components’ of this structure will be in text, and therefore carefully calling ‘substring’ with meticulously calculated value will often yield the correct answer. However, when the Component is of type ‘QUAN’, like ‘QTY_GR_GI below:


 

And the ABAP type is of type ‘P’ like this:


 

Means that the type will be a Packed BCD, which contains lossless numerical values encoded in 4 bits (a nibble) like this { 0x00,0x00, 0x00, 0x00, 0x01, 0x50, 0x0c }. Since the beginning values are 0x0 (which is a NULL character) is WS script, a ‘structure definition’ need to be used to correctly parsed each Component of the Structure.


Step 3: Define the type object of ouput structure

For each output parameter in the function module, we need to specify individual structure object.

See Convert function module structure detail into type object to generate ready-to-use type object for selected structure.


Can't find the answers you're looking for?