5 Programming DCOM Clients in VB

This section contains the following topics:

Hints and Recommendations for Programming

Error Handling in the Client Program

Reference to the Type Library

Basic Structure of the Program

Example Program: SalesOrder.vbp

Hints and Recommendations for Programming

 

 

 

Error Handling in the Client Program

For error handling in the client program, it is reasonable to distinguish between three categories of errors:

 

The error information of the first two categories is recorded by the DCOM Connector; you can query it in VB. If these types of errors occur, the value of Err.Number is unequal to zero. Execute a query accordingly and let the system display a description of the error from Err.Description.

Note: In this case, use the statement On error resume next before starting a call.

 

For errors at a BAPI call, apart from the query above, you can access predefined return parameters. The most commonly used ABAP Dictionary structures for return parameters are:

 

Example: Structure of BAPIRETURN

 

Reference to the Type Library

To be able access generated proxy objects in a VB project, you must create a reference to the corresponding Type Library. Choose Project ® References.

The figure below shows the naming convention for the reference you must make to the Type Library:

 

 

Basic Structure of the Program

Programming a VB application consists of the following steps:

 


 

Example Program: SalesOrder.vbp

Prerequisites

 

Procedure

To execute the example program, proceed as follows:

 

  1. Choose rfcsdk ® ccsamp ® Sales.VB.
  2. Double-click on the project file SalesOrder.vbp.
    The system starts the development environment of Visual Basic and opens the project SalesOrder.
  3. Choose Project ® References to create a reference to the generated DCOM proxies.
    A list of all available references appears.
  4. Select the reference to the appropriate Type Library and confirm with OK.
  5.  

    Note: For information on the naming convention, see Reference to the Type Library.

     

  6. Choose Start to start the application.
  7. In the initial screen, choose SAP ® Logon to log on to a system.
    The window for entering the logon data appears.
  8.  

  9. Enter your logon data if they differ from the preset values and confirm with OK.
    Show Maintaining Destinations.
  10. In the initial screen, choose SAP ® PlaceOrder.
  11. Enter valid values for the input parameters.
    The example program also contains functions for verifying certain entries.

Note: Use the appropriate input data from your system!

 

 

 

Result

The result containing customer-specific data is displayed in a table: