Skip to Content

SAP NetWeaver Gateway exposes the complex workflow data (as it is maintained in the standard SAP Business systems) in an easy to consume OData service. When you install an SAP NW Gateway server, you get a built-in Workflow service. Even if you choose to extend it, the process below still applies.

In order to develop a business workflow app for Android, I will again use the SAP NetWeaver Gateway plugin for Eclipse. It will help me locate the workflow service I want to work with and to generate the application logic and UI to consume the service.

For information about installing and configuring the plugin, you can refer to one of my previous posts.

Start by opening the New Project wizard and select Starter Application Project under the SAP NetWeaver Gateway node. Give your project a name, and select Android from the dropdown of available target platforms. Follow the wizard steps and select the Workflow Application template from the templates page of the wizard. templatesPage.jpg

After selecting the application template I will need to specify the workflow service by either providing the URL or browsing the Gateway service catalog. The service I will use here is WFSERVICE.

With that I finish the wizard and have an Android project I can already run!/wp-content/uploads/2013/02/app_185969.jpg

The flow of the generated app is straight forward: The first activity is a splash screen. Then, on the application’s login screen you need to enter a user name and password you use to connect to the Gateway server. Once logged in, you can see the Workflow inbox with all the tasks assigned to that user. From the inbox screen you can filter the tasks by type and, of course, search the tasks. In addition, you can take action on a task right from the inbox by long pressing on an item. Alternately, selecting a task will navigate to the task details activity to show all tasks’ additional data, and also lets you apply your decision there. The detailed data may include (if exist) description of the task, comments,
attachments, other participants, xprops, etc.

Once I wish to take a decision, I click on the Decision button, select my decision, optionally write a comment, and send.

If you are familiar with Android development, you can easily customize the code of the generated app and adjust it to your needs. Feel free to share your
feedback in the Comments section.

You can see a live example by my colleague Michal Keidar:

For #SAPGateway blogs and updates please follow @shirilevil Twitter account.

Related Links:

Developing SAP Android Apps is Just a Few Clicks Away

Developing SAP Workflow Apps for iOS –  Setting the Wheels in Motion

To report this post you need to login first.

