Generating Object API Code

Generate object API code containing mobile business object (MBO) references, which allows you to use APIs to develop device applications for various mobile devices.

Prerequisites
  • Before generating device client code, develop the MBOs that will be referenced in the device applications you are developing. You must have an active connection to the data sources to which the MBOs are bound.
  • Ensure the enterprise information system (EIS) data sources referenced by the MBOs are running and available or code generation fails.
  • Install either the net_rim_api.jar file (BlackBerry) or the android.jar file (Android) before generating code for these platforms.
Task
  1. Launch the Code Generation wizard.
    From Action
    The Mobile Application Diagram Right-click within the Mobile Application Diagram and select Generate Code.
    WorkSpace Navigator Right-click the Mobile Application project folder that contains the mobile objects for which you are generating API code, and select Generate Code.
  2. (Optional) Enter the information for these options:
    Note: This page of the code generation wizard is seen only if you are using the Advanced developer profile. See Switching Between Developer Profiles. The most recent configuration is used if the code generation wizard is invoked from the Basic developer profile.
    Option Description
    Code generation configuration A table lists all existing named configurations plus the most recently used configuration. You can select any of these, click Next, and proceed. Additionally, you can:
    • Create new configuration – click Add and enter the Name and optional Description of the new configuration and click OK to save the configuration for future sessions. You can also select Copy from to copy an existing configuration which can then be modified.
    • Most recent configuration – if you click Next the first time you generate code without creating a configuration, the configuration is saved and displays as the chosen configuration the next time you invoke the code generation wizard. If the most recent configuration used is a named configuration, it is saved as the first item in the configuration table, and also "Most recent configuration", even though it is still listed as the original named configuration.
  3. Click Next.
  4. In Select Mobile Objects, select all the MBOs in the mobile application project or select MBOs under a specific synchronization group, whose references, metadata, and dependencies (referenced MBOs) are included in the generated device code.
    Dependent MBOs are automatically added (or removed) from the Dependencies section depending on your selections.
    SAP Mobile WorkSpace automatically computes the default page size after you choose the MBOs based on total attribute size. If an MBO's accumulated attribute size is larger than the page size setting, a warning displays.
  5. Click Next.
  6. Enter the information for these code generation options:
    Option Description
    Language Choose the language used for developing the client applications:
    • Java
    • C#
    • Objective-C
    Platform Select the platform ( target device) from the drop-down list for which the device client code is intended. The platform is dependent on the language selected.
    • Java
      • Java ME for BlackBerry
      • Android
    • C#
      • .NET Framework for Windows
      • .NET Compact Framework 3.5 for Windows Mobile
    • Objective C
      • iOS
    SAP Mobile Server Specify a default SAP Mobile Server connection profile to which the generated code connects at runtime.
    Server domain

    Choose the domain to which the generated code will connect. If you specified an SAP Mobile Server to which you previously connected successfully, the first domain in the list is chosen by default. You can enter a different domain manually.

    Note: This field is only enabled when an SAP Mobile Server is selected.
    Page size
    (Optional) Select the page size for the generated client code. The page size field is filled either with the recommended values if this is the very first invocation (based on the selected MBO's attributes), or the value saved from the previous code generation invocation. In cases where the page size is smaller then the recommended size, the code generation wizard shows the warning:
    Page size is smaller than the maximum business object size, which may cause synchronization failure
    and you must chose a larger page size to avoid a runtime errror.

    The page size should be larger than the sum of all attribute lengths for any MBO that is included with all the MBOs selected, and must be valid for the database. If the page size is changed, but does not meet these guidelines, object queries that use string or binary attributes with a WHERE clause may fail.

    Note: This field is only enabled when an SAP Mobile Server is selected.
    Package, Namespace, or Name Prefix
    • Package – enter a package name for Java. The package name must follow Java naming conventions for packages. For example, no leading or trailing spaces and no special characters such as §&/, except that the first letter may be upper-case.
    • Namespace – enter a namespace for C#.
    • Name Prefix – enter a name prefix for Objective C.
    Destination Specify the destination of the generated device client files. Enter (or Browse) to either a Project path (Mobile Application project) location or File system path location. Select Clean up destination before code generation to clean up the destination folder before generating the device client files.
    Note: If you select Java as the language, enter a project path, specify a mobile application project folder, and select Generated Code as the destination. JAR files are automatically added to the destination for the platform that supports compiling of the generated client code.
    Third-party jar file

    Enter or browse to the location of the third party jar file. For example, net_rim_api.jar for BlackBerry, or android.jar for Android.

    If you select Java as the language, and if the BlackBerry or Android third-party JAR file has not been added, the warning The dependent third-party class 'net.rim.device.api.system.ApplicationDescriptor' cannot be found or The dependent third-party class 'android.content.Context' cannot be found displays.

  7. Select Generate metadata classes to generate metadata for the attributes and operations of each generated client object.
  8. Select Including object manager classes to generate both the metadata for the attributes and operations of each generated client object and an object manager for the generated metadata.
    The Including object manager classes option is enabled only for BlackBerry and C# if you select Generate metadata classes. The object manager allows you to retrieve the metadata of packages, MBOs, attributes, operations, and parameters during runtime using the name instead of the object instance.
    Note: When generating code for Android or iOS, "Generate metadata classes" is automatically selected and cannot be unselected. The "Including object manager classes" option is unavailable and unsupported.
  9. If you selected Java as the language, you can select Generate JavaDoc to include the Object API JavaDoc documentation in the output directory.
  10. Click Finish.