2016 Jun 11 7:45 AM
Hi folks,
because I did not find a good explanation somewhere, I will just ask you for your experiences or better: Best practices:
Scenario: I created ABAP OO application, including a ZCL_VALIDATOR for some input checks. I have a Exception class ZCX_VALIDATOR, which has several TextIDs for the different checks in ZCL_VALIDATOR.
Now, a classic SAP Dynpro should call my application, give some input
like:
DATA lo_validator type ref to ZCL_VALIDATOR.
try.
lo_validator->CHECK_MATNR( iv_matnr = lv_matnr )
catch EXCEPTION TYPE ZCX_VALIDATOR into DATA(lo_exc).
endtry.
Check_matnr does several checks and raises ZCX_VALIDATOR, but dependent on the error case, the GUI should show a 'E' or 'I'.
My approach would be like:
DATA lo_validator type ref to ZCL_VALIDATOR.
try.
lo_validator->CHECK_MATNR( iv_matnr = lv_matnr )
catch EXCEPTION TYPE ZCX_VALIDATOR into DATA(lo_exc).
if lo_exc->textid-msgid eq 'abc'.
MESSAGE type lo_exc DISPLAY LIKE 'I'
else.
MESSAGE type lo_exc DISPLAY LIKE 'E'.
endtry.
Question: Is there any other way to to this?
Thanks for your thoughts on this.
Greetings
michael
Hi folks,
because I did not find a good explanation somewhere, I will just ask you for your experiences or better: Best practices:
Scenario: I created ABAP OO application, including a ZCL_VALIDATOR for some input checks. I have a Exception class ZCX_VALIDATOR, which has several TextIDs for the different checks in ZCL_VALIDATOR.
Now, a classic SAP Dynpro should call my application, give some input
like:
DATA lo_validator type ref to ZCL_VALIDATOR.
try.
lo_validator->CHECK_MATNR( iv_matnr = lv_matnr )
catch EXCEPTION TYPE ZCX_VALIDATOR into DATA(lo_exc).
endtry.
Check_matnr does several checks and raises ZCX_VALIDATOR, but dependent on the error case, the GUI should show a 'E' or 'I'.
My approach would be like:
DATA lo_validator type ref to ZCL_VALIDATOR.
try.
lo_validator->CHECK_MATNR( iv_matnr = lv_matnr )
catch EXCEPTION TYPE ZCX_VALIDATOR into DATA(lo_exc).
if lo_exc->textid-msgid eq 'abc'.
MESSAGE type lo_exc DISPLAY LIKE 'I'
else.
MESSAGE type lo_exc DISPLAY LIKE 'E'.
endtry.
Question: Is there any other way to to this?
Thanks for your thoughts on this.
Greetings
michael
2016 Jun 11 5:17 PM
My point of view is that exceptions should be only used for technical exceptions, not functional validations. Those messages should be collected by "message collectors". Consequently, your question wouldn't need to be asked.
2016 Jun 12 5:45 PM
Hi Sandra,
thanks for your answer. But how to return from method? by bapiret2 or abap_bool?
greetings
michael
2016 Jun 12 6:29 PM
Any internal table for collecting messages. BAPIRET2 for instance ; use it for keeping things simple. The best would be to have an official message collector class but I don't know any standard good one. There are BAL_* function modules. There are unreleased ones: function modules MESSAGES_*, MSG_*, BAL_*, in SAP ERP there is class CL_RECA_MESSAGE_LIST...
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |