on 06-28-2007 4:12 PM
Hi everyone. I know that the WDA framwork will not let me declare a raising clause in the method signature. However, during checks in the component i usually declare some code like this which is not pretty:
The methods below were declared in the view controller.
*---this method is called from DOBEFOREACTION method
METHOD validate_view_fields .
DATA: l_returncode TYPE sysubrc.
CALL METHOD validate_required_fields(
IMPORTING
e_returncode = l_returncode ).
IF l_returncode <> 0.
e_returncode = l_returncode.
ENDIF.
-more code down here-
ENDMETHOD.
I would like the framework to call a method and if something goes wrong I do not want to proceed further down the code or navigate. If I could declare exceptions I could handle this pretty easily.
If assistance classes or model classes are the answer then would I be able to read the context from those classes? I've also read that passing references of the web dynpro controllers to the assistance class could produce some problems.
What's the best way to check the view fields and to prevent going further with the subsequent code if an exception condition is found?
Thanks! Generous points will be awarded!
Hi Alexander,
The best way to check the input fields and prevent the framework from calling further methods is this:
Check the values in WDDOBEFOREACTION. In this method you can check the name of the action, if it is an action of the same view. Maybe you want to skip testing, if the user pressed the CANCEL button or something similar.
Report the message as an error message attached to an attribute. Then the next methods (e.g. event handler) will not be called, and therefore no navigation will take place.
If this does not work as described here, you should check your basis support package. It should be SP11 or higher.
Ciao, Regina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys. Yup I know the message manager prevents the navigation of the view but it does not prevent the processing of subsequent statements after the call to the message manager. For example in ABAP Dynpro, when you trigger an error message the error message is displayed and the code does not continue on. Is there a similar technique in WDA?
If we could use exceptions in the WDA methods then I would not run into this problem as when an exception is raised in a try block, all subsequent statements are not executed because the runtime immediately proceeds to the catch block.
Hoping for your valuable inputs. Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
anyways you are going to raise the exception within an if block i assume, at the end of the method call you can write a RETURN or EXIT statement to stop execution.
if this doesn't satify you then you will have to go ahead with the approach suggested by Nithya.
For raising exceptions or error messages, message manager is the only interface provided by the WDA framework and it is the suggested way too.
Regards,
Shweta
Hi,
if you want to just do validation then it is good idea to use REPORT_ATTRIBUTE_....
kind of message as they will point to the attribute where the validation has failed.
There are also exception messages available..
May be you can check the link below for all type of messages available
http://help.sap.com/saphelp_nw04s/helpdata/en/77/3545415ea6f523e10000000a155106/frameset.htm
Hello Alexander,
reporting error messages using the methods of the interface if_wd_message_manager also prevents further processing.
you can check out the methods raise_exception, report_fatal_exception, report_error_message etc.
you can use code wizard to generate the code required to use these methods.
Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
You can have a class with static methods that raise exceptions. In your Web Dynpro method, just call these classes, in case of exceptions, raise error messages and execute the return statement. That will suffice to prevent further processing.
For eg, if you want have a simple login view and take the user to the details view after validating the login info, you can read the context, pass the username and password to your static method, if an exception is raised, just give an error message. This will help the user stay in the same view. If no exception is raised, fire an outbound plug.
You have to read the context, I dont think it can be read from the classes.
Regards,
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.