Start of Content Area

Procedure documentation Unit 10: Creating a Method with Parameters  Locate the document in its SAP Library structure

Use

In this unit, you will create and implement the method Create as a method with parameters. Methods may require parameters in order to be executed or return them after they have been executed.

You must implement this method if your object type supports the IFCREATE interface.

Prerequisites

The method Create creates an object of the specified type. This is one of the methods that your object type inherits from the IFCREATE (Create) interface.

This method is not yet implemented for the interface. The implementation program must be extended correspondingly. To do this, the transaction (or function module) of the application is called in the implementation of the method Create , with which the object is edited. For sales orders, this is transaction VA01 .

The following properties and exceptions of the method Create are inherited from the interface IFCREATE :

The method Create is a synchronous, instance-independent method, which runs with dialog and does not return a result.

Procedure

Analyzing application functionality

  1. Choose Logistics ® Sales and Distribution ® Sales ® Order ® Create.
  2. Choose System ® Status.
  3. You see that you have called transaction VA01 .

  4. Choose This graphic is explained in the accompanying text.
  5. The screen Create Sales Order: Initial Screen is displayed again.

    The Order type is a required entry field. If you want to create a sales order using the method Create , you must either carry out dialog or pass the order type as a parameter when calling.

  6. Position the cursor in the field.
  7. Press F1.
  8. You go to the dialog box with the field help.

  9. Choose Technical info.
  10. You can see from the section Field data, that the input field involves the table field VBAK-AUART .

  11. Leave the dialog box and the screen for creating sales orders. Return to the Business Object Builder in the processing of your object type.

Defining a method

  1. Position the cursor on the method Create .
  2. Choose This graphic is explained in the accompanying text.
  3. The color of the entry changes.

  4. Double-click the method name to open the method definition.
  5. On the tab page ABAP, enter the transaction VA01 in the field Name and select Transaction.
  6. Choose This graphic is explained in the accompanying text.
  7. Creating parameters

  8. Position the cursor on the method Create .
  9. Select Parameters.
  10. The method container, which is still empty, is then displayed.

  11. Choose This graphic is explained in the accompanying text.
  12. Answer the query Create with ABAP Dictionary field proposals? with Yes.
  13. Enter VBAK in the Table field.
  14. From the table fields displayed, select the field AUART (sales document type).
  15. Choose This graphic is explained in the accompanying text.
  16. The dialog box for creating a parameter is displayed.

  17. Create the parameter SalesDocumentType as proposed by choosing This graphic is explained in the accompanying text.
  18. Choose This graphic is explained in the accompanying text.
  19. Position the cursor on the method Create .
  20. Choose Program. Let the system create the template for the missing method.

The implementation of the method Create , which was taken automatically from your specifications, remains unchanged.

Using the provided container macros SWC_GET_ELEMENT (for single-line elements) and SWC_GET_TABLE (for multiline elements), import parameters of the method are read from the container ( CONTAINER ) and passed to the function module or transaction or its processing parameters ("SET/GET parameters").

Export parameters are set in the containers (CONTAINER) when a method is implemented. To do this, use the container macro SWC_SET_ELEMENT for a single-line return parameter or the container macro SWC_SET_TABLE for a multiline return parameter.

You can find the source text in the appendix in lines 118-125.

Result

Testing a method with parameters

  1. The object type must first be generated so that it can be instantiated and tested. Choose This graphic is explained in the accompanying text.
  2. The system informs you if the object type still contains errors. Try to correct these errors in the error overview (Goto ® Error list).

  3. To test the method, choose This graphic is explained in the accompanying text.
  4. The Test Object Type <Object Name>: No Instance screen appears.

  5. Choose This graphic is explained in the accompanying text Instance.
  6. Identify an object of the type sales order by entering the number of a sales order of your choice. Use the F4 input help if necessary.

  7. Choose This graphic is explained in the accompanying text.

The Test Object Type <Object Name> screen then appears, in which you can test your object type (execute methods, check attribute values).