Skip to content

Commit c6fc6bf

Browse files
authored
Add files via upload
1 parent ebde5be commit c6fc6bf

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ Create messages easily from
99

1010
There are two possible ways of creating messages like those; one is to use the factory class, the other is to use the subclasses. The two are not too coupled (the factory uses only the class ZCL_MESSAGE, while the subclasses don't use the factory at all) and are a sort of convenience, for myself, in the form of code duplication
1111

12-
The interface has a type so a message from an object like this should be sent with "MESSAGE ..." (without the TYPE addition)
12+
The interface has a type so a message from an object like this should be sent with "MESSAGE ..." (without the TYPE addition)
13+
14+
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/zcl_message.clas.abap

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@ class zcl_message definition
55

66
public section.
77

8-
interfaces: if_t100_dyn_msg.
8+
interfaces: if_abap_behv_message.
99

1010
aliases: get_longtext for if_message~get_longtext,
1111
get_text for if_message~get_text.
1212

1313
types: begin of enum valid_type structure type,
14-
abortion,
1514
error,
1615
information,
1716
warning,
18-
exit,
1917
success,
2018
end of enum valid_type structure type.
2119

@@ -43,7 +41,7 @@ class zcl_message definition
4341
"! @parameter r_self | <p class="shorttext synchronized" lang="EN"></p>
4442
methods send
4543
returning
46-
value(r_self) type ref to if_t100_dyn_msg.
44+
value(r_self) type ref to if_abap_behv_message.
4745

4846
"! <p class="shorttext synchronized" lang="EN">Sends message and displays it like a specific type</p>
4947
"!
@@ -53,21 +51,21 @@ class zcl_message definition
5351
importing
5452
i_type type zcl_message=>valid_type
5553
returning
56-
value(r_self) type ref to if_t100_dyn_msg.
54+
value(r_self) type ref to if_abap_behv_message.
5755

5856
"! <p class="shorttext synchronized" lang="EN">Sends message that displays at the end of the process</p>
5957
"!
6058
"! @parameter r_self | <p class="shorttext synchronized" lang="EN"></p>
6159
methods display
6260
returning
63-
value(r_self) type ref to if_t100_dyn_msg.
61+
value(r_self) type ref to if_abap_behv_message.
6462

6563
"! <p class="shorttext synchronized" lang="EN">Sends message that displays before continuing the process</p>
6664
"!
6765
"! @parameter r_self | <p class="shorttext synchronized" lang="EN"></p>
6866
methods display_immediately
6967
returning
70-
value(r_self) type ref to if_t100_dyn_msg.
68+
value(r_self) type ref to if_abap_behv_message.
7169

7270
endclass.
7371
class zcl_message implementation.
@@ -85,9 +83,7 @@ class zcl_message implementation.
8583
me->if_t100_dyn_msg~msgty = switch #( i_type
8684
when type-error then 'E'
8785
when type-information then 'I'
88-
when type-abortion then 'A'
8986
when type-warning then 'W'
90-
when type-exit then 'X'
9187
when type-success then 'S' ).
9288

9389
me->if_t100_message~t100key = value #( msgid = i_id
@@ -97,6 +93,12 @@ class zcl_message implementation.
9793
attr3 = 'IF_T100_DYN_MSG~MSGV3'
9894
attr4 = 'IF_T100_DYN_MSG~MSGV4' ).
9995

96+
me->if_abap_behv_message~m_severity = switch #( i_type
97+
when type-error then if_abap_behv_message=>severity-error
98+
when type-information then if_abap_behv_message=>severity-information
99+
when type-warning then if_abap_behv_message=>severity-warning
100+
when type-success then if_abap_behv_message=>severity-success ).
101+
100102
endmethod.
101103
method if_message~get_longtext.
102104

src/zcl_message_factory.clas.abap

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class zcl_message_factory definition
1010
"! @parameter r_system_message | <p class="shorttext synchronized" lang="EN"></p>
1111
methods from_system_message
1212
returning
13-
value(r_system_message) type ref to if_t100_dyn_msg.
13+
value(r_system_message) type ref to if_abap_behv_message.
1414

