You are on page 1of 58

 

SAP How-to Guide
 
Mobile  Technology  
 
Sybase  Unwired  Platform  
SAP  NetWeaver  Gateway  

How-To…Subscription & Notification with SAP
NetWeaver Gateway - Android + Code Sample

Applicable Releases:
Sybase Unwired Platform 2.1.1
SAP NetWeaver Gateway 2.0

Version 1.0
February 2012

 

 

All  other  product  and  service  names  m entioned  are  the  trademarks  of  their  respective  companies.  Data  contained  in  this  document  serves  informational  purposes  only.  National  product  specifications  m ay  vary.    
The  information  in  this  document  is  proprietary  to  SAP.  No  part  of  this  document  m ay  be  reproduced,  copied,  or  transmitted  in  any  form  or  for  any  purpose  w ithout  the  express  prior  w ritten  permission  of  SAP  AG.    
This  document  is  a  preliminary  version  and  not  subject  to  your  license  agreement  or  any  other  agreement  w ith  SAP.  This  document  contains  only  intended  strategies,  developments,  and  functionalities  of  the  SAP®  product  and  is  not  intended  to  be  binding  upon  SAP  to  any  particular  course  of  business,  product  strategy,  and/or  development.  Please  note  that  this  document  is  subject  to  change  and  m ay  be  changed  by  SAP  at  any  time  w ithout  notice.    
SAP  assumes  no  responsibility  for  errors  or  omissions  in  this  document.  SAP  does  not  w arrant  the  accuracy  or  completeness  of  the  information,  text,  graphics,  links,  or  other  items  contained  w ithin  this  m aterial.  This  document  is  provided  w ithout  a  w arranty  of  any  kind,  either  express  or  implied,  including  but  not  limited  to  the  implied  w arranties  of  m erchantability,  fitness  for  a  particular  purpose,  or  non-­‐infringement.    
SAP  shall  have  no  liability  for  damages  of  any  kind  including  w ithout  limitation  direct,  special,  indirect,  or  consequential  damages  that  m ay  result  from  the  use  of  these  m aterials.  This  limitation  shall  not  apply  in  cases  of  intent  or  gross  negligence.    
The  statutory  liability  for  personal  injury  and  defective  products  is  not  affected.  SAP  has  no  control  over  the  information  that  you  m ay  access  through  the  use  of  hot  links  contained  in  these  m aterials  and  does  not  endorse  your  use  of  third-­‐party  W eb  pages  nor  provide  any  w arranty  w hatsoever  relating  to  third-­‐party  W eb  pages.    

©  Copyright  2012  SAP  AG.  All  rights  reserved.  
No  part  of  this  publication  m ay  be  reproduced  or  transmitted  in  any  form  or  for  any  purpose  w ithout  the  express  permission  of  SAP  AG.  The  information  contained  herein  m ay  be  changed  w ithout  prior  notice.    
Some  software  products  m arketed  by  SAP  AG  and  its  distributors  contain  proprietary  software  components  of  other  software  vendors.    
Microsoft,  W indows,  Excel,  Outlook,  and  PowerPoint  are  registered  trademarks  of  M icrosoft  Corporation.    
IBM,  DB2,  DB2  Universal  Database,  System  i,  System  i5,  System  p,  System  p5,  System  x,  System  z,  System  z10,  System  z9,  z10,  z9,  iSeries,  pSeries,  xSeries,  zSeries,  eServer,  z/VM,  z/OS,  i5/OS,  S/390,  OS/390,  OS/400,  AS/400,  S/390  Parallel  Enterprise  Server,  PowerVM,  Power  Architecture,  POWER6+,  POWER6,  POWER5+,  POWER5,  POWER,  OpenPower,  PowerPC,  BatchPipes,  BladeCenter,  System  Storage,  GPFS,  HACMP,  RETAIN,  DB2  Connect,  RACF,  Redbooks,  OS/2,  Parallel  Sysplex,  M VS/ESA,  AIX,  Intelligent  M iner,  W ebSphere,  Netfinity,  Tivoli  and  Informix  are  
trademarks  or  registered  trademarks  of  IBM  Corporation.    
Linux  is  the  registered  trademark  of  Linus  Torvalds  in  the  U.S.  and  other  countries.    
Adobe,  the  Adobe  logo,  Acrobat,  PostScript,  and  Reader  are  either  trademarks  or  registered  trademarks  of  Adobe  Systems  Incorporated  in  the  United  States  and/or  other  countries.    
Oracle  is  a  registered  trademark  of  Oracle  Corporation.    
UNIX,  X/Open,  OSF/1,  and  M otif  are  registered  trademarks  of  the  Open  Group.    
Citrix,  ICA,  Program  Neighborhood,  M etaFrame,  W inFrame,  VideoFrame,  and  M ultiWin  are  trademarks  or  registered  trademarks  of  Citrix  Systems,  Inc.    
HTML,  XML,  XHTML  and  W 3C  are  trademarks  or  registered  trademarks  of  W 3C®,  W orld  W ide  W eb  Consortium,  M assachusetts  Institute  of  Technology.    
Java  is  a  registered  trademark  of  Sun  M icrosystems,  Inc.    
JavaScript  is  a  registered  trademark  of  Sun  M icrosystems,  Inc.,  used  under  license  for  technology  invented  and  implemented  by  Netscape.    
SAP,  R/3,  SAP  NetWeaver,  Duet,  PartnerEdge,  ByDesign,  SAP  BusinessObjects  Explorer,  StreamWork,  and  other  SAP  products  and  services  m entioned  herein  as  w ell  as  their  respective  logos  are  trademarks  or  registered  trademarks  of  SAP  AG  in  Germany  and  other  countries.    

SAP  “How-­‐to”  Guides  are  intended  to  simplify  the  product  implementtation.  
While  specific  product  features  and  procedures  typically  are  explained  in  a  

Business  Objects  and  the  Business  Objects  logo,  BusinessObjects,  Crystal  

practical  business  context,  it  is  not  implied  that  those  features  and  procedures  

Reports,  Crystal  Decisions,  Web  Intelligence,  Xcelsius,  and  other  Business  

are  the  only  approach  in  solving  a  specific  business  problem  using  SAP  

Objects  products  and  services  mentioned  herein  as  well  as  their  respective  

NetWeaver.  Should  you  wish  to  receive  additional  information,  clarification  or  

logos  are  trademarks  or  registered  trademarks  of  Business  Objects  Software  

support,  please  refer  to  SAP  Consulting.  

Ltd.  Business  Objects  is  an  SAP  company.  

Any  software  coding  and/or  code  lines  /  strings  (“Code”)  included  in  this  

 

documentation  are  only  examples  and  are  not  intended  to  be  used  in  a  
productive  system  environment.  The  Code  is  only  intended  better  explain  and  
visualize  the  syntax  and  phrasing  rules  of  certain  coding.  SAP  does  not  warrant  
the  correctness  and  completeness  of  the  Code  given  herein,  and  SAP  shall  not  
be  liable  for  errors  or  damages  caused  by  the  usage  of  the  Code,  except  if  such  
damages  were  caused  by  SAP  intentionally  or  grossly  negligent.  
Disclaimer  
Some  components  of  this  product  are  based  on  Java™.  Any  code  change  in  
these  components  may  cause  unpredictable  and  severe  malfunctions  and  is  
therefore  expressively  prohibited,  as  is  any  decompilation  of  these  
components.  
Any  Java™  Source  Code  delivered  with  this  product  is  only  to  be  used  by  SAP’s  
Support  Services  and  may  not  be  modified  or  altered  in  any  way.  

 

 

Document History
Document  Version  

Description  

1.00  

First  official  release  of  this  guide  

 
 
 

 

 

Typographic Conventions

Icons

Type  Style    

Description  

Icon  

Example Text

Words  or  characters  quoted  
from  the  screen.  These  include  
field  names,  screen  titles,  
pushbuttons  labels,  menu  
names,  menu  paths,  and  menu  
options.  

Example  text  

Cross-­‐references  to  other  
documentation  

 

Emphasized  words  or  phrases  
in  body  text,  graphic  titles,  and  
table  titles  

 

 

Example text

File  and  directory  names  and  
their  paths,  messages,  names  
of  variables  and  parameters,  
source  text,  and  names  of  
installation,  upgrade  and  
database  tools.  

Example text

User  entry  texts.  These  are  
words  or  characters  that  you  
enter  in  the  system  exactly  as  
they  appear  in  the  
documentation.  

<Example
text>

Variable  user  entry.  Angle  
brackets  indicate  that  you  
replace  these  words  and  
characters  with  appropriate  
entries  to  make  entries  in  the  
system.  

EXAMPLE TEXT  

Keys  on  the  keyboard,  for  
example,  F2  or  ENTER.  

 

 

Description  

 

Caution  

 

Note  or  Important  

 

Example  

 

Recommendation  or  Tip  

 

