Beruflich Dokumente
Kultur Dokumente
com/2013/04/02/my-journey-creating-a-sapui5-mobile-app-at-home-part-i/
Nicolas Busson
share 0
share 0
tweet
share 0
like0
Follow
Starting point
Im a SAP CRM functional consultant (hence the serie for dummies), highly interested in the dark side,
a.k.a technical development. So Ive already downloaded and installed The specified item was not found. on a
virtual machine running Windows 7 64Bits using VirtualBox. This allows me to create any VM I need, scratch
them and come back with a fresh install in a second. But until now, I never used the Gateway capacity of my
Netweaver installation (my virtual machines were not even visible on my network, and didnt have any access
to the Internet as I used the Loopback Adapter technique). So to be able to communicate between my mobile
phone and my VM where SAP Gateway was running, the first thing I had to do was to adapt my VM
settings
1
Step 1: make your VM visible on the network
Go to your VM settings, click on the Network tab, mark the Enable Network Adapter and select the
Bridged Adapter as shown in the picture below :
2
Click Next until the end and close the popup (you can cancel the step where youre asked to enter a
password to join Workgroup domain).
Then go to Network and Sharing center from the control panel. Disable any other network connection (in my
case it was the loopback adapter). For this, first click on the Local Area Connection as shown in the picture
below:
In the popup that will come up, click the Disable button:
3
Now edit your host file located in C:\Windows\System32\drivers\etc to add those last 2 lines (of course youll
have to change 192.168.0.9 so that it corresponds to the IP address you chose at step 2):
Try and start your SAP system via sapmmc: everything should work as before, and if you start Internet
Explorer from within your VM, you should have access to the Internet. If youre facing issues starting your
SAP instance (youre stuck with an orange light in your sapmmc console for example), try to shutdown and
reboot your VM. It should work.
Conclusion
It took me approx. 20 minutes to get everything ready, although I already had a SAP Netweaver ABAP trial
with SAP Gateway up and running that I used to develop many projects available on code exchange Lets
see what will come up with the next steps: go to Part II.
Nicolas Busson
share 0
share 0
tweet
share 0
like0
Follow
4
Part II: Create your first service with SAP Gateway
Part III: Develop your mobile app on Eclipse
Part IV: Test your mobile app on your phone
Part V: Troubleshooting and finally make it work!
Useful links:
New E2E Tutorial: Gain Hands-on Developer Experience with SAPUI5 and SAP NetWeaver Gateway
Gateway Service Builder (SEGW) with a focus on DDIC Importer
A popup will be shown where you have to click the Activate button.
Then click the Manage SAP system aliases as shown below:
Start tcode SICF and activate service Default_Host/sap/opu and all its subnodes:
5
Step 2: create a new project
Start tcode SEGW and click the New button to create a new project which will hold our brand new service
dedicated to read business partner data (I created everything as local objects because obviously on my own PC
I do not intend to transport anything, but remember to enter a correct package on a real development
system):
Right click the Data Model Node and select Import >> DDIC Structure
6
In the next screen, select structure BUT000, flag checkbox As entity type and press Enter (if you do not
press enter at this point in time, the system will overwrite the name of the entity and give it the name of the
structure). Now fill in the name Partner and select the components you want. On my system I marked every
component with usage Ignore except the following ones:
Now double click on the node named Entity Set, and add the following entry:
In fact, the name of my entity was the same as one of its component which seems to be forbidden. So lets
fix it by double clicking on the Properties subnode of our Partner entity, and rename component Partner
to PartnerNo:
8
To keep things very simple, I decided to return every entry found in BUT000 table (in my case this is a
sandbox system so this table contains only 2 entries):
Now redefine method PARTNERSET_GET_ENTITY. As far as Im concerned I used the same KISS
principle as above:
9
Click the Add service button
Fill-in the required information to retrieve your service and select its technical name:
In the popup that is displayed you do not have to change any value. Just fill in a package name:
10
Come back to the previous screen: you should now see your Z_Partner service. Click the Call browser
button to test it:
If everything goes as expected, you should see something like this (meaning the service is up and running):
11
Step 5: troubleshooting
OK nice, our service seems to work fine. But is it?
If you try to start the following URL, you should see a list of business partners:
http://<host>:<port>/sap/opu/odata/sap/Z_PARTNER_SRV_SRV/PartnerSet
But instead of the expected list, youll probably face an HTTP 500 error page:
In my case that was happening because I selected components CHDAT and CHTIM when I created the
Partner entity Unfortunately if those fields are left blank in the database, the service is throwing an
exception at some point in the program. So I expected this to be a bug in the software and searched for OSS
notes. [Update: thanks to Sebastien BENOIT who added a comment below, I now know that I should have
marked the checkbox nullable in the entity types properties to tell the system that this exception could be
ignored].
However, as I couldnt find any patch, I tried to simply remove those components from my service definition
by clicking the delete button (tcode SEGW >> Data Model >> Entity Types >> Partner >> Properties) :
12
I saved and activated my service again.
But the problem still remained so I analyzed the service metadata via the following URL:
http://<host>:<port>/sap/opu/odata/sap/Z_PARTNER_SRV_SRV/$metadata
I realized that even though those components were successfully removed via tcode SEGW, they were still there
in the service definition So I suspected another bug in the software. [Update: to regenerate your service
after a change, it seems that you need first to delete the assignment to a system, then delete the service itself,
only then will your changes be taken into account]
Again, I couldnt find any notes, and I didnt know how to change the service metadata manually, so instead of
creating a new service from scratch again, I opened all business partners created in my system (they were only
2) to change of one their properties. After saving my modifications, fields CHDAT and CHTIM were no
longer empty in the database and the service was working smoothly:
Conclusion
It took me approx. 4 hours to reach this point where I finally have a Gateway service up and running on my
laptop Lets see if I can create a mobile app consuming that service now: go to Part III.
My journey creating a SAPUI5 mobile app at home [Part III]
April 3, 2013 | 169 Views |
Nicolas Busson
share
share
tweet
13
share
like0
Follow
But as in the end Im planning to use SAPUI5 to develop my application (because they say its cool), I
chose Eclipse IDE for Java EE Developers as mentioned in the corresponding installation guide (after wasting
my time on a few other versions, of course). By the way it is also mentioned in the very same document that
Java Runtime Environment 1.6 should also be installed.
Thats why I ran through those steps:
1. Download and Install the java runtime environment (version 6 = 1.6?) jre-6u43-windows-
x64.exe (16,4 Mo)
2. Download eclipse-jee-juno-SR2-win32-x86_64.zip (228 Mo)
3. Extract content of eclipse-jee-juno-SR2-win32-x86_64.zip to C:\
(apparently Eclipse is ready to go without the need for any further installation)
1. Download UI Development toolkit for HTML5 (I found this link in the second comment of
blog SAPUI5 version 1.8 is available but I guess for a production use you should always download
the latest version from SMP, see Note 1747308 Installation Guide UI development toolkit for
HTML5 (SAPUI5))
2. Extract content to C:\sapui5
3. Open Eclipse (I let the system choose the default workspace location)
4. Go to Help >> Install new software
14
5. Click on Add >> Local >> C:\sapui5\tools-updatesite. Select everything displayed as below:
At this stage I was able to create a very simple Hello World application using SAPUI5 libraries following
this article:How to Build a SAP HTML5 Application Using MVC with the SAPUI5 Application Development
Tool. However, in order to benefit from some wizards related to SAP Gateway when creating my a-little-
more-complex application (to search for existing services for example, let the system generate views for me,
etc.) I installed SAP Netweaver Gateway Plug-in for Eclipse too:
Then follow the wizard to give your project a name, a type (HTML5), a template (List/Detail based on
SAPUI5).
Click the Catalog button to search for the Gateway service created in Part II.
And if you followed exactly the same steps as mine, youll be facing this error There are no addressable
collections in the service:
Step 4: troubleshooting
It is not possible to complete the wizard without solving the above problem. So after some research, I found
out that when creating your entity set (see Part II step 2), you should flag the Addressable checkbox. But,
when I did this and tried to re-generate my service, I faced the exact same issue as in Part II step 5: the system
kept telling me that everything was correctly generated, but nothing was changed at all (Im wondering if this
is because Im creating LOCAL objects I dont know really). [Update: Sebastien BENOIT added a
comment to part II of this blog series explaining that to regenerate your service after a change, you need
first to delete the assignment to a system, then delete the service itself, only then will your changes be taken
into account so thats worth giving it a try instead of recreating the service from scratch like I did below]
The problem is: this time I couldnt find any workaround (deleting the generated classes to force the system to
create new ones seems to have no effect), so I had to create a new service from scratch. And to avoid any more
surprises (even if the Addressable flag is probably the only one missing) I flagged almost every checkboxes:
16
I saved my new service, activated it, etc. (see Part II step 3 and 4).
Once done, I was able to complete the Eclipses wizard in order to create my SAPUI5 mobile app with two
views:
However I couldnt test it: when selecting the index.html page that had been generated for me, and choosing
Run as >> Web App Preview in the context menu, only a blank page was displayed. I spent a lot of time
trying to understand the reason behind this failure. In the end I gave up. As far as I understand, this problem
could be related to some Cross-domain-origin policy and you need to install/configure a reverse proxy to
by-pass this limitation (which is above my current skills). So lets cross our fingers and see if we can still
deploy this app on our mobile, and use it.
Conclusion
When you dont know anything about the Eclipse world it is not that easy to come up and build your first
app and even after a few tries and errors I wasnt able to figure out how to test my application (I spent an
entire day trying to understand what was wrong). And now Im crossing every fingers hoping that this mobile
app will work once it is installed on my own phone (an old HTC Desire running Android 2.3). Go to Part IV.
17