Unit 10: Creating a Method with Parameters
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
You see that you have called transaction
VA01 .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.You go to the dialog box with the field help.
You can see from the section Field data, that the input field involves the table field
VBAK-AUART .Defining a method
The color of the entry changes.
Creating parameters
The method container, which is still empty, is then displayed.
The dialog box for creating a parameter is displayed.
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
The system informs you if the object type still contains errors. Try to correct these errors in the error overview (Goto
® Error list).The Test Object Type <Object Name>: No Instance screen appears.
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.
The Test Object Type <Object Name> screen then appears, in which you can test your object type (execute methods, check attribute values).