Table of Contents
1.   Business  Scenario  ....................................................................................................................................  1  
2.   Background  Information  ........................................................................................................................  1  
2.1   SAP  Business  Suite  ....................................................................................................................   2  
2.2   SAP  NetWeaver  Gateway  .........................................................................................................   2  
2.3   Sybase  Unwired  Platform  (SUP)  &  Online  Data  Proxy  (ODP)  ................................................  3  
2.4   Clients  &  Sybase  OData  SDK  Development  .............................................................................  4  
2.5   Process  Flow  .............................................................................................................................  5  
2.6   Offline/Online  ............................................................................................................................  8  
2.7   Push/Pull  ....................................................................................................................................  8  
3.   System  Prerequisites  ............................................................................................................................  10  
4.   Tasks  .......................................................................................................................................................  11  
5.   Gateway  Configuration   ........................................................................................................................  12  
5.1   Check  the  SUP  SM59  Destination  in  Gateway.  .......................................................................  13  
6.   SUP/ODP  Configuration  ........................................................................................................................  14  
6.1   Create  Security  Configuration  .................................................................................................  14  
6.2   Create  Application  ...................................................................................................................  16  
6.3   Create  Application  Connection  ...............................................................................................  18  
7.   Configuring  the  Development  Environment  .....................................................................................  20  
7.1   Download  the  IDE  ...................................................................................................................  20  
7.2   Setting  up  the  Android  SDK  Manager  ....................................................................................  21  
7.3   Update  you  Android  SDK  with  2.2  API  8  Libraries  ..................................................................  22  
7.4   Create  an  Android  Project  .......................................................................................................  22  
7.5   Importing  Libraries  to  your  Android  Application  Project  ......................................................  25  
7.6   Setting  Project  Properties  ......................................................................................................  26  
8.   Developing  your  Application  ...............................................................................................................  27  
8.1   A  typical  application  .................................................................................................................  27  
8.2   Initialization  ............................................................................................................................  28  
8.3   Calling  Gateway  Services   .......................................................................................................  33  
8.4   Creating  &  Deleting  Subscriptions  .........................................................................................  39  
8.5   Receiving  Notifications  ..........................................................................................................  43  
9.   Running  the  Sample  Application  ........................................................................................................  45  
9.1   Application  Structure  ..............................................................................................................  45  
9.2   Preparing  the  Application  ......................................................................................................  46  
9.3   Running  the  application  .........................................................................................................  47  
10.   Notification  Routing  Explained  .........................................................................................................  50  
11.   Communication  Architectures  (Device  Specific)  ...............................................................................  51  
12.   Appendix  –  Subscription  Collection  ...................................................................................................  52  

 

   This  document  is  one  of  a  number  of  guides  that  cover  this  topic.     Overview   • How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Overview   Gateway  Configuration   • • • How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  –  Generation  Tools   How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  –  Custom  Development  (OData  Channel)     How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  –  Workflow     Client  Development  &  SUP  Configuration   • • • How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  –  iOS  +  Code  Sample   How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  –  Android  +  Code  Sample   How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  –  Blackberry  +  Code  Sample     April  2012   1   . Business Scenario    SAP  NetWeaver  Gateway  offers  the  ability  to  send  notifications  to  a  device  and  user  who  have  subscribed   to  a  suitable  Gateway  service. Background Information   Before  we  create  the  Android  application  it  is  important  to  describe  how  each  component  is  used  in  the   architecture  above  and  how  it  fits  into  the  Subscription  &  Notification  process  flow  of  SAP  NetWeaver   Gateway.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     1.    The  illustration  below  highlights  the  basic  premise  behind   notifications  with  SAP  NetWeaver  Gateway.    This  capability  is  different  to  SUP’s  Data  Change  Notification   function  and  is  not  covered  in  this  document.      For  this  document  we  will  discuss  how  to  create  an  Android   application  to  consume  subscription  and  notification  enabled  Gateway  services  via  SUP.    Hypothetically  you  could  subscribe  to  all  new  employee  hires  or  sales   order  creation  events  and  push  these  to  an  interested  user  or  device.         2.    This  capability  does  not  need  to  be  mobility  centric  however  for  the  purpose   of  this  document  we  shall  assume  it  is.   Subscription  and  Notification  with  SAP  NetWeaver  Gateway  allows  you  to  send  events  to  the  mobile  device   for  changes  of  a  specific  SAP  Object.

 platforms  and  programming  framework.1 SAP Business Suite The  SAP  Business  Suite  represents  the  business  logic  or  application  layer  responsible  for  holding  the  actual   business  data.    In  this  document  we  shall  describe  the  subscription   and  notification  scenario  with  a  standalone  Gateway  instance  integrating  with  a  separate  back-­‐end  Business   Suite  application  server.    See  Design  Decisions  and  Variations  for  more   information.  This  is  the  vehicle  to  connect  SAP  Business  Suite  data  and  functionality  to  the   target  clients.  Employee  and  Material  can  be  exposed  to  allow  various  clients  to  interact  using  Create.  Update  and  Delete  methods.     April  2012   2   .   2.  CRM  &  SRM  are  examples  of  SAP  Business  Suite  applications  and  represent  the   core  location  for  the  application  logic.  Query.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.     SAP  NetWeaver  Gateway  offers  development  and  generation  tools  to  create  OData  services  to  a  variety  of   client  development  tools.  which  you  can  install  on  top  of  your  existing  SAP  Business  Suite  or  application  platform.    SAP  ERP.   Read.      Developers  and  architects  need  to  choose  between  generating   Gateway  services  off  existing  entities  such  as  BOR/RFC  &  Screen  Transactions  or  implement  a  programmatic   service  leveraging  the  Odata  Channel  framework.2 SAP NetWeaver Gateway SAP  NetWeaver  Gateway  is  a  REST  enabler  that  is  available  as  a  SAP  NetWeaver  Application  Server  ABAP   (AS  ABAP)  add-­‐on.    In  the  context  of  Gateway  and  RESTful  services  objects  such  as   Purchase  Order.

   For  the  purpose  of  this  document  SUP  &  ODP  refer  to  the  same   capability  or  component.     April  2012   3   .    If  you  install  SUP  in  full  you  have  the  ODP  capabilities  already  embedded  and  no   further  action  is  required.                                               Sybase  Unwired  Platform  is  SAP’s  mobility  platform  and  provides  various  capabilities  beyond  the  scope  of   subscription  and  notification  discussed  in  this  document.    In  addition  to  SUP  the  Online  Data  Proxy  (ODP)  is   a  lightweight  edition  of  the  Sybase  Unwired  Platform  that  provides  a  robust  mobile  infrastructure  for   enterprise  IT  organizations  to  securely  rollout  and  manage  the  deployment  of  light-­‐weight  applications  in  a   controlled  and  monitored  approach.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.       The  ODP  or  SUP  installation  option  provides  the  following  in  the  context  of  subscription  and  notification   with  SAP  NetWeaver  Gateway:   • • • • • • • • Device  &  User  Onboarding   Application  creation  and  management   Security  profiling   Secure  proxy  connection  to  SAP  NetWeaver  Gateway  abstracting  SAP  Business  Suite  Applications   Notification  queuing  &  routing  to  specific  device   Device  online  v  offline  determination   Device  push  notification  registration   Connectivity  to  3rd  Party  messaging  services.    APNS.        The  diagram  below  illustrates  the  inclusion  of  SUP  in  the  architecture   independent  of  security  and  3rd  party  device  specific  messaging  services.3 Sybase Unwired Platform (SUP) & Online Data Proxy (ODP) For  the  purpose  of  this  document  we  shall  assume  a  mobile  device  scenario  and  hence  SUP  plays  a  very   important  role  in  this  scenario.  BES  etc.

 BlackBerry  and  iOS  platforms  and  it   is  based  on  the  native  device  SDKs  of  the  platforms.  automatic   layout)   Exploit  different  input  methods  (for  example.  Connection  pools  for  optimal  performance     For  our  sample  application  we  shall  use  a  subset  of  what  is  available  above  and  focus  on  Cache   Management.org  website  here.  Security.     The  SAP  OData  SDK  supports  Android.    Note  for  Gateway  standalone  (non-­‐SUP)  scenarios  these  libraries   are  not  required.   Cache  Management  –  Storing/accessing  OData  objects  in  memory.  Supportability  &  Configuration.  Efficient  search  OData  entries  in   memory.   • • • • • Parsing  –  Parsing  of  OData  XML  to  native  OData  objects.  for  example:   • • • • Adapt  to  each  device’s  form  factor  (for  example.  There  is  an   implementation  for  each  platform.   Persistence  –  Storing  objects  and  raw  data  on  the  physical  storage  of  the  device.       April  2012   4   .  Tracing  (SAP  Passport)   SUP  Connectivity  –  Synchronous  and  asynchronous  HTTP  request  handling.  Native  applications  installed  on  the   devices  allow  the  client  application  to  leverage  the  support  provided  by   the  given  platform.  touch  screen.    For  more   information  please  see  the  official  help  documentation  here.  Event  logging.  Connectivity.  Data  Parser.   keyboard  or  trackball)   Cache  data  in  native  device  data  stores  for  better  performance   Tightly  integrate  with  the  features  of  the  device     The  main  function  of  the  libraries  is  to  provide  the  following  high-­‐level  abstracted  functions.4 Clients & Sybase OData SDK Development To  integrate  clients  with  SUP  into  SAP  NetWeaver  Gateway.    For  more  information  please  the  OData.  Managing  size  of  Cache.  Provide  easy  access   to  all  OData  Fields  and  structures  via  objects.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.  Data  Encryption     Supportability  –  Common  exception  and  error  handling.  Request  types  as  support  by  OData  Protocol.  SAP  has  delivered  a  number  of  device  specific   libraries  that  abstract  the  developer  from  low  activities.  Validate  OData  XML.  Compresses  payload   handling.    This  is  known  as  the  OData  SDK  and  consists  of  a   collection  of  runtime  libraries  and  classes.  Easy  and  quick   access  to  stored  objects  and  raw  data.

 followed  by  a  description  of   each  step  in  the  process.5 Process Flow The  Subscription  and  Notification  scenario  is  explained  greater  detail  within  the  document  “How-­‐ To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  –  Overview”.     Creates  a  security  profile  to  determine  how  user  will  be   authenticated  in  SUP.  relay  servers  and  3rd  party  messaging  services   are  left  out  of  the  diagram  intentionally.  Security  Profile  and  activation   codes.    For  the  purpose  of  brevity  the   following  high-­‐level  process  summarizes  our  scenario.    The  following  illustration  depicts  the  basic   architecture  independent  of  3rd  party  messaging  and  security  components.Registration (SUP) This  process  can  be  automated  however  for  to  explain  exactly  what  is  configured  a  SUP  Administrator  logs   onto  the  Sybase  Control  Center  and  creates  the  following:     • • • • Creates  an  application.  Application  ID.    Note  the  use  of  security  firewalls.       April  2012   5   .5.   Maintains  application  connection  properties  with   Gateway  service  URL  and  push  endpoint  URL.1 Step 1 .     Creates  an  application  connection  that  binds  a  SUP   User.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.             2.

3 Step 3 – Calling Gateway Services (Client) Once  the  activation  and  initialization  is  done  the  client  then  calls  the  gateway  services  a  normal  application   independent  of  a  subscription  and  notification  scenario.    In  out  case  we  perform  a  simple  query  on  FlightCollection  –  send.2 Step 2 – SUP Activation (Client) Using  the  SAP  Odata  SDK  the  developer  creates  a  mobile  application  in  the  appropriate   IDE  and  at  runtime  the  client  programmatically  over  HTTP/s:   • • • • • • Connects  to  SUP   Activates  the  user  and  binds  a  device  ID  to  the  application  connection  created  in   the  first  step.5.  parse   &  cache   Display  on  screen.  (Long  poll  initiated)   Retrieves  the  Gateway  URLs  from  the  SUP  application  connection  properties   Retrieves  the  push  URL  endpoint  form  the  SUP  application  connection  properties     Retrieves  messages  from  SUP  found  in  the  application  connection  queue           2.5.     Call  as  many  collections  as  you  need  and  perform  create.  receive.  receive.  read.  update  &  delete  operations  as   required.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.   Registers  the  mobile  application  for  push  notifications.  receive.  parse  &  cache     Subsequent  Data  Calls  (as  many  as  required):   • • • Data  Collection/s.  parse  &  cache   Gateway  Metadata  Document  –  send.       April  2012   6   .    If  you  were  developing  an  standard  SUP/Gateway   enabled  application  you  could  stop  here  and  just  perform  CRUD  operations  of  your  Collections.         The  initial  Gateway  Service  calls  in  sequence  (once  only):   • • Gateway  Service  Document  –  send.

  Once  a  notification  has  been  received  in  Gateway  the  message  is  sent  to  SUP  via  a  SM59  RFC  Destination.Trigger Notification (Backend) Once  a  subscription  has  been  created  against  a  suitable  Entity  or  Collection  the  client  waits  for  a   notification.    We  will  talk  more  about  how  to  enable  Gateway  Services  for   subscription  in  other  How-­‐To  guides  but  for  now  we  can  assume  that  for  a  given  Gateway  Service  such  as   SFLIGHT  subscription  is  enabled.  such  as  a  exit  or  BADI.    If  you  choose  to  use  the   custom  development  approach  known  as  the  OData  Channel  you  will  need  to  implement  the  trigger   yourself  in  the  appropriate  business  process  location.5.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.  SUP  and  the  observing  device  and  user.5.     Please  see  the  next  chapter  for  more  information  regarding  push/pull  and  offline/online.                       2.    Depending  on  how  the   Gateway  Service  was  implemented  the  trigger  may  be  executed  by  normal  business  processing  such  as  a   Purchase  Order  Create  or  Sales  Order  Change  which  forces  a  Business  Object  Repository  object  state   change.    The  device   application  accepts  the  message  or  notification  via  a  standard  class  method  and  then  the  developer  can   execute  any  action  he  or  she  wants.6 Step 5 .4 Step 4 .5.     2.Create Subscription (Client) Before  a  user  can  receive  any  notifications  the  client  application  needs  to  subscribe  explicitly  to  a  Gateway   service  entity  that  is  subscription  enabled.       April  2012   7   .    Note  –  For  Android  scenarios  SAP  only  supports  online  scenarios.    This  method  is  a  SAP  concept  and  is  leveraged  by  SAP  Business  Workflow  and  many  other   applications.    Asynchronous   communications  between  the  Backend  system  and  Gateway  are  executed  using  Background  Remote   Function  calls  (BGRFC).      For  more  information  have  a  look  at  transactions  SWO1  &  SWO2.5 Step 4 .    Normal  business  processing  occurs  in  the  Backend  until  a  trigger  is  fired  and  starts  the   notification  process  back  to  Gateway.Receive Notification (Client) In  SUP  the  server  checks  if  the  mobile  device  is  online  and  then  sends  the  message  to  the  device  via  a   response  using  the  long  poll  connection  established  continuously  at  application  initialization.     SUP  always  listens  on  a  set  URL  for  inbound  HTTP/s  notifications  coming  from  Gateway  and  this  value  was   stored  in  the  application  connection  properties  in  SUP  and  also  would  be  defined  in  the  SM59  HTTP   Destination:    http://host:port/GWC/SUPNotification/.

     The   client  needs  to  call  a  separate  Gateway  service  that  comes  standard  and  is  dependent  on  the  framework   used  at  design  time  within  Gateway.    This   configuration  is  performed  in  the  application  connection  properties  in  SUP  SCC.    You  may  be  in   an  area  where  connectivity  is  restricted  such  as  a  plane  or  tunnel.    In  this  scenario  you  device   may  have  Internet  capability  yet  not  explicitly  connected  to  SUP.  SP3  &  SP2  have  different  URLs.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.7.6.1 Pull Notifications  are  stored  in  SAP  NetWeaver  Gateway  for  later  retrieval  explicitly  made  by  the  client.6.    In  such  situations  notifications  cannot   reach  the  phone  or  mobile  device.       If  you  have  a  Blackberry  or  iOS  device  you  can  integrate  vendor  specific  messaging  services  such  APNS.    When  a  notification  arrives  in  SUP  the  server   determines  if  a  device  is  offline  or  online  and  routes  the  notification  via  ODP  (default)  mechanism  or  3rd   party  messaging  service  if  configured  appropriately.    For  Android  only  online  scenarios  are   supported.    In  addition  to  this  the  device  must  register  for  push  notifications.    The  following  describes  each  in  more  detail:     2.  i.     2.    In  such  cases  SUP  does  not  perform  any  queuing  functionality  or   communications  to  3rd  part  messaging  services  like  APNS  etc.    Notifications  are  stored  in  the  messaging  queues  and  once  a  device  re-­‐ connects  with  SUP  the  notifications  are  send  to  the  device  in  push  scenarios.    This  approach  is  effectively  an  explicit   request/response  made  from  the  client  as  if  you  were  attempting  to  query  a  Flight  service  you  would  be   querying  a  Notification  service.    Push  is  where  the   notifications  are  sent  to  device  and  pull  is  where  the  device  explicitly  requests  the  notifications.   2.    You  can   check  if  a  device  is  online  or  offline  via  the  SUP  SCC  application  connection  screen.1 Offline A  device  is  offline  when  it  is  not  connected  to  SUP  and  the  application  is  not  in  foreground.    The  persistNotifications  element  in   the  subscription  create  step  defines  if  push  or  pull  is  used.    They  are  described  below  in  further   detail  and  are  implemented  via  configuration  and  application  design  within  the  IDE.e.2 Online A  device  is  determined  to  be  online  if  is  has  connectivity  to  SUP  and  initiated  or  started  the  client   communications  explicitly.7 Push/Pull SAP  NetWeaver  Gateway  &  SUP  supports  two  types  of  notifications.     April  2012   8   .    We  will  demonstrate   this  capability  with  our  sample  application.   2.6 Offline/Online Offline  and  online  capabilities  are  supported  generically  with  SUP  however  with  Android  and  the  current   lack  of  support  for  C2DM  only  online  scenarios  are  available.

   The  pushed  message  can  be   received  if  the  application  is  „background“  (or  offline)  or  „foreground“  via  Apple’s  APNS  channel.  The   landscape  in  the  production  system  would  have  additional  elements  such  as  a  relay  server  to  handle  firewall     April  2012   9   .2 Push The  push  scenario  is  where  notifications  are  sent  from  SUP  to  the  Device  in  one  of  two  methods.    If  a  device  is  not  connected  to  SUP  then  the  3rd   Party  Messaging  Service  will  be  used  if  configured  correctly  in  SUP  SCC.    The   device  and  application  doesn’t  have  to  be  directly  reachable  to  SUP  server.    If  a  notification  is   sent  to  SUP  in  this  time  it  is  sent  to  the  device  as  the  direct  response.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     2.    So  in  fact   the  push  is  really  client  initiated.  the  device  at  the  initialization  stage   establishes  a  connection  to  SUP  (request)  and  keeps  it  alive  for  a  default  of  5  minutes.       2.7.1 ODP Notifications  are  sent  to  the  device  using  a  SUP  protocol  leveraging  a  long  poll  mechanism.    These   methods  are  described  below  and  can  be  used  together  via  configuration  to  maximize  the  reach  of   notifications  to  your  device.         2.    As  each  mobile   device  does  not  have  a  discrete  web  server  addressed  uniquely.      When  a  device  is  connected  to  SUP  and  registered  for  push  notifications  it  is   determined  to  be  online  and  therefore  ODP  will  be  used.             CAUTION The  diagram  above  is  one  very  simple  example  to  explain  how  push  technology  works  with  SUP.2 3rd Party (APNS + BES) Notifications  are  sent  from  SUP  via  a  3rd  part  messaging  service  such  as  APNS.    SUP  passes  on  what  ever  it  gets  from  Gateway.7.2.2.7.    This  simulates  a  push  by  always   maintaining  an  open  connection  that  SUP  can  respond  to  via  a  normal  request/response  cycle.  APNS  works  if  the  device  is  in   the  public  Internet  and  not  able  to  connect  to  SUP.

  • You  have  access  to  the  Sybase  Developer  Workspace  (required  libraries)   • You  have  access  to  SUP  SCC.02  SP6  or  higher  system.       April  2012   10   .1  installed.   • Connections  between  SAP  NetWeaver  Gateway  system  and  backend  SAP  application  are  configured.   • You  have  SUP  2.   • You  have  a  subscription  and  notification  enabled  service  configured  in  Gateway  such  as   RMTSAMPLEFLIGHT.   • Backend  SAP  application  with  the  IW_BEP  Gateway  add-­‐on  installed. System Prerequisites The  following  are  the  prerequisites  to  complete  the  steps  in  this  guide:   • You  have  access  to  a  NetWeaver  7.  which  the  SAP  NetWeaver  Gateway   ABAP  add-­‐ons  have  been  installed.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     3.

      The  code  sample  attached  demonstrates  holistically  and  can  be  run  easily.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     4.  persistence.    The  first  is  a  pre-­‐requisite  to   ensure  you  have  the  sample  SFLIGHT  gateway  service  running  in  your  system.    Once  this  is  done  we  will  look  at  the   Android  development  environment  and  discuss  the  coding  steps  to  get  an  application  working. Tasks   The  scenario  detailed  in  this  document  has  four  major  configuration  steps.     Subscription 1 2 OData 3 SUP (ODP) 4 SAP NetWeaver Gateway OData RFC bgRFC SAP Business Suite 5 Notification       Step   Gateway  Configuration   • • Download  the  IDE   Setting  up  the  Android  SDK  Manager   Update  Android  SDK  with  Libraries   Create  an  Android  Project   Importing  Libraries  to  your  Android  Application  Project   Setting  Project  Properties   Android  –  Develop  your  application   • • • •         Security  Profile   Application  /  Application  Template   Application  Connection   Android  –  Configuring  your  Development  Environment   • • • • • • SUP   Gateway     Check  the  Service  is  available   Maintain  Destinations  for  Client  Notifications   SUP/ODP  Configuration   • • • Android   Initialization   Calling  Gateway  Services   Creating  &  Deleting  Subscriptions   Receiving  Notifications   April  2012                                 11   .  Android  release  compatibility  and  application  state  changes  are  not  covered.    Following  this  we  move  into   SUP  and  perform  the  configuration  for  manual  user  onboarding.    It  is  important  to  emphasize  any   sample  code  is  purely  for  demonstration  purposes  and  not  for  production.    There  are  a  couple  of   variations  of  this  service  depending  on  the  SP  level  of  your  Gateway  instance.    Aspects  such  as  strong  security   mechanisms.

   Below  is  an  example  of  the  service   document  from  the  RMTSAMPLEFLIGHT.    You  can  see  the  metadata  document  indicates  it  is   subscription  and  notification  enabled  and  actually  shows  the  schema  of  the  each.    The  typical  URL  for  this   service  can  be  seen  below.     April  2012   12   .           Below  is  an  example  of  the  metadata  document.To”  guides  explicitly  describe  the  required   steps  to  configure  such  scenarios.    Please  official  help  for  more  information.    For  the  purpose  of  discussion  and  our  sample  code  we  will  be   referencing  RMTSAMPLEFLIGHT.     Conversely  it  also  shows  us  what  a  subscription  request  would  look  like  from  a  payload  perspective. Gateway Configuration   Before  we  can  build  an  application  you  need  to  have  a  gateway  service  configured  and  available.    There  a   many  ways  to  create  a  service  using  Gateway  and  other  “How.     • http://gatewayserver:port/sap/opu/sdata/IWFND/RMTSAMP LEFLIGHT       Once  you  have  a  created  or  enabled  you  service  to  be  subscription   and  notification  enabled  the  metadata  document  and  service   document  should  reflect  this.    We   will  use  this  when  we  create  the  subscription  highlighted  later  in  this  document.    That  tells  us  what  an   inbound  notification  would  look  like  and  how  the  client  API  can  easily  covert  to  consumable  data  types.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     5..  which  is  shipped  with  all  Gateway  instances.    Note  for  SP3  enabled  services  this  URL   may  differ.    You  can  see  the  service   document  indicates  it  is  subscription  and  notification  enabled  and   that  the  FlightCollection  can  be  subscribed  against.

    This  URL  determines  how  to  send  the  notification  to  SUP.         April  2012   13   .1 Check the SUP SM59 Destination in Gateway.   5. This  step  is  described  in  other  documents  and  is  specific  to  the  gateway  configuration.   update.    For  SUP  scenarios  this  should  be  constant  and   equal  to  below.    At  runtime  when  a   notification  is  created  in  gateway  it  looks  at  who  created  the  subscription  and  matches  a  delivery  address   used  in  the  payload  on  creation  and  then  checks  if  a  SM59  Destination  exists  with  the  same  server/port/url.  delete.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android         It  is  important  to  note  that  the  Subscription  Collection  acts  like  any  other  Collection.    “/GWC/SUPNotification”  on  port  8000  subject  to  security  and  SSL.    For  more  information  please  see  „Appendix  –  Subscription  Collection“  for  more  information.  read  and  query  any  subscriptions  using  the  HTTP  Verb  combination  with  an  appropriate  URL   and  payload.    You  can  create.

Log  onto  the  Sybase  Control  Center.    For  external  authentication  SUP  checks  another  system   according  to  the  option  selected  and  then  responds  with  success  or  failure.           April  2012     14   .   6.    In  some  cases  these  steps  may  be   automated  (onboarding)  but  to  gain  a  clear  understanding  of  what  is  happening  it  is  beneficial  to  create   these  manually.    The  following   options  are  available:     • • • • Manual  User  Onboarding  –  No  Authentication   External  Authentication  –  Username/Password   External  Authentication  –  SSO2   External  Authentication  –  Certificates       For  the  purpose  of  our  simple  application  we  will  be  using  manual  user  onboarding  and  hence  will  create  a   security  profile  with  no  authentication  requirements.    It  is  really  important  to  do  these  steps  prior  to  creating  and  running  an  application  on  a   device  as  there  are  key  entities  our  Odata  SDK  API  or  client  application  will  interact  with  dynamically  at   runtime.     SUP  does  not  hold  the  security  information  in  the  server  but  checks  the   external  provider  in  line  with  your  corporate  security  strategy. 2.1 Create Security Configuration In  the  Sybase  Control  Centre  you  need  to  login  and  create  a  security   configuration  to  determine  how  your  application  will  be  authenticated  in  SUP.     The  steps  are  easy  and  would  be  performed  by  an  administrator. SUP/ODP Configuration Before  we  actually  create  an  Android  application  we  need  to  configure  SUP  using  the  Sybase  Control  Center.     1.   Click  on  the  Security  Node  on  the  left  hand  side.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     6.    The  following  steps  describe  this  configuration.     There  are  a  couple  of  options  available  and  are  discussed  in  further  detail  in   other  documents.

   From  the  pull  down  option  select  “NoSecLoginModule”  and   click  “OK”.         5. Find  the  newly  created  profile  as  a  child  to  the  Security  node  on  the  left  hand  side.    In  the  main   screen  click  the  tabe  “Authentication”  and  then  click  the  button  “New”.   Click  on  “New”  in  the  main  tab  and  enter  a  new  Name  such  as  “ManualUserOnboarding”. A  new  screen  will  appear  in  dialogue.       April  2012   15   .How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android   3.         4.

        3.    This  is  the   key  as  is  allows  us  to  specify  the  security  profile  and  connectivity  URLs  pointing  to  Gateway.    Of  course  in  production  you   would  not  have  this  and  would  select  a  strong  level  of  authentication.    For  the  security   configuration  select  the  profile  you  created  in  the  previous  step  “ManualUserOnboarding”  and   select  a  valid  domain.dc01212.    This  step  creates  a  template   that  we  can  bind  application  users  to  in  the  next  step.    It  is  important  to  select  the  “Configure  additional  settings”  at  the  bottom   and  the  click  “Next”.0152/doc/html/ mqu1264545412442.    For  the  purpose  of  our  application   and  a  development  environment  it  meets  our  needs.jsp?topic=/com. In  the  dialogue  box  fill  in  the  details  as  per  below  using  “Gateway_Flight_Push”.infocenter.html 6.    Other  options   cab  be  configured  here  such  as  3rd  party  messaging  connections  like  APNS.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     At  this  stage  we  now  have  a  security  profile  with  no  security  requirements.2 Create Application The  next  step  is  to  create  an  application  object  in  SUP  SCC  representing  our  Mobile  application.com/help/index. 2.     April  2012   16   . In  SCC  click  on  the  “Applications”  node  in  the  left  hand  index.       1.sybase.sybase.   In  the  “Applications”  tab  on  the  right  hand  side  click  on  “New”.    For  more  information  on  ODP/SUP  security  options   please  refer  to  the  appropriate  help  documentation  here:       • http://infocenter.

        • • Application  Endpoint  –  This  is  the  Gateway  URL  our  application  is  bound  to.      Also   this  address  will  match  the  SM59  destination  created  by  the  Gateway  Administrator.    This  could  be  QA  or  Production  and  it  allows  you  to  abstract  between  tiers.  Please  look  at  the  chapter  “Notification  Routing  Explained"  to  see  how  this   is  used  at  runtime  and  mapped  to  device  when  the  notification  arrives  in  SUP.    This  screen  creates  a  template  that  we  will  use  as  we  add  device  users  in   subsequent  steps.  as  we  will  use  this  in  the  next  step.         Template  Name  –  “Gateway_Flight_Push_default_ManualUserOnboarding”     Maintain  the  following  URLs  in  the  “PROXY”  tab.    In  our   case  this  is  the  flight  service  shipped  with  all  Gateway  instances.                                                                             http://SUPHOST:8000/GWC/SUPNotification       April  2012   17   .     In  screen  shown  you  need  to  maintain  the  Proxy  tab  settings  and  enter  the  URL  pointing  to  your   Gateway  service.    It  represents  the   starting  place  for  your  application  from  which  at  runtime  your  client  application  would   suffix  Collections  or  $metadata  calls  to  retrieve  and  navigate  through  your  application.   http://GATEWAYHOST:PORT/sap/opu/sdata/IWFND/RMTSAMPLEFLIGHT     Push  Endpoint    -­‐  This  is  the  SUP  entry  point  for  inbound  notifications  coming  from   Gateway.    Take  note  of  the  template  name.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android   4.    Why?    Both  the  application  endpoint  and  push   endpoint  values  will  be  dynamically  retrieved  by  the  client  application  at  runtime  to  provide   landscape  abstraction.

    Your  newly  created  application  show  is  now  visible  and  if  you  click  “Application  Connection   Template”  tab  you  will  see  a  new  template  created  in  this  step.   6.       2.       1.    This   user  will  represent  the  mobile  device  user.           3. Click  the  “Register”  button.    For  Android  we  only  support  online   push/pull  and  therefore  we  do  not  need  to  maintain  these.    Note  this  is  user  is  not  the   gateway  ABAP  user  but  a  abstracted  device  user  which  will  be  specified  in  device  application.         Click  “Finish”.    We  do  this  by  creating  “Registering”  and  “Application   Connection”.   April  2012   18   .3 Create Application Connection Now  that  we  have  an  application  created  with  a  useful  template. In  the  “Applications”  screen  click  on  the  “Application  Connections”  tab.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android         Before  you  click  “Finish”  have  a  look  at  the  APNS  and  Blackberry  Push  Notification  tabs. On  the  screen  provided  enter  a  username  we  will  use  at  runtime.    This   would  be  where  you  configure  connectivity  to  these  services.  we  can  now  manually  onboard  users.

    On  the  screen  provided  select  the  template  we  created  earlier.     5.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android   4. Click  on  the  “Properties”  button.    We  will  use  these  values  in  the  Android  java  code  later!             1.    Notice  that   the  Status  is  “Pending  Activation”. On  the  screen  provided  check  the  “Specify  activation  code”  radio  box  and  maintain  an  activation   code  such  as  “abc”.         3.     April  2012   19   .    This  will  pre-­‐fill  many  fields  and   bind  the  connectivity  parameters  in  background. 2.     Once  this  step  is  complete  you  can  now  see  your  user  has  been  on-­‐boarded  manually.    This  will  happen  at  runtime  once  the  device  connects  to  SUP   using  the  Odata/SUP  libraries.    You  can  also  see  “Pending  Items”  in  the  queue. Click  the  “OK”.    On  the  screen  displayed  you  will  see  the  properties  maintained   earlier  when  we  created  the  template.    Make  sure  the  endpoint  hosts  names  are  correct  and  will  be   accessible  from  your  SUP  server  and  Device  or  development  environment.    We  will  see  how   this  changes  once  we  get  an  application  running.

Configuring the Development Environment   Now  that  we  have  a  Gateway  service  ready  and  the  configuration  in  SUP/ODP  is   complete  lets  look  at  the  steps  required  to  get  an  Android  application  working.  select  Install  New   Software.   • Click  Add.         7.   • Click  Next.oracle.2)  from  the  following  URL:   http://www.   • In  the  Add  Repository  dialog.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     7.   • Review  the  tools  to  be  downloaded.         April  2012   20   . Start  the  Eclipse  environment  and  perform  the  following:   • From  the  Help  menu.   • Enter  one  of  the  following  for  URL:   • https://dl-­‐ssl.org/downloads/     3.   • Select  the  Developer  Tools  checkbox  and   click  Next.  restart  Eclipse.   • Once  the  installation  is  complete.html     Download  Eclipse  Helios  (3. Download  the  Java  Standard  Edition  (6  Update  24)  Development  Kit  from   the  following  URL:   http://www.com/android/eclipse/   • Click  OK.1 Download the IDE   1.   • Read  and  accept  the  license  agreement   and  click  Finish. 2.eclipse.google.     The  first  step  is  to  set  up  your  development  and  correctly  reference  the  SUP/Odata   SDK  libraries.google.6.  enter  a   Name  for  the  new  plugin.com/technetwork/java/javase/downloads/index.com/android/eclipse/   • http://dl-­‐ssl.

        4. 3.   6.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     7. In  the  Eclipse  environment.S  release  like  2. Download  the  Android  SDK  Manager  based  on  your  system  requirements  from  the  following  URL:   http://developer. Click  Browse  to  search  for  the  location  where  you  have  stored  the  Android  SDK.     1.zip.2 Setting up the Android SDK Manager The  Android  SDK  Manager  handles  the  Android  library  versions  specific  to  a  device  O.2.    Once  we  have  done  this  we  can   integrate  it  into  our  Eclipse  environment. In  the  left  navigation  pane.android.com/sdk/index.2  etc.  select  Preferences.  from  the  Window  menu.  select  the  Android  node.   Unzip  the  archive  to  a  location  of  you  choosing. 2.     April  2012   21   . Click  Apply  and  OK.html   Download  the  zip  file  such  as  android-­‐sdk_r15-­‐windows.   5.     You  need  to  download  this  and  install  the  required  libraries  in  our  case  2.   7.

