125
SAP How-to Guide SAP Mobility SAP Mobile Platform (SMP) provided by SAP Mobile - Rapid Innovation Group Applicable Releases: SAP Mobile Platform 2.3 Agentry 6.x Version 1.0 June 2013 How To - Part 1: Build an Agentry based app from scratch connecting to a SAP ERP back-end

How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

Embed Size (px)

DESCRIPTION

How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

Citation preview

Page 1: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

SAP How-to Guide SAP Mobility SAP Mobile Platform (SMP)

provided by SAP Mobile - Rapid Innovation Group

Applicable Releases:

SAP Mobile Platform 2.3 Agentry 6.x

Version 1.0

June 2013

How To - Part 1: Build an Agentry based app from scratch connecting to a SAP ERP back-end

Page 2: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

© Copyright 2013 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form

or for any purpose without the express permission of SAP AG. The

information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors

contain proprietary software components of other software vendors.

Microsoft, Windows, Excel, Outlook, and PowerPoint are registered

trademarks of Microsoft 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,

MVS/ESA, AIX, Intelligent Miner, WebSphere, 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 Motif are registered trademarks of the Open

Group.

Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame,

and MultiWin are trademarks or registered trademarks of Citrix Systems,

Inc.

HTML, XML, XHTML and W3C are trademarks or registered trademarks

of W3C®, World Wide Web Consortium, Massachusetts Institute of

Technology.

Java is a registered trademark of Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems, 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 mentioned herein as well as their respective logos are

trademarks or registered trademarks of SAP AG in Germany and other

countries.

Business Objects and the Business Objects logo, BusinessObjects,

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

Business Objects products and services mentioned herein as well as their

respective logos are trademarks or registered trademarks of Business

Objects Software Ltd. Business Objects is an SAP company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere,

and other Sybase products and services mentioned herein as well as their

respective logos are trademarks or registered trademarks of Sybase, Inc.

Sybase is an SAP company.

All other product and service names mentioned are the trademarks of

their respective companies. Data contained in this document serves

informational purposes only. National product specifications may vary.

The information in this document is proprietary to SAP. No part of this

document may be reproduced, copied, or transmitted in any form or for

any purpose without the express prior written permission of SAP AG.

This document is a preliminary version and not subject to your license

agreement or any other agreement with 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 may be changed by SAP at

any time without notice.

SAP assumes no responsibility for errors or omissions in this document.

SAP does not warrant the accuracy or completeness of the information,

text, graphics, links, or other items contained within this material. This

document is provided without a warranty of any kind, either express or

implied, including but not limited to the implied warranties of

merchantability, fitness for a particular purpose, or non-infringement.

SAP shall have no liability for damages of any kind including without

limitation direct, special, indirect, or consequential damages that may

result from the use of these materials. 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 may access

through the use of hot links contained in these materials and does not

endorse your use of third-party Web pages nor provide any warranty

whatsoever relating to third-party Web pages.

SAP “How-to” Guides are intended to simplify the product implement-

tation. While specific product features and procedures typically are

explained in a practical business context, it is not implied that those

features and procedures are the only approach in solving a specific

business problem using SAP NetWeaver. Should you wish to receive

additional information, clarification or support, please refer to SAP

Consulting.

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.

Page 3: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

Document History Document Version Description

1.00 First official release of this guide

Page 4: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

Typographic Conventions Type Style Description

Example Text Words or characters quoted from the screen. These include field names, screen titles, pushbuttons labels, menu names, menu paths, and menu options. Cross-references to other documentation

Example text 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.

Icons Icon Description

Caution

Note or Important

Example

Recommendation or Tip

Page 5: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

Table of Contents

1. Business Scenario .................................................................................................................1

2. Background Information .......................................................................................................1

3. Prerequisites ..........................................................................................................................1

4. Step-by-Step Procedure ...................................................................................................... 2 4.1 Agentry Server installation .............................................................................................. 2 4.2 Agentry Editor Plugin installation ..................................................................................13 4.3 Create Application Configuration in SAP ERP back-end ........................................... 23 4.4 Building a Fetch mechanism for the mobile app (Agentry Editor) ........................... 32

4.4.1 Create an Agentry Project ................................................................................ 32 4.4.2 Create a System Connection in the Agentry Project .................................... 38 4.4.3 Add a New Object in the Agentry Project ....................................................... 39 4.4.4 Create Required Java Files ............................................................................... 41 4.4.5 Create Properties for the Object with Agentry Connector Studio ............... 55 4.4.6 Create the Business Logic in the SAP ERP Backend ..................................... 58 4.4.7 Create Required ABAP Classes ....................................................................... 60 4.4.8 Create Required BAPI Wrapper ....................................................................... 63 4.4.9 Create Mobile Data Object in the Config Panel .............................................. 64 4.4.10 Agentry Editor Java Definitions ....................................................................... 69 4.4.11 Create Steps and Assign Fetch ....................................................................... 83 4.4.12 Create Screens, Screen Sets and Actions...................................................... 86 4.4.13 Publish Application to the Server .................................................................. 100 4.4.14 Add Application Parameters in Config Panel ............................................... 106 4.4.15 Test Application in ATE .................................................................................. 109

5. Appendix ............................................................................................................................ 114

Page 6: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

1. Business Scenario This How-to guide will show you step by step how to create a very simple mobile app based on Agentry, which will fetch flight information from an SAP ERP back-end and display it on the mobile device/Agentry Test Environment.

2. Background Information The Agentry technology also allows building custom mobile apps and this How-to guide is meant to show how you can start the scratch with building a metadata driven app using the Agentry technology and connecting to an SAP back-end. The example we are providing here is aiming at building a simple mobile app that fetches data from an SAP ERP back-end and displays that data on the mobile device. At the end of this guide, you will be able to see data from the back-end in your mobile app simulation in the Agentry Test Environment tool. For that purpose, this guide will take you through the installation of the software components, the creation of an Agentry project in the development environment, the required ABAP classes in the back-end and the required Java classes in the Agentry project to be able to fetch the data from the back-end, as well as the UI elements in the Agentry project to build the mobile app display of data.

3. Prerequisites In order to be able to follow all the steps mentioned in this guide, you need to have the following in place:

• An installed and running SAP ERP system that you can connect to and for which you have a developer key

• Agentry SAP Framework Administration installed in the SAP ERP back-end you intend to use in this exercise

• Access to the installation file for Agentry Server 6.0.XX as a standalone or Agentry Server 6.1.03 as part of the SAP Mobile Platform 2.3*

*If you have the SAP Mobile Platform 2.3, in order to be able to develop a new Agentry based app, you will need the SAP Mobile SDK as well, which will include the Agentry Development Server, the Agentry Editor plugin, the Agentry Test Environment

• Access to the installation file for Agentry Server Administrator 6.0.31 or higher • Access to the installation file for Agentry Editor Plugin (either individually downloaded from

the SAP Service Marketplace or as a part of the SAP Mobile SDK 2.3) • Installed Eclipse Indigo 3.7.2 on the machine where you intend to do this exercise • Installed JDK 1.6 or higher on the machine you will be using for this exercise • Valid license keys • Administration rights on the machine you’re working on

You can install the Agentry Server, the Agentry Editor and the Agentry Test Environment components on the same machine. A previous understanding of the Agentry technology is a must for this How-to Guide. ABAP and Java understanding is recommended.

October 2013 1

Page 7: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4. Step-by-Step Procedure First we need to setup our development environment and install the Agentry Development Server as well as the Agentry Editor. Next we are going to create a new Application Configuration in the Configuration panel available in the SAP ERP back-end. This will be your application configuration which will be used by your Agentry server, to know which MDO’s/BAPI Wrappers in the backed ERP system are going to be used. By doing this your Agentry server uniquely talks to your application configurations and in turn your own MDO Objects and BAPI Wrappers. Once this step is done you will be set to create you first Agentry mobile application connecting to an SAP ERP backend. Then we will create a mobile application to display a list of Flight schedules with the following information Flight date, Airport From, Airport To, Carrier ID. In the example SAP ERP back-end we are using, the information needed for these 2 screens are available in 3 different tables SFLIGHT, SPFLI and SCARR. You need to create the backend business logic to get this information and an Agentry app with definitions for the Fetch mechanism which will bring the data from the back-end system, as well as the UI elements to display this data on the device or the Agentry Test Environment. In addition to this, you will need to create in your Agentry Project the Java Classes required to call the SAP back-end and provide the information to your Agentry mobile app. The business logic and BAPI Wrapper is made available to you by a template class (Z00_GET_FLIGHT_SCHEDULE) and template BAPI Wrapper (Z00_BAPI_GET_FLIGHT_SCHEDULE), for which the source code is available in the Appendix section of this document. Once the business logic is created and the fetch mechanism is built you can test your mobile app by displaying the example data from the SAP ERP back-end in the Agentry Test Environment.

4.1 Agentry Server installation ... Exercise 1 - Agent ry Serv er Ins tall ation

1. Right Click on the File Agentry_6.1.xx_Server_x64.exe on a 64-bit machine or Agentry_6.1.xx_Server_win32.exe on a 32-bit machine.

2. Right-click and select Run as Administrator 3. Based on your System User Access Control Settings, you may get a prompt like the one

below asking you to confirm running the File with Administrator Privilege

October 2013 2

Page 8: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4. Click on Yes

5. Click Next to Start the Agentry Server Setup

October 2013 3

Page 9: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

6. Click on Yes to Agree to the License Agreement and continue with the installation

7. Enter the Server Serial Number provided to you, and click on Next

October 2013 4

Page 10: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

8. Enter the User Key, Device Key and Expiration Key, and click on Next

9. Uncheck the Production Server and select only the Development Server option and click on

Next

October 2013 5

Page 11: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

10. Provide Agentry Server installation location and click on Next

11. Uncheck all the options on the screen: below Create shortcut… and Install Development

Server as a Service and then click on Next.

October 2013 6

Page 12: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

If the “Install Development Server as a Service” option is checked the Agentry Development Server will be installed as a Windows Service. For the purpose of our exercises and ease of use, we will not use this option, because we will have to restart the server several times.

12. Installation begins and may take a minute or so to complete.

13. In some cases you might be prompted with the above message. Click on Ok, this is because

the server tries to install a VC runtime and you might get this message if the VC Runtime is already available in your system and the installation is unable to overwrite.

October 2013 7

Page 13: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

14. Once the installation is complete you will get the above screen, Click on Finish

You have now successfully installed the Agentry Development Server on your system. Next, we will add JAVA to our system PATH (so Agentry can easily locate JVM, Java, etc.). Click Start menu and type “System Environment Variables”

October 2013 8

Page 14: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

15. Click on “Edit the system environment variables”

October 2013 9

Page 15: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

16. Click on the button

October 2013 10

Page 16: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

17. Under System variables, click “Path” variable and click on the button

18. Review the path and ensure the following path exists else add it to the beginning to the path

C:\[JDK_LOCATION]\bin;C:\ [JDK_LOCATION]\jre\bin\server;C:\ [JDK_LOCATION]\jre\lib; [JDK_LOCATION] is the location where the JDK is installed on your system, note that each path is separated by a semi-colon (;) Example PATH would look like the one below: C:\Program Files\Java\jdk1.7.0_07\bin;C:\Program Files\Java\jdk1.7.0_07\jre\bin\server;C:\Program Files\Java\jdk1.7.0_07\jre\lib;

Click on the button to add System Variable.

Click on button again to close out Environment Variables window.

October 2013 11

Page 17: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Click on button again to close out the System Properties window.

19. Now we are ready to start the Agentry Development Server Locate the Server’s directory using Windows Explorer (i.e. c:\Agentry\ServerDev)

20. Right-click on the File AgentryGUI.exe and select Run as Administrator, this will launch the

Agentry Administration Client (or Agentry Server Administrator)

21. You will get an Error as above, Click on OK, 22. Open the Agentry Administration Client and scroll up the Events section of the Administration

Client

23. You will notice that there is an Error that says [System Connection] section not found in

Agentry.ini File (Publish From Editor to Correct)

October 2013 12

Page 18: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

This means that the server currently does not have any application Definition or Backend Connections defined. In the next step, we will create a new Application and publish it to this server. 24. Click on the Server Menu and select Stop Server

25. Close the Agentry Administration Client

4.2 Agentry Editor Plugin installation ..

1. If not previously installed, extract the appropriate Eclipse file (eclipse-SDK-3.7.2-win32-x86_64.zip or eclipse-SDK-3.7.2-win32.zip) based on whether you are working on a 64 bit or a 32 bit system. Once extracted, move the Eclipse dir under C:\.

2. Launch Eclipse by opening the eclipse.exe

3. In the next screen you will be prompted to Select a workspace, you can keep the default

Workspace folder or Browse and select an appropriate folder to save your activities 4. Check the option - Use this as the default and do not ask me again and click on OK

October 2013 13

Page 19: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

5. You will see the Welcome Page of Eclipse

6. Next we will install the Agentry Plug-in. Click on Help Menu > Install New Software

October 2013 14

Page 20: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

October 2013 15

Page 21: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

7. Click on Add

8. In the next screen, click on Archive

9. Locate the Agentry Editor Plugin file that you previously downloaded

October 2013 16

Page 22: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

10. Choose the right one depending upon whether you are using a 64bit/32bit system and click on Open 11. Click on OK

12. Select the checkbox next to Agentry 64/32 Bit Editor and click on Next

October 2013 17

Page 23: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

13. The system will check the Plugin file

14. Wait until the Eclipse reviews the new Plugin, then click on Next

October 2013 18

Page 24: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

15. Accept the Terms and Conditions and click on Finish

16. Installation now begins:

October 2013 19

Page 25: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

If you get a Security Warning (like below), just click on OK to continue

The installation normally takes anywhere between 10-15 minutes.

If the installation seems to take too long, make sure that you have the correct version of Eclipse on your system.

17. After a successful installation of the plugin, you will get a prompt to restart Eclipse. Click on Restart Now

18. Eclipse will restart and you will be presented again with the Welcome Screen

October 2013 20

Page 26: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

19. From File menu, click Windows > Open Perspective > Other…

October 2013 21

Page 27: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

20. Choose Agentry (Properties) and then click on OK

21. Eclipse now opens the Agentry Perspective

22. This completes the installation of the Agentry Editor Plugin.

October 2013 22

Page 28: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4.3 Create Application Configuration in SAP ERP back-end ...

1. Launch Transaction /n/syclo/configpanel from SAP GUI which will launch a new window.

You will need to change the URL to reflect the ERP hostname that you want to connect to (otherwise you may receive a “Page not found” error)

2. Click on button 3. Enter the same user credentials for the SAP ERP System that you are connecting to

4. Click on the link

5. Click on button to create a new Application Configuration 6. Enter the Following details:

Name: ZXX_FlightBooking Description: XX Flight Booking App

October 2013 23

Page 29: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

7. Click on button 8. You will be prompted to specify a Transport Request

9. Click on button 10. Short Description: XX Configuration Request

11. In the next screen you will be asked to choose the Transport Request you just created

Click on button 12. You will now see the new Application you just created on the left side under Defined Mobile

Application List 13. If you do not see your Application Configuration press F5 button or click on the refresh button

on your Internet Explorer window

For User Management and Session Management, in this How-to guide we will use standard classes and BAPI Wrappers available as a part of the SAP Add-on installed on the ERP System, we create Mobile Data Objects and link the existing BAPI Wrappers to the methods of our MDO Object

October 2013 24

Page 30: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

14. Click on the link

15. Click on the link

16. Click on the button 17. Enter the following details:

