├── .abapgit.xml
├── .github
└── FUNDING.yml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── abaplint.json
├── img
└── export_scarr.png
└── src
├── package.devc.xml
├── zcx_export_cluster_table.clas.abap
├── zcx_export_cluster_table.clas.xml
├── zcx_export_empty.clas.abap
├── zcx_export_empty.clas.xml
├── zcx_export_error.clas.abap
├── zcx_export_error.clas.xml
├── zcx_export_invalid_name.clas.abap
├── zcx_export_invalid_name.clas.xml
├── zcx_export_object_exists.clas.abap
├── zcx_export_object_exists.clas.xml
├── zcx_export_table_duplicate.clas.abap
├── zcx_export_table_duplicate.clas.xml
├── zcx_export_to_file.clas.abap
├── zcx_export_to_file.clas.xml
├── zcx_export_tr_order.clas.abap
├── zcx_export_tr_order.clas.xml
├── zcx_export_where_clause_invali.clas.abap
├── zcx_export_where_clause_invali.clas.xml
├── zcx_import_error.clas.abap
├── zcx_import_error.clas.xml
├── zcx_import_merge_conflict.clas.abap
├── zcx_import_merge_conflict.clas.xml
├── zcx_import_not_allowed.clas.abap
├── zcx_import_not_allowed.clas.xml
├── zcx_import_object_not_exists.clas.abap
├── zcx_import_object_not_exists.clas.xml
├── zexport.msag.xml
├── zexport_batch_input.prog.abap
├── zexport_batch_input.prog.xml
├── zexport_bundle.clas.abap
├── zexport_bundle.clas.xml
├── zexport_bundle_in_cluster.clas.abap
├── zexport_bundle_in_cluster.clas.xml
├── zexport_bundle_in_tdc.clas.abap
├── zexport_bundle_in_tdc.clas.testclasses.abap
├── zexport_bundle_in_tdc.clas.xml
├── zexport_changed_sign.dtel.xml
├── zexport_fake_table.dtel.xml
├── zexport_file_mime_to_frontend.clas.abap
├── zexport_file_mime_to_frontend.clas.xml
├── zexport_gui.prog.abap
├── zexport_gui.prog.xml
├── zexport_is_initial.dtel.xml
├── zexport_overwrite.doma.xml
├── zexport_overwrite.dtel.xml
├── zexport_source_table.dtel.xml
├── zexport_table_list.tabl.xml
├── zexport_table_mod.tabl.xml
├── zexport_ut1.tabl.xml
├── zexport_ut2.tabl.xml
├── zexport_ut3.tabl.xml
├── zexport_utils.clas.abap
├── zexport_utils.clas.testclasses.abap
├── zexport_utils.clas.xml
├── zimport_bundle.clas.abap
├── zimport_bundle.clas.xml
├── zimport_bundle.fugr.lzimport_bundletop.abap
├── zimport_bundle.fugr.lzimport_bundletop.xml
├── zimport_bundle.fugr.saplzimport_bundle.abap
├── zimport_bundle.fugr.saplzimport_bundle.xml
├── zimport_bundle.fugr.xml
├── zimport_bundle.fugr.zimport_bundle_from_cluster.abap
├── zimport_bundle.fugr.zimport_bundle_from_tdc.abap
├── zimport_bundle.fugr.zimport_prevent_commit_work.abap
├── zimport_bundle.fugr.zrfc_import_bundle_from_tdc.abap
├── zimport_bundle.fugr.zrfcimport_bundle_from_cluster.abap
├── zimport_bundle_from_cluster.clas.abap
├── zimport_bundle_from_cluster.clas.testclasses.abap
├── zimport_bundle_from_cluster.clas.xml
├── zimport_bundle_from_tdc.clas.abap
├── zimport_bundle_from_tdc.clas.testclasses.abap
├── zimport_bundle_from_tdc.clas.xml
├── zimport_tvarvc.tabl.xml
├── zimport_ut1.tabl.xml
├── zimport_ut2.tabl.xml
├── ztest_export_gui.prog.abap
└── ztest_export_gui.prog.xml
/.abapgit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | E
6 | /src/
7 | PREFIX
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: ["https://paypal.me/bunysae"]
2 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing #
2 | Contributions are welcome. Please open a issue before submitting a bigger pull-request.
3 |
4 | ## Styleguide ##
5 | Development should be sustainable (clean-code).
6 | Please stick to [clean-code styleguides](https://github.com/sap/styleguides).
7 | Refactorings are always welcome!
8 |
9 | * Please use the Pretty Printer with keywords in upper-case.
10 | * Code should be compatible with release 7.40. The sytnax check
11 | shouldn't find any errors, if features from higher releases are used.
12 | * Development objects should begin with `zexport` or with `zimport`.
13 |
14 | ## Testing ##
15 | The classes `zimport_bundle_from_cluster` and `zimport_bundle_from_tdc`
16 | contains automated tests. The automated tests overwrite the MIME-object `ZBUNDLE_UNIT_TEST` and the ECATT test data container `ZBUNDLE_UNIT_TEST`. Please make sure,
17 | these objects are not used otherwise.
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Bunyanuch Saengnet
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 | # ABAP Database preparator #
2 | Database preparation for unit testing made simple. Store snapshots
3 | (bundles) of your database records for later use in unit tests.
4 |
5 | ## No more breaking unit tests ##
6 | The snapshots should avoid breaking unit tests after system copies and
7 | other database manipulations. This is achieved by providing a wrapper
8 | for the OpenSQL replacement service in class `cl_osql_replace`, that
9 | makes huge setups unnecessary.
10 |
11 | ### Good bye huge setups ###
12 | Replace this huge setup method
13 | ```ABAP
14 | METHOD setup.
15 | DATA: airlines TYPE STANDARD TABLE OF zcarr_fake,
16 | replaced_tables TYPE cl_osql_replace=>tt_replacement.
17 |
18 | DELETE FROM airlines.
19 | airlines = VALUE #(
20 | ( carrid = 'TG' carrname = 'Thai Airways' )
21 | ).
22 | INSERT zcarr_fake FROM airlines.
23 |
24 | replaced_tables = VALUE #(
25 | ( source = 'SCARR' target = 'ZCARR_FAKE' )
26 | ).
27 | cl_osql_replace=>activate_replacement( EXPORTING
28 | replacement_table = replaced_tables ).
29 |
30 | ENDMETHOD.
31 | ```
32 | by just two method calls:
33 | ```ABAP
34 | METHOD setup.
35 |
36 | DATA(db_preparator) = NEW zimport_bundle_from_tdc( tdc = 'ZAIRLINES'
37 | tdc_version = 1 variant = 'ECATTDEFAULT' ).
38 | db_preparator->replace_content_completly( ).
39 | db_preparator->activate_osql_replacement( ).
40 |
41 | ENDMETHOD.
42 | ```
43 |
44 | ## How it works ##
45 | Bundles are stored either in an ECATT test data container
46 | or in a cluster (binary MIME-object in transaction smw0).
47 |
48 | ### Export step ###
49 | In the first step we can choose the database records,
50 | which should be exported into the bundle.
51 | The OpenSQL replacement service needs a so called fake table with the same
52 | structure as the original table. From this fake table the database records are
53 | read or they are written back in this fake table. In the export step we link
54 | original and fake table as shown in the picture below.
55 | 
56 | *Figure 1 Export step for table scarr in program `zexport_gui`*
57 | In figure 1 the original table is named `scarr`, the fake table `zcarr_fake`.
58 |
59 | Fake tables can be left empty, if the OpenSQL replacement service isn't
60 | installed.
61 |
62 | #### FOR ALL ENTRIES IN ####
63 | The SQL where restriction can be prefixed a `FOR ALL ENTRIES IN`, which acts
64 | like the corresponding ABAP-statement. As internal table any original table from the bundle can be given. Internal table name should be `'X' && table_name`. E.g.
65 | Database table | Fake database table | SQL where restriction
66 | -------------- | ------------------- | ---------------------
67 | SCARR | ZCARR_FAKE | carrid in ('TG', 'AA')
68 | SPFLI | ZSPFLI_FAKE | FOR ALL ENTRIES IN xzcarr_fake WHERE carrid = xzcarr_fake-carrid
69 |
70 | #### JOINS ####
71 | Joins can be expressed with subqueries. Let's consider the following join:
72 | ```
73 | SELECT * FROM sflight AS f INNER JOIN spfli AS p
74 | ON p~carrid = f~carrid AND p~connid = f~connid
75 | WHERE p~airpto = 'BKK' AND f~fldate = '20210420'.
76 | ```
77 | The database records can be picked up in programm ```zexport_gui``` with subqueries:
78 | Database table | Fake database table | SQL where restriction
79 | -------------- | ------------------- | ---------------------
80 | SFLIGHT | ZCARR_SFLIGHT | fldate = '20210420' AND EXISTS ( SELECT * FROM spfli WHERE carrid = sflight~carrid AND connid = sflight~connid AND airpto = 'BKK' )
81 | SPFLI | ZCARR_SPFLI | FOR ALL ENTRIES IN xsflight WHERE carrid = xsflight-carrid AND connid = xsflight-connid
82 |
83 | ### Import step ###
84 | In the ABAP unit-testclass the database records exported in previous step
85 | can be imported in the fake tables or in the original tables,
86 | if the corresponding fake table was left empty.
87 | The API for the import step is located in class `zimport_bundle_from_cluster`
88 | for clusters or in class `zimport_bundle_from_tdc` for
89 | ECATT test data container.
90 |
91 | For testing Rfc-Client- or Rfc-Serverprograms or programs,
92 | which interact through the [JSON Adapter for ABAP Function Modules](https://github.com/cesar-sap/abap_fm_json/)
93 | a API is located in function-group `zimport_bundle`.
94 |
95 | A example can be found in the listing below.
96 | ```ABAP
97 | CLASS test_airlines DEFINITION FOR TESTING DURATION SHORT
98 | RISK LEVEL HARMLESS.
99 |
100 | PRIVATE SECTION.
101 |
102 | " activate replacement service
103 | METHODS setup.
104 |
105 | METHODS thai_should_be_found FOR TESTING.
106 |
107 | ENDCLASS.
108 |
109 | CLASS test_airlines IMPLEMENTATION.
110 |
111 | METHOD setup.
112 |
113 | DATA(db_preparator) = NEW zimport_bundle_from_tdc( tdc = 'ZAIRLINES'
114 | tdc_version = 1 variant = 'ECATTDEFAULT' ).
115 | db_preparator->replace_content_completly( ).
116 | db_preparator->activate_osql_replacement( ).
117 |
118 | ENDMETHOD.
119 |
120 | METHOD thai_should_be_found.
121 | DATA: exp_airlines TYPE STANDARD TABLE OF scarr.
122 |
123 | exp_airlines = VALUE #( ( carrid = 'TG' carrname = 'Thai airways'
124 | currcode = 'THB' url = 'https://thaiairways.com' ) ).
125 |
126 | SELECT * FROM scarr INTO TABLE @DATA(act_airlines).
127 |
128 | cl_abap_unit_assert=>assert_equals( exp = exp_airlines
129 | act = act_airlines ).
130 |
131 | ENDMETHOD.
132 |
133 | ENDCLASS.
134 | ```
135 |
136 | ### Authorization ###
137 | The APIs in class `zimport_bundle_from_cluster` or
138 | in class `zimport_bundle_from_tdc` can only be used in
139 | development systems, where
140 | dangerous ABAP unit-testclasses are enabled.
141 |
142 | ### Whitelist-check ###
143 | Content of fake tables listed in the whitelist can be completely
144 | overriden. The whitelist is maintained in parameter
145 | `ZIMPORT_REPLACE_WHITELIST` (transaction `stvarv`, table `tvarvc`).
146 |
147 | ## Terms ##
148 |
149 | * Bundle: a collection of database records, which are stored outside
150 | of the database tables.
151 | * Cluster: a MIME-object in transaction `smw0`, which contains the bundle
152 | * TDC: abbreviation for ECATT test data container
153 |
154 | ## Cloning this repository ##
155 | Cloning can be done with [abapGit](https://github.com/larshp/abapgit).
156 | The code is backwards compatible until release 7.40. The replacement services
157 | need higher releases (SAP NetWeaver 7.51 or 7.52).
158 |
159 | ## Further links ##
160 | [Blog entry on SAP community network](https://blogs.sap.com/?p=1049057)
161 | [Repository mirror](https://github.com/ABAP-prep/abap_db_preparator)
162 |
--------------------------------------------------------------------------------
/abaplint.json:
--------------------------------------------------------------------------------
1 | {
2 | "global": {
3 | "files": "/src/**/*.*",
4 | "skipGeneratedGatewayClasses": true,
5 | "skipGeneratedPersistentClasses": true,
6 | "skipGeneratedFunctionGroups": true
7 | },
8 | "dependencies": [
9 | {
10 | "url": "https://github.com/abaplint/deps",
11 | "folder": "/deps",
12 | "files": "/src/**/*.*"
13 | }
14 | ],
15 | "syntax": {
16 | "version": "v745",
17 | "errorNamespace": "^(Z|Y|LT?CL_|TY_|LIF_)",
18 | "globalConstants": [],
19 | "globalMacros": []
20 | },
21 | "rules": {
22 | "downport": false,
23 | "line_break_multiple_parameters": false,
24 | "unknown_types": true,
25 | "forbidden_void_type": {
26 | "check": []
27 | },
28 | "forbidden_identifier": true,
29 | "try_without_catch": false,
30 | "unused_variables": false,
31 | "prefix_is_current_class": {
32 | "omitMeInstanceCalls": false
33 | },
34 | "allowed_object_naming": true,
35 | "check_comments": false,
36 | "fully_type_constants": true,
37 | "keep_single_parameter_on_one_line": false,
38 | "prefer_returning_to_exporting": false,
39 | "selection_screen_naming": true,
40 | "sicf_consistency": true,
41 | "sql_escape_host_variables": false,
42 | "xml_consistency": true,
43 | "check_no_handler_pragma": true,
44 | "newline_between_methods": false,
45 | "chain_mainly_declarations": false,
46 | "check_abstract": true,
47 | "check_text_elements": true,
48 | "type_begin_single_include": true,
49 | "types_naming": false,
50 | "7bit_ascii": true,
51 | "abapdoc": false,
52 | "check_ddic": true,
53 | "check_include": true,
54 | "form_no_dash": true,
55 | "allowed_object_types": false,
56 | "ambiguous_statement": false,
57 | "avoid_use": {
58 | "define": false,
59 | "endselect": false,
60 | "execSQL": true,
61 | "kernelCall": true,
62 | "communication": true,
63 | "systemCall": true,
64 | "defaultKey": false,
65 | "break": false,
66 | "statics": false
67 | },
68 | "begin_end_names": true,
69 | "check_transformation_exists": true,
70 | "check_syntax": true,
71 | "class_attribute_names": {
72 | },
73 | "cloud_types": true,
74 | "colon_missing_space": true,
75 | "commented_code": true,
76 | "constructor_visibility_public": true,
77 | "contains_tab": true,
78 | "definitions_top": true,
79 | "description_empty": true,
80 | "double_space": false,
81 | "empty_line_in_statement": {
82 | "allowChained": true
83 | },
84 | "empty_statement": true,
85 | "empty_structure": {
86 | "loop": true,
87 | "if": false,
88 | "while": true,
89 | "case": true,
90 | "select": true,
91 | "do": true,
92 | "at": true
93 | },
94 | "exit_or_check": true,
95 | "exporting": true,
96 | "form_tables_obsolete": false,
97 | "functional_writing": {
98 | "ignoreExceptions": true
99 | },
100 | "global_class": true,
101 | "identical_form_names": true,
102 | "if_in_if": true,
103 | "implement_methods": true,
104 | "in_statement_indentation": false,
105 | "indentation": {
106 | "ignoreExceptions": true,
107 | "alignTryCatch": false,
108 | "globalClassSkipFirst": false,
109 | "ignoreGlobalClassDefinition": false,
110 | "ignoreGlobalInterface": false
111 | },
112 | "inline_data_old_versions": true,
113 | "keyword_case": {
114 | "style": "upper",
115 | "ignoreExceptions": true,
116 | "ignoreLowerClassImplmentationStatement": true,
117 | "ignoreGlobalClassDefinition": false,
118 | "ignoreGlobalInterface": false,
119 | "ignoreKeywords": [],
120 | "ignoreFunctionModuleName": false
121 | },
122 | "line_length": {
123 | "length": 120
124 | },
125 | "line_only_punc": {
126 | "ignoreExceptions": true
127 | },
128 | "local_class_naming": {
129 | },
130 | "local_testclass_location": true,
131 | "local_variable_names": {
132 | },
133 | "main_file_contents": true,
134 | "max_one_statement": true,
135 | "message_exists": false,
136 | "method_length": {
137 | "statements": 100,
138 | "ignoreTestClasses": false,
139 | "errorWhenEmpty": false
140 | },
141 | "method_parameter_names": false,
142 | "mix_returning": true,
143 | "msag_consistency": true,
144 | "nesting": {
145 | "depth": 5
146 | },
147 | "no_public_attributes": false,
148 | "object_naming": {
149 | "clas": "^Z",
150 | "intf": "^Z",
151 | "prog": "^Z",
152 | "fugr": "^Z",
153 | "tabl": "^Z",
154 | "ttyp": "^Z",
155 | "dtel": "^Z",
156 | "doma": "^Z",
157 | "msag": "^Z",
158 | "tran": "^Z",
159 | "enqu": "^EZ",
160 | "auth": "^Z",
161 | "pinf": "^Z",
162 | "idoc": "^Z",
163 | "ssfo": "^Z",
164 | "ssst": "^Z",
165 | "xslt": "^Z"
166 | },
167 | "obsolete_statement": {
168 | "refresh": true,
169 | "compute": true,
170 | "add": true,
171 | "subtract": true,
172 | "multiply": true,
173 | "move": true,
174 | "divide": true,
175 | "requested": true,
176 | "setExtended": true,
177 | "occurs": true
178 | },
179 | "parser_error": {},
180 | "preferred_compare_operator": {
181 | "badOperators": [
182 | "EQ",
183 | "><",
184 | "NE",
185 | "GE",
186 | "GT",
187 | "LT",
188 | "LE"
189 | ]
190 | },
191 | "release_idoc": true,
192 | "remove_descriptions": {
193 | },
194 | "rfc_error_handling": false,
195 | "sequential_blank": {
196 | "lines": 4
197 | },
198 | "short_case": {
199 | "length": 1,
200 | "allow": [
201 | "iv_action",
202 | "sy"
203 | ]
204 | },
205 | "space_before_colon": true,
206 | "space_before_dot": {
207 | "ignoreGlobalDefinition": true,
208 | "ignoreExceptions": true
209 | },
210 | "start_at_tab": true,
211 | "superclass_final": true,
212 | "tabl_enhancement_category": true,
213 | "type_form_parameters": true,
214 | "unreachable_code": true,
215 | "use_new": true,
216 | "when_others_last": true,
217 | "whitespace_end": true
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/img/export_scarr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bunysae/abap_db_preparator/5d4681bd4a572b69d489aa9b5d049310a450680f/img/export_scarr.png
--------------------------------------------------------------------------------
/src/package.devc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | DB preparator
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/zcx_export_cluster_table.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcx_export_cluster_table DEFINITION
2 | PUBLIC
3 | INHERITING FROM zcx_export_error
4 | FINAL
5 | CREATE PUBLIC .
6 |
7 | PUBLIC SECTION.
8 |
9 | CONSTANTS:
10 | BEGIN OF zcx_export_cluster_table,
11 | msgid TYPE symsgid VALUE 'ZEXPORT',
12 | msgno TYPE symsgno VALUE '015',
13 | attr1 TYPE scx_attrname VALUE '',
14 | attr2 TYPE scx_attrname VALUE '',
15 | attr3 TYPE scx_attrname VALUE '',
16 | attr4 TYPE scx_attrname VALUE '',
17 | END OF zcx_export_cluster_table .
18 | DATA:
19 | table_name TYPE tabname.
20 |
21 | METHODS constructor
22 | IMPORTING
23 | !textid LIKE if_t100_message=>t100key OPTIONAL
24 | !previous LIKE previous OPTIONAL
25 | !msgv1 TYPE symsgv OPTIONAL
26 | !msgv2 TYPE symsgv OPTIONAL
27 | !msgv3 TYPE symsgv OPTIONAL
28 | !msgv4 TYPE symsgv OPTIONAL
29 | !table_name TYPE tabname OPTIONAL.
30 | protected section.
31 | private section.
32 | ENDCLASS.
33 |
34 |
35 |
36 | CLASS ZCX_EXPORT_CLUSTER_TABLE IMPLEMENTATION.
37 |
38 |
39 | method CONSTRUCTOR.
40 | CALL METHOD SUPER->CONSTRUCTOR
41 | EXPORTING
42 | PREVIOUS = PREVIOUS
43 | MSGV1 = MSGV1
44 | MSGV2 = MSGV2
45 | MSGV3 = MSGV3
46 | MSGV4 = MSGV4
47 | .
48 | me->TABLE_NAME = TABLE_NAME .
49 | clear me->textid.
50 | if textid is initial.
51 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_CLUSTER_TABLE .
52 | else.
53 | IF_T100_MESSAGE~T100KEY = TEXTID.
54 | endif.
55 | endmethod.
56 | ENDCLASS.
57 |
--------------------------------------------------------------------------------
/src/zcx_export_cluster_table.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_CLUSTER_TABLE
7 | E
8 | Exporting cluster tables
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 | CONSTRUCTOR
18 | E
19 | CONSTRUCTOR
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/zcx_export_empty.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcx_export_empty DEFINITION
2 | PUBLIC
3 | INHERITING FROM zcx_export_error
4 | CREATE PUBLIC .
5 |
6 | PUBLIC SECTION.
7 |
8 | CONSTANTS: BEGIN OF zcx_export_empty,
9 | msgid TYPE symsgid VALUE 'ZEXPORT',
10 | msgno TYPE symsgno VALUE '013',
11 | attr1 TYPE scx_attrname VALUE 'TABLE_NAME',
12 | attr2 TYPE scx_attrname VALUE '',
13 | attr3 TYPE scx_attrname VALUE '',
14 | attr4 TYPE scx_attrname VALUE '',
15 | END OF zcx_export_empty.
16 | DATA table_name TYPE tabname.
17 |
18 | METHODS constructor
19 | IMPORTING
20 | !textid LIKE if_t100_message=>t100key OPTIONAL
21 | !previous LIKE previous OPTIONAL
22 | !msgv1 TYPE symsgv OPTIONAL
23 | !msgv2 TYPE symsgv OPTIONAL
24 | !msgv3 TYPE symsgv OPTIONAL
25 | !msgv4 TYPE symsgv OPTIONAL
26 | table_name TYPE tabname.
27 | protected section.
28 | private section.
29 | ENDCLASS.
30 |
31 |
32 |
33 | CLASS ZCX_EXPORT_EMPTY IMPLEMENTATION.
34 |
35 |
36 | method CONSTRUCTOR.
37 | CALL METHOD SUPER->CONSTRUCTOR
38 | EXPORTING
39 | PREVIOUS = PREVIOUS
40 | MSGV1 = MSGV1
41 | MSGV2 = MSGV2
42 | MSGV3 = MSGV3
43 | MSGV4 = MSGV4
44 | .
45 | me->TABLE_NAME = TABLE_NAME .
46 | clear me->textid.
47 | if textid is initial.
48 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_EMPTY .
49 | else.
50 | IF_T100_MESSAGE~T100KEY = TEXTID.
51 | endif.
52 | endmethod.
53 | ENDCLASS.
54 |
--------------------------------------------------------------------------------
/src/zcx_export_empty.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_EMPTY
7 | E
8 | Given table is empty (FOR ALL ENTRIES IN)
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_export_error.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_EXPORT_ERROR definition
2 | public
3 | inheriting from CX_STATIC_CHECK
4 | create public .
5 |
6 | public section.
7 |
8 | interfaces IF_T100_MESSAGE .
9 |
10 | data MSGV1 type SYMSGV .
11 | data MSGV2 type SYMSGV .
12 | data MSGV3 type SYMSGV .
13 | data MSGV4 type SYMSGV .
14 |
15 | methods CONSTRUCTOR
16 | importing
17 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
18 | !PREVIOUS like PREVIOUS optional
19 | !MSGV1 type SYMSGV optional
20 | !MSGV2 type SYMSGV optional
21 | !MSGV3 type SYMSGV optional
22 | !MSGV4 type SYMSGV optional .
23 | class-methods WRAP_ECATT_FAILURE
24 | importing
25 | !ECATT_FAILURE type ref to CX_ECATT_TDC_ACCESS
26 | raising
27 | ZCX_EXPORT_ERROR .
28 | class-methods WRAP_T100_MESSAGE
29 | RAISING
30 | zcx_export_error.
31 |
32 | methods IF_MESSAGE~GET_LONGTEXT
33 | redefinition .
34 | methods IF_MESSAGE~GET_TEXT
35 | redefinition .
36 | protected section.
37 | private section.
38 | ENDCLASS.
39 |
40 |
41 |
42 | CLASS ZCX_EXPORT_ERROR IMPLEMENTATION.
43 |
44 |
45 | method CONSTRUCTOR.
46 | CALL METHOD SUPER->CONSTRUCTOR
47 | EXPORTING
48 | PREVIOUS = PREVIOUS
49 | .
50 | me->MSGV1 = MSGV1 .
51 | me->MSGV2 = MSGV2 .
52 | me->MSGV3 = MSGV3 .
53 | me->MSGV4 = MSGV4 .
54 | clear me->textid.
55 | if textid is initial.
56 | IF_T100_MESSAGE~T100KEY = IF_T100_MESSAGE=>DEFAULT_TEXTID.
57 | else.
58 | IF_T100_MESSAGE~T100KEY = TEXTID.
59 | endif.
60 | endmethod.
61 |
62 |
63 | method IF_MESSAGE~GET_LONGTEXT.
64 |
65 | IF previous IS BOUND.
66 | result = previous->if_message~get_longtext( preserve_newlines ).
67 | ELSE.
68 | result = super->if_message~get_longtext( preserve_newlines ).
69 | ENDIF.
70 |
71 | endmethod.
72 |
73 |
74 | method IF_MESSAGE~GET_TEXT.
75 |
76 | IF previous IS BOUND.
77 | result = previous->if_message~get_text( ).
78 | ELSE.
79 | result = super->if_message~get_text( ).
80 | ENDIF.
81 |
82 | endmethod.
83 |
84 |
85 | method WRAP_ECATT_FAILURE.
86 |
87 | RAISE EXCEPTION TYPE zcx_export_error
88 | EXPORTING
89 | previous = ecatt_failure.
90 |
91 | endmethod.
92 |
93 |
94 | method WRAP_T100_MESSAGE.
95 | DATA: textid TYPE scx_t100key.
96 |
97 | textid = VALUE #( msgid = sy-msgid msgno = sy-msgno
98 | attr1 = 'MSGV1' attr2 = 'MSGV2' attr3 = 'MSGV3'
99 | attr4 = 'MSGV4' ).
100 |
101 | RAISE EXCEPTION TYPE zcx_export_error
102 | EXPORTING
103 | textid = textid
104 | msgv1 = sy-msgv1
105 | msgv2 = sy-msgv2
106 | msgv3 = sy-msgv3
107 | msgv4 = sy-msgv4.
108 |
109 | endmethod.
110 | ENDCLASS.
111 |
--------------------------------------------------------------------------------
/src/zcx_export_error.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_ERROR
7 | E
8 | Export error
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_export_invalid_name.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcx_export_invalid_name DEFINITION
2 | PUBLIC
3 | INHERITING FROM zcx_export_error
4 | CREATE PUBLIC .
5 |
6 | PUBLIC SECTION.
7 |
8 | CONSTANTS:
9 | BEGIN OF zcx_export_invalid_name,
10 | msgid TYPE symsgid VALUE 'ZEXPORT',
11 | msgno TYPE symsgno VALUE '014',
12 | attr1 TYPE scx_attrname VALUE 'NAME',
13 | attr2 TYPE scx_attrname VALUE '',
14 | attr3 TYPE scx_attrname VALUE '',
15 | attr4 TYPE scx_attrname VALUE '',
16 | END OF zcx_export_invalid_name .
17 | DATA name TYPE tabname.
18 |
19 | METHODS constructor
20 | IMPORTING
21 | !textid LIKE if_t100_message=>t100key OPTIONAL
22 | !previous LIKE previous OPTIONAL
23 | !msgv1 TYPE symsgv OPTIONAL
24 | !msgv2 TYPE symsgv OPTIONAL
25 | !msgv3 TYPE symsgv OPTIONAL
26 | !msgv4 TYPE symsgv OPTIONAL
27 | !name TYPE tabname.
28 | protected section.
29 | private section.
30 | ENDCLASS.
31 |
32 |
33 |
34 | CLASS ZCX_EXPORT_INVALID_NAME IMPLEMENTATION.
35 |
36 |
37 | method CONSTRUCTOR.
38 | CALL METHOD SUPER->CONSTRUCTOR
39 | EXPORTING
40 | PREVIOUS = PREVIOUS
41 | MSGV1 = MSGV1
42 | MSGV2 = MSGV2
43 | MSGV3 = MSGV3
44 | MSGV4 = MSGV4
45 | .
46 | me->NAME = NAME .
47 | clear me->textid.
48 | if textid is initial.
49 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_INVALID_NAME .
50 | else.
51 | IF_T100_MESSAGE~T100KEY = TEXTID.
52 | endif.
53 | endmethod.
54 | ENDCLASS.
55 |
--------------------------------------------------------------------------------
/src/zcx_export_invalid_name.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_INVALID_NAME
7 | E
8 | Invalid name
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_export_object_exists.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_EXPORT_OBJECT_EXISTS definition
2 | public
3 | inheriting from ZCX_EXPORT_ERROR
4 | final
5 | create public .
6 |
7 | public section.
8 |
9 | constants:
10 | BEGIN OF zcx_export_object_exists,
11 | msgid TYPE symsgid VALUE 'ZEXPORT',
12 | msgno TYPE symsgno VALUE '000',
13 | attr1 TYPE scx_attrname VALUE 'TESTCASE_ID',
14 | attr2 TYPE scx_attrname VALUE '',
15 | attr3 TYPE scx_attrname VALUE '',
16 | attr4 TYPE scx_attrname VALUE '',
17 | END OF zcx_export_object_exists .
18 | constants:
19 | BEGIN OF tdc_exists,
20 | msgid TYPE symsgid VALUE 'ZEXPORT',
21 | msgno TYPE symsgno VALUE '007',
22 | attr1 TYPE scx_attrname VALUE 'TDC_NAME',
23 | attr2 TYPE scx_attrname VALUE '',
24 | attr3 TYPE scx_attrname VALUE '',
25 | attr4 TYPE scx_attrname VALUE '',
26 | END OF tdc_exists .
27 | data TESTCASE_ID type W3OBJID .
28 | data TDC_NAME type ETOBJ_NAME .
29 |
30 | methods CONSTRUCTOR
31 | importing
32 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
33 | !PREVIOUS like PREVIOUS optional
34 | !MSGV1 type SYMSGV optional
35 | !MSGV2 type SYMSGV optional
36 | !MSGV3 type SYMSGV optional
37 | !MSGV4 type SYMSGV optional
38 | !TESTCASE_ID type W3OBJID optional
39 | !TDC_NAME type ETOBJ_NAME optional .
40 | protected section.
41 | private section.
42 | ENDCLASS.
43 |
44 |
45 |
46 | CLASS ZCX_EXPORT_OBJECT_EXISTS IMPLEMENTATION.
47 |
48 |
49 | method CONSTRUCTOR.
50 | CALL METHOD SUPER->CONSTRUCTOR
51 | EXPORTING
52 | PREVIOUS = PREVIOUS
53 | MSGV1 = MSGV1
54 | MSGV2 = MSGV2
55 | MSGV3 = MSGV3
56 | MSGV4 = MSGV4
57 | .
58 | me->TESTCASE_ID = TESTCASE_ID .
59 | me->TDC_NAME = TDC_NAME .
60 | clear me->textid.
61 | if textid is initial.
62 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_OBJECT_EXISTS .
63 | else.
64 | IF_T100_MESSAGE~T100KEY = TEXTID.
65 | endif.
66 | endmethod.
67 | ENDCLASS.
68 |
--------------------------------------------------------------------------------
/src/zcx_export_object_exists.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_OBJECT_EXISTS
7 | E
8 | Object already exists
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_export_table_duplicate.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_EXPORT_TABLE_DUPLICATE definition
2 | public
3 | inheriting from ZCX_EXPORT_ERROR
4 | final
5 | create public .
6 |
7 | public section.
8 |
9 | constants:
10 | BEGIN OF zcx_export_table_duplicate,
11 | msgid TYPE symsgid VALUE 'ZEXPORT',
12 | msgno TYPE symsgno VALUE '003',
13 | attr1 TYPE scx_attrname VALUE 'TABLE',
14 | attr2 TYPE scx_attrname VALUE '',
15 | attr3 TYPE scx_attrname VALUE '',
16 | attr4 TYPE scx_attrname VALUE '',
17 | END OF zcx_export_table_duplicate .
18 | data TABLE type TABNAME .
19 |
20 | methods CONSTRUCTOR
21 | importing
22 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
23 | !PREVIOUS like PREVIOUS optional
24 | !MSGV1 type SYMSGV optional
25 | !MSGV2 type SYMSGV optional
26 | !MSGV3 type SYMSGV optional
27 | !MSGV4 type SYMSGV optional
28 | !TABLE type TABNAME .
29 | protected section.
30 | private section.
31 | ENDCLASS.
32 |
33 |
34 |
35 | CLASS ZCX_EXPORT_TABLE_DUPLICATE IMPLEMENTATION.
36 |
37 |
38 | method CONSTRUCTOR.
39 | CALL METHOD SUPER->CONSTRUCTOR
40 | EXPORTING
41 | PREVIOUS = PREVIOUS
42 | MSGV1 = MSGV1
43 | MSGV2 = MSGV2
44 | MSGV3 = MSGV3
45 | MSGV4 = MSGV4
46 | .
47 | me->TABLE = TABLE .
48 | clear me->textid.
49 | if textid is initial.
50 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_TABLE_DUPLICATE .
51 | else.
52 | IF_T100_MESSAGE~T100KEY = TEXTID.
53 | endif.
54 | endmethod.
55 | ENDCLASS.
56 |
--------------------------------------------------------------------------------
/src/zcx_export_table_duplicate.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_TABLE_DUPLICATE
7 | E
8 | Table used more than one time
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_export_to_file.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_EXPORT_TO_FILE definition
2 | public
3 | inheriting from CX_STATIC_CHECK
4 | final
5 | create private .
6 |
7 | public section.
8 |
9 | CONSTANTS: BEGIN OF zcx_export_to_file,
10 | msgid TYPE symsgid VALUE 'ZEXPORT',
11 | msgno TYPE symsgno VALUE '006',
12 | attr1 TYPE scx_attrname VALUE 'FILENAME',
13 | attr2 TYPE scx_attrname VALUE 'REASON',
14 | attr3 TYPE scx_attrname VALUE '',
15 | attr4 TYPE scx_attrname VALUE '',
16 | END OF zcx_export_to_file.
17 |
18 | INTERFACES if_t100_message.
19 | DATA: filename TYPE string,
20 | reason TYPE string.
21 |
22 | methods CONSTRUCTOR
23 | importing
24 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
25 | !PREVIOUS like PREVIOUS optional
26 | filename TYPE string
27 | reason TYPE string.
28 | class-methods DOWNLOAD_FAILED
29 | importing
30 | !FILENAME type STRING
31 | VALUE(SUBRC) type SYST-SUBRC
32 | RAISING
33 | zcx_export_to_file.
34 | protected section.
35 | private section.
36 |
37 | TYPES: BEGIN OF _return_code_map,
38 | subrc TYPE i,
39 | reason TYPE string,
40 | END OF _return_code_map.
41 | CLASS-DATA: return_code_map TYPE STANDARD TABLE OF _return_code_map.
42 |
43 | CLASS-METHODS initialize.
44 | ENDCLASS.
45 |
46 |
47 |
48 | CLASS ZCX_EXPORT_TO_FILE IMPLEMENTATION.
49 |
50 |
51 | method CONSTRUCTOR.
52 | CALL METHOD SUPER->CONSTRUCTOR
53 | EXPORTING
54 | PREVIOUS = PREVIOUS
55 | .
56 | me->FILENAME = FILENAME .
57 | me->REASON = REASON .
58 | clear me->textid.
59 | if textid is initial.
60 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_TO_FILE .
61 | else.
62 | IF_T100_MESSAGE~T100KEY = TEXTID.
63 | endif.
64 | endmethod.
65 |
66 |
67 | method DOWNLOAD_FAILED.
68 | DATA: reason TYPE string.
69 |
70 | initialize( ).
71 |
72 | READ TABLE return_code_map REFERENCE INTO DATA(ret)
73 | WITH KEY subrc = subrc.
74 | IF sy-subrc = 0.
75 | reason = ret->*-reason.
76 | ELSE.
77 | reason = subrc.
78 | ENDIF.
79 |
80 | RAISE EXCEPTION TYPE zcx_export_to_file
81 | EXPORTING
82 | filename = filename
83 | reason = reason.
84 |
85 | endmethod.
86 |
87 |
88 | method INITIALIZE.
89 |
90 | return_code_map = VALUE #(
91 | ( subrc = 2 reason = text-002 )
92 | ( subrc = 4 reason = text-004 )
93 | ( subrc = 6 reason = text-006 )
94 | ( subrc = 8 reason = text-008 )
95 | ( subrc = 10 reason = text-010 )
96 | ).
97 |
98 | endmethod.
99 | ENDCLASS.
100 |
--------------------------------------------------------------------------------
/src/zcx_export_to_file.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_TO_FILE
7 | E
8 | Export to file failed
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 | I
18 | 002
19 | Error writing file
20 | 28
21 |
22 |
23 | I
24 | 004
25 | GUI refuses filetransfer
26 | 48
27 |
28 |
29 | I
30 | 006
31 | no authority
32 | 22
33 |
34 |
35 | I
36 | 008
37 | access denied
38 | 23
39 |
40 |
41 | I
42 | 010
43 | unexpected error
44 | 26
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/zcx_export_tr_order.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_EXPORT_TR_ORDER definition
2 | public
3 | inheriting from ZCX_EXPORT_ERROR
4 | final
5 | create public .
6 |
7 | public section.
8 |
9 | CONSTANTS: BEGIN OF zcx_export_tr_order,
10 | msgid TYPE symsgid VALUE 'ZEXPORT',
11 | msgno TYPE symsgno VALUE '009',
12 | attr1 TYPE scx_attrname VALUE 'TR_ORDER',
13 | attr2 TYPE scx_attrname VALUE '',
14 | attr3 TYPE scx_attrname VALUE '',
15 | attr4 TYPE scx_attrname VALUE '',
16 | END OF zcx_export_tr_order.
17 | DATA tr_order TYPE e070-trkorr.
18 |
19 | methods CONSTRUCTOR
20 | importing
21 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
22 | !PREVIOUS like PREVIOUS optional
23 | !MSGV1 type SYMSGV optional
24 | !MSGV2 type SYMSGV optional
25 | !MSGV3 type SYMSGV optional
26 | !MSGV4 type SYMSGV optional
27 | tr_order TYPE e070-trkorr.
28 | protected section.
29 | private section.
30 | ENDCLASS.
31 |
32 |
33 |
34 | CLASS ZCX_EXPORT_TR_ORDER IMPLEMENTATION.
35 |
36 |
37 | method CONSTRUCTOR.
38 | CALL METHOD SUPER->CONSTRUCTOR
39 | EXPORTING
40 | PREVIOUS = PREVIOUS
41 | MSGV1 = MSGV1
42 | MSGV2 = MSGV2
43 | MSGV3 = MSGV3
44 | MSGV4 = MSGV4
45 | .
46 | me->TR_ORDER = TR_ORDER .
47 | clear me->textid.
48 | if textid is initial.
49 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_TR_ORDER .
50 | else.
51 | IF_T100_MESSAGE~T100KEY = TEXTID.
52 | endif.
53 | endmethod.
54 | ENDCLASS.
55 |
--------------------------------------------------------------------------------
/src/zcx_export_tr_order.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_TR_ORDER
7 | E
8 | Transport order is invalid
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_export_where_clause_invali.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_EXPORT_WHERE_CLAUSE_INVALI definition
2 | public
3 | inheriting from ZCX_EXPORT_ERROR
4 | final
5 | create public .
6 |
7 | public section.
8 |
9 | constants:
10 | BEGIN OF ZCX_EXPORT_WHERE_CLAUSE_INVALI,
11 | msgid TYPE symsgid VALUE 'ZEXPORT',
12 | msgno TYPE symsgno VALUE '008',
13 | attr1 TYPE scx_attrname VALUE 'TABLE',
14 | attr2 TYPE scx_attrname VALUE 'WHERE_CLAUSE',
15 | attr3 TYPE scx_attrname VALUE 'FAILURE_DESCRIPTION',
16 | attr4 TYPE scx_attrname VALUE '',
17 | END OF ZCX_EXPORT_WHERE_CLAUSE_INVALI .
18 | data TABLE type TABNAME .
19 | data WHERE_CLAUSE type STRING .
20 | data failure_description type STRING.
21 |
22 | methods CONSTRUCTOR
23 | importing
24 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
25 | !PREVIOUS like PREVIOUS optional
26 | !MSGV1 type SYMSGV optional
27 | !MSGV2 type SYMSGV optional
28 | !MSGV3 type SYMSGV optional
29 | !MSGV4 type SYMSGV optional
30 | !TABLE type TABNAME
31 | !WHERE_CLAUSE type STRING
32 | failure_description type STRING.
33 | protected section.
34 | private section.
35 | ENDCLASS.
36 |
37 |
38 |
39 | CLASS ZCX_EXPORT_WHERE_CLAUSE_INVALI IMPLEMENTATION.
40 |
41 |
42 | method CONSTRUCTOR.
43 | CALL METHOD SUPER->CONSTRUCTOR
44 | EXPORTING
45 | PREVIOUS = PREVIOUS
46 | MSGV1 = MSGV1
47 | MSGV2 = MSGV2
48 | MSGV3 = MSGV3
49 | MSGV4 = MSGV4
50 | .
51 | me->TABLE = TABLE .
52 | me->WHERE_CLAUSE = WHERE_CLAUSE .
53 | me->FAILURE_DESCRIPTION = FAILURE_DESCRIPTION .
54 | clear me->textid.
55 | if textid is initial.
56 | IF_T100_MESSAGE~T100KEY = ZCX_EXPORT_WHERE_CLAUSE_INVALI .
57 | else.
58 | IF_T100_MESSAGE~T100KEY = TEXTID.
59 | endif.
60 | endmethod.
61 | ENDCLASS.
62 |
--------------------------------------------------------------------------------
/src/zcx_export_where_clause_invali.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_EXPORT_WHERE_CLAUSE_INVALI
7 | E
8 | Where-Clause is invalid
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_import_error.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcx_import_error DEFINITION
2 | PUBLIC
3 | INHERITING FROM cx_static_check
4 | CREATE PUBLIC .
5 |
6 | PUBLIC SECTION.
7 |
8 | METHODS constructor
9 | IMPORTING
10 | !textid LIKE textid OPTIONAL
11 | !previous LIKE previous OPTIONAL .
12 | CLASS-METHODS wrap_ecatt_failure
13 | IMPORTING
14 | ecatt_failure TYPE REF TO cx_ecatt_tdc_access
15 | RAISING
16 | zcx_import_error.
17 |
18 | METHODS if_message~get_text REDEFINITION.
19 |
20 | METHODS if_message~get_longtext REDEFINITION.
21 | protected section.
22 | private section.
23 | ENDCLASS.
24 |
25 |
26 |
27 | CLASS ZCX_IMPORT_ERROR IMPLEMENTATION.
28 |
29 |
30 | method CONSTRUCTOR.
31 | CALL METHOD SUPER->CONSTRUCTOR
32 | EXPORTING
33 | TEXTID = TEXTID
34 | PREVIOUS = PREVIOUS
35 | .
36 | endmethod.
37 |
38 |
39 | METHOD if_message~get_longtext.
40 |
41 | IF previous IS BOUND.
42 | result = previous->if_message~get_longtext( preserve_newlines ).
43 | ELSE.
44 | result = super->if_message~get_longtext( preserve_newlines ).
45 | ENDIF.
46 |
47 | ENDMETHOD.
48 |
49 |
50 | method IF_MESSAGE~GET_TEXT.
51 |
52 | IF previous IS BOUND.
53 | result = previous->if_message~get_text( ).
54 | ELSE.
55 | result = super->if_message~get_text( ).
56 | ENDIF.
57 |
58 | endmethod.
59 |
60 |
61 | method WRAP_ECATT_FAILURE.
62 |
63 | RAISE EXCEPTION TYPE zcx_import_error
64 | EXPORTING
65 | previous = ecatt_failure.
66 |
67 | endmethod.
68 | ENDCLASS.
69 |
--------------------------------------------------------------------------------
/src/zcx_import_error.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_IMPORT_ERROR
7 | E
8 | Import-Errors
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_import_merge_conflict.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zcx_import_merge_conflict DEFINITION
2 | PUBLIC
3 | INHERITING FROM zcx_import_error
4 | FINAL
5 | CREATE PUBLIC .
6 |
7 | PUBLIC SECTION.
8 |
9 | INTERFACES if_t100_message .
10 |
11 | CONSTANTS: BEGIN OF zcx_import_merge_conflict,
12 | msgid TYPE symsgid VALUE 'ZEXPORT',
13 | msgno TYPE symsgno VALUE '003',
14 | attr1 TYPE scx_attrname VALUE 'TABLE',
15 | attr2 TYPE scx_attrname VALUE '',
16 | attr3 TYPE scx_attrname VALUE '',
17 | attr4 TYPE scx_attrname VALUE '',
18 | END OF zcx_import_merge_conflict.
19 | DATA: table TYPE tabname.
20 |
21 | METHODS constructor
22 | IMPORTING
23 | !textid LIKE if_t100_message=>t100key OPTIONAL
24 | !previous LIKE previous OPTIONAL
25 | table TYPE tabname.
26 | protected section.
27 | private section.
28 | ENDCLASS.
29 |
30 |
31 |
32 | CLASS ZCX_IMPORT_MERGE_CONFLICT IMPLEMENTATION.
33 |
34 |
35 | method CONSTRUCTOR.
36 | CALL METHOD SUPER->CONSTRUCTOR
37 | EXPORTING
38 | PREVIOUS = PREVIOUS
39 | .
40 | me->TABLE = TABLE .
41 | clear me->textid.
42 | if textid is initial.
43 | IF_T100_MESSAGE~T100KEY = ZCX_IMPORT_MERGE_CONFLICT .
44 | else.
45 | IF_T100_MESSAGE~T100KEY = TEXTID.
46 | endif.
47 | endmethod.
48 | ENDCLASS.
49 |
--------------------------------------------------------------------------------
/src/zcx_import_merge_conflict.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_IMPORT_MERGE_CONFLICT
7 | E
8 | Merge conflict
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_import_not_allowed.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_IMPORT_NOT_ALLOWED definition
2 | public
3 | inheriting from ZCX_IMPORT_ERROR
4 | final
5 | create public .
6 |
7 | public section.
8 |
9 | interfaces IF_T100_MESSAGE .
10 |
11 | constants:
12 | begin of ZCX_IMPORT_NOT_ALLOWED,
13 | msgid type symsgid value 'ZEXPORT',
14 | msgno type symsgno value '001',
15 | attr1 type scx_attrname value '',
16 | attr2 type scx_attrname value '',
17 | attr3 type scx_attrname value '',
18 | attr4 type scx_attrname value '',
19 | end of ZCX_IMPORT_NOT_ALLOWED .
20 |
21 | methods CONSTRUCTOR
22 | importing
23 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
24 | !PREVIOUS like PREVIOUS optional .
25 | protected section.
26 | private section.
27 | ENDCLASS.
28 |
29 |
30 |
31 | CLASS ZCX_IMPORT_NOT_ALLOWED IMPLEMENTATION.
32 |
33 |
34 | method CONSTRUCTOR.
35 | CALL METHOD SUPER->CONSTRUCTOR
36 | EXPORTING
37 | PREVIOUS = PREVIOUS
38 | .
39 | clear me->textid.
40 | if textid is initial.
41 | IF_T100_MESSAGE~T100KEY = ZCX_IMPORT_NOT_ALLOWED .
42 | else.
43 | IF_T100_MESSAGE~T100KEY = TEXTID.
44 | endif.
45 | endmethod.
46 | ENDCLASS.
47 |
--------------------------------------------------------------------------------
/src/zcx_import_not_allowed.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_IMPORT_NOT_ALLOWED
7 | E
8 | Import not allowed outside unit-test
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zcx_import_object_not_exists.clas.abap:
--------------------------------------------------------------------------------
1 | class ZCX_IMPORT_OBJECT_NOT_EXISTS definition
2 | public
3 | inheriting from ZCX_IMPORT_ERROR
4 | final
5 | create public .
6 |
7 | public section.
8 |
9 | interfaces IF_T100_MESSAGE .
10 |
11 | constants:
12 | begin of ZCX_IMPORT_OBJECT_NOT_EXISTS,
13 | msgid type symsgid value 'ZEXPORT',
14 | msgno type symsgno value '012',
15 | attr1 type scx_attrname value 'TESTCASE_ID',
16 | attr2 type scx_attrname value '',
17 | attr3 type scx_attrname value '',
18 | attr4 type scx_attrname value '',
19 | end of ZCX_IMPORT_OBJECT_NOT_EXISTS .
20 | data TESTCASE_ID type W3OBJID .
21 |
22 | methods CONSTRUCTOR
23 | importing
24 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional
25 | !PREVIOUS like PREVIOUS optional
26 | !TESTCASE_ID type W3OBJID .
27 | protected section.
28 | private section.
29 | ENDCLASS.
30 |
31 |
32 |
33 | CLASS ZCX_IMPORT_OBJECT_NOT_EXISTS IMPLEMENTATION.
34 |
35 |
36 | method CONSTRUCTOR.
37 | CALL METHOD SUPER->CONSTRUCTOR
38 | EXPORTING
39 | PREVIOUS = PREVIOUS
40 | .
41 | me->TESTCASE_ID = TESTCASE_ID .
42 | clear me->textid.
43 | if textid is initial.
44 | IF_T100_MESSAGE~T100KEY = ZCX_IMPORT_OBJECT_NOT_EXISTS .
45 | else.
46 | IF_T100_MESSAGE~T100KEY = TEXTID.
47 | endif.
48 | endmethod.
49 | ENDCLASS.
50 |
--------------------------------------------------------------------------------
/src/zcx_import_object_not_exists.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZCX_IMPORT_OBJECT_NOT_EXISTS
7 | E
8 | Imported MIM-Object doesn't exist
9 | 40
10 | 1
11 | X
12 | X
13 | X
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/zexport.msag.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZEXPORT
7 | E
8 | Export in Cluster
9 |
10 |
11 |
12 | E
13 | ZEXPORT
14 | 000
15 | Testcase &1 already exists. Overwritting is not active.
16 |
17 |
18 | E
19 | ZEXPORT
20 | 001
21 | Import is just allowed when dangerous testclasses can be executed.
22 |
23 |
24 | E
25 | ZEXPORT
26 | 002
27 | Please add some tables to the bundle
28 |
29 |
30 | E
31 | ZEXPORT
32 | 003
33 | Table &1 is used more than one time
34 |
35 |
36 | E
37 | ZEXPORT
38 | 004
39 | &1 doesn't exists
40 |
41 |
42 | E
43 | ZEXPORT
44 | 005
45 | &1 isn't a database table
46 |
47 |
48 | E
49 | ZEXPORT
50 | 006
51 | Download of file &1 failed (reason: &2)
52 |
53 |
54 | E
55 | ZEXPORT
56 | 007
57 | Testdatacontainer &1 already exists. Overwritting is not active.
58 |
59 |
60 | E
61 | ZEXPORT
62 | 008
63 | The where-clause for table &1 is invalid.
64 |
65 |
66 | E
67 | ZEXPORT
68 | 009
69 | The transport request &1 must exists and must be open.
70 |
71 |
72 | E
73 | ZEXPORT
74 | 010
75 | The content-handler &1 is invalid.
76 |
77 |
78 | E
79 | ZEXPORT
80 | 011
81 | The name can't be changed, if the table isn't reexported (table &1)
82 |
83 |
84 | E
85 | ZEXPORT
86 | 012
87 | Can't find bundle with id &1
88 |
89 |
90 | E
91 | ZEXPORT
92 | 013
93 | FOR ALL ENTRIES IN is only possible when table &1 is not empty.
94 |
95 |
96 | E
97 | ZEXPORT
98 | 014
99 | &1 is a invalid name.
100 |
101 |
102 | E
103 | ZEXPORT
104 | 015
105 | Cluster-Tables can only be added, when a table type is defined.
106 |
107 |
108 |
109 |
110 |
111 | NA
112 |
113 | E
114 | E
115 | 0001
116 | X
117 | 00004
118 |
119 |
120 | DOKU
121 | ZEXPORT001
122 | NA
123 | E
124 | S_DOCU_SHOW
125 | S_DOCUS1
126 | 00001
127 | 072
128 |
129 |
130 |
131 | U1
132 | &CAUSE&
133 |
134 |
135 | AS
136 | Testclasses (ABAP Unit) have different risk levels. The import is not
137 |
138 |
139 | allowed, when just the execution of harmless testclasses is permitted.
140 |
141 |
142 | U1
143 | &WHAT_TO_DO&
144 |
145 |
146 | AS
147 | Set the risk level limit to dangerous or critical in report
148 |
149 |
150 | SAUNIT_CLIENT_SETUP.
151 |
152 |
153 | AS
154 |
155 |
156 |
157 |
158 |
159 | NA
160 |
161 | E
162 | E
163 | 0001
164 | X
165 | 00002
166 |
167 |
168 | DOKU
169 | ZEXPORT008
170 | NA
171 | E
172 | S_DOCU_SHOW
173 | S_DOCUS1
174 | 00001
175 | 072
176 |
177 |
178 |
179 | U1
180 | &CAUSE&
181 |
182 |
183 | AS
184 | &V3&
185 |
186 |
187 | U1
188 | &WHAT_TO_DO&
189 |
190 |
191 | AS
192 | Please correct the where-clause.
193 |
194 |
195 |
196 |
197 |
198 | NA
199 |
200 | E
201 | E
202 | 0001
203 | X
204 | 00006
205 |
206 |
207 | DOKU
208 | ZEXPORT010
209 | NA
210 | E
211 | S_DOCU_SHOW
212 | S_DOCUS1
213 | 00001
214 | 072
215 |
216 |
217 |
218 | U1
219 | &CAUSE&
220 |
221 |
222 | AS
223 | The content-handler must be a public method of the class "ZIMPORT_BUNDLE
224 |
225 |
226 | =
227 | ".
228 |
229 |
230 | U1
231 | &WHAT_TO_DO&
232 |
233 |
234 | AS
235 | Valid content-handlers are:
236 |
237 |
238 | B1
239 | REPLACE_CONTENT_ALL_TABLES
240 |
241 |
242 | B1
243 | REPLACE_CONTENT_COMPLETLY
244 |
245 |
246 | B1
247 | ADD_CONTENT_ALL_TABLES
248 |
249 |
250 |
251 |
252 |
253 | NA
254 |
255 | E
256 | E
257 | 0001
258 | X
259 | 00004
260 |
261 |
262 | DOKU
263 | ZEXPORT015
264 | NA
265 | E
266 | S_DOCU_SHOW
267 | S_DOCUS1
268 | 00001
269 | 072
270 |
271 |
272 |
273 | U1
274 | &CAUSE&
275 |
276 |
277 | AS
278 | Cluster-Tables need a table type defined in ABAP-dictionary in order
279 |
280 |
281 | =
282 | to be added to the test data container.
283 |
284 |
285 | U1
286 | &WHAT_TO_DO&
287 |
288 |
289 | AS
290 | Please create a table type for dictionary structure &V1& of kind
291 |
292 |
293 | =
294 | standard table.
295 |
296 |
297 |
298 |
299 |
300 | C
301 |
302 |
303 |
304 | C
305 | ZEXPORT
306 | Export in Cluster
307 |
308 |
309 |
310 |
311 | C
312 | 000
313 | Testcase &1 already exists. Overwritting is not active.
314 |
315 |
316 | C
317 | 001
318 | Import is just allowed when dangerous testclasses can be executed.
319 |
320 |
321 | C
322 | 002
323 | Please add some tables to the bundle
324 |
325 |
326 | C
327 | 003
328 | Table &1 is used more than one time
329 |
330 |
331 | C
332 | 004
333 | &1 doesn't exists
334 |
335 |
336 | C
337 | 005
338 | &1 isn't a database table
339 |
340 |
341 | C
342 | 006
343 | Download of file &1 failed (reason: &2)
344 |
345 |
346 | C
347 | 007
348 | Testdatacontainer &1 already exists. Overwritting is not active.
349 |
350 |
351 | C
352 | 008
353 | The where-clause for table &1 is invalid.
354 |
355 |
356 | C
357 | 009
358 | The transport request &1 must exists and must be open.
359 |
360 |
361 | C
362 | 010
363 | The content-handler &1 is invalid.
364 |
365 |
366 | C
367 | 011
368 | The name can't be changed, if the table isn't reexported (table &1)
369 |
370 |
371 | C
372 | 012
373 | Can't find bundle with id &1
374 |
375 |
376 | C
377 | 013
378 | FOR ALL ENTRIES IN is only possible when table &1 is not empty.
379 |
380 |
381 | C
382 | 014
383 | &1 is a invalid name.
384 |
385 |
386 |
387 |
388 |
389 |
--------------------------------------------------------------------------------
/src/zexport_batch_input.prog.abap:
--------------------------------------------------------------------------------
1 | CLASS batch_input DEFINITION.
2 |
3 | PUBLIC SECTION.
4 |
5 | METHODS dynpro_field
6 | IMPORTING
7 | name TYPE clike
8 | fvalue TYPE any.
9 |
10 | METHODS dynpro_head
11 | IMPORTING
12 | report TYPE syst-repid
13 | dynpro TYPE syst-dynnr.
14 |
15 | METHODS call_transaction
16 | IMPORTING code TYPE tcode
17 | VALUE(options) TYPE ctu_params OPTIONAL.
18 |
19 | METHODS command
20 | IMPORTING command TYPE syst-ucomm.
21 |
22 | METHODS subscreen
23 | IMPORTING subscreen TYPE bdc_fval.
24 |
25 | PROTECTED SECTION.
26 | DATA: input_map TYPE STANDARD TABLE OF bdcdata.
27 |
28 | ENDCLASS.
29 |
30 | CLASS batch_input IMPLEMENTATION.
31 |
32 | METHOD dynpro_field.
33 | DATA: conv_exit TYPE tfdir-funcname.
34 |
35 | APPEND INITIAL LINE TO input_map ASSIGNING FIELD-SYMBOL().
36 | -fnam = name.
37 |
38 | DESCRIBE FIELD fvalue EDIT MASK conv_exit.
39 |
40 | IF conv_exit <> space.
41 | WRITE fvalue TO -fval USING EDIT MASK conv_exit.
42 | ELSE.
43 | ##WRITE_MOVE
44 | WRITE fvalue TO -fval.
45 | ENDIF.
46 |
47 | ENDMETHOD.
48 |
49 | METHOD dynpro_head.
50 |
51 | APPEND INITIAL LINE TO input_map ASSIGNING FIELD-SYMBOL().
52 |
53 | -program = report.
54 | -dynpro = dynpro.
55 | -dynbegin = abap_true.
56 |
57 | ENDMETHOD.
58 |
59 | METHOD command.
60 |
61 | APPEND INITIAL LINE TO input_map ASSIGNING FIELD-SYMBOL().
62 | -fnam = 'BDC_OKCODE'.
63 | -fval = command.
64 |
65 | ENDMETHOD.
66 |
67 | METHOD subscreen.
68 |
69 | APPEND INITIAL LINE TO input_map ASSIGNING FIELD-SYMBOL().
70 | -fnam = 'BDC_SUBSCR'.
71 | -fval = subscreen.
72 |
73 | ENDMETHOD.
74 |
75 | METHOD call_transaction.
76 |
77 | CALL TRANSACTION code WITH AUTHORITY-CHECK USING input_map
78 | OPTIONS FROM options.
79 |
80 | ENDMETHOD.
81 |
82 | ENDCLASS.
83 |
--------------------------------------------------------------------------------
/src/zexport_batch_input.prog.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZEXPORT_BATCH_INPUT
7 | I
8 | S
9 | E
10 | X
11 |
12 |
13 |
14 | R
15 | API for batch-input
16 | 27
17 |
18 |
19 |
20 |
21 | D
22 |
23 |
24 | R
25 | Include ZMAKROS_BATCH_INPUT
26 | 27
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/zexport_bundle.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zexport_bundle DEFINITION
2 | PUBLIC
3 | CREATE PUBLIC
4 | ABSTRACT.
5 |
6 | PUBLIC SECTION.
7 | PROTECTED SECTION.
8 | DATA table_list TYPE STANDARD TABLE OF zexport_table_list .
9 |
10 | METHODS select
11 | IMPORTING
12 | table_conjunction TYPE zexport_table_list
13 | EXPORTING
14 | content TYPE STANDARD TABLE
15 | RAISING
16 | zcx_export_error.
17 |
18 | METHODS get_exported_content ABSTRACT
19 | IMPORTING
20 | table_conjunction TYPE zexport_table_list
21 | CHANGING
22 | table_for_all_entries TYPE REF TO data
23 | RAISING
24 | zcx_export_error.
25 |
26 | PRIVATE SECTION.
27 | ENDCLASS.
28 |
29 |
30 |
31 | CLASS ZEXPORT_BUNDLE IMPLEMENTATION.
32 |
33 |
34 | METHOD select.
35 | DATA: table_for_all_entries TYPE REF TO data.
36 |
37 | zexport_utils=>get_table_for_all_entries( EXPORTING
38 | table_conjunction = table_conjunction
39 | RECEIVING table_name = DATA(table_name)
40 | EXCEPTIONS not_for_all_entries_cond = 4 ).
41 | IF sy-subrc = 0.
42 |
43 | READ TABLE table_list REFERENCE INTO DATA(foe_conjunction)
44 | WITH KEY fake_table = table_name+1.
45 | IF sy-subrc <> 0.
46 | RAISE EXCEPTION TYPE zcx_export_invalid_name
47 | EXPORTING
48 | name = table_name.
49 | ENDIF.
50 |
51 | CREATE DATA table_for_all_entries TYPE STANDARD TABLE OF (table_name+1).
52 | get_exported_content( EXPORTING table_conjunction = foe_conjunction->*
53 | CHANGING table_for_all_entries = table_for_all_entries ).
54 | ASSIGN table_for_all_entries->* TO FIELD-SYMBOL().
55 | zexport_utils=>select( EXPORTING table_for_all_entries =
56 | table_conjunction = table_conjunction table_name = table_name
57 | IMPORTING result = content ).
58 |
59 | ELSE.
60 |
61 | TRY.
62 | SELECT * FROM (table_conjunction-source_table)
63 | INTO CORRESPONDING FIELDS OF TABLE @content
64 | WHERE (table_conjunction-where_restriction).
65 | CATCH cx_sy_dynamic_osql_error INTO DATA(osql_syntax_error).
66 | RAISE EXCEPTION TYPE zcx_export_where_clause_invali
67 | EXPORTING
68 | table = table_conjunction-source_table
69 | where_clause = table_conjunction-where_restriction
70 | failure_description = osql_syntax_error->msgtext.
71 | ENDTRY.
72 |
73 | ENDIF.
74 |
75 | ENDMETHOD.
76 | ENDCLASS.
77 |
--------------------------------------------------------------------------------
/src/zexport_bundle.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZEXPORT_BUNDLE
7 | E
8 | Export Bundle baseclass
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zexport_bundle_in_cluster.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zexport_bundle_in_cluster DEFINITION
2 | PUBLIC
3 | FINAL
4 | CREATE PUBLIC
5 | INHERITING FROM zexport_bundle.
6 |
7 | PUBLIC SECTION.
8 |
9 | METHODS constructor
10 | IMPORTING
11 | !testcase_id TYPE w3objid
12 | !force_overwrite TYPE abap_bool DEFAULT abap_false
13 | !dev_package TYPE devclass
14 | !title TYPE w3_text
15 | RAISING
16 | zcx_export_object_exists .
17 | "! Add the content of the table to the bundle (uses the builder-pattern).
18 | "! @parameter _table |
19 | "!
20 | "!
Component "source_table":
21 | "! Database table (transparent table), where the content lies.
22 | "!
23 | "!
Component "fake_table":
24 | "! The fake table, which is used in the unit-test.
25 | "! The import-class zimport_bundle_from_cluster
26 | "! overwrites the content of the fake-table.
27 | "! This parameter can be used, if working with class cl_osq_replace
28 | "! to replace table contents.
29 | "! If this parameter is omitted, parameter table is used.
30 | "!
31 | "!
Component "where_restriction":
32 | "! An valid sql-where-clause for an restriction of the exported rows.
33 | "!
34 | "!
35 | "! @raising zcx_export_error | If a table name is
36 | "! used more than one time,
37 | "! or the "where_restriction" is invalid.
38 | METHODS add_table_to_bundle
39 | IMPORTING
40 | VALUE(_table) TYPE zexport_table_list
41 | RETURNING
42 | VALUE(instance) TYPE REF TO zexport_bundle_in_cluster
43 | RAISING
44 | zcx_export_error .
45 | METHODS export .
46 | "! Attach the MIME-Object to an workbench order for transportation pruposes
47 | METHODS attach_to_wb_order
48 | RAISING
49 | zcx_export_error .
50 | METHODS add_prior_content
51 | IMPORTING
52 | VALUE(_table) TYPE zexport_table_list
53 | content TYPE REF TO data
54 | RETURNING VALUE(instance) TYPE REF TO zexport_bundle_in_cluster
55 | RAISING
56 | zcx_export_error.
57 | PROTECTED SECTION.
58 | METHODS get_exported_content REDEFINITION.
59 | PRIVATE SECTION.
60 |
61 | DATA cluster_objects TYPE abap_trans_srcbind_tab .
62 | DATA mime_key TYPE wwwdatatab .
63 |
64 | METHODS serialize
65 | RETURNING
66 | VALUE(result) TYPE REF TO cl_sxml_string_writer .
67 | METHODS create_mime_object
68 | IMPORTING
69 | !content TYPE REF TO cl_sxml_string_writer .
70 | METHODS set_filesize
71 | IMPORTING
72 | !size TYPE i .
73 | ENDCLASS.
74 |
75 |
76 |
77 | CLASS ZEXPORT_BUNDLE_IN_CLUSTER IMPLEMENTATION.
78 |
79 |
80 | METHOD add_prior_content.
81 |
82 | IF _table-fake_table IS INITIAL.
83 | _table-fake_table = _table-source_table.
84 | ENDIF.
85 | IF line_exists( cluster_objects[ name = _table-fake_table ] ).
86 | RAISE EXCEPTION TYPE zcx_export_table_duplicate
87 | EXPORTING
88 | table = _table-fake_table.
89 | ENDIF.
90 |
91 | INSERT _table INTO TABLE table_list.
92 |
93 | APPEND INITIAL LINE TO cluster_objects
94 | ASSIGNING FIELD-SYMBOL().
95 | -name = _table-fake_table.
96 | -value = content.
97 |
98 | instance = me.
99 |
100 | ENDMETHOD.
101 |
102 |
103 | METHOD add_table_to_bundle.
104 | FIELD-SYMBOLS: TYPE STANDARD TABLE.
105 |
106 | IF _table-fake_table IS INITIAL.
107 | _table-fake_table = _table-source_table.
108 | ENDIF.
109 | IF line_exists( cluster_objects[ name = _table-fake_table ] ).
110 | RAISE EXCEPTION TYPE zcx_export_table_duplicate
111 | EXPORTING
112 | table = _table-fake_table.
113 | ENDIF.
114 |
115 | INSERT _table INTO TABLE table_list.
116 |
117 | APPEND INITIAL LINE TO cluster_objects
118 | ASSIGNING FIELD-SYMBOL().
119 | -name = _table-fake_table.
120 |
121 | CREATE DATA -value TYPE STANDARD TABLE OF
122 | (_table-source_table).
123 | ASSIGN -value->* TO .
124 |
125 | select( EXPORTING table_conjunction = _table
126 | IMPORTING content = ).
127 |
128 | instance = me.
129 |
130 | ENDMETHOD.
131 |
132 |
133 | METHOD attach_to_wb_order.
134 | DATA: header TYPE STANDARD TABLE OF ko200,
135 | items TYPE STANDARD TABLE OF e071k.
136 |
137 | header = VALUE #(
138 | ( pgmid = 'R3TR' object = 'W3' && mime_key-relid obj_name = mime_key-objid
139 | masterlang = sy-langu devclass = mime_key-devclass ) ).
140 |
141 | CALL FUNCTION 'TR_OBJECTS_CHECK'
142 | TABLES
143 | wt_ko200 = header
144 | wt_e071k = items
145 | EXCEPTIONS
146 | cancel_edit_other_error = 2
147 | show_only_other_error = 4.
148 | IF sy-subrc <> 0.
149 | zcx_export_error=>wrap_t100_message( ).
150 | ENDIF.
151 |
152 | CALL FUNCTION 'TR_OBJECTS_INSERT'
153 | TABLES
154 | wt_ko200 = header
155 | wt_e071k = items
156 | EXCEPTIONS
157 | cancel_edit_other_error = 2
158 | show_only_other_error = 4.
159 | IF sy-subrc <> 0.
160 | zcx_export_error=>wrap_t100_message( ).
161 | ENDIF.
162 |
163 | ENDMETHOD.
164 |
165 |
166 | METHOD constructor.
167 |
168 | super->constructor( ).
169 | mime_key-relid = 'MI'.
170 | mime_key-objid = testcase_id.
171 | mime_key-devclass = dev_package.
172 | mime_key-text = title.
173 |
174 | IF force_overwrite = abap_false.
175 | SELECT COUNT(*) FROM wwwdata WHERE relid = @mime_key-relid
176 | AND objid = @mime_key-objid.
177 | IF sy-subrc = 0.
178 | RAISE EXCEPTION TYPE zcx_export_object_exists
179 | EXPORTING
180 | testcase_id = testcase_id.
181 | ENDIF.
182 | ENDIF.
183 |
184 | ENDMETHOD.
185 |
186 |
187 | METHOD create_mime_object.
188 | DATA: mime_content TYPE STANDARD TABLE OF w3mime,
189 | binary_content TYPE xstring,
190 | length TYPE i.
191 |
192 | DATA(binary_table_content) = content->get_output( ).
193 |
194 | " exporting the table list is necessary for deserialization
195 | EXPORT content = binary_table_content table_list = table_list
196 | TO DATA BUFFER binary_content.
197 |
198 | CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
199 | EXPORTING
200 | buffer = binary_content
201 | IMPORTING
202 | output_length = length
203 | TABLES
204 | binary_tab = mime_content.
205 |
206 | CALL FUNCTION 'WWWDATA_EXPORT'
207 | EXPORTING
208 | key = mime_key
209 | TABLES
210 | mime = mime_content.
211 |
212 | set_filesize( length ).
213 |
214 | ENDMETHOD.
215 |
216 |
217 | METHOD export.
218 |
219 | create_mime_object( serialize( ) ).
220 |
221 | ENDMETHOD.
222 |
223 |
224 | METHOD get_exported_content.
225 |
226 | READ TABLE cluster_objects ASSIGNING FIELD-SYMBOL()
227 | WITH KEY name = table_conjunction-fake_table.
228 | IF sy-subrc <> 0.
229 | RAISE EXCEPTION TYPE zcx_export_invalid_name
230 | EXPORTING
231 | name = table_conjunction-fake_table.
232 | ENDIF.
233 | table_for_all_entries = -value.
234 |
235 | ENDMETHOD.
236 |
237 |
238 | METHOD serialize.
239 |
240 | result = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
241 |
242 | CALL TRANSFORMATION id
243 | SOURCE (cluster_objects)
244 | RESULT XML result.
245 |
246 | ENDMETHOD.
247 |
248 |
249 | METHOD set_filesize.
250 | DATA: filesize_param TYPE wwwparams.
251 |
252 | filesize_param-relid = mime_key-relid.
253 | filesize_param-objid = mime_key-objid.
254 | filesize_param-name = 'filesize'.
255 | filesize_param-value = size.
256 | MODIFY wwwparams FROM filesize_param.
257 |
258 | ENDMETHOD.
259 | ENDCLASS.
260 |
--------------------------------------------------------------------------------
/src/zexport_bundle_in_cluster.clas.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ZEXPORT_BUNDLE_IN_CLUSTER
7 | E
8 | Export Tablebundel into cluster
9 | 1
10 | X
11 | X
12 | X
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/zexport_bundle_in_tdc.clas.abap:
--------------------------------------------------------------------------------
1 | CLASS zexport_bundle_in_tdc DEFINITION
2 | PUBLIC
3 | FINAL
4 | CREATE PUBLIC
5 | INHERITING FROM zexport_bundle.
6 |
7 | PUBLIC SECTION.
8 |
9 | METHODS constructor
10 | IMPORTING
11 | !tdc TYPE REF TO cl_apl_ecatt_tdc_api
12 | !variant TYPE etvar_id
13 | RAISING
14 | cx_ecatt_tdc_access .
15 | "! Add the content of the table to the bundle (uses the builder-pattern).
16 | "! @parameter _table |
17 | "!
18 | "!
Component "source_table":
19 | "! Database table (transparent table), where the content lies.
20 | "!
21 | "!
Component "fake_table":
22 | "! The fake table, which is used in the unit-test.
23 | "! The import-class zimport_bundle_from_cluster
24 | "! overwrites the content of the fake-table.
25 | "! This parameter can be used, if working with class cl_osq_replace
26 | "! to replace table contents.
27 | "! If this parameter is omitted, parameter table is used.
28 | "!
29 | "!
Component "where_restriction":
30 | "! An valid sql-where-clause for an restriction of the exported rows.
31 | "!
32 | "!
33 | "! @raising zcx_export_error | If a table name is
34 | "! used more than one time or,
35 | "! if the "where_restriction" is invalid.
36 | METHODS add_table_to_bundle
37 | IMPORTING
38 | VALUE(_table) TYPE zexport_table_list
39 | RETURNING
40 | VALUE(instance) TYPE REF TO zexport_bundle_in_tdc
41 | RAISING
42 | zcx_export_error .
43 | METHODS export
44 | IMPORTING
45 | !transport_request TYPE e070-trkorr
46 | RAISING
47 | zcx_export_error .
48 | METHODS add_prior_content
49 | IMPORTING
50 | table_conjunction TYPE zexport_table_list
51 | RAISING
52 | zcx_export_error .
53 | PROTECTED SECTION.
54 | METHODS get_exported_content REDEFINITION.
55 | PRIVATE SECTION.
56 |
57 | DATA tdc TYPE REF TO cl_apl_ecatt_tdc_api .
58 | DATA variant TYPE etvar_id .
59 |
60 | METHODS create_parameter
61 | IMPORTING
62 | !table TYPE tabname
63 | RETURNING
64 | VALUE(name) TYPE etp_name
65 | RAISING
66 | zcx_export_error
67 | cx_ecatt_tdc_access .
68 | METHODS set_parameter_value
69 | IMPORTING
70 | !content TYPE STANDARD TABLE
71 | !name TYPE etp_name
72 | RAISING
73 | cx_ecatt_tdc_access .
74 | "! Invalid characters for ecatt parameters are replaced by '_'.
75 | METHODS get_parameter_name
76 | IMPORTING
77 | !table_name TYPE tabname
78 | RETURNING
79 | VALUE(result) TYPE etp_name .
80 | METHODS get_parameter_definition
81 | IMPORTING
82 | !table_name TYPE tabname
83 | RETURNING
84 | VALUE(result) TYPE string
85 | RAISING
86 | zcx_export_error.
87 | METHODS search_for_table_types
88 | IMPORTING
89 | !table_name TYPE tabname
90 | RETURNING
91 | VALUE(result) TYPE ttypename
92 | RAISING
93 | zcx_export_error.
94 | METHODS is_cluster_table
95 | IMPORTING
96 | !table_name TYPE tabname
97 | RETURNING
98 | VALUE(result) TYPE sap_bool .
99 | ENDCLASS.
100 |
101 |
102 |
103 | CLASS ZEXPORT_BUNDLE_IN_TDC IMPLEMENTATION.
104 |
105 |
106 | METHOD add_prior_content.
107 |
108 | IF line_exists( table_list[ fake_table = table_conjunction-fake_table ] ).
109 | RAISE EXCEPTION TYPE zcx_export_table_duplicate
110 | EXPORTING
111 | table = table_conjunction-fake_table.
112 | ENDIF.
113 |
114 | INSERT table_conjunction INTO TABLE table_list.
115 |
116 | ENDMETHOD.
117 |
118 |
119 | METHOD add_table_to_bundle.
120 | DATA: content TYPE REF TO data,
121 | param_name TYPE etp_name.
122 | FIELD-SYMBOLS: TYPE STANDARD TABLE.
123 |
124 | " Parameters in test data containers can only refer to the
125 | " CDS-Database-view. So write CDS-Database-view-name to fake table name.
126 | IF zexport_utils=>is_cds_view_entity( _table-source_table ) = abap_true.
127 | _table-fake_table = zexport_utils=>get_cds_view_name( _table-source_table ).
128 | ELSEIF _table-fake_table IS INITIAL.
129 | _table-fake_table = _table-source_table.
130 | ENDIF.
131 | IF line_exists( table_list[ fake_table = _table-fake_table ] ).
132 | RAISE EXCEPTION TYPE zcx_export_table_duplicate
133 | EXPORTING
134 | table = _table-fake_table.
135 | ENDIF.
136 |
137 | TRY.
138 | _table-tdc_parameter_name = create_parameter( _table-fake_table ).
139 |
140 | CREATE DATA content TYPE STANDARD TABLE OF (_table-fake_table).
141 | ASSIGN content->* TO .
142 |
143 | select( EXPORTING table_conjunction = _table
144 | IMPORTING content = ).
145 | _table-is_initial = xsdbool( IS INITIAL ).
146 |
147 | set_parameter_value( content = name = _table-tdc_parameter_name ).
148 |
149 | INSERT _table INTO TABLE table_list.
150 |
151 | CATCH cx_ecatt_tdc_access INTO DATA(ecatt_failure).
152 | zcx_export_error=>wrap_ecatt_failure( ecatt_failure ).
153 | ENDTRY.
154 |
155 | ENDMETHOD.
156 |
157 |
158 | METHOD constructor.
159 |
160 | super->constructor( ).
161 | me->tdc = tdc.
162 | me->variant = variant.
163 |
164 | " create variant, if not exists
165 | TRY.
166 | tdc->create_variant( i_variant_name = variant ).
167 | CATCH cx_ecatt_tdc_access INTO DATA(failure).
168 | IF failure->textid <> cx_ecatt_tdc_access=>variant_exists.
169 | RAISE EXCEPTION failure.
170 | ENDIF.
171 | ENDTRY.
172 |
173 | ENDMETHOD.
174 |
175 |
176 | METHOD create_parameter.
177 | DATA: type_definition TYPE string.
178 |
179 | type_definition = get_parameter_definition( table ).
180 | name = get_parameter_name( table ).
181 |
182 | TRY.
183 | tdc->create_parameter( i_param_name = name
184 | i_param_def = type_definition ).
185 | CATCH cx_ecatt_tdc_access INTO DATA(failure).
186 | IF failure->textid = cx_ecatt_tdc_access=>parameter_exists.
187 | IF tdc->get_param_definition( name ) <> type_definition.
188 | tdc->change_parameter( i_param_name = name
189 | i_param_def = type_definition ).
190 | ENDIF.
191 | ELSE.
192 | RAISE EXCEPTION failure.
193 | ENDIF.
194 | ENDTRY.
195 |
196 | ENDMETHOD.
197 |
198 |
199 | METHOD export.
200 |
201 | TRY.
202 | DATA(param_for_list) = create_parameter( table = 'ZEXPORT_TABLE_LIST' ).
203 | set_parameter_value( content = table_list name = param_for_list ).
204 |
205 | tdc->commit_changes( i_commit_mode = abap_false
206 | i_tr_order = transport_request i_release_lock = abap_true ).
207 |
208 | CATCH cx_ecatt_tdc_access INTO DATA(ecatt_failure).
209 | zcx_export_error=>wrap_ecatt_failure( ecatt_failure ).
210 | ENDTRY.
211 |
212 | ENDMETHOD.
213 |
214 |
215 | METHOD get_exported_content.
216 |
217 | ASSIGN table_for_all_entries->* TO FIELD-SYMBOL().
218 | select( EXPORTING table_conjunction = table_conjunction
219 | IMPORTING content = ).
220 |
221 | ENDMETHOD.
222 |
223 |
224 | METHOD get_parameter_definition.
225 |
226 | " search for table types first as type "standard table of" for cluster tables
227 | " is changed to character like type in TDC, which causes a dump
228 | result = search_for_table_types( table_name ).
229 | IF result IS NOT INITIAL.
230 | RETURN.
231 | ENDIF.
232 |
233 | CONCATENATE 'STANDARD TABLE OF' table_name INTO result
234 | SEPARATED BY space.
235 |
236 | ENDMETHOD.
237 |
238 |
239 | METHOD get_parameter_name.
240 |
241 | result = table_name.
242 | REPLACE ALL OCCURRENCES OF REGEX '[^A-Za-z0-9_\s]'
243 | IN result WITH '_'.
244 |
245 | ENDMETHOD.
246 |
247 |
248 | METHOD is_cluster_table.
249 |
250 | SELECT COUNT(*) FROM dd02l
251 | WHERE tabname = @table_name AND as4local = 'A' AND tabclass = 'CLUSTER'.
252 | result = xsdbool( sy-subrc = 0 ).
253 |
254 | ENDMETHOD.
255 |
256 |
257 | METHOD search_for_table_types.
258 | DATA:
259 | objects_to_search TYPE STANDARD TABLE OF rsfind,
260 | scope_object_classes TYPE STANDARD TABLE OF seu_obj,
261 | found_table_types TYPE STANDARD TABLE OF rsfindlst,
262 | table_type_range TYPE RANGE OF ttypename.
263 |
264 | objects_to_search = VALUE #( ( object = table_name ) ).
265 | scope_object_classes = VALUE #( ( 'DA' ) ).
266 | CALL FUNCTION 'RS_EU_CROSSREF'
267 | EXPORTING
268 | i_find_obj_cls = 'DS'
269 | i_answer = 'N'
270 | no_dialog = abap_true
271 | expand_source_in_online_mode = abap_true
272 | rekursiv = abap_true
273 | TABLES
274 | i_findstrings = objects_to_search
275 | i_scope_object_cls = scope_object_classes
276 | o_founds = found_table_types
277 | EXCEPTIONS
278 | OTHERS = 4.
279 | IF ( sy-subrc <> 0 OR found_table_types IS INITIAL )
280 | AND is_cluster_table( table_name ) = abap_true.
281 | RAISE EXCEPTION TYPE zcx_export_cluster_table
282 | EXPORTING
283 | table_name = table_name.
284 | ELSEIF found_table_types IS INITIAL.
285 | RETURN.
286 | ENDIF.
287 |
288 | table_type_range = VALUE #(
289 | FOR IN found_table_types
290 | ( sign = 'I' option = 'EQ' low = -object ) ).
291 | SELECT typename FROM dd40l
292 | WHERE typename IN @table_type_range AND as4local = 'A' AND accessmode = 'T'
293 | INTO @result.
294 | ENDSELECT.
295 | IF sy-subrc <> 0 AND is_cluster_table( table_name ) = abap_true.
296 | RAISE EXCEPTION TYPE zcx_export_cluster_table
297 | EXPORTING
298 | table_name = table_name.
299 | ENDIF.
300 |
301 | ENDMETHOD.
302 |
303 |
304 | METHOD set_parameter_value.
305 |
306 | tdc->set_value( i_param_name = name i_param_value = content
307 | i_variant_name = variant ).
308 |
309 | ENDMETHOD.
310 | ENDCLASS.
311 |
--------------------------------------------------------------------------------
/src/zexport_bundle_in_tdc.clas.testclasses.abap:
--------------------------------------------------------------------------------
1 | CLASS test_export_bundle DEFINITION FOR TESTING
2 | DURATION SHORT RISK LEVEL HARMLESS.
3 |
4 | PRIVATE SECTION.
5 | " TDC is temporary created
6 | CONSTANTS: tdc_name TYPE etobj_name VALUE 'ZEXPORT_UNIT_TEST'.
7 | CLASS-DATA: cut TYPE REF TO zexport_bundle_in_tdc.
8 |
9 | CLASS-METHODS class_setup
10 | RAISING cx_static_check.
11 |
12 | " Testcases for method get_parameter_name:
13 | "
14 | "