How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     7.  select  Create  new  project  and  enter  the  project  name   GatewayFlightPush.sap.  select  New  -­‐>  Project-­‐>Android-­‐>Android  Project.    You  may  want  to  create  an   Android  application  for  a  device  with  a  later  operating  system  version.  from  the  Window  menu. From  the  toolbar. In  the  New  Android  Project  wizard.2  for  a  basic  application.   2. Click  Install  Packages     7.3 Update you Android SDK with 2.     April  2012   22   . The  available  Android  libraries  will  be  listed.    It  is  up  to  you  to  decide   what  you  need  here.     1.    If  you  would  like  to  use  our  sample  code  I  suggest  you  stick  to  csa.   2. In  the  Eclipse  environment.       3.   4.  select  Android  SDK  Manager.2 API 8 Libraries 1.4 Create an Android Project We  assume  you  have  a  basic  understanding  of  creating  Android  projects  and  are  familiar  with  Android   programming. Check  Android  2.    The  purpose  of  this  document  is  not  to  explain  Android  best  practices  but  rather   demonstrate  the  key  APi’s  and  methodology  associated  with  integrating  SUP  and  NetWeaver  Gateway  for   subscription  and  notification  scenarios.    I’ve  used  2.com   that  way  you  can  easily  copy  and  paste  the  classes  into  your  project  with  little  alteration.2  and  any  other  packages  you  wish  to  download.

  4.    If  you  would  like  to  use  our  sample  code  I  suggest   you  stick  to  csa.g.  Android  2.com.         E.2  API  8. Click  Next.sap.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       3.     5.sap.com  that  way  you  can  easily  copy  and  paste  the  classes  into  your  project  with   little  alteration. Select  the  build  target  from  the  Android  Release  Libraries  you  downloaded  in  the  previous  step. Click  Next.   6.       April  2012   23   . Enter  a  suitable  package  name  like  csa.

