Skip to Content
Author's profile photo Former Member

Pushing Notifications Made Easy!!! : How to Subscribe?

The ‘What’ part – “Notifications”, you must be familiar with this word if you have used iPhones/BlackBerry or any other smartphones and even Facebook!!! Excited to see the notifications from your friends and family!!! How cool would it be to receive notifications regarding SAP Business Processes in your daily office work? Managers, wouldn’t it be cool to get an employee’s leave request on your mobile instead of getting it in the mail client in your laptop? It must be great to do some office activities from the mobile while having no access to your machine, e.g. in the departmental store, in the shopping mall, etc.

So the next question, how do we do it?? You know, it’s really easy and cool!!! Just follow a few steps mentioned below and you’ll be done in no time. Well, that’s not absolutely true!!! It’ll take some time, but not much. 🙂

Before we start, let’s have a quick introduction of the SAP NetWeaver Gateway Subscription & Notification framework.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Basic fact —– Subscribe to get Notified !!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          It’s important to understand that Subscription & Notification are two different functions in Gateway. The below picture shows the difference in a nutshell.

            Capture.JPG

          It exactly works like subscribing for a newsletter. Once you subscribe for it, you receive it. Similarly, in case of a Gateway service, you have to subscribe to a Collection in order to get notified about the Business Process. But that’s not the whole story. We’ll see what else needs to be done in the steps to come. Stay tuned!!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Sample Use Case —— SAP User Administration

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          Let’s understand the use case in brief. In an organization, an Admin user wants to keep track of all the new SAP usernames being created/changed/deleted in a system. He doesn’t want to login to the system everyday and check for any new users. Instead, he wants to get notified the moment a user is created/changed/deleted.

          He thinks it would be great for him to get these alerts in his iPhone. So, he asks for an application which will connect to the Gateway system and get this information to his mobile device. Now, let’s see what needs to be done in the Gateway system in order to get this working for the Admin.

The development activities for this scenario have been split into two steps:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Creating a Subscription-Enabled OData Service

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Step 1 — Creating Model & Data Provider classes

          Let’s create a new OData Service for the above mentioned business scenario, which will be enabled for subscription.

    1. Create a class Z_CL_PUSHDEMO_MPC by inheriting from /IWBEP/CL_MGW_PUSH_ABS_MODEL. Capture.JPG
    2. Redefine the method DEFINE in this class and create your OData service interface. The sample code can be found here.
    3. Create another class Z_CL_PUSHDEMO_DPC by inheriting from /IWBEP/CL_MGW_PUSH_ABS_DATA. Capture.JPG
    4. Redefine the method CHECK_SUBSCRIPTION_AUTHORITY and write some code to check if the requesting user is authorized to subscribe to this service. You can find some sample code here. Please note that if you get any authorization error later while running a query on UserCollection, comment this code.
    5. Redefine the method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET and write some code to get a list of users. The sample code can be found here.
    6. Redefine the method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY and write some code to get details for a user. The sample code can be found here.

    Step 2 — Configuring the OData Service

          Once the above steps are completed, maintain the model & service group in the IMG path shown below:

              MaintainMandS.jpg

              Screen1.JPG

          In the Gateway Hub system, activate the above service as shown below.

                    Capture.JPG

                    Screen2.JPG

                    Capture.JPG

          Activate the service ZPUSHDEMOSRV by clicking on it.

          The OData service is now ready to be used for Query & Read operations. 🙂   The table below gives the URLs for various operations supported.

Operations URLs
Service Document http://<hostname>:<port>/sap/opu/odata/sap/ZPUSHDEMOSRV/?$format=xml
Metadata

http://<hostname>:<port>/sap/opu/odata/sap/ZPUSHDEMOSRV/$metadata 

Query http://<hostname>:<port>/sap/opu/odata/sap/ZPUSHDEMOSRV/UserCollection
Read http://<hostname>:<port>/sap/opu/odata/sap/ZPUSHDEMOSRV/UserCollection(‘A.M’)

The service document (see below) shows that the ‘UserCollection’ is made subscribable and also you can see two new entities added to the service document (SubscriptionCollection and NotificationCollection).   

              Service.jpg

