├── .abapgit.xml ├── LICENSE ├── README.md └── src ├── package.devc.xml ├── zcl_idoc_edidd.clas.abap ├── zcl_idoc_edidd.clas.xml ├── zcl_idoc_edidd_segment.clas.abap ├── zcl_idoc_edidd_segment.clas.xml ├── zcl_idoc_messages.msag.xml ├── zcx_idoc_exceptions.clas.abap └── zcx_idoc_exceptions.clas.xml /.abapgit.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | E 6 | /src/ 7 | PREFIX 8 | 9 | /.gitignore 10 | /LICENSE 11 | /README.md 12 | /package.json 13 | /.travis.yml 14 | /.gitlab-ci.yml 15 | /abaplint.json 16 | /azure-pipelines.yml 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mateusz Adamus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IDoc-with-ABAP-OOP 2 | IDoc modifications with ABAP Object Oriented Programming 3 | -------------------------------------------------------------------------------- /src/package.devc.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | IDoc with ABAP OOP 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/zcl_idoc_edidd.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_idoc_edidd DEFINITION 2 | PUBLIC 3 | CREATE PROTECTED . 4 | 5 | PUBLIC SECTION. 6 | 7 | CLASS-METHODS create_with_data 8 | IMPORTING 9 | !iv_idoc_type TYPE edi_idoctp 10 | !iv_idoc_extension TYPE edi_cimtyp 11 | !it_edidd TYPE edidd_tt OPTIONAL 12 | RETURNING 13 | VALUE(ro_instance) TYPE REF TO zcl_idoc_edidd 14 | RAISING 15 | zcx_idoc_exceptions . 16 | METHODS add_segment 17 | IMPORTING 18 | !is_edidd TYPE edidd 19 | RETURNING 20 | VALUE(ro_segment) TYPE REF TO zcl_idoc_edidd_segment 21 | RAISING 22 | zcx_idoc_exceptions . 23 | METHODS get_edidd 24 | RETURNING 25 | VALUE(rt_edidd) TYPE edidd_tt . 26 | METHODS get_segments 27 | IMPORTING 28 | !iv_name TYPE edilsegtyp OPTIONAL 29 | RETURNING 30 | VALUE(ro_segments) TYPE REF TO cl_object_collection . 31 | METHODS remove_segment 32 | IMPORTING 33 | !io_segment TYPE REF TO zcl_idoc_edidd_segment 34 | RETURNING 35 | VALUE(rv_removed) TYPE flag . 36 | PROTECTED SECTION. 37 | 38 | TYPES: 39 | ygt_idoc_structure_sorted TYPE SORTED TABLE OF edi_iapi06 40 | WITH UNIQUE KEY idoctyp cimtyp nr 41 | WITH UNIQUE SORTED KEY segtyp COMPONENTS segtyp . 42 | 43 | DATA ao_segments TYPE REF TO cl_object_collection . 44 | DATA at_idoc_structure TYPE fkk_edi_iapi06_tt . 45 | DATA at_idoc_structure_sorted TYPE ygt_idoc_structure_sorted . 46 | DATA av_idoc_extension TYPE edi_cimtyp . 47 | DATA av_idoc_type TYPE edi_idoctp . 48 | 49 | METHODS add_segment_do 50 | FINAL 51 | IMPORTING 52 | !is_edidd TYPE edidd 53 | RETURNING 54 | VALUE(ro_segment) TYPE REF TO zcl_idoc_edidd_segment 55 | RAISING 56 | zcx_idoc_exceptions . 57 | METHODS constructor 58 | IMPORTING 59 | !iv_idoc_type TYPE edi_idoctp 60 | !iv_idoc_extension TYPE edi_cimtyp 61 | !it_edidd TYPE edidd_tt OPTIONAL 62 | !it_idoc_structure TYPE fkk_edi_iapi06_tt 63 | RAISING 64 | zcx_idoc_exceptions . 65 | PRIVATE SECTION. 66 | 67 | METHODS add_segments_in_given_sequence 68 | IMPORTING 69 | !it_edidd TYPE edidd_tt 70 | RAISING 71 | zcx_idoc_exceptions . 72 | ENDCLASS. 73 | 74 | 75 | 76 | CLASS zcl_idoc_edidd IMPLEMENTATION. 77 | 78 | 79 | METHOD add_segment. 80 | DATA: 81 | lo_parent TYPE REF TO zcl_idoc_edidd_segment. 82 | 83 | READ TABLE at_idoc_structure_sorted REFERENCE INTO DATA(ld_idoc_structure) 84 | WITH KEY segtyp COMPONENTS segtyp = is_edidd-segnam. 85 | IF sy-subrc <> 0. 86 | RAISE EXCEPTION TYPE zcx_idoc_exceptions 87 | EXPORTING 88 | textid = zcx_idoc_exceptions=>segment_incorrect_for_idoc 89 | msgv1 = is_edidd-segnam 90 | msgv2 = av_idoc_type 91 | msgv3 = av_idoc_extension. 92 | ENDIF. 93 | 94 | IF ld_idoc_structure->parseg IS INITIAL. 95 | ro_segment = add_segment_do( is_edidd ). 96 | ELSE. 97 | DATA(lo_segments) = get_segments( ld_idoc_structure->parseg ). 98 | IF lo_segments->is_empty( ). 99 | RAISE EXCEPTION TYPE zcx_idoc_exceptions 100 | EXPORTING 101 | textid = zcx_idoc_exceptions=>parent_segment_not_found 102 | msgv1 = ld_idoc_structure->parseg. 103 | ENDIF. 104 | 105 | " add new segment to the last parent segment 106 | DATA(lo_iterator) = lo_segments->get_iterator( ). 107 | WHILE lo_iterator->has_next( ). 108 | lo_parent ?= lo_iterator->get_next( ). 109 | ENDWHILE. 110 | 111 | ro_segment = lo_parent->add_segment( is_edidd ). 112 | ENDIF. 113 | ENDMETHOD. 114 | 115 | 116 | METHOD add_segments_in_given_sequence. 117 | TYPES: 118 | BEGIN OF yls_last_segment, 119 | number TYPE posno, 120 | segment TYPE REF TO zcl_idoc_edidd_segment, 121 | END OF yls_last_segment, 122 | ylt_last_segments TYPE SORTED TABLE OF yls_last_segment 123 | WITH UNIQUE KEY number. 124 | 125 | DATA: 126 | lt_last_segments TYPE ylt_last_segments, 127 | lo_segment TYPE REF TO zcl_idoc_edidd_segment. 128 | 129 | LOOP AT it_edidd REFERENCE INTO DATA(ld_edidd). 130 | READ TABLE at_idoc_structure_sorted REFERENCE INTO DATA(ld_idoc_structure) 131 | WITH KEY segtyp COMPONENTS segtyp = ld_edidd->segnam. 132 | IF sy-subrc <> 0. 133 | RAISE EXCEPTION TYPE zcx_idoc_exceptions 134 | EXPORTING 135 | textid = zcx_idoc_exceptions=>segment_incorrect_for_idoc 136 | msgv1 = ld_edidd->segnam 137 | msgv2 = av_idoc_type 138 | msgv3 = av_idoc_extension. 139 | ENDIF. 140 | 141 | DATA(lo_parent) = me. 142 | IF ld_idoc_structure->parpno IS NOT INITIAL. 143 | READ TABLE lt_last_segments REFERENCE INTO DATA(ld_last_segment) 144 | WITH TABLE KEY number = ld_idoc_structure->parpno. 145 | IF sy-subrc <> 0. 146 | RAISE EXCEPTION TYPE zcx_idoc_exceptions 147 | EXPORTING 148 | textid = zcx_idoc_exceptions=>parent_segment_not_found 149 | msgv1 = ld_idoc_structure->parseg. 150 | ENDIF. 151 | 152 | lo_parent = ld_last_segment->segment. 153 | ENDIF. 154 | 155 | CREATE OBJECT lo_segment 156 | EXPORTING 157 | iv_idoc_type = av_idoc_type 158 | iv_idoc_extension = av_idoc_extension 159 | is_edidd = ld_edidd->* 160 | it_idoc_structure = at_idoc_structure. 161 | lo_parent->ao_segments->add( lo_segment ). 162 | 163 | READ TABLE lt_last_segments REFERENCE INTO ld_last_segment 164 | WITH TABLE KEY number = ld_idoc_structure->nr. 165 | IF sy-subrc <> 0. 166 | CREATE DATA ld_last_segment. 167 | ld_last_segment->number = ld_idoc_structure->nr. 168 | INSERT ld_last_segment->* INTO TABLE lt_last_segments REFERENCE INTO ld_last_segment. 169 | ENDIF. 170 | 171 | ld_last_segment->segment = lo_segment. 172 | ENDLOOP. 173 | ENDMETHOD. 174 | 175 | 176 | METHOD add_segment_do. 177 | DATA: 178 | lv_added TYPE flag VALUE abap_false, 179 | lt_segments TYPE TABLE OF REF TO zcl_idoc_edidd_segment, 180 | lo_segment TYPE REF TO zcl_idoc_edidd_segment. 181 | 182 | CREATE OBJECT ro_segment 183 | EXPORTING 184 | iv_idoc_type = av_idoc_type 185 | iv_idoc_extension = av_idoc_extension 186 | is_edidd = is_edidd 187 | it_idoc_structure = at_idoc_structure. 188 | 189 | DATA(lo_iterator) = ao_segments->get_iterator( ). 190 | WHILE lo_iterator->has_next( ). 191 | lo_segment ?= lo_iterator->get_next( ). 192 | APPEND lo_segment TO lt_segments. 193 | ENDWHILE. 194 | 195 | ao_segments->clear( ). 196 | 197 | READ TABLE at_idoc_structure_sorted REFERENCE INTO DATA(ld_idoc_structure) 198 | WITH KEY segtyp COMPONENTS segtyp = is_edidd-segnam. 199 | DATA(lv_new_segment_position) = ld_idoc_structure->nr. 200 | 201 | LOOP AT lt_segments INTO lo_segment. 202 | " new segments still needs to be added 203 | IF lv_added = abap_false. 204 | READ TABLE at_idoc_structure_sorted REFERENCE INTO ld_idoc_structure 205 | WITH KEY segtyp COMPONENTS segtyp = lo_segment->get_name( ). 206 | DATA(lv_old_segment_position) = ld_idoc_structure->nr. 207 | 208 | IF lv_old_segment_position > lv_new_segment_position. 209 | ao_segments->add( ro_segment ). 210 | lv_added = abap_true. 211 | ENDIF. 212 | ENDIF. 213 | 214 | ao_segments->add( lo_segment ). 215 | ENDLOOP. 216 | 217 | " if segment was not inserted between other segments 218 | " then add it to the end of the collection 219 | CHECK lv_added = abap_false. 220 | ao_segments->add( ro_segment ). 221 | ENDMETHOD. 222 | 223 | 224 | METHOD constructor. 225 | av_idoc_type = iv_idoc_type. 226 | av_idoc_extension = iv_idoc_extension. 227 | at_idoc_structure[] = it_idoc_structure[]. 228 | at_idoc_structure_sorted[] = it_idoc_structure[]. 229 | 230 | CREATE OBJECT ao_segments. 231 | 232 | CHECK it_edidd[] IS NOT INITIAL. 233 | add_segments_in_given_sequence( it_edidd ). 234 | ENDMETHOD. 235 | 236 | 237 | METHOD create_with_data. 238 | DATA: 239 | lt_idoc_structure TYPE fkk_edi_iapi06_tt. 240 | 241 | CALL FUNCTION 'EDI_IDOC_SYNTAX_GET' 242 | EXPORTING 243 | pi_idoctyp = iv_idoc_type 244 | pi_cimtyp = iv_idoc_extension 245 | TABLES 246 | pt_syntax_table = lt_idoc_structure 247 | EXCEPTIONS 248 | syntax_not_found = 1 249 | OTHERS = 2. 250 | IF sy-subrc <> 0. 251 | RAISE EXCEPTION TYPE zcx_idoc_exceptions. 252 | ENDIF. 253 | 254 | CREATE OBJECT ro_instance 255 | EXPORTING 256 | iv_idoc_type = iv_idoc_type 257 | iv_idoc_extension = iv_idoc_extension 258 | it_edidd = it_edidd 259 | it_idoc_structure = lt_idoc_structure. 260 | ENDMETHOD. 261 | 262 | 263 | METHOD get_edidd. 264 | DATA: 265 | lo_segment TYPE REF TO zcl_idoc_edidd_segment. 266 | 267 | DATA(lo_iterator) = ao_segments->get_iterator( ). 268 | WHILE lo_iterator->has_next( ). 269 | lo_segment ?= lo_iterator->get_next( ). 270 | DATA(lt_edidd) = lo_segment->get_edidd( ). 271 | APPEND LINES OF lt_edidd TO rt_edidd. 272 | ENDWHILE. 273 | ENDMETHOD. 274 | 275 | 276 | METHOD get_segments. 277 | DATA: 278 | lv_found TYPE flag VALUE abap_false, 279 | lo_segment TYPE REF TO zcl_idoc_edidd_segment, 280 | lo_child_segment TYPE REF TO zcl_idoc_edidd_segment. 281 | 282 | CREATE OBJECT ro_segments. 283 | 284 | DATA(lo_iterator) = ao_segments->get_iterator( ). 285 | WHILE lo_iterator->has_next( ). 286 | lo_segment ?= lo_iterator->get_next( ). 287 | 288 | IF iv_name IS SUPPLIED. 289 | IF lo_segment->get_name( ) = iv_name. 290 | lv_found = abap_true. 291 | ro_segments->add( lo_segment ). 292 | ENDIF. 293 | ELSE. 294 | ro_segments->add( lo_segment ). 295 | ENDIF. 296 | 297 | " if segments with given name was found on this level 298 | " then do not search deeper 299 | CHECK lv_found = abap_false. 300 | 301 | DATA(lo_child_segments) = lo_segment->get_segments( iv_name = iv_name ). 302 | DATA(lo_child_iterator) = lo_child_segments->get_iterator( ). 303 | WHILE lo_child_iterator->has_next( ). 304 | lo_child_segment ?= lo_child_iterator->get_next( ). 305 | ro_segments->add( lo_child_segment ). 306 | ENDWHILE. 307 | ENDWHILE. 308 | ENDMETHOD. 309 | 310 | 311 | METHOD remove_segment. 312 | DATA: 313 | lo_segment TYPE REF TO zcl_idoc_edidd_segment. 314 | 315 | rv_removed = abap_false. 316 | 317 | DATA(lo_iterator) = ao_segments->get_iterator( ). 318 | WHILE lo_iterator->has_next( ). 319 | lo_segment ?= lo_iterator->get_next( ). 320 | IF lo_segment = io_segment. 321 | ao_segments->remove( io_segment ). 322 | rv_removed = abap_true. 323 | RETURN. 324 | ENDIF. 325 | 326 | IF lo_segment->remove_segment( io_segment ). 327 | rv_removed = abap_true. 328 | RETURN. 329 | ENDIF. 330 | ENDWHILE. 331 | ENDMETHOD. 332 | ENDCLASS. 333 | -------------------------------------------------------------------------------- /src/zcl_idoc_edidd.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_IDOC_EDIDD 7 | E 8 | IDoc data (EDIDD table) 9 | 1 10 | X 11 | X 12 | X 13 | K 14 | 15 | 16 | 17 | ZCL_IDOC_EDIDD 18 | AT_IDOC_STRUCTURE 19 | E 20 | Table Type for API Structure for IDoc Syntax 21 | 22 | 23 | ZCL_IDOC_EDIDD 24 | AV_IDOC_EXTENSION 25 | E 26 | Extension 27 | 28 | 29 | ZCL_IDOC_EDIDD 30 | AV_IDOC_TYPE 31 | E 32 | Basic type 33 | 34 | 35 | ZCL_IDOC_EDIDD 36 | CONSTRUCTOR 37 | E 38 | CONSTRUCTOR 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/zcl_idoc_edidd_segment.clas.abap: -------------------------------------------------------------------------------- 1 | class ZCL_IDOC_EDIDD_SEGMENT definition 2 | public 3 | inheriting from ZCL_IDOC_EDIDD 4 | final 5 | create public 6 | 7 | global friends ZCL_IDOC_EDIDD . 8 | 9 | public section. 10 | 11 | methods CONSTRUCTOR 12 | importing 13 | !IV_IDOC_TYPE type EDI_IDOCTP 14 | !IV_IDOC_EXTENSION type EDI_CIMTYP 15 | !IS_EDIDD type EDIDD 16 | !IT_IDOC_STRUCTURE type FKK_EDI_IAPI06_TT 17 | raising 18 | ZCX_IDOC_EXCEPTIONS . 19 | methods GET_HIERARCHY_LEVEL 20 | returning 21 | value(RV_VALUE) type EDI_HLEVEL . 22 | methods GET_IDOC_NUMBER 23 | returning 24 | value(RV_VALUE) type EDI_DOCNUM . 25 | methods GET_NAME 26 | returning 27 | value(RV_VALUE) type EDILSEGTYP . 28 | methods GET_PARENT_NUMBER 29 | returning 30 | value(RV_VALUE) type EDI_PSGNUM . 31 | methods GET_SDATA 32 | returning 33 | value(RS_VALUE) type EDI_SDATA . 34 | methods GET_SEGMENT_NUMBER 35 | returning 36 | value(RV_VALUE) type IDOCDSGNUM . 37 | methods SET_SDATA 38 | importing 39 | !IS_VALUE type ANY 40 | returning 41 | value(RO_INSTANCE) type ref to ZCL_IDOC_EDIDD_SEGMENT . 42 | 43 | methods ADD_SEGMENT 44 | redefinition . 45 | methods GET_EDIDD 46 | redefinition . 47 | PROTECTED SECTION. 48 | PRIVATE SECTION. 49 | 50 | DATA as_edidd TYPE edidd . 51 | ENDCLASS. 52 | 53 | 54 | 55 | CLASS ZCL_IDOC_EDIDD_SEGMENT IMPLEMENTATION. 56 | 57 | 58 | METHOD add_segment. 59 | READ TABLE at_idoc_structure_sorted REFERENCE INTO DATA(ld_idoc_structure) 60 | WITH KEY segtyp COMPONENTS segtyp = is_edidd-segnam. 61 | IF sy-subrc <> 0. 62 | RAISE EXCEPTION TYPE zcx_idoc_exceptions 63 | EXPORTING 64 | textid = zcx_idoc_exceptions=>segment_incorrect_for_idoc 65 | msgv1 = is_edidd-segnam 66 | msgv2 = av_idoc_type 67 | msgv3 = av_idoc_extension. 68 | ENDIF. 69 | 70 | IF get_name( ) <> ld_idoc_structure->parseg. 71 | RAISE EXCEPTION TYPE zcx_idoc_exceptions 72 | EXPORTING 73 | textid = zcx_idoc_exceptions=>segment_child_of_segment 74 | msgv1 = is_edidd-segnam 75 | msgv2 = ld_idoc_structure->parseg. 76 | ENDIF. 77 | 78 | ro_segment = add_segment_do( is_edidd ). 79 | ENDMETHOD. 80 | 81 | 82 | METHOD constructor. 83 | super->constructor( 84 | iv_idoc_type = iv_idoc_type 85 | iv_idoc_extension = iv_idoc_extension 86 | it_idoc_structure = it_idoc_structure ). 87 | 88 | as_edidd = is_edidd. 89 | ENDMETHOD. 90 | 91 | 92 | METHOD get_edidd. 93 | DATA: 94 | lo_segment TYPE REF TO zcl_idoc_edidd_segment. 95 | 96 | APPEND as_edidd TO rt_edidd. 97 | 98 | DATA(lo_iterator) = ao_segments->get_iterator( ). 99 | WHILE lo_iterator->has_next( ). 100 | lo_segment ?= lo_iterator->get_next( ). 101 | DATA(lt_edidd) = lo_segment->get_edidd( ). 102 | APPEND LINES OF lt_edidd TO rt_edidd. 103 | ENDWHILE. 104 | ENDMETHOD. 105 | 106 | 107 | METHOD get_name. 108 | rv_value = as_edidd-segnam. 109 | ENDMETHOD. 110 | 111 | 112 | METHOD get_sdata. 113 | rs_value = as_edidd-sdata. 114 | ENDMETHOD. 115 | 116 | 117 | METHOD set_sdata. 118 | MOVE is_value TO as_edidd-sdata. 119 | ro_instance = me. 120 | ENDMETHOD. 121 | 122 | 123 | METHOD get_hierarchy_level. 124 | rv_value = as_edidd-hlevel. 125 | ENDMETHOD. 126 | 127 | 128 | METHOD get_idoc_number. 129 | rv_value = as_edidd-docnum. 130 | ENDMETHOD. 131 | 132 | 133 | METHOD get_parent_number. 134 | rv_value = as_edidd-psgnum. 135 | ENDMETHOD. 136 | 137 | 138 | METHOD get_segment_number. 139 | rv_value = as_edidd-segnum. 140 | ENDMETHOD. 141 | ENDCLASS. -------------------------------------------------------------------------------- /src/zcl_idoc_edidd_segment.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_IDOC_EDIDD_SEGMENT 7 | E 8 | IDoc data (EDIDD segment) 9 | 1 10 | X 11 | X 12 | X 13 | K 14 | 15 | 16 | 17 | ZCL_IDOC_EDIDD_SEGMENT 18 | AS_EDIDD 19 | E 20 | Data record (IDoc) 21 | 22 | 23 | ZCL_IDOC_EDIDD_SEGMENT 24 | CONSTRUCTOR 25 | E 26 | CONSTRUCTOR 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/zcl_idoc_messages.msag.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_IDOC_MESSAGES 7 | E 8 | Messages for IDoc parsing 9 | 10 | 11 | 12 | E 13 | ZCL_IDOC_MESSAGES 14 | 000 15 | &1&2&3&4 16 | 17 | 18 | E 19 | ZCL_IDOC_MESSAGES 20 | 001 21 | Segment &1 is incorrect for IDoc type &2/&3 22 | 23 | 24 | E 25 | ZCL_IDOC_MESSAGES 26 | 002 27 | Segment &1 should be a child of segment &2 28 | 29 | 30 | E 31 | ZCL_IDOC_MESSAGES 32 | 003 33 | Parent segment &1 not found 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/zcx_idoc_exceptions.clas.abap: -------------------------------------------------------------------------------- 1 | class ZCX_IDOC_EXCEPTIONS definition 2 | public 3 | inheriting from CX_STATIC_CHECK 4 | final 5 | create public . 6 | 7 | public section. 8 | 9 | interfaces IF_T100_MESSAGE . 10 | 11 | constants: 12 | " Segment &1 is incorrect for IDoc type &2/&3 13 | BEGIN OF segment_incorrect_for_idoc, 14 | msgid TYPE symsgid VALUE 'ZCL_IDOC_MESSAGES', 15 | msgno TYPE symsgno VALUE '001', 16 | attr1 TYPE scx_attrname VALUE 'MSGV1', 17 | attr2 TYPE scx_attrname VALUE 'MSGV2', 18 | attr3 TYPE scx_attrname VALUE 'MSGV3', 19 | attr4 TYPE scx_attrname VALUE '', 20 | END OF segment_incorrect_for_idoc . 21 | constants: 22 | " Parent segment &1 not found 23 | begin of PARENT_SEGMENT_NOT_FOUND, 24 | msgid type symsgid value 'ZCL_IDOC_MESSAGES', 25 | msgno type symsgno value '003', 26 | attr1 type scx_attrname value 'MSGV1', 27 | attr2 type scx_attrname value '', 28 | attr3 type scx_attrname value '', 29 | attr4 type scx_attrname value '', 30 | end of PARENT_SEGMENT_NOT_FOUND . 31 | constants: 32 | " Segment &1 should be a child of segment &2 33 | begin of SEGMENT_CHILD_OF_SEGMENT, 34 | msgid type symsgid value 'ZCL_IDOC_MESSAGES', 35 | msgno type symsgno value '002', 36 | attr1 type scx_attrname value 'MSGV1', 37 | attr2 type scx_attrname value 'MSGV2', 38 | attr3 type scx_attrname value '', 39 | attr4 type scx_attrname value '', 40 | end of SEGMENT_CHILD_OF_SEGMENT . 41 | data MSGV1 type SYST_MSGV read-only . 42 | data MSGV2 type SYST_MSGV read-only . 43 | data MSGV3 type SYST_MSGV read-only . 44 | data MSGV4 type SYST_MSGV read-only . 45 | 46 | methods CONSTRUCTOR 47 | importing 48 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional 49 | !PREVIOUS like PREVIOUS optional 50 | !MSGV1 type CLIKE optional 51 | !MSGV2 type CLIKE optional 52 | !MSGV3 type CLIKE optional 53 | !MSGV4 type CLIKE optional . 54 | PROTECTED SECTION. 55 | PRIVATE SECTION. 56 | ENDCLASS. 57 | 58 | 59 | 60 | CLASS ZCX_IDOC_EXCEPTIONS IMPLEMENTATION. 61 | 62 | 63 | METHOD constructor. 64 | CALL METHOD super->constructor 65 | EXPORTING 66 | previous = previous. 67 | 68 | me->msgv1 = msgv1. 69 | me->msgv2 = msgv2. 70 | me->msgv3 = msgv3. 71 | me->msgv4 = msgv4. 72 | 73 | CLEAR me->textid. 74 | IF textid IS INITIAL. 75 | if_t100_message~t100key = if_t100_message=>default_textid. 76 | ELSE. 77 | if_t100_message~t100key = textid. 78 | ENDIF. 79 | ENDMETHOD. 80 | ENDCLASS. 81 | -------------------------------------------------------------------------------- /src/zcx_idoc_exceptions.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCX_IDOC_EXCEPTIONS 7 | E 8 | IDoc Exceptions 9 | 40 10 | 1 11 | X 12 | X 13 | X 14 | K 15 | ZCL_IDOC_MESSAGES 16 | 17 | 18 | 19 | ZCX_IDOC_EXCEPTIONS 20 | CONSTRUCTOR 21 | E 22 | CONSTRUCTOR 23 | 24 | 25 | ZCX_IDOC_EXCEPTIONS 26 | MSGV1 27 | E 28 | ABAP System Field: Message Variable 29 | 30 | 31 | ZCX_IDOC_EXCEPTIONS 32 | MSGV2 33 | E 34 | ABAP System Field: Message Variable 35 | 36 | 37 | ZCX_IDOC_EXCEPTIONS 38 | MSGV3 39 | E 40 | ABAP System Field: Message Variable 41 | 42 | 43 | ZCX_IDOC_EXCEPTIONS 44 | MSGV4 45 | E 46 | ABAP System Field: Message Variable 47 | 48 | 49 | 50 | 51 | 52 | --------------------------------------------------------------------------------