How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       7. Click  Finish.     You  will  now  have  an  empty  project  that  represent  the  starting  point  for  development.    The  next  step  is  to   add  the  SAP  shipped  libraries  specific  to  Odata  SDK  and  SUP.       April  2012   24   .

jar   SDMCommon.   2.    Select  from  File  System  and  point  to  the  physical  file  locations.5 Importing Libraries to your Android Application Project 1.jar   SUPProxyClient.  In  your  IDE  project  structure  create  a  folder  called  lib.jar   SDMPersistence.    Make   sure  they  are  highlighted.jar   SDMConnectivity.    You  should  end  up  with  a  project  structure  similar  the  image  below.jar   SDMParser. Copy  the  SUP/Odata  SDK  Libraries  centrally  from  the  following  location:     <UnwiredPlatform_InstallDir>\MobileSDK\OData\Android\libraries\   • • • • • • • • sup-­‐json.             April  2012   25   .jar   ClientLib.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     7.jar     In  the  IDE  import  the  files  to  your  project  under  the  directory  lib.    You  can  do  this  by  selecting  lib  and  right   click  to  find  the  menu  item  IMPORT.jar   SDMCache.

  2.   4.   3.     You  are  now  ready  to  start  developing  your  SUP/ODP  Gateway  enabled  application. Click  OK.  which  is  not  the  aim  here.  locate  and  highlight  all  the  Jar  files  from  in  the  newly  created  lib   subdirectory.    Our  next  chapter  will   look  at  the  API’s  available  and  the  general  process  for  developing  an  application  with  subscription  and   notification  scenarios.    This  process  is  the   same  for  every  project  so  it  makes  sense  to  copy  the  library  files  somewhere  handy.                 April  2012   26   .   1. Check  the  radio  boxes  for  all  the  libraries  you  just  imported  into  the  lib  directory.   3.    Please  refer  to  the  example  project  chapter  to  see  how  to  plug  in  the  shipped  code   sample  into  the  structure  you  just  created  above.   5.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     7. Click  the  Order  and  Export  tab  and  should  now  see  you  Jar  files  are  available  for  selection.           1. Select  the  two  project  GatewayFlightPush  items  and  select  Bottom.6 Setting Project Properties Now  that  our  libraries  are  in  our  project  structure  we  need  to  set  the  project  properties  and  build  path  so   they  are  referenced  correctly.    The  Chapter  developing  your  application  talks  about  the   basic  steps  and  the  approach  without  stepping  through  copy/paste. Click  OK. Select  Add  JARs…    button.   2. Select  Java  Build  Path  from  the  index  and  select  the  Libraries  tab  on  the  main  screen  to  the  right. Click  on  the  top  node  of  your  project  in  the  left  hand  index  and  right  click  to  select  Properties.

