Generating Code 

Use

To specify the parameters for generating code, and to generate code with the SAP Assistant.

You can specify items such as which business objects or RFC functions to generate code for, which target language to generate the code for, where to place the generated files, and which code generator to use.

Prerequisites

The code generator of the Sap Assistant gets the metadata for the specified business objects or functions from a specific R/3 system. You must therefore be logged onto that R/3 system.

Alternatively, you can use a local repository, in which you have previously saved the metadata of the business objects or functions you wish to generate code for.

It may be more efficient to use the local repository for code generation, for example, if you are generating code for many objects or functions, or if the network connection between the application's computer and the R/3 server is slow.

Procedure

  1. Display the appropriate view to see either business objects or RFC functions.
  2. For each business object or RFC function you wish to generate code for:
    1. Select a single business object or RFC function.
    2. Choose Code Generator à Mark For Code Generation.

The icon next to the marked item changes to an arrow.

You can mark in this way multiple business objects along with multiple RFC functions.

You can switch between RFC and business objects views until you complete your selection of items for code generation.

  1. When you are done selecting business objects and functions, choose Code Generator à Generate Code.
  2. The BAPI Wizard - Introduction screen appears. Check the box skip this screen in future, if you wish. Choose Next.
  3. The BAPI Wizard - Language screen appears.
  4. Enter data in the BAPI Wizard - Language screen as follows:

    Field

    Description

    Output Folder

    Enter the path of the file where you wish the generated files to be placed.

    The code generator uses the output directory you specify to create subdirectories in which to place the files belonging to the individual business objects or RFC functions. For example, for the business object CompanyCode, the BAPI Wizard would create a subdirectory companycode (if it did not already exist) to store all the files generated for that business object.

    Language

    Select the programming language in which the proxy classes are generated.

    Choose between C++ and Java. To use a Custom language, you or someone else must have created custom templates. Creating custom templates is not described in this document.

    Generate DCOM Connector Proxies

    Checking this box uses a different code generator than the one used for the C++ or Java options above: it uses the code generator that comes with the SAP DCOM Connector product.

    Check this box only if you wish to generate code for VB or other COM-compatible languages.

    For C++ we recommend that you do not use this code generator (do not check this box).

    Template and Macro

    SAP Assistant points to the template and macro files of the appropriate language. It includes the full path to these files, using the default subdirectory for the template and macro files (where these files were originally installed). Normally you should take the path suggested by the code generator.

    However, if the SAP Assistant executable or the template or macro files have been moved to another directory, the path to the template and macro files may be invalid.

    It is highly recommended that you leave all of these files in their installed location. However if you do move any of these files, make sure that the path and file name specified in the Template and Macro fields are correct. You can choose the button next to the Template or Macro field to browse for the applicable file.

  5. Choose Next.
  6. The BAPI Wizard - BAPI Selector screen appears. This screen allows you to pick and choose a subset of the methods and even a subset of method parameters for business objects. It also allows you to enter values for individual fields.
  7. See Navigating the BAPI Selector screen for details of how to select items or enter values.

  8. Choose Next. The BAPI Wizard - Final Step screen appears.
  9. When you are satisfied with your selections and with the preset values for parameters and fields, choose Finish to start the code generation.
  10. To examine the code, double-click the entry in the List of Generated Files.

  11. To exit the BAPI Wizard, choose Cancel.

Result

The BAPI Wizard generates the code and displays the path and name of all the generated files.

See Also

The C++ BAPI Proxy Classes, The Java BAPI Proxy Classes