Now, once you are done with the above steps, you can start with subscribing for a Collection. Nothing much to do here, just a regular HTTP POST as shown below. The sample request body can be found here.

Request.jpg

Please note that we will be using a HTTP listener application for receiving the notifications. Hence, the deliveryAddress used while subscribing should be the IP address from the application.

Once you have fired the call, the response is a subscription for this service as shown below.

/wp-content/uploads/2012/12/response_154916.jpg

With this, you have become one of the subscribers for the ZPUSHDEMOSRVSAP NetWeaver Gateway service. Let’s see what else needs to be done for receiving notifications in the next blog – Create a Notification Push Application!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     Related Information

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     Create a Notification Push Application

Assigned Tags

      28 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi,

      At step, Activate and maintain services->Add services , in field 'system alias' i am passing Alias name of the server(back-end server) on which Data model and service have been created.

      After activating the service when i press on call browser,

      i get following error in the browser:

      <error><code>CX_XSLT_RUNTIME_ERROR/EE1D984A671BED4AAD4D1BD10D509C75</code><message xml:lang="en">No valid source context supplied</message><innererror><transactionid>784C3DE2C55EF1E585DC001F29E5DD9A</transactionid><errordetails/></innererror></error>.

      Please help. what could be the reason for this error?

      Author's profile photo Former Member
      Former Member

      Hi Rajender,

           As I can see from the screenshot, the ICF node for ODATA is not active. Please activate it by clicking on "Activate ICF Node" button and try again.

      Best Regards,

      Anirvan.

      Author's profile photo Former Member
      Former Member

      Hi Anirvan,

      The ICF node for ODATA is already been activated , don't know why its showing grey cross under status tab.

      There shouldn't be any problem in the RFC destination connection as i have used same system alias for other gateway services, created using BAPIs or RFCs, which are working fine.

      Author's profile photo Former Member
      Former Member

      Hi Rajender,

      This looks like an ICF node activation issue and nothing specific to Subscription/Notification. Please post the issue in the Discussions forum so that it can be resolved.

      Best Regards,

      Anirvan.

      Author's profile photo Carlos Roggan
      Carlos Roggan

      Thanks a lot, Anirvan, for this very good and helpful Blog!

      Author's profile photo Ashish Kumar
      Ashish Kumar

      nice blog..

      Regards, Ashish

      Author's profile photo Former Member
      Former Member

      Great blog! Looking forward to the next one about

      Enabling Notification Push for the subscribed users!

      Author's profile photo Former Member
      Former Member

      Hi Ning-Jing,

      The next one is already available. Please find it here.

      Thanks,

      Anirvan.

      Author's profile photo Former Member
      Former Member

      Hi Anirvan,

      What is the service pack that we have to use? I tried with SP3, but several parameters are missing.

      Thank,

      Rajib

      Author's profile photo Aakash Raj
      Aakash Raj

      Hi Rajib,

      You can use SP5 and above. It would be good if the latest version is used which is SP6 - has many other features.

      Best regards,

      Aakash

      Author's profile photo Former Member
      Former Member

      Hello Everyone,

      A very informative video has been posted on YouTube channel related to the same topic. Please check the link below:

      https://www.youtube.com/watch?v=oSEKImsfvAo

      Regards,

      Anirvan.

      Author's profile photo Sheetal Reddy Proddutur
      Sheetal Reddy Proddutur

      Hi Anirvan,

      Did you ever tried to create Subscriptions/Notifications for a service which is created through SEGW ?

      Thanks,

      Sheetal Reddy

      Author's profile photo Former Member
      Former Member

      Hi Sheetal,

      I have never tried that. But it doesn't make any difference and should work exactly how its shown above. Let us know if you are facing any specific issue in doing this.

      Regards,

      Anirvan.

      Author's profile photo Sheetal Reddy Proddutur
      Sheetal Reddy Proddutur

      Hi Anirvan,

      I was at Teched Banaglore last week and as per the information I got, still notifications are not supported in SEGW transaction (SP4), SAP is planning to implement in next release 🙁 ....

      Thanks,

      Sheetal Reddy

      Author's profile photo Former Member
      Former Member

      Hi Sheetal,

      Did you try marking the entity set as subscribable.

      This you can do by clicking the Entity Set Node in SEGW and then checking the checkbox "Subscribable". This option is available from SP04 in SEGW.

      Regards

      Chandan

      Author's profile photo Sheetal Reddy Proddutur
      Sheetal Reddy Proddutur

      Hi Chandan,

      I tried subscriptions and it is updating /IWBEP/D_MGW_SUB table also, but not able to succeed testing notifications.

      Thanks,

      Sheetal Reddy

      Author's profile photo Former Member
      Former Member

      Hi Sheetal,

      Well you need to now explain in detail

      1) how did you configure your BEP and FND systems

      2) how did you push the notifications

      3) What error are you getting

      You could run the transaction SBGRFCMON transaction in BEP and FND system to see where your notifications are stuck and with what error.

      regards

      Chandan

      Author's profile photo Former Member
      Former Member

      Hi Anirvan,

      Thanks for a very userful blog, I have a query if you can help, we are trying to push notifications on new work flow items for approval. I am able to successfully subscribe to service http:// /sap/opu/odata/IWWRK/WFSERVICE/SubscriptionCollection

      I get a 201 status code , but I do not see the entry in table /IWFND/D_SUB_CNT

      Also when I run the job RSWNSEL, i get 0 notifications back, can you suggest if I have done any config wrong?

      Sandeep

      Author's profile photo Raju P
      Raju P

      Hi Anirvan,

      The subscriptions are going to store in /IWBEP/D_MGW_SUB. Also can you check the /iwfnd/error_log for errors you are getting while posting a notification.

      Regards

      Raju

      Author's profile photo Former Member
      Former Member

      Hi Raju,

      Thanks for the response.. but when I run the program nothing turns up , are there any configurations that I should care for, ??

      Thanks in advance for your help.

      Sandeep

      Author's profile photo Aakash Raj
      Aakash Raj

      Hi Sandeep,

      This Push Notification feature is enabled by SAP NetWeaver Gateway, and it has nothing to do with report program that you have mentioned. Gateway provides necessary APIs to send notification from SAP system. After you have created your subscription please follow the next part of the blog Pushing Notifications Made Easy!!! : Push a Notification.

      Best regards,

      Aakash

      Author's profile photo Former Member
      Former Member

      Hi Anirvan,

      Good Day!

      Thank you so much for nice information. It really interesting.

      I appreciate.

      Regards,

      Hari Suseelan

      Author's profile photo Former Member
      Former Member

      Hi Anirvan,

      I have recreated the objects as per the blog but I am not able to find the service which I have created in ECC in Gateway system.Hence I am not able to activate and Maintain the service in Gateway.

      I have tried to retrieve the services using different system aliases like 'local', ECC system alias but nothing is fetching me the service created in Backend.

      Can you kindly help.

      Thanks,

      Laawanya

      Author's profile photo Srithar Thillairajan
      Srithar Thillairajan

      Thanks  for the detailed Document, Its really Helpful
      Could You please Send me a link for HTTP Listener,
      actually i google it but  i didn't get .Thanks in advance 🙂

      Author's profile photo Aakash Raj
      Aakash Raj

      Hi Srithar,

      You can use the Membrane monitor (open source):

      http://www.membrane-soa.org/soap-monitor/

      Best regards,

      Aakash

      Author's profile photo Former Member
      Former Member

      Hi Anirvan Karmakar

      Can we use such service to configure with SAP Mobile Platform to configure Push Notification ( using APNS & GCM ) ?

      Please suggest.

      Thanks,

      Shrikant Naidu

      Author's profile photo Former Member
      Former Member

      Hi Shrikant,

      That is definitely possible. We had created a few PoCs in the past to push notifications from Gateway to mobile devices via SMP. However, I don't have the details with me anymore.

      Regards,

      Anirvan.

      Author's profile photo Prashanthi Vangala
      Prashanthi Vangala

      Hi,

      Nice blog. Just a question.,In the existing odata service (Leave Approval) i do not see the subscription collection. Do i have to do any configuration to get the subscription collection?

      Regards,

      Shanthi