h tml     8.sybase.    This  chapter  will  talk  about  the  steps  and  code  examples  in  isolation.    I  have  left  out  some  optional  steps. 2.  model   view  control  patterns  etc.sybase.   You  may  want  to  separate  this  more  and  provide  a  smaller  unit  of  operation  and  it  would  be  recommended   when  considering  productive  scenarios.      How  you  leverage  MVC  and  listener  classes  is  up  to  you.    The  following  steps  highlight  the  approach  with  the   subsequent  sections  giving  more  detail  per  step.    Please  refer  to  the  help   documentation  mentioned  above  to  understand  what  possibilities  exist.    For  productive  scenarios  it  is   recommended  not  to  use  this  example  as  it  doesn't  cater  for  security.    This  chapter  can  be  referenced  with  steps  or  API’s  listed  in  the   Sybase  Help  Website  here:     http://infocenter.  state  change.    It   does  not  go  into  best  practice  for  Android  application  design.1 A typical application The  standard  Odata/SUP/Gateway  enabled  application  follows  similar  process  or  pattern  independent  of   any  subscription  and  notification  requirement.  persistence.com/help/topic/com.    It  is  just  an  EXAMPLE.  which  embrace   alternate  security  and  persistence  activities  and  possible  Afaria  integration.0212/doc/html/nkr1315676693912.infocenter.dc01708. 3.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8. Developing your Application Now  we  are  ready  to  develop  an  application  and  talk  about  the  API’s  available  to  integrate  and  Android   application  with  SUP  and  Gateway. Initialization   • SUP  Onboarding   • Register  for  Push  Notifications  (Long  Poll)     • Retrieve  Endpoints   • Starting  the  client     Calling  Gateway  Services   • Get  Service  Document   • Get  Metadata  Document   • Get  Data  (Flight  Collection)     • Display     Creating  &  Deleting  Subscriptions   • Create  Subscription   • Delete  Subscription     Receiving  Notifications   • Capturing  inbound  notifications       April  2012   27   .    The  sample  application  associated  with  this   document  is  purely  a  demonstration  of  how  the  code  can  be  executed.     1. 4.