Mobile Data Object Id: ZXX_FLIGHTBOOKING_SESSION Description: XX Flight Booking Session MDO Data Object Type: Standard Data Object (Choose from dropdown) Mobile Application: Your Application Configuration (XX Flight Booking App) Data Object Handler: /SYCLO/CL_CORE_MDW_SESSION_DO: DO handler for middleware session (Select from dropdown) Get Method: GET (Select from dropdown) Create Method: CREATE (Select from dropdown) Update Method: UPDATE Delete Method: DELETE (Select from dropdown) Data Object Active: Checked

October 2013 25

Page 31: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Important: Make sure the Data Object Active option is checked

18. Click on button

19. Click on button 20. We have now created an MDO object for Session Management and we need to create

another one for User Management

21. Click on the button

October 2013 26

Page 32: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

22. Enter the following Details: Mobile Data Object Id: ZXX_FLIGHTBOOKING_USER Description: XX Flight Booking User MDO Data Object Type: Standard Data Object Mobile Application: Your Application Configuration (XX Flight Booking App) Data Object Handler: /SYCLO/CL_CORE_USER_SETTING_DO: DO handler: User setting (Please choose the right one because there is another one in the list similar to this) Get Method: GET Data Object Active: Checked

Important: Make sure the Data Object Active option is Checked

23. Click on button

October 2013 27

Page 33: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

24. Click on button

25. Click on the link 26. Linking BAPI Wrappers to the MDO methods 27. We will now link the standard BAPI Wrappers to link to the appropriate methods of the MDO

Object

28. Click on the 29. Make sure the Mobile Application Filter is set to * so that it shows all the BAPI Wrappers

irrespective of its assignment to any specific application

30. Expand the node /SYCLO/BAPI_CORE

October 2013 28

Page 34: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

31. Click on the BAPI Wrapper /SYCLO/CORE_MDW_SESSION_CRT

32. Click on the Assignment Tab

October 2013 29

Page 35: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

33. Click on the button

34. Click on the button under the Mobile Data Object Assignment List 35. Enter the below details

Mobile Application: XX Flight Booking Application (Select your Application) Mobile Data Object Id: ZXX_FLIGHTBOOKING_SESSION (Select your MDO Object) Method Type: Create Method Active Flag: Checked

Important: Make sure the Active Flag is checked

36. Click on button

October 2013 30

Page 36: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

37. Click on the button 38. Again expand the node /SYCLO/BAPI_CORE 39. Click on the BAPI Wrapper /SYCLO/CORE_MDW_SESSION_DEL 40. Click on Assignment Tab

41. Click on the button

42. Click on the button under the Mobile Data Object Assignment List and enter the below details: Mobile Application: XX Flight Booking Application (Select your Application) Mobile Data Object Id: ZXX_FLIGHTBOOKING_SESSION (Select your MDO Object) Method Type: Delete Method Active Flag: Checked

43. Click on button

44. On the prompt to choose a Transport Request, Click on the button 45. We need to do this assignment for another BAPI Wrapper 46. Again Expand the node /SYCLO/BAPI_CORE 47. Click on the BAPI Wrapper /SYCLO/CORE_USER_PROFILE_GET 48. Click on Assignment tab

49. Click on the button

50. Click on the button under the Mobile Data Object Assignment List and enter the below details Mobile Application: XX Flight Booking Application (Select your Application) Mobile Data Object Id: ZXX_FLIGHTBOOKING_USER (Select your MDO Object) Method Type: Get Method Active Flag: Checked

51. Click on button

52. On the prompt to choose a Transport Request, Click on the button

October 2013 31

Page 37: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4.4 Building a Fetch mechanism for the mobile app (Agentry Editor)

4.4.1 Create an Agentry Project

1. Launch Eclipse in Agentry Perspective (The file should be located on C:/Agentry Editor on your system) If it’s in Java Perspective, then change by going to: Window > Open Perspective > Other > Agentry (Properties)

2. Click on File -> New -> Other

3. In the next window, expand Agentry Project

October 2013 32

Page 38: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4. Choose New Agentry Project and click on Next

Development Server: Locate the Agentry.ini file under your server installation directory (typically $InstalledDir\ServerDev\Agentry.ini)

5. Enter the Project Name and Application Name as below: Project Name: FlightBooking Application Name: FlightBooking

6. To choose the Development Server, click on Browse, locate the server installation directory, select the Agentry.ini file and click on Open

October 2013 33

Page 39: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

7. You will see the Development Server information populated. If you installed your Eclipse

other than C:\Agentry, your server path will be different than what’s shown below.

October 2013 34

Page 40: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

8. Click on Finish 9. Next you will be prompted to Add Module, click on Yes

10. You will notice that a lot of definitions are created in your Eclipse 11. Next you will be prompted to add another Module

October 2013 35

Page 41: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Click on No, since we just need one module for the purpose of our application in this how-to guide.

12. The Editor has automatically created the below definitions,

13. Let us give our Module a meaningful name.

Under General Settings, Modify the Name and Display Name of the Module Name: FlightBookingModule Display Name: Flight Booking

14. Click on button to save the changes 15. Under the Project Explorer on the left side, click on Objects

October 2013 36

Page 42: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

16. The Objects are listed in the right side of the Editor

17. Choose the Object that was created automatically - BusinessObject

18. Click on the Delete button ; we will delete this Object and create our own object in a different way.

19. Click on Yes to confirm deletion of this Object

20. On the same screen, double-click on the Main Object and choose Properties, this will show

you a list of properties of the Main Object

October 2013 37

Page 43: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

21. Select the BusinessObject and click on button to delete the collection of the

BusinessObject that was automatically created.

22. Click on Yes to Confirm the deletion of the Property

4.4.2 Create a System Connection in the Agentry Project

23. We will now create a System Connection to connect to the Backend SAP ERP System, Select the System Connections from the Project Explorer

24. Click on the button and then Choose Java Virtual Machine

25. Change the name of the System Connection to: Name: BackendSAPConnection

October 2013 38

Page 44: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

26. Click on button to Save (There is more to do for this System Connection later in this exercise)

27. Next, we will create a new Object for our Application 28. Select Objects from the Project Explorer

29. You will see the MainObject under the Objects List

4.4.3 Add a New Object in the Agentry Project

30. Click on the button to add a new Object

October 2013 39

Page 45: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

31. Change the Name and Display Name of the Object as below:

Name: FlightSchedule (note: space character is not allowed in a Name) Display Name: Flight Schedule

32. Click on button to save the Object 33. Click on Properties

34. Click on the and choose String

October 2013 40

Page 46: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

35. Rename the Name of the Property:

Name: ScheduleID Display Name: Schedule ID Key Property: check

36. Click on button Note: There are two ways to create properties: 1) We can manually create all Properties

required (as just completed for the ScheduleID) or 2) We can create all Properties automatically, using a feature in the Agentry Editor called Agentry Connector Studio. We will see both methods throughout the exercises.

4.4.4 Create Required Java Files

37. Required Java files can be created under a Java Project, so we need to create a Java Project

for this.

October 2013 41

Page 47: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

38. In Eclipse, click File > New > Other

39. Choose Java Project and click on Next

Name: ZFlightBooking

Caution: For the execution environment JRE, chose the given default option by your system. Else, the paths for the JRE library will be not be built correctly. For the purpose of this exercise and the systems we are using, the default option is JavaSE-1.6.

October 2013 42

Page 48: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

40. Click on Finish 41. You will then be prompted to change the perspective to Java Perspective

October 2013 43

Page 49: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

42. Click on Yes 43. You will now see that a new Project is created and shows up in the Java Perspective

44. Right-click on src folder and choose New > Package

Enter Package name - com.syclo.sap.sflight.customer.object (all lower-case)

October 2013 44

Page 50: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

45. Click on Finish 46. Now we will create a Java Class; Right-click on the Package > New > Class

October 2013 45

Page 51: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

47. Give the Name of the Class as FlightSchedule

48. Click on Finish 49. The Editor creates an empty Java Class for you

