abapgit-agent 1.1.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +3 -1
- package/API.md +261 -0
- package/CLAUDE.md +384 -0
- package/README.md +16 -2
- package/RELEASE_NOTES.md +93 -8
- package/abap/CLAUDE.md +282 -6
- package/abap/copilot-instructions.md +79 -0
- package/abap/zcl_abgagt_agent.clas.abap +2 -2
- package/abap/zcl_abgagt_cmd_factory.clas.abap +2 -0
- package/abap/zcl_abgagt_command_inspect.clas.abap +255 -36
- package/abap/zcl_abgagt_command_tree.clas.abap +237 -0
- package/abap/zcl_abgagt_command_tree.clas.xml +15 -0
- package/abap/zcl_abgagt_command_view.clas.abap +240 -0
- package/abap/zcl_abgagt_command_view.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_tree.clas.abap +70 -0
- package/abap/zcl_abgagt_resource_tree.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_view.clas.abap +68 -0
- package/abap/zcl_abgagt_resource_view.clas.xml +15 -0
- package/abap/zcl_abgagt_rest_handler.clas.abap +2 -0
- package/abap/zcl_abgagt_util.clas.abap +2 -2
- package/abap/zcl_abgagt_viewer_clas.clas.abap +58 -0
- package/abap/zcl_abgagt_viewer_clas.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_ddls.clas.abap +83 -0
- package/abap/zcl_abgagt_viewer_ddls.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_dtel.clas.abap +98 -0
- package/abap/zcl_abgagt_viewer_dtel.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_factory.clas.abap +41 -0
- package/abap/zcl_abgagt_viewer_factory.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_intf.clas.abap +58 -0
- package/abap/zcl_abgagt_viewer_intf.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_stru.clas.abap +59 -0
- package/abap/zcl_abgagt_viewer_stru.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_tabl.clas.abap +59 -0
- package/abap/zcl_abgagt_viewer_tabl.clas.xml +15 -0
- package/abap/zcl_abgagt_viewer_ttyp.clas.abap +93 -0
- package/abap/zcl_abgagt_viewer_ttyp.clas.xml +15 -0
- package/abap/zif_abgagt_command.intf.abap +3 -1
- package/abap/zif_abgagt_viewer.intf.abap +12 -0
- package/abap/zif_abgagt_viewer.intf.xml +15 -0
- package/bin/abapgit-agent +605 -38
- package/docs/commands.md +27 -8
- package/docs/tree-command.md +303 -0
- package/docs/view-command.md +501 -0
- package/package.json +1 -1
- package/src/abap-client.js +22 -0
- package/src/agent.js +27 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
" VIEW command implementation - view ABAP object definitions
|
|
5
|
+
CLASS zcl_abgagt_command_view DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
6
|
+
|
|
7
|
+
PUBLIC SECTION.
|
|
8
|
+
INTERFACES zif_abgagt_command.
|
|
9
|
+
|
|
10
|
+
TYPES: BEGIN OF ty_view_params,
|
|
11
|
+
objects TYPE string_table,
|
|
12
|
+
type TYPE string,
|
|
13
|
+
END OF ty_view_params.
|
|
14
|
+
|
|
15
|
+
TYPES: BEGIN OF ty_component,
|
|
16
|
+
field TYPE string,
|
|
17
|
+
key TYPE abap_bool,
|
|
18
|
+
type TYPE string,
|
|
19
|
+
length TYPE int4,
|
|
20
|
+
dataelement TYPE string,
|
|
21
|
+
description TYPE string,
|
|
22
|
+
END OF ty_component.
|
|
23
|
+
|
|
24
|
+
TYPES: BEGIN OF ty_view_object,
|
|
25
|
+
name TYPE string,
|
|
26
|
+
type TYPE string,
|
|
27
|
+
type_text TYPE string,
|
|
28
|
+
description TYPE string,
|
|
29
|
+
domain TYPE string,
|
|
30
|
+
domain_type TYPE string,
|
|
31
|
+
domain_length TYPE int4,
|
|
32
|
+
domain_decimals TYPE int4,
|
|
33
|
+
source TYPE string,
|
|
34
|
+
definition TYPE string,
|
|
35
|
+
not_found TYPE abap_bool,
|
|
36
|
+
components TYPE STANDARD TABLE OF ty_component WITH DEFAULT KEY,
|
|
37
|
+
END OF ty_view_object.
|
|
38
|
+
|
|
39
|
+
TYPES ty_view_objects TYPE STANDARD TABLE OF ty_view_object WITH DEFAULT KEY.
|
|
40
|
+
|
|
41
|
+
TYPES: BEGIN OF ty_summary,
|
|
42
|
+
total TYPE i,
|
|
43
|
+
by_type TYPE string_table,
|
|
44
|
+
END OF ty_summary.
|
|
45
|
+
|
|
46
|
+
TYPES: BEGIN OF ty_view_result,
|
|
47
|
+
success TYPE abap_bool,
|
|
48
|
+
command TYPE string,
|
|
49
|
+
message TYPE string,
|
|
50
|
+
objects TYPE ty_view_objects,
|
|
51
|
+
summary TYPE ty_summary,
|
|
52
|
+
error TYPE string,
|
|
53
|
+
END OF ty_view_result.
|
|
54
|
+
|
|
55
|
+
METHODS detect_object_type
|
|
56
|
+
IMPORTING iv_name TYPE string
|
|
57
|
+
RETURNING VALUE(rv_type) TYPE string.
|
|
58
|
+
|
|
59
|
+
METHODS get_object_info
|
|
60
|
+
IMPORTING iv_name TYPE string
|
|
61
|
+
iv_type TYPE string
|
|
62
|
+
RETURNING VALUE(rs_object) TYPE ty_view_object.
|
|
63
|
+
|
|
64
|
+
METHODS build_summary
|
|
65
|
+
IMPORTING it_objects TYPE ty_view_objects
|
|
66
|
+
RETURNING VALUE(rs_summary) TYPE ty_summary.
|
|
67
|
+
|
|
68
|
+
ENDCLASS.
|
|
69
|
+
|
|
70
|
+
CLASS zcl_abgagt_command_view IMPLEMENTATION.
|
|
71
|
+
|
|
72
|
+
METHOD zif_abgagt_command~get_name.
|
|
73
|
+
rv_name = zif_abgagt_command=>gc_view.
|
|
74
|
+
ENDMETHOD.
|
|
75
|
+
|
|
76
|
+
METHOD zif_abgagt_command~execute.
|
|
77
|
+
DATA: ls_params TYPE ty_view_params,
|
|
78
|
+
ls_result TYPE ty_view_result,
|
|
79
|
+
lt_objects TYPE ty_view_objects,
|
|
80
|
+
lv_object TYPE string,
|
|
81
|
+
lo_factory TYPE REF TO zcl_abgagt_viewer_factory,
|
|
82
|
+
lo_viewer TYPE REF TO zif_abgagt_viewer,
|
|
83
|
+
ls_info TYPE ty_view_object.
|
|
84
|
+
|
|
85
|
+
ls_result-command = zif_abgagt_command=>gc_view.
|
|
86
|
+
|
|
87
|
+
IF is_param IS SUPPLIED.
|
|
88
|
+
ls_params = CORRESPONDING #( is_param ).
|
|
89
|
+
ENDIF.
|
|
90
|
+
|
|
91
|
+
IF ls_params-objects IS INITIAL.
|
|
92
|
+
ls_result-success = abap_false.
|
|
93
|
+
ls_result-error = 'Objects parameter is required'.
|
|
94
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
95
|
+
RETURN.
|
|
96
|
+
ENDIF.
|
|
97
|
+
|
|
98
|
+
lo_factory = zcl_abgagt_viewer_factory=>get_instance( ).
|
|
99
|
+
|
|
100
|
+
LOOP AT ls_params-objects INTO lv_object.
|
|
101
|
+
ls_info-name = lv_object.
|
|
102
|
+
|
|
103
|
+
DATA(lv_type) = ls_params-type.
|
|
104
|
+
IF lv_type IS INITIAL.
|
|
105
|
+
lv_type = detect_object_type( lv_object ).
|
|
106
|
+
ENDIF.
|
|
107
|
+
|
|
108
|
+
" Check if object was not found in TADIR
|
|
109
|
+
IF lv_type IS INITIAL.
|
|
110
|
+
ls_info-not_found = abap_true.
|
|
111
|
+
ls_info-type_text = 'Unknown'.
|
|
112
|
+
ELSE.
|
|
113
|
+
ls_info-type = lv_type.
|
|
114
|
+
|
|
115
|
+
" Set type text
|
|
116
|
+
CASE lv_type.
|
|
117
|
+
WHEN 'CLAS'. ls_info-type_text = 'Class'.
|
|
118
|
+
WHEN 'INTF'. ls_info-type_text = 'Interface'.
|
|
119
|
+
WHEN 'TABL'. ls_info-type_text = 'Table'.
|
|
120
|
+
WHEN 'STRU'. ls_info-type_text = 'Structure'.
|
|
121
|
+
WHEN 'DTEL'. ls_info-type_text = 'Data Element'.
|
|
122
|
+
WHEN 'TTYP'. ls_info-type_text = 'Table Type'.
|
|
123
|
+
WHEN 'DDLS'. ls_info-type_text = 'CDS View'.
|
|
124
|
+
WHEN OTHERS. ls_info-type_text = lv_type.
|
|
125
|
+
ENDCASE.
|
|
126
|
+
|
|
127
|
+
" Get viewer and retrieve info only if object was found
|
|
128
|
+
TRY.
|
|
129
|
+
lo_viewer = lo_factory->get_viewer( lv_type ).
|
|
130
|
+
IF lo_viewer IS BOUND.
|
|
131
|
+
ls_info = lo_viewer->get_info( lv_object ).
|
|
132
|
+
ELSE.
|
|
133
|
+
ls_info = get_object_info( iv_name = lv_object iv_type = lv_type ).
|
|
134
|
+
ENDIF.
|
|
135
|
+
CATCH cx_sy_create_object_error.
|
|
136
|
+
" Fallback for unknown types
|
|
137
|
+
ls_info = get_object_info( iv_name = lv_object iv_type = lv_type ).
|
|
138
|
+
ENDTRY.
|
|
139
|
+
ENDIF.
|
|
140
|
+
|
|
141
|
+
APPEND ls_info TO lt_objects.
|
|
142
|
+
ENDLOOP.
|
|
143
|
+
|
|
144
|
+
ls_result-success = abap_true.
|
|
145
|
+
ls_result-message = 'Retrieved object(s)'.
|
|
146
|
+
ls_result-objects = lt_objects.
|
|
147
|
+
ls_result-summary = build_summary( lt_objects ).
|
|
148
|
+
|
|
149
|
+
rv_result = /ui2/cl_json=>serialize( data = ls_result ).
|
|
150
|
+
ENDMETHOD.
|
|
151
|
+
|
|
152
|
+
METHOD detect_object_type.
|
|
153
|
+
" Query TADIR to find actual object type
|
|
154
|
+
SELECT SINGLE object FROM tadir
|
|
155
|
+
INTO rv_type
|
|
156
|
+
WHERE obj_name = iv_name
|
|
157
|
+
AND object IN ('CLAS', 'INTF', 'TABL', 'DTEL', 'STRU', 'TTYP', 'DDLS').
|
|
158
|
+
ENDMETHOD.
|
|
159
|
+
|
|
160
|
+
METHOD get_object_info.
|
|
161
|
+
DATA lv_obj_name TYPE string.
|
|
162
|
+
DATA lv_devclass TYPE tadir-devclass.
|
|
163
|
+
|
|
164
|
+
rs_object-name = iv_name.
|
|
165
|
+
rs_object-type = iv_type.
|
|
166
|
+
|
|
167
|
+
CASE iv_type.
|
|
168
|
+
WHEN 'CLAS' OR 'INTF'.
|
|
169
|
+
IF iv_type = 'CLAS'.
|
|
170
|
+
rs_object-type_text = 'Class'.
|
|
171
|
+
ELSE.
|
|
172
|
+
rs_object-type_text = 'Interface'.
|
|
173
|
+
ENDIF.
|
|
174
|
+
|
|
175
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
176
|
+
INTO (lv_obj_name, lv_devclass)
|
|
177
|
+
WHERE obj_name = iv_name
|
|
178
|
+
AND object = iv_type.
|
|
179
|
+
IF sy-subrc = 0.
|
|
180
|
+
rs_object-description = |{ rs_object-type_text } { iv_name } in { lv_devclass }|.
|
|
181
|
+
ENDIF.
|
|
182
|
+
|
|
183
|
+
WHEN 'TABL'.
|
|
184
|
+
rs_object-type_text = 'Table'.
|
|
185
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
186
|
+
INTO (lv_obj_name, lv_devclass)
|
|
187
|
+
WHERE obj_name = iv_name
|
|
188
|
+
AND object = 'TABL'.
|
|
189
|
+
IF sy-subrc = 0.
|
|
190
|
+
rs_object-description = |Table { iv_name } in { lv_devclass }|.
|
|
191
|
+
ENDIF.
|
|
192
|
+
|
|
193
|
+
WHEN 'STRU'.
|
|
194
|
+
rs_object-type_text = 'Structure'.
|
|
195
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
196
|
+
INTO (lv_obj_name, lv_devclass)
|
|
197
|
+
WHERE obj_name = iv_name
|
|
198
|
+
AND object = 'TABL'.
|
|
199
|
+
IF sy-subrc = 0.
|
|
200
|
+
rs_object-description = |Structure { iv_name } in { lv_devclass }|.
|
|
201
|
+
ENDIF.
|
|
202
|
+
|
|
203
|
+
WHEN 'DTEL'.
|
|
204
|
+
rs_object-type_text = 'Data Element'.
|
|
205
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
206
|
+
INTO (lv_obj_name, lv_devclass)
|
|
207
|
+
WHERE obj_name = iv_name
|
|
208
|
+
AND object = 'DTEL'.
|
|
209
|
+
IF sy-subrc = 0.
|
|
210
|
+
rs_object-description = |Data Element { iv_name } in { lv_devclass }|.
|
|
211
|
+
ENDIF.
|
|
212
|
+
|
|
213
|
+
WHEN OTHERS.
|
|
214
|
+
rs_object-type_text = iv_type.
|
|
215
|
+
ENDCASE.
|
|
216
|
+
ENDMETHOD.
|
|
217
|
+
|
|
218
|
+
METHOD build_summary.
|
|
219
|
+
rs_summary-total = lines( it_objects ).
|
|
220
|
+
|
|
221
|
+
DATA lv_type TYPE string.
|
|
222
|
+
DATA lv_found.
|
|
223
|
+
DATA ls_type TYPE string.
|
|
224
|
+
|
|
225
|
+
LOOP AT it_objects INTO DATA(ls_obj).
|
|
226
|
+
lv_type = ls_obj-type.
|
|
227
|
+
lv_found = abap_false.
|
|
228
|
+
LOOP AT rs_summary-by_type INTO ls_type.
|
|
229
|
+
IF ls_type = lv_type.
|
|
230
|
+
lv_found = abap_true.
|
|
231
|
+
EXIT.
|
|
232
|
+
ENDIF.
|
|
233
|
+
ENDLOOP.
|
|
234
|
+
IF lv_found = abap_false.
|
|
235
|
+
APPEND lv_type TO rs_summary-by_type.
|
|
236
|
+
ENDIF.
|
|
237
|
+
ENDLOOP.
|
|
238
|
+
ENDMETHOD.
|
|
239
|
+
|
|
240
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_COMMAND_VIEW</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>VIEW command - view ABAP object definitions</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_tree DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~post REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_tree IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~post.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = mo_request->get_entity( )->get_string_data( ).
|
|
18
|
+
|
|
19
|
+
" Parse JSON using /ui2/cl_json
|
|
20
|
+
DATA: BEGIN OF ls_request,
|
|
21
|
+
package TYPE string,
|
|
22
|
+
depth TYPE i,
|
|
23
|
+
include_objects TYPE abap_bool,
|
|
24
|
+
END OF ls_request.
|
|
25
|
+
|
|
26
|
+
/ui2/cl_json=>deserialize(
|
|
27
|
+
EXPORTING
|
|
28
|
+
json = lv_json
|
|
29
|
+
CHANGING
|
|
30
|
+
data = ls_request ).
|
|
31
|
+
|
|
32
|
+
DATA lv_json_resp TYPE string.
|
|
33
|
+
|
|
34
|
+
IF ls_request-package IS INITIAL.
|
|
35
|
+
lv_json_resp = '{"success":"","command":"TREE","error":"Package is required"}'.
|
|
36
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
37
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
38
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
39
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
40
|
+
RETURN.
|
|
41
|
+
ENDIF.
|
|
42
|
+
|
|
43
|
+
" Get command from factory
|
|
44
|
+
DATA(lo_factory) = zcl_abgagt_cmd_factory=>get_instance( ).
|
|
45
|
+
DATA(lo_command) = lo_factory->get_command( zif_abgagt_command=>gc_tree ).
|
|
46
|
+
|
|
47
|
+
IF lo_command IS NOT BOUND.
|
|
48
|
+
lv_json_resp = '{"success":"","command":"TREE","error":"TREE command not found"}'.
|
|
49
|
+
lo_entity = mo_response->create_entity( ).
|
|
50
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
51
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
52
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
53
|
+
RETURN.
|
|
54
|
+
ENDIF.
|
|
55
|
+
|
|
56
|
+
" Execute command with is_param
|
|
57
|
+
DATA ls_params TYPE zcl_abgagt_command_tree=>ty_tree_params.
|
|
58
|
+
ls_params-package = ls_request-package.
|
|
59
|
+
ls_params-depth = ls_request-depth.
|
|
60
|
+
ls_params-include_objects = ls_request-include_objects.
|
|
61
|
+
|
|
62
|
+
DATA(lv_result) = lo_command->execute( is_param = ls_params ).
|
|
63
|
+
|
|
64
|
+
lo_entity = mo_response->create_entity( ).
|
|
65
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
66
|
+
lo_entity->set_string_data( lv_result ).
|
|
67
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
68
|
+
ENDMETHOD.
|
|
69
|
+
|
|
70
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_TREE</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - Tree Resource</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_resource_view DEFINITION PUBLIC FINAL
|
|
5
|
+
INHERITING FROM cl_rest_resource
|
|
6
|
+
CREATE PUBLIC.
|
|
7
|
+
|
|
8
|
+
PUBLIC SECTION.
|
|
9
|
+
METHODS if_rest_resource~post REDEFINITION.
|
|
10
|
+
|
|
11
|
+
ENDCLASS.
|
|
12
|
+
|
|
13
|
+
CLASS zcl_abgagt_resource_view IMPLEMENTATION.
|
|
14
|
+
|
|
15
|
+
METHOD if_rest_resource~post.
|
|
16
|
+
DATA lv_json TYPE string.
|
|
17
|
+
lv_json = mo_request->get_entity( )->get_string_data( ).
|
|
18
|
+
|
|
19
|
+
" Parse JSON using /ui2/cl_json
|
|
20
|
+
DATA: BEGIN OF ls_request,
|
|
21
|
+
objects TYPE string_table,
|
|
22
|
+
type TYPE string,
|
|
23
|
+
END OF ls_request.
|
|
24
|
+
|
|
25
|
+
/ui2/cl_json=>deserialize(
|
|
26
|
+
EXPORTING
|
|
27
|
+
json = lv_json
|
|
28
|
+
CHANGING
|
|
29
|
+
data = ls_request ).
|
|
30
|
+
|
|
31
|
+
DATA lv_json_resp TYPE string.
|
|
32
|
+
|
|
33
|
+
IF ls_request-objects IS INITIAL.
|
|
34
|
+
lv_json_resp = '{"success":false,"command":"VIEW","error":"Objects parameter is required"}'.
|
|
35
|
+
DATA(lo_entity) = mo_response->create_entity( ).
|
|
36
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
37
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
38
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
39
|
+
RETURN.
|
|
40
|
+
ENDIF.
|
|
41
|
+
|
|
42
|
+
" Get command from factory
|
|
43
|
+
DATA(lo_factory) = zcl_abgagt_cmd_factory=>get_instance( ).
|
|
44
|
+
DATA(lo_command) = lo_factory->get_command( zif_abgagt_command=>gc_view ).
|
|
45
|
+
|
|
46
|
+
IF lo_command IS NOT BOUND.
|
|
47
|
+
lv_json_resp = '{"success":false,"command":"VIEW","error":"VIEW command not found"}'.
|
|
48
|
+
lo_entity = mo_response->create_entity( ).
|
|
49
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
50
|
+
lo_entity->set_string_data( lv_json_resp ).
|
|
51
|
+
mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
|
|
52
|
+
RETURN.
|
|
53
|
+
ENDIF.
|
|
54
|
+
|
|
55
|
+
" Execute command with is_param
|
|
56
|
+
DATA ls_params TYPE zcl_abgagt_command_view=>ty_view_params.
|
|
57
|
+
ls_params-objects = ls_request-objects.
|
|
58
|
+
ls_params-type = ls_request-type.
|
|
59
|
+
|
|
60
|
+
DATA(lv_result) = lo_command->execute( is_param = ls_params ).
|
|
61
|
+
|
|
62
|
+
lo_entity = mo_response->create_entity( ).
|
|
63
|
+
lo_entity->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
|
|
64
|
+
lo_entity->set_string_data( lv_result ).
|
|
65
|
+
mo_response->set_status( cl_rest_status_code=>gc_success_ok ).
|
|
66
|
+
ENDMETHOD.
|
|
67
|
+
|
|
68
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_RESOURCE_VIEW</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>VIEW command REST resource handler</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -22,6 +22,8 @@ CLASS zcl_abgagt_rest_handler IMPLEMENTATION.
|
|
|
22
22
|
lo_router->attach( iv_template = '/unit' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_UNIT' ).
|
|
23
23
|
lo_router->attach( iv_template = '/create' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_CREATE' ).
|
|
24
24
|
lo_router->attach( iv_template = '/import' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_IMPORT' ).
|
|
25
|
+
lo_router->attach( iv_template = '/tree' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_TREE' ).
|
|
26
|
+
lo_router->attach( iv_template = '/view' iv_handler_class = 'ZCL_ABGAGT_RESOURCE_VIEW' ).
|
|
25
27
|
|
|
26
28
|
ro_root_handler = lo_router.
|
|
27
29
|
ENDMETHOD.
|
|
@@ -35,9 +35,9 @@ CLASS zcl_abgagt_util IMPLEMENTATION.
|
|
|
35
35
|
RETURN.
|
|
36
36
|
ENDIF.
|
|
37
37
|
|
|
38
|
-
" Last part should be 'ABAP' for verification
|
|
38
|
+
" Last part should be 'ABAP' or 'ASDDLS' for verification
|
|
39
39
|
READ TABLE lt_parts INDEX lv_part_count INTO DATA(lv_last).
|
|
40
|
-
IF lv_last <> 'ABAP'.
|
|
40
|
+
IF lv_last <> 'ABAP' AND lv_last <> 'ASDDLS'.
|
|
41
41
|
RETURN.
|
|
42
42
|
ENDIF.
|
|
43
43
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_viewer_clas DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
5
|
+
|
|
6
|
+
PUBLIC SECTION.
|
|
7
|
+
INTERFACES zif_abgagt_viewer.
|
|
8
|
+
|
|
9
|
+
ENDCLASS.
|
|
10
|
+
|
|
11
|
+
CLASS zcl_abgagt_viewer_clas IMPLEMENTATION.
|
|
12
|
+
|
|
13
|
+
METHOD zif_abgagt_viewer~get_info.
|
|
14
|
+
DATA: lv_obj_name TYPE tadir-obj_name,
|
|
15
|
+
lv_devclass TYPE tadir-devclass,
|
|
16
|
+
lv_prog TYPE program,
|
|
17
|
+
lt_source TYPE TABLE OF string,
|
|
18
|
+
lv_line TYPE string.
|
|
19
|
+
|
|
20
|
+
SELECT SINGLE obj_name devclass FROM tadir
|
|
21
|
+
INTO (lv_obj_name, lv_devclass)
|
|
22
|
+
WHERE obj_name = iv_name
|
|
23
|
+
AND object = 'CLAS'.
|
|
24
|
+
IF sy-subrc = 0.
|
|
25
|
+
rs_info-name = iv_name.
|
|
26
|
+
rs_info-type = 'CLAS'.
|
|
27
|
+
rs_info-type_text = 'Class'.
|
|
28
|
+
rs_info-description = |Class { iv_name } in { lv_devclass }|.
|
|
29
|
+
ELSE.
|
|
30
|
+
rs_info-name = iv_name.
|
|
31
|
+
rs_info-type = 'CLAS'.
|
|
32
|
+
rs_info-type_text = 'Class'.
|
|
33
|
+
rs_info-not_found = abap_true.
|
|
34
|
+
ENDIF.
|
|
35
|
+
|
|
36
|
+
" Get class public section program name using CL_OO_CLASSNAME_SERVICE
|
|
37
|
+
DATA lv_clsname TYPE seoclsname.
|
|
38
|
+
lv_clsname = iv_name.
|
|
39
|
+
CALL METHOD cl_oo_classname_service=>get_pubsec_name
|
|
40
|
+
EXPORTING
|
|
41
|
+
clsname = lv_clsname
|
|
42
|
+
RECEIVING
|
|
43
|
+
result = lv_prog.
|
|
44
|
+
|
|
45
|
+
" Read source from program
|
|
46
|
+
READ REPORT lv_prog INTO lt_source.
|
|
47
|
+
IF sy-subrc = 0.
|
|
48
|
+
LOOP AT lt_source INTO lv_line.
|
|
49
|
+
IF rs_info-source IS INITIAL.
|
|
50
|
+
rs_info-source = lv_line.
|
|
51
|
+
ELSE.
|
|
52
|
+
rs_info-source = rs_info-source && |\n| && lv_line.
|
|
53
|
+
ENDIF.
|
|
54
|
+
ENDLOOP.
|
|
55
|
+
ENDIF.
|
|
56
|
+
ENDMETHOD.
|
|
57
|
+
|
|
58
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_VIEWER_CLAS</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>Viewer for ABAP Classes</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_viewer_ddls DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
5
|
+
|
|
6
|
+
PUBLIC SECTION.
|
|
7
|
+
INTERFACES zif_abgagt_viewer.
|
|
8
|
+
|
|
9
|
+
ENDCLASS.
|
|
10
|
+
|
|
11
|
+
CLASS zcl_abgagt_viewer_ddls IMPLEMENTATION.
|
|
12
|
+
|
|
13
|
+
METHOD zif_abgagt_viewer~get_info.
|
|
14
|
+
DATA: lv_ddls_name TYPE ddlname,
|
|
15
|
+
lo_handler TYPE REF TO if_dd_ddl_handler,
|
|
16
|
+
ls_ddlsrcv TYPE ddddlsrcv,
|
|
17
|
+
lv_devclass TYPE tadir-devclass,
|
|
18
|
+
lv_found TYPE abap_bool.
|
|
19
|
+
|
|
20
|
+
rs_info-name = iv_name.
|
|
21
|
+
rs_info-type = 'DDLS'.
|
|
22
|
+
rs_info-type_text = 'CDS View'.
|
|
23
|
+
|
|
24
|
+
" Get package from TADIR
|
|
25
|
+
SELECT SINGLE devclass FROM tadir
|
|
26
|
+
INTO lv_devclass
|
|
27
|
+
WHERE obj_name = iv_name
|
|
28
|
+
AND object = 'DDLS'.
|
|
29
|
+
IF sy-subrc = 0.
|
|
30
|
+
rs_info-description = |CDS View { iv_name } in { lv_devclass }|.
|
|
31
|
+
ELSE.
|
|
32
|
+
rs_info-not_found = abap_true.
|
|
33
|
+
RETURN.
|
|
34
|
+
ENDIF.
|
|
35
|
+
|
|
36
|
+
" Use DDL handler to read CDS view source
|
|
37
|
+
lo_handler = cl_dd_ddl_handler_factory=>create( ).
|
|
38
|
+
lv_ddls_name = iv_name.
|
|
39
|
+
|
|
40
|
+
" First try to read inactive version (get_state = 'M')
|
|
41
|
+
TRY.
|
|
42
|
+
lo_handler->read(
|
|
43
|
+
EXPORTING
|
|
44
|
+
name = lv_ddls_name
|
|
45
|
+
get_state = 'M'
|
|
46
|
+
IMPORTING
|
|
47
|
+
ddddlsrcv_wa = ls_ddlsrcv ).
|
|
48
|
+
|
|
49
|
+
IF ls_ddlsrcv-source IS NOT INITIAL.
|
|
50
|
+
lv_found = abap_true.
|
|
51
|
+
ENDIF.
|
|
52
|
+
|
|
53
|
+
CATCH cx_dd_ddl_check.
|
|
54
|
+
" Ignore - will try active version
|
|
55
|
+
ENDTRY.
|
|
56
|
+
|
|
57
|
+
" If no inactive version, try active version
|
|
58
|
+
IF lv_found = abap_false.
|
|
59
|
+
TRY.
|
|
60
|
+
lo_handler->read(
|
|
61
|
+
EXPORTING
|
|
62
|
+
name = lv_ddls_name
|
|
63
|
+
get_state = 'A'
|
|
64
|
+
IMPORTING
|
|
65
|
+
ddddlsrcv_wa = ls_ddlsrcv ).
|
|
66
|
+
|
|
67
|
+
IF ls_ddlsrcv-source IS NOT INITIAL.
|
|
68
|
+
lv_found = abap_true.
|
|
69
|
+
ENDIF.
|
|
70
|
+
CATCH cx_dd_ddl_check.
|
|
71
|
+
" Not found
|
|
72
|
+
ENDTRY.
|
|
73
|
+
ENDIF.
|
|
74
|
+
|
|
75
|
+
" Set source code if found
|
|
76
|
+
IF lv_found = abap_true.
|
|
77
|
+
rs_info-source = ls_ddlsrcv-source.
|
|
78
|
+
ELSE.
|
|
79
|
+
rs_info-not_found = abap_true.
|
|
80
|
+
ENDIF.
|
|
81
|
+
ENDMETHOD.
|
|
82
|
+
|
|
83
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_VIEWER_DDLS</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>Viewer for CDS Views</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|