How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.    Remember  the   sample  application  associated  with  this  document  demonstrates  how  they  all  work  together  in  sequence   bound  to  a  user  interface.  parameters  and  request  manager.  parser.                   You  can  see  from  the  code  snippet  above  we  need  to  initialize  the  objects  that  will  be  used  in  the  project.2 Initialization The  initialization  phase  start  the  application  and  establishes  connection  to  SUP  with  additional  registration   activities.    I’ve  created  a  method  to  wrap  these  steps  neatly   but  there  is  nothing  stopping  you  from  putting  this  into  one.  logger.     April  2012   28   .    Before  we  even  connect  you  must  initialize  the  objects  or  libraries  we  imported   previously.    We  will  step  through  each  of  these  and  show  some  sample  code  for  each.    From  the  total  SDK  libraries  available  the  following  will  be  used  in  our  application.    How  you  segment  your  code  is  up  to  you.    They  will  be  used  at  length   during  our  interaction  and  calling  of  Gateway  services.   such  as  preferences.  cache.

2.         Remember  the  “Andy/abc”  user  and  activation  code  combination?  Here  is  where  it  is  used.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.1 SUP Onboarding As  we  are  using  SUP  in  this  solution  we  need  register  the  device/user  with  SUP  at  runtime  using  the   matching  activation  code  and  user  we  created  manually  in  SUP.    Have  a  look  at  the  code  snippet  and  see   how  is  it  executed.    You  can  see  we  check  to  see  if  the  device  is  already  registered  with  the  Boolean  check.           April  2012   29   .

 It  is  only   one  line  of  code.2 Start the client In  the  same  segment  of  code  we  start  the  client  to  initiate  the  communications  such  that  the  messages  in   the  pending  queue  of  the  application  connection  for  the  given  device  are  sent  to  the  application.    If  it  has   not  been  registered  the  messaging  happens  automatically  when  you  call  the  registration  method  and  so  is   not  needed.    See  below.2.    If  the  device  has  already  been  registered  the  client  needs  to  be  started  explicitly.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.     April  2012   30   .

      April  2012   31   .    It  is  as  simple  as  one  lin   of  code  but  it  technically  kicks  off  a  long  poll  which  continuously  sends  a  request  to  SUP  every  5  minutes  so   SUP  can  send  notifications  back  as  part  of  the  response.    We  will  talk  about   this  in  the  next  chapter.    This  tells  the  program  that  this   class  will  listen  for  notifications  via  a  specific  method.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.2.    As  mentioned  previously  you  can  implement  your   own  separate  class  to  keep  the  size  reasonable  and  improve  android  application  design.3 Register for Push Notifications (Long Poll) In  the  same  segment  of  code  we  need  to  register  the  application  for  notifications.         If  you  really  wanted  to  see  how  this  works  you  could  set  up  a  http  trace  program  to  sit  between  SUP  and   the  device  and  listen  on  the  5000  port  for  HTTP.    You  can  see  that  we  pass  “this”  to  the  method.    This  was  discussed  in  the  chapter  “Background   Information  –  Push  v  Pull”.

 we  save  them  to   local  variables  and  use  them  later.4 Retrieve Endpoints In  the  same  segment  of  code  we  need  to  retrieve  the  two  URLs  that  were  maintained  manually  by  the  SUP   Administrator.    It  is  up  to   you  to  implement  what  is  suitable  for  your  application  design  best  practice.    Remember  we  did  this  in  the  SUP  configuration  steps?    Once  retrieved.     Application  Endpoint   For  the  Application  Endpoint  or  Gateway  Service  Document  URL  we  can  then  dynamically  build  URLs  at   runtime  with  particular  suffixes  to  call  service  in  the  way  we  wish.    We  will  dynamically  insert  it  into  the   payload  of  a  subscription  request  so  in  Gateway  the  notification  will  come  back  to  the  correct  SUP   landscape  dependent  URL.     The  SDK  offers  a  listener  to  notify  the  client  at  runtime  if  a  change  in  the  URLs  has  taken  place.         Application  URL  =  http://gatewayserver:port/sap/opu/sdata/IWFND/RMTSAMPLEFLIGHT     Then  we  can  build  this  into  various  combinations  at  runtime  such  as  :   • • Application  URL  +  “/FlightCollection”   Application  URL  +  “/BookingCollection”         Push  Endpoint   The  Push  endpoint  will  be  used  later  when  we  create  a  subscription.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.2.    The  example  can  be  seen  below.         April  2012   32   .    It  is  up  to  the  developer  to  save  or  just  check  the  endpoint  each  time.

   It  is  not  the  best  programming  and  is  just  an  example!   April  2012   33   .      As  an  example  there  is  no  point  calling  a  Flight  Collection  when  you  don't  even  know  what   the  structure  of  a  Flight  may  be.  the  application  class  or  an  activity  class.    Note  a  bundle  is  a  series  of  calls  which  will  be  execute  sequentially.  HTTP   Verb  and  payload  if  any.1 Call the Service Document When  you  create  an  Android  application  for  use  with  SUP  &  Gateway  you  need  to  determine  what  class  is   going  to  handle  the  data  calls.3.    You  schedule  a   call  and  execute  and  then  implement  an  onSuccess  and  onError  method  to  capture  the  response  from  SUP   and  Gateway.1.       In  this  code  snippet  you  can  see  I  call  a  helper  method  call  buildRequest.3 Calling Gateway Services At  runtime  the  Android  application  will  need  to  interact  with  Gateway  services.    All  calls  are   asynchronous  from  a  coding  perspective  releasing  the  Android  application  to  perform  other  activities.    Then  we  simply  add  it  to  the  request  bundle  and  fire  the  request  manager  to  make   the  call.  So  its  important  to  execute  these  in  a  particular  order  and  control  it   sequentially.    Over   the  wire  it  is  still  a  synchronous  call.  meaning  the  class  will  receive  the   responses  elsewhere  in  another  method.    This  is  your  decision  as  there  is  nothing  stopping  you  from  putting  it  in  a   standard  java  class.1 Calling In  the  class  you  have  chosen  you  simply  use  the  SDMConnectivity  library  to  build  a  request  and  send  to  the   Request  Manager.    We  need  to  get  the  service   document  and  metadata  document  first  as  this  holds  important  schema  information  for  the  subsequent   collection  calls.    It  is  up  to  you  if  you  want  to   use  bundles  or  not.    These  methods  or  listener  class  can  be  separate  to  the  one  we  have  used.    The  method  can  be  seen  below  and  is  just  an   example  of  abstraction.  then  retrieve  the  metadata  document  and  finally   execute  Data  calls  to  perform  CRUD  operations  with  your  actual  service.    The  next  section  explains  this  in  detail.   8.3.       8.    The  key  point  here  is  we  set  a  listener  to  “this”.       How  is  this  done?    Using  the  API’s  we  easily  build  request  and  send  them  to  the  request  manager.      The  process  is  always  the  same  with  every  Odata  application  running  through  SUP.    I’ve  created  this  to  add  HTTP   headers  and  payloads  depending  on  my  CRUD  operation.    The  screens  shot  below  shows  an  example.    To  do  this  we  need  to  use   the  connectivity  libraries  to  build  Odata  requests  and  send  them  either  as  a  batch  (synchronously)  or  in   isolation.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.    When  we  initialized  the  application  we   create  the  object  requestmanager  so  we  only  have  to  create  a  request  object  and  fill  it  with  the  URL.    The   important  thing  to  note  here  is  the  request  is  not  synchronous  from  the  code  perspective.    Either  way  the  process  is  the  same.       You  need  to  always  retrieve  the  Service  Document.

   I’ve   done  this  to  push  a  dialogue  box  to  the  UI  for  demonstration  purposes.  the  actual  response  is  captured  elsewhere  in  you  class.    In  my  example  I  chose  to  use  a  Boolean  variable  to  wait  for  a   state  change  and  then  continue.    This  is  just  an  example  and  ideally  you  would  not  hold  the  UI  in  such  a  state.     Even  though  we  are  waiting  for  the  response  here.1.  the  code  continues  independent  of  the  request  manager  executing  the  call.2 Receiving Once  the  call  has  been  sent.     To  do  this  you  always  have  to  implement  the  ISDMNetListener  interface  for  the  class  doing  the  work.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       8.    Here  I’ve  declared  it  to  implement  ISDMNetListener.    So   you  need  to  manage  your  code  appropriately.    The   example  below  shows  a  class  called  model.3.     April  2012   34   .    You  can  see  this  in  the  code  snippet  below  from  the  same  segment  of   code  as  the  initial  request.

