Hi RAM,
Check out this option as well:
I don't think there a need to have references of other views in comp controller and then use in MAIN view, instead you can directly place the logic for checking mandatory fields in WDDOBEFOREACTION( ) method of each sub view.
Please follow the below steps:
- Create a global attribute GV_ACTION in component controller
- Collect the current action of MAIN view in WDDOBEFOREACTION( ) method as below
wd_comp_controller->gv_action = lo_action.
- Now, go to WDDOBEFOREACTION( ) method of sub views, write the logic as below
case wd_component_controller->gv_action.
when 'SAVE'.
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = lo_api_controller.
when OTHERS.
ENDCASE.
Here, we are distributing the error handling of each view inside its own methods i.e. the view, which owns the fields and the validation of these fields is its responsibility.
Hope this helps you.
Regards,
Rama