Unit 8: Creating the ExistenceCheck Method Without Parameters
Use
In this unit, you will create and implement the method
ExistenceCheck as a method without a parameter.You must implement this method if your object type supports the SAP standard interface.
Prerequisites
The
ExistenceCheck method checks whether the object identified by the key fields actually exists. The ExistenceCheck method is one of the methods inherited by every object type from the SAP standard interface (technical name: IFSAP) .This method is not yet implemented for the interface. The implementation program must be extended correspondingly.
The following properties and exceptions of the method
ExistenceCheck are inherited from the interface IFSAP :The
The exception The object does not exist is defined for the method ExistenceCheck with the number 0001 .
This exception must be implemented at the appropriate point in the source text. Use the macro command EXIT_RETURN 0001 SPACE SPACE SPACE SPACE for this purpose.
Defining exceptions
Exceptions can be defined for each method. For each exception, you must specify whether a temporary error or an application or system error is involved. Each exception is identified by a 4-digit number and linked to a message text that is supplemented by up to four variables at runtime. You can use the following number ranges:
Implementing exceptions
You trigger the exception within the implementation of the method, that is within the macro commands
BEGIN_METHOD and END_METHOD , if an error occurs when the method is processed. Use the macro command with the call: EXIT_RETURN Code Variable1 Variable2 Variable3 Variable4.As the code (ABAP Dictionary reference SWOTINVOKE-CODE), enter the four-digit number of the exception which was specified when the exception was defined. The four variables (maximum) are determined from the definition of the message that is linked to the exception.
For more information, see
Programming Exceptions.Procedure
The color of the entry changes.
Add the implementation program of the
ExistenceCheck method, which you can take from the implementation program in the appendix (lines 104-111), to the program. The VBAK table, which contains the header data of a sales order, is scanned with the key entered. If this was not successful, exception 0001 is triggered.Result
Testing a method without 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).