3 Parsing As  mentioned  above  in  the  onSuccess  method  you  need  to  put  some  logic  to  determine  what  the  response   is  actually  in  response  to.   Notification  or  Collection  call.  Subscription.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       Once  we  have  done  this  we  have  to  implement  two  methods  onSuccess  and  onError.     April  2012   35   .    You  will  do  this  with  every  call  except  you  will  cast  it  to  a  different  entity.    Once  you  have  done  this  you  need  to  parse  the  payload  into  an  existing  Entity   which  is  defined  from  your  service.1.    Have  a  look  at  the  code  snippet  below  and  see  how  we  call  the  parser  for   in  this  case  the  Service  Document.    See  below  for  the  signature   of  each  method.    You  must  implement  them!    For  the  onSuccess  method  you  need  to  interrogate  the   incoming  response  “aResponse”  and  check  for  additional  HTTP  Status  codes.    By  looking  at  the  request   URL  also  you  can  determine  whether  the  response  was  a  Service  Document.3.             8.    These  methods  are   used  to  capture  the  responses  to  any  Odata  calls  we  make  to  Gateway  via  SUP.    Now  you  see  why  we  have  to  call  the  Service  Document  and  metadata   documents  in  a  particular  order.  Metadata.

   All  that  changes  is  the  HTTP  method.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       8.     You  can  see  it  from  the  code  snippet  below.1.       Note  –  See  how  I  used  the  Boolean  statement  at  the  end  to  signal  the  other  method  data  is  available?    You   can  implement  this  however  you  want.    This  is  really  easy  and  is  one  line  of  code.3.4 Caching So  now  that  we  have  captured  and  parsed  a  call  coming  in  from  Gateway  and  SUP  we  then  need  to  put  it   into  the  cache  so  we  can  leverage  it  easily  later  in  our  application.  payloads  and  interrogation   on  the  response  coming  back  in.    It  is  just  an  example.     April  2012   36   .    Once  this  is  done  you  now  have  the  approach  for  all   subsequent  calls  using  this  methodology.

3 Calling   8.    I  will  not  describe  the  process  again  rather  show  the  differences  in  via  code  snippets.3.       8.3.4 Receiving & Parsing & Caching   April  2012   37   .How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.2 Call the Metadata Document So  the  same  process  applies  to  the  metadata  document  except  we  will  use  a  different  URL  and  receive  a   difference  entity.3.

   This  was  direct  decision  as  I  was  not  sure  of  what  data  would  be  available  cross  system.3.         I  will  not  describe  the  process  again  rather  show  the  differences  in  via  code  snippets.    I’ve  chose  to  use  the  $filter  notation  as  an  example  instead  of  an  explicit  read   of  a  unique  flight.3.       8.    You  can  implement   whatever  call  you  want  here.3.5 Call the Data Collection (Flight) Once  again  we  execute  in  the  same  manner  with  some  slight  variations.    I  want  to  call  the  Flight  Collection   so  I  can  display  a  particular  flight  on  the  user  interface  before  we  actually  subscribe.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.7 Receiving & Parsing & Caching April  2012   38   .6 Calling   8.

   More  on  that  later!   8.4.  Remember  all  we  need  to  do  is  call  the   SubscriptionCollection  with  a  HTTP  POST  (Create).  some  HTTP  Headers  (SP2/Sp3  specific)  and  attached  the   payload.    This  document  does  not  describe  how  to  render  the  data.    Let’s  take  a  look  at  how  we  do  this  in  the  code.1 Calling       April  2012     39   .         8.1 Create Subscription The  process  of  create  a  subscription  is  no  different  to  interacting  with  any  other  Gateway  Collection  except   we  just  have  a  specific  payload  to  adhere  to.1.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.    The  sample  code  demonstrates  an  example  of  how  you  could  separate  and  Android  Activity   with  a  model  class  but  is  only  for  demonstration  purposes.4 Creating & Deleting Subscriptions Once  we  have  an  application  running  and  the  core  Gateway  services  in  cache  we  can  display  the  data   appropriately.4.    What  is  really  nice  about  the  Odata  SDK  is  the  classes  will  help   you  build  the  subscription  payload  very  easily.  as  it  is  really  core  Android   programming.

   I   am  just  connecting  the  end-­‐to-­‐end  scenario  for  a  demonstration.com/ado/2007/08/dataservices"> <d:deliveryAddress>http://SUPHOST:8000/GWC/SUPNotification</d:deliveryAddress> <d:collection>FlightCollection</d:collection> <d:filter></d:filter> <d:select>*</d:select> <d:persistNotifications>false</d:persistNotifications> </m:properties> </atom:content> </atom:entry>    The  following  table  describes  the  most  important  XML  elements  and  their  meaning  in  relation  to  our   scenario.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.org/2005/Atom"> <atom:id/> <atom:title>Subscription</atom:title> <atom:author/> <atom:updated/> <atom:content type="application/xml"> <m:properties xmlns:m="http://schemas.    If  there  are  two  or  more  SM59  destination  it  will  retrieve   the  first  entry  only.       <atom:entry xmlns:atom="http://www.    We  will   put  a  trace  on  this  location  to  demonstrate  what  is  posted  in  when  a  Backend  Business   Object  event  is  created.g  If  the  filter  is  left  empty  we  will  subscribe  to  all  material   creation  events.    This  complies  to  the  normal  Odata  $filter  notation  and  supports   only  AND  operators.w3.microsoft.    The  following  is  an  example  of  Sales  Order.    In  our  sample  application  we  are  not  subscribing  to  a  particular  flight  using  the  filter  element.     Element   Description   title   This  can  be  any  text   deliveryAddress   Specifies  the  location  of  subsequent  notifications  for  Business  Object  events.microsoft.    If  you  are   unsure  of  this  name  you  can  always  search  for  it  in  the  metadata  document  available  by   performing  a  HTTP  Get  on  http://<Gateway  hostname>:<Gateway  host  http  port>   /sap/opu/sdata/sap/<your  service  document>/$metadata   filter   A  filter  enables  the  user  to  either  subscribe  to  all  business  object  instances  or  only  a   specific  entity  instance.G.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     What  does  that  actually  build?    The  XML  Payload  can  be  seen  below.   Collection   The  Gateway  Business  Object  Collection  created  in  the  pre-­‐requisite  scenario.    We  can  put  something  like  the  following  to  subscribe  only  to  a  specific   material.    For  mobile  scenarios  with  SUP  this  URL  can  be  retrieved  dynamically   from  SUP  application  connection  properties  set  by  an  administrator.  <d:filter>value  eq   '0000004003'  and  scheme_id  eq  'SALES_ORDER'  and  scheme_agency_id  eq   'Q5K_004'</d:filter>   April  2012   40   .    E.    At  runtime  this  URL  and  port  is  compared  to  the  HTTP   destinations  defined  in  SM59.    E.

   This  is  the  responsibility  of  the  application  in  the  backend  to  populate  the   entire  payload  or  business  object  contents.   persistNotifications   This  element  determines  if  notifications  are  sent  (pushed)  to  SUP  and  persisted  or   whether  they  are  stored  in  Gateway  for  later  retrieval  via  a  pull.    This  uniquely  identifies  the  subscription  so   you  can  unsubscribe  later.4.     8.    Note  you  will  need  to  check  the  HTTP  response   codes  as  they  will  bring  back  201  and  possibly  204  for  a  successful  create.2 Receiving & Parsing & Caching The  same  process  applies  for  creating  the  subscription.    Remember  you  need  to  save  the   subscription  GUID  that  comes  back  from  the  Gateway  Server.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     select   Either  *  or  blank.     Example  :   http://<hostname>:<port>/sap/opu/sdata/iwfnd/NOTIFICATIONSTORE/NotificationCollect ion?$format=xmlsap-­‐client=<clientnumber>   Note  –  This  is  only  supported  when  implementing  subscription  and  notification  when   using  the  OData  channel.        To  retrieve   notifications  via  pull  you  need  to  call  a  different  service  all  together.    It  is  possible  to  retrieve  the  object  content  instead  of  just  the  event   information.    Please  consult  the  backend  application   documentation  to  understand  if  this  is  supported.           April  2012   41   .1.    You  simply  check  the  request/response  information   in  the  onSuccess  and  then  parse  and  cache  accordingly.

2.4.    We  don't  need  to   parse  or  cache  the  response.  as  it  will  be  empty.2 Delete Subscription Deleting  a  subscription  is  very  easy  and  follows  the  normal  convention  of  deleting  an  entity  in  a  RESTful   paradigm.2 Receiving   April  2012   42   .How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.    We  combine  this  with  some  HTTP  headers  and  the  HTTP  verb  DELETE.2.1 Calling   8.    As  long  as  it  is  successful!   8.4.4.    All  we  need  to  do  is  build  a  URL  with  a  suffix  of  SubscriptionCollection  and  the  unique  ID  we   want  to  delete.    You  may  just  want  to  delete  any  cache  items  to  be   consistent.

1 Receive & Parse & Cache The  code  below  shows  the  same  process  is  followed  in  the  onSuccess  method.    This  is  done  with  the  setChanged  and  notifyObserver  methods.   8.           Given  in  here  I  cannot  raise  UI  events  or  interact  the  notification  center  I  use  a  observer/observable  pattern   to  notify  the  Activity  class.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     8.    All  we  need  to  do  is  use  the  same  onSuccess  method  to  check  the   inbound  message  and  see  if  it  is  a  notification.    The  difference  here  is  in  my   application  I’ve  separated  the  Activity  class  (UI)  with  the  model  (calls/etc)  class.    So  we  don't  have  to  do  the  call  here  is  just  a  case  of  receive.   parse  and  cache.    This  retrieves  it  from  the   cache.   The  code  snipper  below  comes  from  my  Activity  class  (DIFFERENT)  and  shows  how  I  receive  the  state   change  and  then  retrieve  the  notifications  from  the  model  using  a  get  method.         April  2012   43   .5.    This  is  really   outside  the  scope  of  this  document  as  its  up  to  you  to  determine  how  to  design  your  Android  application.5 Receiving Notifications When  a  trigger  occurs  Gateway  or  a  Backend  the  notification  comes  into  SUP  and  into  the  device  via  our   long  poll  mechanism  described  earlier.

   You  can  see   that  below.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       The  step  in  the  Activity  class  is  just  to  pass  it  to  the  notification  center  of  the  operating  system.    It  is  just  an  example.                                   April  2012   44   .