50. Delete the entire source code and replace it with the following source:

package com.syclo.sap.sflight.customer.object;

October 2013 46

Page 52: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

import com.sap.mw.jco.JCO.Table; import com.syclo.sap.User; import com.syclo.sap.SAPObject; import com.syclo.sap.bapi.BAPI; public class FlightSchedule extends SAPObject { public String ScheduleID; public String CarrierID; public String ConnectionID; public String CarrierName; public String FlightDate; public String PlaneType; public String AirportFrom; public String AirportTo; public String CityFrom; public String CityTo; public String CountryFrom; public String CountryTo; public String Price; public String Currency; public FlightSchedule(Table arg0) throws Exception{ setScheduleID(arg0.getString("SCHEDULEID")); setCarrierID(arg0.getString("CARRID")); setConnectionID(arg0.getString("CONNID")); setCarrierName(arg0.getString("CARRNAME")); setFlightDate(arg0.getString("FLDATE")); setPlaneType(arg0.getString("PLANETYPE")); setPrice(arg0.getString("PRICE")); setCurrency(arg0.getString("CURRENCY")); setCountryFrom(arg0.getString("COUNTRYFR")); setCountryTo(arg0.getString("COUNTRYTO")); setCityFrom(arg0.getString("CITYFROM")); setCityTo(arg0.getString("CITYTO")); setAirportFrom(arg0.getString("AIRPFROM")); setAirportTo(arg0.getString("AIRPTO")); } public FlightSchedule() { ScheduleID = ""; CarrierID = "";

October 2013 47

Page 53: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

ConnectionID= ""; CarrierName= ""; FlightDate= ""; PlaneType= ""; AirportFrom= ""; AirportTo= ""; CityFrom= ""; CityTo= ""; CountryFrom= ""; CountryTo= ""; Price= ""; Currency= ""; } @Override public String getID() { return getScheduleID(); } public String getScheduleID() { return ScheduleID; } public void setScheduleID(String scheduleID) { ScheduleID = scheduleID; } public String getCarrierID() { return CarrierID; } public void setCarrierID(String carrierID) { CarrierID = carrierID; } public String getConnectionID() { return ConnectionID; } public void setConnectionID(String connectionID) { ConnectionID = connectionID; } public String getCarrierName() { return CarrierName; }

October 2013 48

Page 54: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

public void setCarrierName(String carrierName) { CarrierName = carrierName; } public String getFlightDate() { return FlightDate; } public void setFlightDate(String flightDate) { FlightDate = flightDate; } public String getPlaneType() { return PlaneType; } public void setPlaneType(String planeType) { PlaneType = planeType; } public String getAirportFrom() { return AirportFrom; } public void setAirportFrom(String airportFrom) { AirportFrom = airportFrom; } public String getAirportTo() { return AirportTo; } public void setAirportTo(String airportTo) { AirportTo = airportTo; } public String getCityFrom() { return CityFrom; } public void setCityFrom(String cityFrom) { CityFrom = cityFrom; } public String getCityTo() { return CityTo; }

October 2013 49

Page 55: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

public void setCityTo(String cityTo) { CityTo = cityTo; } public String getCountryFrom() { return CountryFrom; } public void setCountryFrom(String countryFrom) { CountryFrom = countryFrom; } public String getCountryTo() { return CountryTo; } public void setCountryTo(String countryTo) { CountryTo = countryTo; } public String getPrice() { return Price; } public void setPrice(String price) { Price = price; } public String getCurrency() { return Currency; } public void setCurrency(String currency) { Currency = currency; } @Override public void setNotes(Table arg0) throws Exception { } @Override public void setProperties(Table arg0) throws Exception { // TODO Auto-generated method stub }

October 2013 50

Page 56: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

} 51. You will notice that there are a lot of errors because of the missing libraries; we will fix them

in the next steps

52. Click on the button to save the file 53. Right-click on the Java file you just created and select Build Path > Configure Build Path

54. You will be presented with the Java Build Path screen as seen below:

October 2013 51

Page 57: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

55. Click the Libraries tab

56. Then click on button 57. Locate the Server installation directory and locate the Java folder:

58. Locate the Agentry-v5.jar file and click Open 59. You will notice that the Jar file is now added to the Libraries

60. Again click on the button 61. Locate the following Jar files and add them to the Libraries

• ini4j.jar • SAPCommon-121161.jar • sapjco.jar

The first two jar files are part of SMP 2.3 SP01 and the sapjco.jar is part of the SAP JCO installation

October 2013 52

Page 58: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

62. The Libraries should look like the below screenshot after adding the required Jar files:

63. Click on Ok 64. Once we added Java files, you will notice that all the errors have now been resolved with the

Libraries we added to the Java Project

October 2013 53

Page 59: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

65. Notice the class variables that are available in the FlightSchedule.Java Class. These variables will be used in creating the Object Properties for our FlightSchedule Object automatically

66. Now we are ready to create the Object Properties for our FlightSchedule Object using the Java File

67. Switch back to Agentry (Properties) Perspective by clicking on the tab in the upper right hand corner (or by going to: Window > Open Perspective > Other > Agentry (Properties)

68. Within the Agentry Perspective, locate the Class Constructor for FlightSchedule

Class(Class constructor is the one with the C icon)

69. Right-click on the Class Constructor and select Agentry Connector Studio -> Object Wizard, please note that the option “Agentry Connector Studio” will be available only in the Agentry (Properties) Perspective.

October 2013 54

Page 60: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4.4.5 Create Properties for the Object with Agentry Connector Studio

70. Agentry Connector Studio will launch and the Editor will automatically propose the Module

for which we are about to create the Object and Properties.

71. Click Next

October 2013 55

Page 61: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

72. You will notice that the ScheduleID field is read-only. This is because, previously, we

created this field manually. 73. Review the Object Name – FlightSchedule, which is the Object that is already created and

the Agentry Connector Studio will create the Properties listed for the Object FlightSchedule

The Agentry Connector Studio is also capable of creating an Object along with its associated Properties which we will see later in other exercises.

74. Click Next

75. You will notice that the Parent Object is automatically set to Main Object, and a Collection

called Flight Schedule Collection will be added as a Property to the Main Object. The Key Field is already set to ScheduleID (we created this Property manually and set this as a Key Property)

October 2013 56

Page 62: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Even though the Key Property dropdown is greyed out, you could choose a different property than the suggested one, if needed.

76. Click Next

77. We are not going to Create the Add, Edit, and Delete Transactions here, so uncheck all

three Step and click Next

78. We will manually create the Get Step, so uncheck the “Get” Step and click Finish 79. Click on the FlightSchedule Object and view its Properties

October 2013 57

Page 63: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

80. Note that these Object Properties were created using the Agentry Connector Studio

automatically

4.4.6 Create the Business Logic in the SAP ERP Backend

Until now we have created Objects and Object Properties. Next we will create the business logic required to populate the Objects from the SAP ERP Backend System As a pre-requisite for creating the business logic required to fetch the Objects from the SAP ERP, we will create Package and Function Group in SAP ERP 1. Logon to SAP ERP with the user and password provided to you by your Instructor 2. Launch Transaction /nse80

3. Click on from the left side of the screen 4. Choose Package from the dropdown and enter Name ZXX_FLIGHTBOOKING (XX being the

number provided by your Instructor)

5. Click on the button

October 2013 58

Page 64: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

6. Click on button Enter Package Description: Package for XX

7. Click on button

8. In the next screen click on button to create a new Workbench request (Transport) Enter a Short Description: Transport Request for XX

Click on button

9. Click on the button

10. Next we will create a new Function group which is required in the further parts of the exercises

11. Right-click on the Package and choose Create > Function Group

12. Enter the Name and Description for the new Function group as below

Name: ZXX_FLIGHTBOOKING_FGRP Description: Function Group for XX

October 2013 59

Page 65: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

13. Click on button 14. In the next screen, the Package you’ve created is already populated for you. Click on the

button 15. The Transport Request is also automatically populated

Click on the button 16. You have now successfully created a Package and a Function group to be used in the later

parts of the exercises

4.4.7 Create Required ABAP Classes

Next, we will create the business logic required for fetching data from the SAP ERP. 1. Launch Transaction /nSE24 and type Enter

Object Type: Z00_GET_FLIGHT_SCHEDULE

2. Click on the button to copy the class In the next screen, the system will ask you to provide a name of the destination class Copy To: ZXX_GET_FLIGHT_SCHEDULE

3. Click on 4. Click Save on Create Object Directory Entry Screen

October 2013 60

Page 66: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

5. Click OK on Prompt for local workbench request

6. The Class is copied successfully

7. Click on button (Make sure to have the filter checkbox checked)

8. Click on the icon to activate the Class that was just copied

9. Click on the button 10. Review the Methods in the class

October 2013 61

Page 67: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

11. The GET Method contains the business logic to retrieve the flight schedules from the SFLIGHT table

12. The GET_DATA_FILTER_LIST Method defines a filter that controls the data that will be retrieved by the GET Method

For example, we can set a Filter at the application level to retrieve only flight schedules of LH-Lufthansa or UA-United Airlines etc.

October 2013 62

Page 68: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4.4.8 Create Required BAPI Wrapper

Next, we will create a BAPI Wrapper that calls the Class created above 1. Launch Transaction /nse37 and type Enter

2. Enter Function Module Name Z00_BAPI_GET_FLIGHT_SCHEDULE and click on (Use the source code given in the Appendix of this document)

Enter the following details: To Function module: ZXX_BAPI_GET_FLIGHT_SCHEDULE Function group: ZXX_FLIGHTBOOKING_FGRP (Your Function Group)

3. Click on button

4. Click on 5. Enter the name of your Function Module you just copied

ZXX_BAPI_GET_FLIGHT_SCHEDULE

October 2013 63

Page 69: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

6. Click on

7. Click on the button and OK. We now have the business logic required to fetch the data from SAP ERP.

4.4.9 Create Mobile Data Object in the Config Panel

Next, we need to create Mobile Data Object in the Config Panel 1. Launch the Config Panel by executing the transaction /n/syclo/configpanel from the SAP

GUI

2. Click on the link

October 2013 64

Page 70: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

3. Use the Mobile Application Filter to filter out the MDO objects for you application (not required, but this way you will see only the MDO’s used in your Application)

4. Expand the DO – Standard Data Object Node

5. Click on the button Enter the following: Mobile Data Object id: ZXX_FLIGHT_SCHEDULE (XX is your unique number provided by your instructor) Description: XX Flight Schedule MDO Data Object Type: Standard Data Object Mobile Application: XX Flight Booking App Data Object Handler: ZXX_GET_FLIGHT_SCHEDULE Get Method: GET Data Object Active: Checked

6. Click on Data Filter Tab

October 2013 65

Page 71: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

7. Expand the Get Method – GET under Defined Filters

8. Click on the button Enter the following values Sign: Inclusive Option: = Low Value: UA Active Flag: Checked

October 2013 66

Page 72: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

What we have done here is defined a filter at the Application Level; meaning the business logic of the fetch will be filtered based on the value specified here, so we will only retrieve the flight schedules for the specified airlines.

9. Click on the button

10. Click on button on the Transport Request screen. Now you should have the following displayed in the MDO section.

Next, we need to create a BAPI Wrapper

11. Click on the link

12. Click on the link

13. Click on the button

October 2013 67

Page 73: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

14. Click on the next to the BAPI Wrapper Name:

15. Enter Function Module Name as ZXX_BAPI_GET_FLIGHT_SCHEDULE and click on the

button (Use the source code given in the Appendix of this document)

16. Choose the BAPI Name and click on the button 17. Click on the Assignment tab

October 2013 68

Page 74: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

18. Scroll down to the Assignment details and enter the following data:

Mobile Application: XX Flight Booking App (Your Application Configuration) Mobile Data Object Id: XX Flight Schedule MDO (Your MDO) Method Type: Get method Active Flag: Checked

19. Click on the button

20. Click on button on the Transport Request screen

4.4.10 Agentry Editor Java Definitions

Now we will get back to the definitions in the Agentry Editor. We will now create Steplet, StepHandler and Bapi Java Classes

1. Open the Java Perspective on your eclipse Editor by clicking on the button 2. Right-click on src folder and select New > Package

October 2013 69

Page 75: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Enter Package name - com.syclo.sap.sflight.customer.steplet

3. Click Finish 4. Right-click on the newly created Package com.syclo.sap.sflight.customer.steplet and

select New > Class

October 2013 70

Page 76: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

5. Enter the Name of the Class

Name: FlightScheduleSteplet

October 2013 71

Page 77: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

6. Click Finish 7. This will create an empty class, replace the source file of this Java Class with this source

code: package com.syclo.sap.sflight.customer.steplet; import com.syclo.agentry.AgentryException; import com.syclo.agentry.BusinessLogicException; import com.syclo.agentry.FetchSession; import com.syclo.sap.Steplet; import com.syclo.sap.sflight.customer.object.FlightSchedule; import com.syclo.sap.sflight.customer.stephandler.FlightScheduleStephandler; public class FlightScheduleSteplet extends Steplet{ public FlightSchedule[] _returnData; public FlightScheduleSteplet(FetchSession session) throws AgentryException, BusinessLogicException { super(session); } @Override public boolean execute() throws AgentryException { try{ FlightScheduleStephandler handler = new FlightScheduleStephandler((com.syclo.sap.User)_user); _returnData = handler.getFlightSchedules(); return true; } catch(Throwable exception){ throwExceptionToClient(exception); return false; } } }

8. Click Save button to save file 9. You might notice some errors, you can ignore them for now as they will be resolved

automatically after creating the other Java Classes 10. Right-click on src folder and select New > Package

October 2013 72

Page 78: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Enter Package name - com.syclo.sap.sflight.customer.stephandler

11. Click Finish 12. Right-click on the newly created package com.syclo.sap.sflight.customer.stephandler and

select New > Class Name: FlightScheduleStephandler

October 2013 73

Page 79: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

13. Replace the source file of FlightScheduleStephandler.java file with this source code: package com.syclo.sap.sflight.customer.stephandler; import java.util.ArrayList; import java.util.GregorianCalendar; import com.syclo.sap.SAPObject; import com.syclo.sap.StepHandler; import com.syclo.sap.User; import com.syclo.sap.sflight.customer.bapi.FlightScheduleBapi; import com.syclo.sap.sflight.customer.object.FlightSchedule; public class FlightScheduleStephandler extends StepHandler{ com.syclo.sap.User user = null; public FlightScheduleStephandler(User usr) { super(usr); user = (com.syclo.sap.User)usr; // TODO Auto-generated constructor stub } public FlightSchedule [] getFlightSchedules() throws Exception{ FlightSchedule[] array = null; FlightSchedule spfliObj = new FlightSchedule();

October 2013 74

Page 80: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

FlightScheduleBapi bapi = new FlightScheduleBapi(user, new GregorianCalendar()); bapi.run(spfliObj); ArrayList<SAPObject> spfliList = bapi.processResults(); array = new FlightSchedule[spfliList.size()]; array = spfliList.toArray(array); return array; } }

14. Click Save button to save file 15. Right-click on src folder and select New > Package

Enter Package name - com.syclo.sap.sflight.customer.bapi

October 2013 75

Page 81: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

16. Click Finish 17. Right-click on the newly created Package and select New > Class

18. Enter the Name of the Class:

Name: FlightScheduleBapi

October 2013 76

Page 82: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

19. Click Finish 20. Replace the source of the FlightScheduleBapi.java file with this source code:

package com.syclo.sap.sflight.customer.bapi; import java.util.ArrayList; import java.util.GregorianCalendar; import com.sap.mw.jco.JCO; import com.syclo.sap.Logger; import com.syclo.sap.SAPObject; import com.syclo.sap.User; import com.syclo.sap.bapi.AbstractFetchBAPI; import com.syclo.sap.sflight.customer.object.FlightSchedule; public class FlightScheduleBapi extends AbstractFetchBAPI{ public User user = null; public FlightScheduleBapi(User u, GregorianCalendar lu) throws Exception { super(u, lu); user = (User) u; // TODO Auto-generated constructor stub } @Override

October 2013 77

Page 83: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

public ArrayList<SAPObject> processResults() throws Exception { ArrayList<SAPObject> spfliTab = new ArrayList<SAPObject>(); JCO.Table _sTab = _tables.getTable("ET_FLT_SCHEDULE"); int rows = _sTab.getNumRows(); for(int i = 0; i<rows; i++) { _sTab.setRow(i); FlightSchedule spfliLine = new FlightSchedule(_sTab); spfliTab.add(spfliLine); } return spfliTab; // TODO Auto-generated method stub } @Override public void setParameters(SAPObject obj) throws Exception { // TODO Auto-generated method stub super.setParameters(obj); try { } catch (Exception e) { user.rethrowException(e, true); } } }

21. Click Save button to save file 22. Right-click on src folder and select New > Package

October 2013 78

Page 84: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

23. Enter Java Package name - com.syclo.sap.sflight.server

24. Click Finish 25. Right-click on the newly created package and select New > Class

October 2013 79

Page 85: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

26. Enter Name of the Java Class:

Name: Server

27. Click Finish 28. Replace the source of the Server.Java with this code:

package com.syclo.sap.sflight.server; import com.syclo.agentry.SessionData; import com.syclo.sap.Logger;

October 2013 80

Page 86: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

import com.syclo.sap.PushSession; import com.syclo.sap.User; public class Server extends com.syclo.sap.Server { public Server() throws Exception { super(); } /* (non-Javadoc) * @see com.syclo.sap.Server#createUser(java.lang.String) */ public User createUser(String name) { Logger log = new Logger(this, "createUser(String name)"); User u = null; try { u = new User(name, this); log.info("done"); } catch (Exception e) { log.fatal(e.getMessage()); } return u; } /*// @Override // protected void createRemoteUser(com.syclo.sap.User u) throws Exception { // Logger log = new Logger(this, "createRemoteUser"); // super.createRemoteUser(u); // u.getUserProfileData(); // u.setProfileInfo(); // WorkOrderAssignmentTypeDelegate delegate = WorkOrderAssignmentTypeDelegateFactory.getAssignmentTypeDelegate(u); // if(delegate!= null){ // delegate.validateAssignmentType(log); // } // } *//** * Factory method that creates a new {@link PushSession} object for a push * session that is not tied to a specific user. It is called by the Agentry * Server whenever a fetch is requested by the client application. If the * {@link PushSession} class is extended, then this method must be

October 2013 81

Page 87: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

* overridden to return the new subclass. * <P> * Note that if you create a new subclass of {@link PushSession}, then you * must override both this method and the * {@link #createPushUserSession(String, SessionData, User) * createPushUserSession} method. * * @param pushName The name of the push being processed, as configured by * the designer in the Agentry Editor. * @param sessionData Provides access to current session data, such as * flunky values. * @return A new {@link PushSession} object. * * @since 110421 *//* @Override public PushSession createPushSession(String pushName, SessionData sessionData) { Logger log = new Logger(this, this.getClass().getName() + "::createPushSession::" + pushName, Logger.DEBUG); log.debug("--------------------------------"); return new PushSession(pushName, this, sessionData); } *//** * Factory method that creates a new {@link PushSession} object for a push * session. It is called by the Agentry Server whenever a fetch is * requested by the client application. If the {@link PushSession} class is * extended, then this method must be overridden to return the new * subclass. * <P> * Note that if you create a new subclass of {@link PushSession}, then you * must override both this method and the * {@link #createPushUserSession(String, SessionData, User) * createPushUserSession} method. * * @param pushName The name of the push being processed, as configured by * the designer in the Agentry Editor. * @param sessionData Provides access to current session data, such as * flunky values. * @param user Represents the client user that is performing the push. * @return A new {@link PushSession} object. * * @since 110421 *//* @Override public PushUserSession createPushUserSession(String pushName, SessionData sessionData, com.syclo.agentry.User user) {

October 2013 82

Page 88: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Logger log = new Logger(this, this.getClass().getName() + "::createPushUserSession::" + pushName + "::" + user.getName() , Logger.DEBUG); log.debug("--------------------------------"); return new PushUserSession(pushName, this, sessionData, (com.syclo.sap.User) user); }*/ @Override protected void setAppName() { } }

29. Click Save button to save file

4.4.11 Create Steps and Assign Fetch

30. Switch back to Agentry (Properties) Perspective (if not already in this perspective) 31. Click on Steps under the Project Explorer

32. Click on the button > Java Steplet > Existing Class…

October 2013 83

Page 89: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

33. In Select entries type: FlightScheduleSteplet

34. Select entry: FlightScheduleSteplet – com.syclo.sap.sflight.customer.steplet

35. Click on button 36. Expand the Fetch Node under the Project Explorer and select MainFetch

October 2013 84

Page 90: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

37. Under Fetch Definition of MainFetch > General Settings, click on and select FlightScheduleCollection

38. Under Clear Collection, uncheck Clear client data before transmit?

39. Click button to save 40. Choose Server Exchange Steps

41. Click on the button

42. Click on

October 2013 85

Page 91: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

43. Choose Steps > NewJavaSteplet1

44. Click button to save

4.4.12 Create Screens, Screen Sets and Actions

45. From the Project Explorer, expand the Screen Sets node, click on MainScreenSet that was automatically created.

46. Change Name to ShowFlightSchedules

47. Click on the button 48. Click on Platforms

49. Click on the button > Windows Mobile > Pocket PC - Portrait

October 2013 86

Page 92: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

50. Enter Caption: Flight Schedule

51. Click button to save Platform Definitions 52. Click on Platform Screens

53. Click button > List Screen

October 2013 87

Page 93: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

54. We need to select the columns that we want to show up on the screen (on device)

55. Select the following in the same order as below; to add a Property, select from the Available

Properties and click on and to re-order you can use the buttons

October 2013 88

Page 94: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

56. Click Finish

Change the below values and change Name and Caption in General Settings: Name: ShowFlightSchedules_PPC_List Caption: Flight Schedules

October 2013 89

Page 95: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

57. Click Save button 58. We will add another screen set to show the details of the schedule 59. Click Screen Sets under Project Explorer

60. Click on the button and update the following: Name: ShowFlightScheduleDetails Displays (Object): FlightSchedule

61. Click Save 62. Click Platforms

October 2013 90

Page 96: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

63. Click on the button > Windows Mobile > Pocket PC - Portrait

64. Enter Caption: Schedule Details

65. Click Save button 66. Click Platform Screens

67. Click on button > Detail Screen

68. In the next screen, we need to select the fields to be displayed on the screen

October 2013 91

Page 97: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

69. Choose the following fields in the order below:

CarrierName FlightDate CityFrom CityTo Price Currency PlaneType

October 2013 92

Page 98: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

70. Click Finish 71. Update Name and Caption in General Settings:

Name: ShowFlightScheduleDetails_PPC_Detail Caption: Flight Details

72. Click Save button 73. Next, create an Action to Show the Details Screen and to Close the Detail Screen 74. Click Actions, under the FlightBookingModule Module

October 2013 93

Page 99: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

75. Click on button to Add an Action and update the following values: Name: ShowFlightScheduleDetails Display Name: Schedule Details For Object: FlightSchedule

October 2013 94

Page 100: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

76. Click Save button 77. Click Action Steps

78. Click on the button > Navigation

October 2013 95

Page 101: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

79. Update the following values:

Name: ShowScheduleDetailsStep Screen Set: ShowFlightScheduleDetails

80. Click Save button 81. Click on Actions under the FlightBookingModule Module

82. Click on button and update the following values: Name: CloseThisScreenSet

October 2013 96

Page 102: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Display Name: Close For Object: - -None--

83. Click Save button 84. Click Action Steps

85. Click on the button > Navigation

October 2013 97

Page 103: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Update the following values: Step Name: CloseThisScreenStep Close Screen Set(s): Close all screen sets except for the main screen set

86. Click Save button 87. Next, we will create buttons on the Screens to call the Actions created. 88. In the Project Explorer, expand Screen Sets > ShowFlightSchedules Screenset > Screens >

ShowFlightSchedules_PPC_List > Buttons

89. Click on the button Update the following Fields Name: Transmit Label: Transmit Action: Transmit Target: "MainObject" Object (which contains the "FlightScheduleCollection" Collection)

Choose Transmit Action by clicking on ->Actions-> Transmit

Similarly, you can select the Target by clicking on -> "MainObject" Object (which contains the "FlightScheduleCollection" Collection)

October 2013 98

Page 104: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

90. Click Save button

91. Click Back button to go back to the Buttons definitions screen 92. We need to add another button to take you to the ShowFlightScheduleDetails screen

93. Click on the button Update the following Fields Name: ScheduleDetails Label: Details Action: ShowFlightScheduleDetails Target: Selected "FlightSchedule" Object

94. Click Save button 95. Next, we need to add a button to close the details Screen 96. From the Project Explorer, expand Screen Sets > ShowFlightScheduleDetails > Screens >

ShowFlightScheduleDetails_PPC_Detail > Buttons

October 2013 99

Page 105: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

97. Click on the button Update the following Fields Name: Close Label: Close Action: CloseThisScreenSet Target: "FlightSchedule" Object

98. Click Save button 99. Now we are ready to publish the definitions to the Agentry Server

4.4.13 Publish Application to the Server

1. Click on the button on the top menu to publish the definitions to the Agentry Server

October 2013 100

Page 106: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

2. Click on the button

3. Click Yes button; this is a warning that says that the Agentry.ini file may be modified with this publish

October 2013 101

Page 107: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4. Click on button 5. Next, we need to publish the Java Project that we created to define the Java logic 6. Click on File > Export

October 2013 102

Page 108: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

7. In the next screen, Expand Java folder and select JAR file

8. Click on button Update the following values Select ZFlightBooking under Select resources to export Uncheck .classpath and .project

October 2013 103

Page 109: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Select options Export all output folders for checked projects Select Export Java source files and resources

9. Click on the button and locate the Agentry Server’s installation directory

October 2013 104

Page 110: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

10. Give the filename ZFlightBooking.jar and click on button

October 2013 105

Page 111: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

11. Click on button

4.4.14 Add Application Parameters in Config Panel

1. Launch the Config Panel by executing the Transaction /n/syclo/configpanel from the SAP GUI

2. Click on the link 3. Click your Mobile Application from the Defined Mobile Application List on the left side

October 2013 106

Page 112: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

4. Click on the button 5. Click on the Parameters Tab

6. Click on the button under Application Parameters Enter the following details: Parameter Group: SAPOBJECT Param. Name: FlightSchedule Param. Value: com.syclo.sap.sflight.customer.object.FlightSchedule Active Flag: Checked

October 2013 107

Page 113: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

7. Click on the button again to add another parameter Enter the following details: Parameter Group: BAPI_WRAPPER Param. Name: com.syclo.sap.sflight.customer.bapi.FlightScheduleBapi Param. Value: ZXX_BAPI_GET_FLIGHT_SCHEDULE (Your BAPI Function Module) Active Flag: Checked

8. Click on button

9. Click on button on the Transport Request screen 10. Copy the following files from to the Agentry Server Directory ( C:\Agentry\ServerDev)

You will need to create the JavaBE.ini file. See the documentation available for that here:

Create the JavaBE.ini file for SAP Systems 11. Open the JavaBE.ini file in a text editor

Update the following in the JavaBE.ini file Under [HOST] Section server=Your-SAP-ERP-Server APPNAME=ZXX_FLIGHTBOOKING (Your Application Configuration) Under [SERVICE_LOGON] section Update the following

October 2013 108

Page 114: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

UID=<Your-SAPERP-User> UPASSWORD=<Your-SAPERP-Password> SERVERSERIALNUM=<Server-Serial-Number>(as per License Key) Locate the [Client] section in the file and update the client with the client number given in the instructions in the beginning of the class for the ERP logon. [CLIENT_NUM] CLIENT=XXX

12. Save the JavaBE.ini File 13. Open the Agentry.ini File using a text editor 14. Locate the [Java-1] section in the file 15. Update the following parameter value

enableAuthentication=true classPath=./Java/Agentry-v5.jar;ini4j.jar;sapjco.jar;SAPCommon-121161.jar;ZFlightBooking.jar; serverClass=com/syclo/sap/sflight/server/Server

16. Save the Agentry.ini file 17. Start your Agentry Server (Restart if it is already running) 18. Your Agentry Server should now start without any error.

4.4.15 Test Application in ATE

1. If you haven’t done so yet, you will need to install the Agentry Test Environment to be able to test your mobile application

2. Click on the Agentry_Test_Environment. Exe file and click on Next

October 2013 109

Page 115: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

3. On the next screen click on “Yes” to agree to the license terms 4. For convenience, choose the installation path as C:\Agentry\TestEnvironment\ and then

click on Next

October 2013 110

Page 116: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

5. On the following screen, uncheck the options given and then click Install 6. Click then on Finish. Now you’re ready to start the ATE tool.

October 2013 111

Page 117: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

7. When you first start the ATE, you will need to provide the User ID and Password, which are the credentials used to log into the SAP ERP back-end system.

8. Next you will need to provide the server login information. Click on OK.

9. In the next window you should be able to see the Agentry Server that is already running on

your system. Click on OK.

October 2013 112

Page 118: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Note: In case the list is empty, check that your Agentry Server is in fact running.

10. Once you click the OK button and the data is correct, the first Transmit will begin and you will see the Agentry Client Transmit window. However what you will see in the system may be different than the screenshot below.

11. Check to see if the Fetch works as per the configured filters (UA or LH) 12. If you want to use a different platform than the suggested default for testing, you can

change the testing platform from the top menu Test -> Select Platform…This will require a new Transmit.

13. If the application has been built correctly and the transmit has functioned correctly as well,

you should be able to see the following screen:

October 2013 113

Page 119: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

5. Appendix Appendix A – Source Code for Z00_GET_FLIGHT_SCHEDULE

class Z00_GET_FLIGHT_SCHEDULE definition public inheriting from /SYCLO/CL_CORE_DO_HANDLER_BASE create public . public section. *"* public components of class Z00_GET_FLIGHT_SCHEDULE *"* do not include other source files here!!! methods /SYCLO/IF_CORE_DO_HANDLER~GET redefinition . methods /SYCLO/IF_CORE_FILTER_SERV~GET_DATA_FILTER_LIST redefinition . protected section. *"* protected components of class Z00_GET_FLIGHT_SCHEDULE *"* do not include other source files here!!! private section. *"* private components of class Z00_GET_FLIGHT_SCHEDULE *"* do not include other source files here!!! ENDCLASS. CLASS Z00_GET_FLIGHT_SCHEDULE IMPLEMENTATION. * <SIGNATURE>---------------------------------------------------------------------------------------+ * | Instance Public Method Z00_GET_FLIGHT_SCHEDULE->/SYCLO/IF_CORE_DO_HANDLER~GET * +-------------------------------------------------------------------------------------------------+ * | [--->] IREF_RFC_OO_DATA TYPE REF TO /SYCLO/CL_CORE_RFC_OO_DATA * +--------------------------------------------------------------------------------------</SIGNATURE> METHOD /SYCLO/IF_CORE_DO_HANDLER~GET. DATA: lt_abap_param TYPE abap_parmbind_tab, ls_abap_param TYPE abap_parmbind, ls_return TYPE bapiret2. DATA: lref_exception TYPE REF TO cx_root.

October 2013 114

Page 120: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

DATA: lt_flt_schedule TYPE TABLE OF ZFLIGHT_SCHEDULE. "Business data, in my case SPFLI table DATA wa_flt_schedule type ZFLIGHT_SCHEDULE. * DATA: lt_sbook TYPE TABLE OF sbook. * DATA: ls_travel_date type STRING, * ls_city_from type spfli-cityfrom, * ls_city_to type spfli-cityto. FIELD-SYMBOLS: <wa_travel_date> TYPE ANY, <wa_city_from> type any, <wa_city_to> type any, <source> TYPE any, <return> TYPE bapiret2_t. ASSIGN iref_rfc_oo_data->dref_return->* TO <return>. DATA: BEGIN OF ls_dof_filter_vals, carrid TYPE REF TO /syclo/core_range_tab, "/syclo/mm_rsnum_range_str, END OF ls_dof_filter_vals. CREATE DATA: ls_dof_filter_vals-carrid. me->oref_mdo_data->map_local_dof_filter( CHANGING cs_filters = ls_dof_filter_vals ). * Retrieve BAPI Import Parameters iref_rfc_oo_data->get_ooref_param_tab( IMPORTING et_in_ooref_param_tab = lt_abap_param ). *Step 1. Timestamp for mobile IF me->mobile_timestamp_in IS INITIAL. me->mobile_timestamp_out = /syclo/cl_core_do_services=>get_sys_timestamp( ). ENDIF. *Step 2. Fetch the data

October 2013 115

Page 121: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

SELECT A~CARRID A~CONNID C~CARRNAME A~FLDATE A~PLANETYPE B~AIRPFROM B~AIRPTO B~CITYFROM B~CITYTO B~COUNTRYFR B~COUNTRYTO A~PRICE A~CURRENCY FROM SFLIGHT AS A INNER JOIN SPFLI AS B ON A~CARRID EQ B~CARRID INNER JOIN SCARR as C on A~CARRID EQ C~CARRID into CORRESPONDING FIELDS OF TABLE lt_flt_schedule WHERE A~FLDATE GE SY-DATUM and A~CARRID IN ls_dof_filter_vals-carrid->*. sort lt_flt_schedule by CONNID FLDATE. delete ADJACENT DUPLICATES FROM lt_flt_schedule COMPARING ALL FIELDS. data it_temp type table of ZFLIGHT_SCHEDULE. data int_i type i value 1. *it_temp[] = lt_flt_schedule[]. loop at lt_flt_schedule into wa_flt_schedule. wa_flt_schedule-SCHEDULEID = SY-TABIX. insert wa_flt_schedule into table it_temp. *int_i = int_i + 1. endloop. lt_flt_schedule[] = it_temp[]. *Step 3. Map the data to return parameters TRY. IF lt_flt_schedule[] IS NOT INITIAL. GET REFERENCE OF lt_flt_schedule[] INTO ls_abap_param-value. ls_abap_param-kind = /syclo/cl_core_constants=>rfc_table. ls_abap_param-name = 'ET_FLT_SCHEDULE[]'. iref_rfc_oo_data->copy_to_ooref_param( EXPORTING is_abap_param = ls_abap_param ). ENDIF. CATCH cx_root INTO lref_exception. "#EC CATCH_ALL me->logger->catch_class_exception( EXPORTING iv_mobile_user = me->str_bapi_input-mobile_user iv_mobile_id = me->str_bapi_input-mobile_id iv_user_guid = me->str_bapi_input-user_guid "<-ins 310_700 bugid 25317 iref_exception = lref_exception iref_return_tab = iref_rfc_oo_data->dref_return ). ENDTRY. ENDMETHOD.

October 2013 116

Page 122: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

* <SIGNATURE>---------------------------------------------------------------------------------------+ * | Instance Public Method Z00_GET_FLIGHT_SCHEDULE->/SYCLO/IF_CORE_FILTER_SERV~GET_DATA_FILTER_LIST * +-------------------------------------------------------------------------------------------------+ * | [--->] IV_MTHD TYPE /SYCLO/CORE_DO_MTHD_DTE(optional) * | [<-()] ET_DATA_FILTERS TYPE /SYCLO/CORE_FILTER_SERV_TAB * +--------------------------------------------------------------------------------------</SIGNATURE> METHOD /SYCLO/IF_CORE_FILTER_SERV~GET_DATA_FILTER_LIST. ************************************************************************ * Data Declaration Section ************************************************************************ * Tables & Structures DATA: lt_data_filter TYPE /syclo/core_filter_serv_tab. * Field Symbols FIELD-SYMBOLS: <data_filter> TYPE LINE OF /syclo/core_filter_serv_tab. * Constants CONSTANTS: lc_get_mthd TYPE /syclo/core_do_mthd_dte VALUE 'GET'. ************************************************************************ * Main Section ************************************************************************ super->get_data_filter_list( ). REFRESH et_data_filters. *Field selector for method GET APPEND INITIAL LINE TO lt_data_filter ASSIGNING <data_filter>. <data_filter>-do_handler = me->clsname. <data_filter>-do_mthd = lc_get_mthd. <data_filter>-dof_name = 'CARRID'. <data_filter>-usage_tabname = 'SFLIGHT'. <data_filter>-usage_fieldname = 'CARRID'. et_data_filters[] = lt_data_filter[]. ENDMETHOD. ENDCLASS.

October 2013 117

Page 123: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

How To Build an Agentry based app from scratch connecting to a SAP ERP back-end – Part 1

Appendix B – Source code for Z00_BAPI_GET_FLIGHT_SCHEDULE

FUNCTION Z00_BAPI_GET_FLIGHT_SCHEDULE. *"-------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(IS_BAPI_INPUT) TYPE /SYCLO/CORE_BAPI_INPUT_STR *" EXPORTING *" VALUE(ES_BAPI_OUTPUT) TYPE /SYCLO/CORE_BAPI_OUTPUT_STR *" TABLES *" ET_FLT_SCHEDULE STRUCTURE ZFLIGHT_SCHEDULE OPTIONAL *" ET_RETURN STRUCTURE BAPIRET2 OPTIONAL *"-------------------------------------------------------------------- sy-debug = 'X'. INCLUDE /syclo/core_bapi_template_incl. ENDFUNCTION.

October 2013 118

Page 124: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

www.sap.com/contactsap

http://scn.sap.com/community/mobile

http://developers.sap.com/mobile

SAP Mobile Platform How-To Guides

Page 125: How-To Build an Agentry Based Mobile App From Scratch Connecting to an SAP Back-End Part 1

www.sap.com

© 2013 SAP AG. All rights reserved.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP

BusinessObjects Explorer, StreamWork, SAP HANA, and other SAP

products and services mentioned herein as well as their respective

logos are trademarks or registered trademarks of SAP AG in Germany

and other countries.

Business Objects and the Business Objects logo, BusinessObjects,

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

other Business Objects products and services mentioned herein as

well as their respective logos are trademarks or registered trademarks

of Business Objects Software Ltd. Business Objects is an SAP

company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL

Anywhere, and other Sybase products and services mentioned herein

as well as their respective logos are trademarks or registered

trademarks of Sybase Inc. Sybase is an SAP company.

Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are

registered trademarks of Crossgate AG in Germany and other

countries. Crossgate is an SAP company.

All other product and service names mentioned are the trademarks of

their respective companies. Data contained in this document serves

informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials

are provided by SAP AG and its affiliated companies ("SAP Group")

for informational purposes only, without representation or warranty of

any kind, and SAP Group shall not be liable for errors or omissions

with respect to the materials. The only warranties for SAP Group

products and services are those that are set forth in the express

warranty statements accompanying such products and services, if

any. Nothing herein should be construed as constituting an additional

warranty. .