Display availability of material

An employee in the field may often need to have a quick look at the stocks of a certain material. We will add this possibility to CIS mobile in this example. 

With SAP GUI: Stock of material P-103

With CIS mobile: Stock of material P-103


Step 1: Showing add-on placeholders

Activate the test output with placeholders for add-ons in the CIS mobile settings and then navigate to the context where you would later like to add some additional information. In our example this is the placeholder "MaterialButtons2" that will be replaced by a possibility for the user to unfold a list of stocks. The method will be implemented in VB.net and must have the name "BuildMaterialButtons2".

NB: This step is similar to step 1 in example 3 because we add two additional buttons at the same position: one for the stocks and another one for the complaints.

Activating the testoutput for addons

A potential spot for the addon

Step 2: Checking keys for the request

Just click on one of the colored placeholders to display a list of all keys and their values that are available in that context. We need them in order to request data from the SAP system, in this case it is the material number (MATNR).

Available keys in the context of material P-103

Step 3: Implementing ABAP function

In this example we request the required data from the SAP system using an RFC call to an ABAP function that we implemented. You can find it in the function module CISADDON_INTERFACE (transaction SE37).

* Stock quantities for each plant
* In
* 1 MATNR Material number
* Out
*  Stock quantities

form MaterialStock tables reqparm resparm   
               changing   rc type c   msg type c.

Step 4: Implementing the VB.net method

The method in VB.net consists of two parts: First part is about requesting the data from the SAP system, second part is the formatting received data as an HTML table. Please note the following particularities of the code:

- if the parameter "deferred" is set to true for the rfc-request then it will not be executed immediately. Instead, all requests called with this flag will be bundled and executed at the same time by the command "ic.RfcExecuteDeferredCalls()". This will increase performance in most cases.

- Messages that the SAP system creates (e.g. an error message due to lack of authorizations) will be handed over to CIS mobile and are available to the developer in the folder "rfcmessages"

- Checking authorizations has to be done either within the VB.net method or in the ABAP function. (Details can be found in the topic "Security")

    ' Stock overview 
    Public Function BuildMaterialStock(ByVal keys _
             As Dictionary(Of String, String), _ 
                                ByRef buttons As String) As String

        ' We use CIS addon ABAP function to read the stock quantities

        ' Clear input/output

        ' Build up input
        Dim s As addonsimplestring = _
                          DirectCast(rfc_input.AddNew(), addonsimplestring)
        s.content = GetItem(keys, "MATNR")

        ' Request data
        ic.RfcRequest("CISADDON.MATERIALSTOCK", "S", _
                                rfc_input, rfc_output, deferred:=True)

        ' execute all requests (one only in our case)

        ' Buld up HTML output table
        Dim sb As New StringBuilder

        For Each line As addonsimplestring In rfc_output

            Dim fields() As String = line.content.Split(vbTab)

            Dim werks As String = fields(0)
            Dim wname As String = fields(1)

            ' werks
            sb.Append("<div  style='float:left; text-align:left; width:80px;'>")


        If rfc_output.Count = 0 Then
            ' no stock
            sb.Append("<br><i>" & ic.MessageText("NO_STOCK") & "</i>")
        End If

        ' RFCmessages (no authorization etc.)
        If rfcmessages.Count > 0 Then
            For Each rfcmsg As addonrfcmsg In rfcmessages
                sb.Append("<br><i>" & rfcmsg.msg & "</i>")
        End If

        Return sb.ToString

    End Function