1515
"! <p class="shorttext synchronized" lang="EN">Returns a new message from a free text</p>
1616
"!
@@ -22,7 +22,7 @@ class zcl_message_factory definition
2222
i_free_text type string
2323
i_type type zcl_message=>valid_type default zcl_message=>type-information
2424
returning
25-
value(r_free_message) type ref to if_t100_dyn_msg.
25+
value(r_free_message) type ref to if_abap_behv_message.
2626

2727
"! <p class="shorttext synchronized" lang="EN">Returns a new message from a text symbol</p>
2828
"! Replaces placeholders &1, &2, &3, and &4 if provided
@@ -43,7 +43,7 @@ class zcl_message_factory definition
4343
i_placeholder3 type sy-msgv3 optional
4444
i_placeholder4 type sy-msgv4 optional
4545
returning
46-
value(r_text_symbol_message) type ref to if_t100_dyn_msg.
46+
value(r_text_symbol_message) type ref to if_abap_behv_message.
4747

4848
"! <p class="shorttext synchronized" lang="EN">Returns a new message from an exception message</p>
4949
"! The type is whatever the exception has if it implements {@link IF_T100_DYN_MSG}, or error if it doesn't
@@ -55,7 +55,7 @@ class zcl_message_factory definition
5555
importing
5656
i_exception type ref to cx_root
5757
returning
58-
value(r_error_message) type ref to if_t100_dyn_msg
58+
value(r_error_message) type ref to if_abap_behv_message
5959
raising
6060
cx_sy_message_illegal_text.
6161

@@ -69,7 +69,7 @@ class zcl_message_factory definition
6969
i_message type ref to if_t100_message
7070
i_new_type type zcl_message=>valid_type optional
7171
returning
72-
value(r_copied_message) type ref to if_t100_dyn_msg.
72+
value(r_copied_message) type ref to if_abap_behv_message.
7373

7474
endclass.
7575
class zcl_message_factory implementation.
@@ -81,10 +81,9 @@ class zcl_message_factory implementation.
8181
i_type = switch #( sy-msgty
8282
when 'E' then zcl_message=>type-error
8383
when 'I' then zcl_message=>type-information
84-
when 'A' then zcl_message=>type-abortion
8584
when 'W' then zcl_message=>type-warning
86-
when 'X' then zcl_message=>type-exit
87-
when 'S' then zcl_message=>type-success )
85+
when 'S' then zcl_message=>type-success
86+
else throw cx_sy_message_illegal_text( ) )
8887
i_var1 = sy-msgv1
8988
i_var2 = sy-msgv2
9089
i_var3 = sy-msgv3
@@ -121,7 +120,7 @@ class zcl_message_factory implementation.
121120
sub = '&3'
122121
with = i_placeholder3 )
123122
sub = '&4'
124-
with = i_placeholder4 )
123+
with = i_placeholder4 )
125124
i_type = i_type ).
126125

127126
endmethod.
@@ -130,7 +129,7 @@ class zcl_message_factory implementation.
130129
cl_message_helper=>set_msg_vars_for_if_t100_msg( cast #( i_exception ) ).
131130

132131
sy-msgty = cond #( when i_exception is instance of if_t100_dyn_msg
133-
then cast if_t100_dyn_msg( i_exception )->msgty
132+
then cast if_t100_dyn_msg( i_exception )->msgty
134133
else 'E' ).
135134

136135
r_error_message = me->from_system_message( ).

src/zcl_sy_message.clas.abap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class zcl_sy_message implementation.
2020
i_type = switch #( sy-msgty
2121
when 'E' then type-error
2222
when 'I' then type-information
23-
when 'A' then type-abortion
2423
when 'W' then type-warning
25-
when 'X' then type-exit
2624
when 'S' then type-success
2725
else throw cx_sy_message_illegal_text( ) )
2826
i_var1 = sy-msgv1

0 commit comments

Comments
 (0)