java)   The  Activity  class  was  automatically  created  for  you  when   you  created  the  project.xml   The  android  manifest  xml  document  is  created   automatically  however  we  need  to  make  alterations  to   allow  permission  for  accessing  phone  capabilities.    It  is  just  a  connectivity  example.xml   These  files  are  stored  under  the  folder  /res/layout  directory  and  describe  the  screen  layout.    This  is  the  class  that  implements  the   SUP/Odata  SDK  specific  interfaces  with  the  onSuccess  and   onError  methods.    This  is  not  production  worthy  as  it  is  just  an  example!    There  are   only  two  classes  and  three  other  files  requiring  change  in  this  project:     • • • • Activity  –  (GatewayFlightPushActivity.       April  2012   45   .    You  will  not  see  this  if  you  use  Apple  Preview.java)   This  class  represents  the  engine  room  for  interaction  with   SUP  and  Gateway.com     Model  –  (Model.    Please  use  your  own  java  class  pattern  combination  that  suited  your   requirements  and  is  production  worthy.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     9.sap. Running the Sample Application 9.    The  sample  application  is  attached!    Please  use  Adobe  Viewer  to   view  the  attachments.xml  &  Main.  onboarding  and   eventing  capability  from  which  the  activity  class  would  call   as  required.     Layout_border.com     AndroidManifest.    It  handles  the  calling.    This  file  is  located  in  the   folder  src/csa.    This  file  is  located  in  the  folder   src/csa.1 Application Structure The  sample  application  mentioned  in  this  document  is  really  simple  and  does  not  reflect  a  complete   approach  to  Android  application  design.    This  class  handles  the  lifecycle  of   the  application  and  enables  interaction  with  the  user   interface.sap.    I’ve  abstracted  the  data  calls  away  from  this   class  to  demonstrate  abstraction.   which  enables  the  basics.

   //  SUP  Server  Host   protected  static  final  String  SUP_PORT  =  "5001".How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     9. Change  the  GW_PASSWORD  and  GW_USERNAME  to  equal  your  intended  SAP  NetWeaver  Gateway   credentials.1.     April  2012   46   .2 Change Model.   Change  the  SUP_HOST  and  SUP_PORT  to  reflect  your  SUP  specific  information.2 Preparing the Application 9.      //  SUP  User  Name   protected  static  final  String  SUP_ACTCODE  =  "abc".java Before  we  can  run  the  application  you  need  to  make  changes  to  the  model  class  replacing  the  user  logon   information  specific  to  your  landscape.          //  Activation  Code   protected  static  final  String  GW_USERNAME  =  "XXXXX".              //  SUP  Port   protected  static  final  String  SUP_COMPANYID  =  "0".     9. 2.2.   You  should  not  need  to  change  the  SUP  username.  activation  code  and  application  if  you  followed   the  instructions  correctly  in  the  previous  chapters.  //  Gateway  User  Name   protected  static  final  String  GW_PASSWORD  =  "XXXXX".    In  some  cases  you  will  need  to   overwrite  and  existing  file.  //       1.2.                     //  Settings  for  Connectivity   protected  static  final  String  SUP_HOST  =  "10.1 Copy the files To  make  you  application  runnable  you  need  to  copy  and  paste  the  files  listed  above  which  are  attached  to   this  PDF  document  into  the  directory  structures  mentioned  above.1.    In  a  productive  environment  you  would  leverage  the  vault  api  and   not  embed  the  username  and  password  information  in  the  code!    Please  change  the  following. 3.55".          //  Farm  ID   protected  static  final  String  SUP_USERNAME  =  "Andy".  //  Gateway  Password   protected  static  final  String  SUP_APPLICATION  =  "Gateway_Flight_Push".

The  application  loads  and  steps  through  the  SUP  onboarding  and  gateway  service  call  process. The  application  UI  shows  the  steps  are  being  performed.     April  2012   47   .3 Running the application Run  the  application  as  per  a  normal  Android  application  and  view  the  SUP  logs  to  see  the  interaction.    I   highly  recommend  you  debug  this  application  first  as  you  will  see  meaningful  debugging  information  in  the   logcat  view  within  the  eclipse  environment.     Activation/Registration.    You  should  see  the  following  screens  if  the  services  are  called   correctly.    You  can  see  these  below.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     9.     You  can  check  in  SUP  SCC  to  see  the  application  connection  shows  the  device  or  simulator  is   registered!         2.           1.

You  should  see  the  Gateway  Services  being  called  Service  Document.             April  2012       48   .  Metadata  Document  and   finally  the  Data  Collection.  For  us  the  FlightCollection.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       3.

  To  perform  a  subscription  click  the  subscribe  button  and  wait  for  the  subscription  create  call  to  be   executed.                                         5.    Log  into  the  gateway  instance  and  run  the  sample  report  that  will  trigger  a   notification  for  the  flight  scenario. 6.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android   4.    For  more  info  please  see  the  next  chapter  notification   routing  explained.     Remember  this  is  just  an  example  of  the  end-­‐to-­‐end  connectivity.    You  should  see  the  subscription  status  updated  appropriately.    Also  look  at  the  SUP  logs  to  see   how  the  notification  is  routed  to  the  device.   In  the  application  you  should  see  the  event  notification  arrive  and  displayed  appropriately.                                               April  2012   49   . Once  this  is  done.    The  report  is  “/IWBEP/R_MGW_PUSH_TEST”.

 Create  Subscription   The  client  uses  the  URL  and  suffixes  with   application  connection  id.  Receive  Notification   Client  accepts  response  in  specific  method  if     online.  user. Notification Routing Explained So  the  big  question.  Trigger  Notification   Once  the  notification  is  in  Gateway  the  SM59   destination  with  a  constant  host.  APNS  etc.1.   ONLINE  NOTIFICATIONS  RETRIEVED  FROM  SUP   5.  port  and  basic   URL  prefix  is  matched  to  previous  step  persisted   in  a  table  at  subscription  creation  time.  Activation   The  client  retrieves  the  URL  and  saves.       NOTIFICATION  SENT  TO  SUP   If  notification  persisted  =  true  then  notifications   stored  in  gateway  for  later  PULL  and  not  sent  to   SUP.    This  is   Gateway_Flight_Push   the  KEY!   Application  Id  =  Gateway_Flight_Push   User  =  Andy   Domain  =  default     3.     SUP  checks  if  offline  connectivity  settings  exist.   2.     Step   1.   APNS  etc.   NOTIFICATION  PERSISTED  IN  GATEWAY   FORMAT  =   http://SUPHOST:port/GWC/SUPNotification/Applica tionConnectionId/User/Application/Domain   http://SUPHOST:8000/GWC/SUPNotification/Simul ator3930223a-­‐f36f-­‐4da7-­‐a47c-­‐573acb106e6c__   Gateway_Flight_Push   /Andy/Gateway_Notification/default   4.    Client  accepts  response  from  proprietary   messaging  service.  Registration   Key  Info   Example   Push  Notification  Endpoint  URL  maintained  in  the   http://SUPHOST:8000/GWC/SUPNotification   application  connection  properties.  Client  may  call   notification  service  if  PULL  scenario  chosen   NOTIFICATION  ACCEPTED   April  2012   50   .  application  and   domain  and  includes  in  subscription  create   payload  element  deliveryAddress.  How  is  subscription  and  notification  bound  and  what  information  is  required  to  reverse   route  back  to  the  device?    The  table  below  shows  the  key  information  and  routing  process.   NOTIFICATIONS  STORED  IN  GATEWAY   SUP  looks  at  application  connection  table  and   compares  with  the  full  URL  used.1.   SM59  Destination   Target  Host:  10.   Application  Connection  Id  =  Simulator3930223a-­‐ In  the  application  connection  SCC  screen  the   f36f-­‐4da7-­‐a47c-­‐573acb106e6c__   values  are  assigned  as  seen  to  the  right.How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     10.55   Service  No:  8000   Path  Prefix:  /GWC/SUPNotification   DEVICE  &  USER  FOUND   SUP  checks  if  user/application  is  online  or  offline.   NOTIFICATION  SENT  TO  DEVICE   Application  loaded  in  foreground.

1)  Android  C2DM  is  not  supported.    Also  the  intention  for  using  APNS  and  NOC  is  to  not  channel  the   payload  through  this  mechanism  but  rather  trigger  the  application  to  load  in  foreground  and  perform  an   online  notification  against  the  pending  device  specific  queues.       April  2012   51   .How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android       11.Communication Architectures (Device Specific)   The  communications  between  SUP  and  device  in  online  mode  utilize  HTTP/s  however  what  we  have  not   discussed  thus  far  is  the  use  of  3rd  party  device  specific  messaging  services  such  APNS  or  BES.    For  more  detailed  configuration  steps  please  see  the  relevant  How-­‐To  guide  for  each  device.    The  first   step  in  the  process  flow  dictates  that  these  settings  must  be  maintained  against  the  application  connection   properties.1.     Apple  and  Blackberry  notification  services  are  supported  however  at  this  point  in  time  (Gateway  SP3  &  SUP   2.    The   following  diagram  illustrates  the  relationship  between  SUP  and  the  device  specific  architectures.

 Read.    This  means  that  a  user  or  application  can  Query. Appendix – Subscription Collection   The  subscription  collection  bound  to  you  enabled  Gateway  service  follows  the  same  principal  as  any   Gateway  service.  HTTP  verb  and  payload.  Create.     Action   HTTP  Verb   Request  Payload   Sample  URL   Query   GET   Empty   …/SubscriptionCollection   Read   GET   Empty   …/SubscriptionCollection(‘ID=1323098ASDAS’)   Create   POST   Subscription  Entity   …/SubscriptionCollection(‘ID=1323098ASDAS’)   Delete   DELETE   Empty   …/SubscriptionCollection(‘ID=1323098ASDAS’)   Update   PUT   Subscription  Entity   …/SubscriptionCollection(‘ID=1323098ASDAS’)             April  2012   52   .How-­‐To…Subscription  &  Notification  with  SAP  NetWeaver  Gateway  -­‐  Android     12.  Update  and  Delete   subscriptions  simply  by  using  the  combination  of  URL.

www.sdn.sap.com/contactsap www.com/irj/sdn/howtoguides         .sap.