21 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member

    Hi,

    I’m trying to create an application based on SAP Workflow. I was using tutorial from the link below.

    http://scn.sap.com/community/netweaver-gateway/blog/2013/06/12/how-to-create-sap-workflow-based-android-application-consuming-odata-workflow-service-with-help-of-gateway-productivity-accelerator-gwpa

    Everything was going smooth till I uploaded my app to emulator. when i try to logon logcat in eclipse returns the following error:

    01-08 13:56:52.539: E/Connectivity(758): Delta handling is disabled. Please add Persistence & Cache libraries to enable it.

    Both libraries are included in the project. Do you have any idea what could I do wrong?

    Best regards,

    Daniel Myslinski

    (0) 
      1. Former Member

        Hi,

        Yes but i didn’t figureout wat was cause of the problem. Check if all components are in required version. I remember that this error wasn’t important after all beacuse even when app was working good, error was still prompted.

        Regards,

        Daniel

        (0) 
  2. Former Member

    Hi Gal,  

    Thanks for Excellent article. This help us understand the mobile WF.

    Here I have a question in UI side can you please guide me.

    How much customization is possible in UI side?

    1. Grouping the WF inbox item in different folders based on Modules and folder kind of     view in WF inbox is it possible?

    2. It is possible to view the full details of each WF item??

    3. It is possible to change the view of ‘APPROVE’, ‘REJECT’ and ‘FORWARD’.

    If yes, do we need to make any specific configurations / Software for that? Please let me know.

    Thanks in Advance.

    Venky.

    (0) 
    1. Midhun VP

      You can customize the UI to any extend since you have complete control over the project. The android screens are designed in XML, you can very much customize the app to change the look and feel and you can add more functionalities to it.

      – Midhun VP

      (0) 
      1. Former Member

        HI Midun,

        Thanks for reply.

        We are trying approve the workflow decision by POST the HTTP request with Headers (SAP Business Workflow with SAP NetWeaver Gateway version 7.4).

        HTTP POST with Headers (x-csrf-token)

        we are following the SAP document  http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/509c922a-aa9a-2f10-328c-d3814560de06?overridelayout=true

        Below the code we are trying the same.

        var oHeaders = {};

        oHeaders[“x-csrf-token”] = “<?php echo $csrftoken[‘xcsrfToken’];?>”;

        oHeaders[“Authorization”] = “Basic ZGV2ZWxvcGVyOm5vc2VjcmV0”;

        jQuery.ajax({

            type: “POST”,

            url: “http://server:port/sap/opu/odata/IWWRK/WFSERVICE/ApplyDecision?workitem_id='000000072621'&dec_key='0001'&comments='Approved‘”,

            data: null,

            headers: oHeaders,

            success: successFunc,

            error: errorFuncDefault

        });

        function successFunc(data) {

            alert(data);

        }

        function errorFuncDefault(data) {

            alert(data + ‘error’);

        }

        We facing the below errors like Method not supported some time and Authorization failed and we tried all possible ways but no result.

        Could please help me, where  we are going wrong.

        Thanks in advances

        Venky.

        (0) 
        1. Midhun VP

          Make sure the services created is working with any REST client as given in the document. Later implement it in the device code.

          Midhun VP

          (0) 
          1. Former Member

            Midhun thanks for the quick reply,

            Workflow services woking fine with REST client, HML5 and Android application.

            But im failed to POST the HTTP request from PHP.

            Thanks and Regards,

            Venky.

            (0) 
              1. Former Member

                Yes services are working fine in REST Client also.

                _______________________________________________________________________

                We try jQuery  – But we getting error (Method not found ) check the below code


                var oHeaders = {};

                oHeaders[“x-csrf-token”] = “<?php echo $csrftoken[‘xcsrfToken’];?>”;

                oHeaders[“Authorization”] = “Basic ZGV2ZWxvcGVyOm5vc2VjcmV0”;

                jQuery.ajax({

                    type: “POST”,

                    url: “http://server:port/sap/opu/odata/IWWRK/WFSERVICE/ApplyDecision?workitem_id='000000072621'&dec_key='0001'&comments='Approved‘”,

                    data: null,

                    headers: oHeaders,

                    success: successFunc,

                    error: errorFuncDefault

                });

                  

                function successFunc(data) {

                    alert(data);

                }

                function errorFuncDefault(data) {

                    alert(data + ‘error’);

                }

                _________________________________________________________________________________

                PHP Code

                $curl_req = curl_init();

                // set URL and other appropriate options

                curl_setopt($curl_req, CURLOPT_URL, $url);

                curl_setopt($curl_req, CURLOPT_RETURNTRANSFER, true);

                curl_setopt($curl_req, CURLOPT_FOLLOWLOCATION, true);

                curl_setopt($curl_req, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

                curl_setopt($curl_req, CURLOPT_USERPWD, sprintf(“%s:%s”,$username,$password));

                curl_setopt ($curl_req, CURLOPT_POST, 1);

                $fetch_req_headers = array(

                “X-CSRF-Token:”.$token[‘xcsrfToken’],

                “Content-Type:text/plain; charset=UTF-8”,

                );

                curl_setopt($curl_req, CURLOPT_HTTPHEADER, $fetch_req_headers);

                curl_setopt($curl_req, CURLOPT_HEADER, true);

                // send the created request

                $response = curl_exec($curl_req);

                error: we getting error connection Timed-Out

                we trying from last 3 day on this POST method .

                Please help us.

                Regards,

                Venky.

                (0) 
    1. Former Member

      Hi Syam,

      Thanks for the email.

      Please find the below my code .

      We try jQuery  – But we getting error (Method not found ) check the below code


      var oHeaders = {};

      oHeaders[“x-csrf-token”] = “<?php echo $csrftoken[‘xcsrfToken’];?>”;

      oHeaders[“Authorization”] = “Basic ZGV2ZWxvcGVyOm5vc2VjcmV0”;

      jQuery.ajax({

          type: “POST”,

          url: “http://server:port/sap/opu/odata/IWWRK/WFSERVICE/ApplyDecision?workitem_id='000000072621'&dec_key='0001'&comments='Approved‘”,

          data: null,

          headers: oHeaders,

          success: successFunc,

          error: errorFuncDefault

      });

        

      function successFunc(data) {

          alert(data);

      }

      function errorFuncDefault(data) {

          alert(data + ‘error’);

      }

      _________________________________________________________________________________

      PHP Code

      $curl_req = curl_init();

      // set URL and other appropriate options

      curl_setopt($curl_req, CURLOPT_URL, $url);

      curl_setopt($curl_req, CURLOPT_RETURNTRANSFER, true);

      curl_setopt($curl_req, CURLOPT_FOLLOWLOCATION, true);

      curl_setopt($curl_req, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

      curl_setopt($curl_req, CURLOPT_USERPWD, sprintf(“%s:%s”,$username,$password));

      curl_setopt ($curl_req, CURLOPT_POST, 1);

      $fetch_req_headers = array(

      “X-CSRF-Token:”.$token[‘xcsrfToken’],

      “Content-Type:text/plain; charset=UTF-8”,

      );

      curl_setopt($curl_req, CURLOPT_HTTPHEADER, $fetch_req_headers);

      curl_setopt($curl_req, CURLOPT_HEADER, true);

      // send the created request

      $response = curl_exec($curl_req);

      error: we getting error connection Timed-Out

      we trying from last 3 day on this POST method .

      Please help us.

      Regards,

      Venky.

      (0) 

Leave a Reply