Skip to content

Commit ba2af35

Browse files
authored
Add files via upload
1 parent 0e308b4 commit ba2af35

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
Exceptions that implement the message interface and that take a message in the constructor
44

5-
The interface has a type so a message from an exception like this should be sent with "MESSAGE ..." (without the TYPE addition)
5+
The interface has a type so a message from an exception like this should be sent with "MESSAGE ..." (without the TYPE addition)
6+
7+
Since ABAP 7.53 the addition USING MESSAGE can be used to throw an exception with the current message variables of sy structure, making creating an exception of this type by feeding it a ZCL_SY_MESSAGE object somewhat obsolete
8+
9+
While it is technically possible to modify the value of the attribute "severity" of the new interface, the code was implemented assuming that the severity and the type will match

src/zcx_dynamic_check.clas.abap

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class zcx_dynamic_check definition
66

77
public section.
88

9-
interfaces: if_t100_dyn_msg.
9+
interfaces: if_abap_behv_message.
1010

1111
"! <p class="shorttext synchronized" lang="EN">Creates an exception. Can use a t100 msg</p>
1212
"!
@@ -66,6 +66,15 @@ class zcx_dynamic_check implementation.
6666
attr3 = 'IF_T100_DYN_MSG~MSGV3'
6767
attr4 = 'IF_T100_DYN_MSG~MSGV4' ).
6868

69+
me->if_abap_behv_message~m_severity = cond #( when i_t100_message is instance of if_abap_behv_message
70+
then cast if_abap_behv_message( i_t100_message )->m_severity
71+
else switch #( sy-msgty
72+
when 'E' then if_abap_behv_message=>severity-error
73+
when 'I' then if_abap_behv_message=>severity-information
74+
when 'W' then if_abap_behv_message=>severity-warning
75+
when 'S' then if_abap_behv_message=>severity-success
76+
else throw cx_sy_message_illegal_text( ) ) ).
77+
6978
else.
7079

7180
me->if_t100_message~t100key = if_t100_message=>default_textid.

src/zcx_no_check.clas.abap

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class zcx_no_check definition
66

77
public section.
88

9-
interfaces: if_t100_dyn_msg.
9+
interfaces: if_abap_behv_message.
1010

1111
"! <p class="shorttext synchronized" lang="EN">Creates an exception. Can use a t100 msg</p>
1212
"!
@@ -66,6 +66,15 @@ class zcx_no_check implementation.
6666
attr3 = 'IF_T100_DYN_MSG~MSGV3'
6767
attr4 = 'IF_T100_DYN_MSG~MSGV4' ).
6868

69+
me->if_abap_behv_message~m_severity = cond #( when i_t100_message is instance of if_abap_behv_message
70+
then cast if_abap_behv_message( i_t100_message )->m_severity
71+
else switch #( sy-msgty
72+
when 'E' then if_abap_behv_message=>severity-error
73+
when 'I' then if_abap_behv_message=>severity-information
74+
when 'W' then if_abap_behv_message=>severity-warning
75+
when 'S' then if_abap_behv_message=>severity-success
76+
else throw cx_sy_message_illegal_text( ) ) ).
77+
6978
else.
7079

7180
me->if_t100_message~t100key = if_t100_message=>default_textid.

src/zcx_static_check.clas.abap

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class zcx_static_check definition
66

77
public section.
88

9-
interfaces: if_t100_dyn_msg.
9+
interfaces: if_abap_behv_message.
1010

1111
"! <p class="shorttext synchronized" lang="EN">Creates an exception. Can use a t100 msg</p>
1212
"!
@@ -66,6 +66,15 @@ class zcx_static_check implementation.
6666
attr3 = 'IF_T100_DYN_MSG~MSGV3'
6767
attr4 = 'IF_T100_DYN_MSG~MSGV4' ).
6868

69+
me->if_abap_behv_message~m_severity = cond #( when i_t100_message is instance of if_abap_behv_message
70+
then cast if_abap_behv_message( i_t100_message )->m_severity
71+
else switch #( sy-msgty
72+
when 'E' then if_abap_behv_message=>severity-error
73+
when 'I' then if_abap_behv_message=>severity-information
74+
when 'W' then if_abap_behv_message=>severity-warning
75+
when 'S' then if_abap_behv_message=>severity-success
76+
else throw cx_sy_message_illegal_text( ) ) ).
77+
6978
else.
7079

7180
me->if_t100_message~t100key = if_t100_message=>default_textid.

0 commit comments

Comments
 (0)