@babamba2/abap-mcp-adt-powerup 4.8.11 → 4.8.12

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/handlers/system/readonly/handleGetJobUsage.d.ts +48 -0
  3. package/dist/handlers/system/readonly/handleGetJobUsage.d.ts.map +1 -0
  4. package/dist/handlers/system/readonly/handleGetJobUsage.js +87 -0
  5. package/dist/handlers/system/readonly/handleGetJobUsage.js.map +1 -0
  6. package/dist/handlers/system/readonly/handleGetTcodeUsage.d.ts +56 -0
  7. package/dist/handlers/system/readonly/handleGetTcodeUsage.d.ts.map +1 -0
  8. package/dist/handlers/system/readonly/handleGetTcodeUsage.js +96 -0
  9. package/dist/handlers/system/readonly/handleGetTcodeUsage.js.map +1 -0
  10. package/dist/handlers/system/readonly/handleGetTransaction.d.ts +32 -6
  11. package/dist/handlers/system/readonly/handleGetTransaction.d.ts.map +1 -1
  12. package/dist/handlers/system/readonly/handleGetTransaction.js +112 -50
  13. package/dist/handlers/system/readonly/handleGetTransaction.js.map +1 -1
  14. package/dist/handlers/system/readonly/handleGetWhereUsed.d.ts +8 -1
  15. package/dist/handlers/system/readonly/handleGetWhereUsed.d.ts.map +1 -1
  16. package/dist/handlers/system/readonly/handleGetWhereUsed.js +52 -7
  17. package/dist/handlers/system/readonly/handleGetWhereUsed.js.map +1 -1
  18. package/dist/handlers/system/readonly/handleReloadProfile.d.ts +4 -3
  19. package/dist/handlers/system/readonly/handleReloadProfile.d.ts.map +1 -1
  20. package/dist/handlers/system/readonly/handleReloadProfile.js +13 -5
  21. package/dist/handlers/system/readonly/handleReloadProfile.js.map +1 -1
  22. package/dist/handlers/transport/readonly/handleGetTransport.d.ts +3 -0
  23. package/dist/handlers/transport/readonly/handleGetTransport.d.ts.map +1 -1
  24. package/dist/handlers/transport/readonly/handleGetTransport.js +24 -0
  25. package/dist/handlers/transport/readonly/handleGetTransport.js.map +1 -1
  26. package/dist/handlers/transport/readonly/handleListTransports.d.ts +2 -1
  27. package/dist/handlers/transport/readonly/handleListTransports.d.ts.map +1 -1
  28. package/dist/handlers/transport/readonly/handleListTransports.js +17 -7
  29. package/dist/handlers/transport/readonly/handleListTransports.js.map +1 -1
  30. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.d.ts.map +1 -1
  31. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.js +10 -0
  32. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.js.map +1 -1
  33. package/dist/lib/legacyLockHint.d.ts +15 -0
  34. package/dist/lib/legacyLockHint.d.ts.map +1 -0
  35. package/dist/lib/legacyLockHint.js +34 -0
  36. package/dist/lib/legacyLockHint.js.map +1 -0
  37. package/dist/lib/legacyTableRead.d.ts +1 -1
  38. package/dist/lib/legacyTableRead.d.ts.map +1 -1
  39. package/dist/lib/legacyTableRead.js +4 -0
  40. package/dist/lib/legacyTableRead.js.map +1 -1
  41. package/dist/lib/legacyTransport.d.ts +78 -0
  42. package/dist/lib/legacyTransport.d.ts.map +1 -0
  43. package/dist/lib/legacyTransport.js +233 -0
  44. package/dist/lib/legacyTransport.js.map +1 -0
  45. package/dist/lib/nativeRfc.d.ts.map +1 -1
  46. package/dist/lib/nativeRfc.js +5 -0
  47. package/dist/lib/nativeRfc.js.map +1 -1
  48. package/dist/lib/odataRfc.d.ts +48 -0
  49. package/dist/lib/odataRfc.d.ts.map +1 -1
  50. package/dist/lib/odataRfc.js +73 -0
  51. package/dist/lib/odataRfc.js.map +1 -1
  52. package/dist/lib/profile.d.ts.map +1 -1
  53. package/dist/lib/profile.js +34 -0
  54. package/dist/lib/profile.js.map +1 -1
  55. package/dist/lib/profileEvents.d.ts +16 -0
  56. package/dist/lib/profileEvents.d.ts.map +1 -0
  57. package/dist/lib/profileEvents.js +29 -0
  58. package/dist/lib/profileEvents.js.map +1 -0
  59. package/dist/lib/rfcBackend.d.ts +2 -0
  60. package/dist/lib/rfcBackend.d.ts.map +1 -1
  61. package/dist/lib/rfcBackend.js +20 -4
  62. package/dist/lib/rfcBackend.js.map +1 -1
  63. package/dist/lib/soapRfc.d.ts +17 -0
  64. package/dist/lib/soapRfc.d.ts.map +1 -1
  65. package/dist/lib/soapRfc.js +39 -0
  66. package/dist/lib/soapRfc.js.map +1 -1
  67. package/dist/lib/zrfcProxy.d.ts.map +1 -1
  68. package/dist/lib/zrfcProxy.js +5 -0
  69. package/dist/lib/zrfcProxy.js.map +1 -1
  70. package/dist/server/BaseMcpServer.d.ts +11 -0
  71. package/dist/server/BaseMcpServer.d.ts.map +1 -1
  72. package/dist/server/BaseMcpServer.js +69 -2
  73. package/dist/server/BaseMcpServer.js.map +1 -1
  74. package/dist/server/StdioServer.d.ts.map +1 -1
  75. package/dist/server/StdioServer.js +9 -0
  76. package/dist/server/StdioServer.js.map +1 -1
  77. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ### Changed
8
+ - **ADT source writes on BASIS < 7.40 now explain the invalid-lock-handle failure.** Some 7.31 systems never send a `sap-contextid` cookie, so no stateful ADT session exists and the lock is gone before the write: the PUT fails with HTTP 423 `ExceptionResourceInvalidLockHandle` in every session mode. No client-side setting fixes it. The error now carries a hint that ADT source writes cannot work on that system and that the source has to be edited in SE38 / SE24 / SE37. Applies to every tool error that mentions an invalid lock handle when `ABAP_RELEASE` < 740.
9
+
10
+ ## [4.8.12] - 2026-10-14
11
+
12
+ ### Fixed
13
+ - **`ReloadProfile` switched the profile but not the connection.** The stdio server kept the connection context it built at boot, so after a switch every tool still talked to the previous system until Claude Code was restarted. A profile switch now rebinds the stdio connection context and drops the RFC sessions of the previous system (SOAP / OData CSRF session, native RFC pool, ZRFC proxy session). Every `SAP_RFC_*` key of the previous profile is cleared, so a profile that does not set one no longer inherits it. The default `MCP_OUTPUT_DIR` (`.sc4sap/work/<alias>/mcp-output`) follows the new alias; a user-chosen directory is left alone. When part of the switch fails, the result is `ok: false` with `restartRequired: true` and `errors`.
14
+ - **`ListTransports` / `GetTransport` returned nothing on BASIS < 7.40.** The ADT transport organizer does not exist there: the list URL answers an empty body, which parsed to 0 transports. On these releases the request header, tasks and objects are read from E070 / E07T / E071 with the standard `RFC_READ_TABLE` over SOAP RFC. No custom ABAP is needed.
15
+ - **`GetWhereUsed` failed on BASIS < 7.40.** There is no repository information system resource. The search now runs in SAP through `ZMCP_ADT_DISPATCH` action `WHERE_USED` (cross-reference tables, DDIC usage) and returns the same shape, with a note that says so.
16
+ - **Read-only DDIC helpers on BASIS 7.31.** There is no SAP Gateway there, so the OData service cannot exist. The table / data element / domain read helpers now also run over SOAP RFC.
17
+
18
+ ### Added
19
+ - **`GetTcodeUsage`** (read-only, ECC): was each transaction used in the last N months, from the ST03N workload monthly aggregates. One boolean per transaction plus `coverage` (months that actually hold data). No user names leave SAP. `destination` (or `SAP_USAGE_RFCDEST` in the profile) reads another system's aggregates over an SM59 destination. Needs the `ZMCP_WL_TCODE_USAGE` FM and the `WlTcodeUsage` function import.
20
+ - **`GetJobUsage`** (read-only, ECC): is each program a step of a background job that is scheduled now or ran inside the window (TBTCO / TBTCP). One boolean per program. Needs the `ZMCP_WL_JOB_USAGE` FM and the `WlJobUsage` function import.
21
+ - **`GetTransaction` `transaction_names`**: several transactions in one call. The result also shows the kind of transaction (program, parameter transaction with its target t-code and parameters, variant transaction).
22
+ - Legacy table reads (`ZMCP_ADT_DISPATCH TABLE_READ`) also allow TSTC, TSTCP, DD03L and DD04L.
23
+
7
24
  ## [4.8.11] - 2026-10-12
8
25
 
9
26
  ### Fixed
@@ -0,0 +1,48 @@
1
+ /**
2
+ * GetJobUsage — read-only: is each program set up as a background job step?
3
+ *
4
+ * Source: job overview TBTCO (header) + TBTCP (steps), read on the SAP side
5
+ * by ZMCP_WL_JOB_USAGE. A program counts as used when it is a step of a job
6
+ * that is scheduled now (released / ready / active) or that finished or was
7
+ * cancelled inside the window. Dialog runs (SE38/SA38) do not count. No user
8
+ * names leave SAP — the FM returns one boolean per program.
9
+ *
10
+ * Backend: ECC only — OData FunctionImport `WlJobUsage` on ZMCP_ADT_SRV.
11
+ *
12
+ * Companion ABAP source: sc4sap/abap/zmcp_wl_job_usage_ecc.abap
13
+ */
14
+ import type { HandlerContext } from '../../../lib/handlers/interfaces';
15
+ export declare const TOOL_DEFINITION: {
16
+ readonly name: "GetJobUsage";
17
+ readonly available_in: readonly ["onprem", "legacy"];
18
+ readonly description: "[read-only] Check whether programs are used as background job steps (SM37 jobs, TBTCO/TBTCP): true when the program is a step of a job that is scheduled now (released/ready/active, incl. periodic) or that finished/was cancelled in the last N months. SE38/SA38 dialog runs do not count. `oldest` = start date of the oldest finished job still kept; job reorganization deletes older ones, so when `complete` is false a false means \"no job since <oldest>\". No user names are returned. ECC-only (ZMCP_WL_JOB_USAGE bridge FM).";
19
+ readonly inputSchema: {
20
+ readonly type: "object";
21
+ readonly properties: {
22
+ readonly programs: {
23
+ readonly type: "array";
24
+ readonly items: {
25
+ readonly type: "string";
26
+ };
27
+ readonly description: "ABAP program names to check (e.g. [\"ZMY_REPORT\"]).";
28
+ };
29
+ readonly months: {
30
+ readonly type: "number";
31
+ readonly description: "Months back including the current one (1-36). Default: 12.";
32
+ readonly default: 12;
33
+ };
34
+ };
35
+ readonly required: readonly ["programs"];
36
+ };
37
+ };
38
+ export declare function handleGetJobUsage(context: HandlerContext, args: {
39
+ programs: string[];
40
+ months?: number;
41
+ }): Promise<{
42
+ isError: boolean;
43
+ content: {
44
+ type: string;
45
+ text: any;
46
+ }[];
47
+ }>;
48
+ //# sourceMappingURL=handleGetJobUsage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleGetJobUsage.d.ts","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetJobUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAQvE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;CAsBlB,CAAC;AAUX,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;GAqD9C"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /**
3
+ * GetJobUsage — read-only: is each program set up as a background job step?
4
+ *
5
+ * Source: job overview TBTCO (header) + TBTCP (steps), read on the SAP side
6
+ * by ZMCP_WL_JOB_USAGE. A program counts as used when it is a step of a job
7
+ * that is scheduled now (released / ready / active) or that finished or was
8
+ * cancelled inside the window. Dialog runs (SE38/SA38) do not count. No user
9
+ * names leave SAP — the FM returns one boolean per program.
10
+ *
11
+ * Backend: ECC only — OData FunctionImport `WlJobUsage` on ZMCP_ADT_SRV.
12
+ *
13
+ * Companion ABAP source: sc4sap/abap/zmcp_wl_job_usage_ecc.abap
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TOOL_DEFINITION = void 0;
17
+ exports.handleGetJobUsage = handleGetJobUsage;
18
+ const rfcBackend_1 = require("../../../lib/rfcBackend");
19
+ const utils_1 = require("../../../lib/utils");
20
+ exports.TOOL_DEFINITION = {
21
+ name: 'GetJobUsage',
22
+ available_in: ['onprem', 'legacy'],
23
+ description: '[read-only] Check whether programs are used as background job steps (SM37 jobs, TBTCO/TBTCP): true when the program is a step of a job that is scheduled now (released/ready/active, incl. periodic) or that finished/was cancelled in the last N months. SE38/SA38 dialog runs do not count. `oldest` = start date of the oldest finished job still kept; job reorganization deletes older ones, so when `complete` is false a false means "no job since <oldest>". No user names are returned. ECC-only (ZMCP_WL_JOB_USAGE bridge FM).',
24
+ inputSchema: {
25
+ type: 'object',
26
+ properties: {
27
+ programs: {
28
+ type: 'array',
29
+ items: { type: 'string' },
30
+ description: 'ABAP program names to check (e.g. ["ZMY_REPORT"]).',
31
+ },
32
+ months: {
33
+ type: 'number',
34
+ description: 'Months back including the current one (1-36). Default: 12.',
35
+ default: 12,
36
+ },
37
+ },
38
+ required: ['programs'],
39
+ },
40
+ };
41
+ /** First day (YYYYMMDD) of the oldest month in the window — same as the FM. */
42
+ function windowStart(months) {
43
+ const d = new Date();
44
+ const start = new Date(d.getFullYear(), d.getMonth() - (months - 1), 1);
45
+ const mm = String(start.getMonth() + 1).padStart(2, '0');
46
+ return `${start.getFullYear()}${mm}01`;
47
+ }
48
+ async function handleGetJobUsage(context, args) {
49
+ const { connection, logger } = context;
50
+ try {
51
+ const programs = (Array.isArray(args?.programs) ? args.programs : [])
52
+ .map((p) => String(p).trim().toUpperCase())
53
+ .filter((p) => p && !p.includes(','));
54
+ if (programs.length === 0) {
55
+ return (0, utils_1.return_error)(new Error('programs must list at least one program'));
56
+ }
57
+ if (process.env.SAP_VERSION?.toUpperCase() !== 'ECC') {
58
+ return (0, utils_1.return_error)(new Error('GetJobUsage currently routes through the ECC bridge (ZMCP_WL_JOB_USAGE via OData FunctionImport WlJobUsage). Set SAP_VERSION=ECC in .sc4sap/sap.env.'));
59
+ }
60
+ const months = Math.min(36, Math.max(1, Math.trunc(Number(args.months ?? 12)) || 12));
61
+ logger?.info(`GetJobUsage: ${programs.length} programs, months=${months}`);
62
+ const fm = await (0, rfcBackend_1.callWlJobUsage)(connection, { programs, months });
63
+ const used = programs.filter((p) => fm.result?.[p] === true);
64
+ const unused = programs.filter((p) => fm.result?.[p] !== true);
65
+ const start = windowStart(months);
66
+ return (0, utils_1.return_response)({
67
+ data: JSON.stringify({
68
+ success: fm.subrc === 0,
69
+ path: 'ecc-odata-rfc',
70
+ message: fm.message,
71
+ months,
72
+ window_start: start,
73
+ oldest: fm.oldest,
74
+ complete: fm.oldest !== '' && fm.oldest <= start,
75
+ used,
76
+ unused,
77
+ result: fm.result ?? {},
78
+ }, null, 2),
79
+ });
80
+ }
81
+ catch (error) {
82
+ const errorMessage = error instanceof Error ? error.message : String(error);
83
+ logger?.error(`GetJobUsage error: ${errorMessage}`);
84
+ return (0, utils_1.return_error)(new Error(errorMessage));
85
+ }
86
+ }
87
+ //# sourceMappingURL=handleGetJobUsage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleGetJobUsage.js","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetJobUsage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AA0CH,8CAuDC;AA9FD,wDAAyD;AACzD,8CAI4B;AAEf,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,aAAa;IACnB,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAU;IAC3C,WAAW,EACT,0gBAA0gB;IAC5gB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,oDAAoD;aAClE;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,4DAA4D;gBAC9D,OAAO,EAAE,EAAE;aACZ;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;CACO,CAAC;AAEX,+EAA+E;AAC/E,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI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*
4
+ * Source: workload monitor (ST03N) monthly aggregates, read on the SAP side
5
+ * by ZMCP_WL_TCODE_USAGE (SWNC_COLLECTOR_GET_AGGREGATES, USERTCODE). User
6
+ * names never leave SAP — the FM returns one boolean per transaction.
7
+ *
8
+ * Backend: ECC only — OData FunctionImport `WlTcodeUsage` on ZMCP_ADT_SRV.
9
+ *
10
+ * Other system: `destination` (or SAP_USAGE_RFCDEST from the profile sap.env)
11
+ * names an SM59 destination on the connected system; the FM then reads that
12
+ * system's aggregates over RFC (DEV profile → QA / PRD business usage). The
13
+ * destination is site-specific — it is never defaulted by the plugin.
14
+ *
15
+ * Companion ABAP source: sc4sap/abap/zmcp_wl_tcode_usage_ecc.abap
16
+ */
17
+ import type { HandlerContext } from '../../../lib/handlers/interfaces';
18
+ export declare const TOOL_DEFINITION: {
19
+ readonly name: "GetTcodeUsage";
20
+ readonly available_in: readonly ["onprem", "legacy"];
21
+ readonly description: "[read-only] Check whether transactions were used in the last N months, from the ST03N workload monthly aggregates. Returns one boolean per transaction plus `coverage` = months that actually hold workload data; when coverage < months, false means \"not used in the last <coverage> months\". No user names are returned. ECC-only (ZMCP_WL_TCODE_USAGE bridge FM).";
22
+ readonly inputSchema: {
23
+ readonly type: "object";
24
+ readonly properties: {
25
+ readonly tcodes: {
26
+ readonly type: "array";
27
+ readonly items: {
28
+ readonly type: "string";
29
+ };
30
+ readonly description: "Transaction codes to check (e.g. [\"VA01\",\"ZMY_TCODE\"]).";
31
+ };
32
+ readonly months: {
33
+ readonly type: "number";
34
+ readonly description: "Months back including the current one (1-36). Default: 12.";
35
+ readonly default: 12;
36
+ };
37
+ readonly destination: {
38
+ readonly type: "string";
39
+ readonly description: "SM59 RFC destination (on the connected system) of the system to measure, e.g. the QA or PRD system. Omitted → SAP_USAGE_RFCDEST from the profile sap.env, else the connected system. \"\" or \"LOCAL\" → the connected system.";
40
+ };
41
+ };
42
+ readonly required: readonly ["tcodes"];
43
+ };
44
+ };
45
+ export declare function handleGetTcodeUsage(context: HandlerContext, args: {
46
+ tcodes: string[];
47
+ months?: number;
48
+ destination?: string;
49
+ }): Promise<{
50
+ isError: boolean;
51
+ content: {
52
+ type: string;
53
+ text: any;
54
+ }[];
55
+ }>;
56
+ //# sourceMappingURL=handleGetTcodeUsage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleGetTcodeUsage.d.ts","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetTcodeUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAQvE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BlB,CAAC;AAEX,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;GAoElE"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * GetTcodeUsage — read-only: was each transaction used in the last N months?
4
+ *
5
+ * Source: workload monitor (ST03N) monthly aggregates, read on the SAP side
6
+ * by ZMCP_WL_TCODE_USAGE (SWNC_COLLECTOR_GET_AGGREGATES, USERTCODE). User
7
+ * names never leave SAP — the FM returns one boolean per transaction.
8
+ *
9
+ * Backend: ECC only — OData FunctionImport `WlTcodeUsage` on ZMCP_ADT_SRV.
10
+ *
11
+ * Other system: `destination` (or SAP_USAGE_RFCDEST from the profile sap.env)
12
+ * names an SM59 destination on the connected system; the FM then reads that
13
+ * system's aggregates over RFC (DEV profile → QA / PRD business usage). The
14
+ * destination is site-specific — it is never defaulted by the plugin.
15
+ *
16
+ * Companion ABAP source: sc4sap/abap/zmcp_wl_tcode_usage_ecc.abap
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.TOOL_DEFINITION = void 0;
20
+ exports.handleGetTcodeUsage = handleGetTcodeUsage;
21
+ const rfcBackend_1 = require("../../../lib/rfcBackend");
22
+ const utils_1 = require("../../../lib/utils");
23
+ exports.TOOL_DEFINITION = {
24
+ name: 'GetTcodeUsage',
25
+ available_in: ['onprem', 'legacy'],
26
+ description: '[read-only] Check whether transactions were used in the last N months, from the ST03N workload monthly aggregates. Returns one boolean per transaction plus `coverage` = months that actually hold workload data; when coverage < months, false means "not used in the last <coverage> months". No user names are returned. ECC-only (ZMCP_WL_TCODE_USAGE bridge FM).',
27
+ inputSchema: {
28
+ type: 'object',
29
+ properties: {
30
+ tcodes: {
31
+ type: 'array',
32
+ items: { type: 'string' },
33
+ description: 'Transaction codes to check (e.g. ["VA01","ZMY_TCODE"]).',
34
+ },
35
+ months: {
36
+ type: 'number',
37
+ description: 'Months back including the current one (1-36). Default: 12.',
38
+ default: 12,
39
+ },
40
+ destination: {
41
+ type: 'string',
42
+ description: 'SM59 RFC destination (on the connected system) of the system to measure, e.g. the QA or PRD system. Omitted → SAP_USAGE_RFCDEST from the profile sap.env, else the connected system. "" or "LOCAL" → the connected system.',
43
+ },
44
+ },
45
+ required: ['tcodes'],
46
+ },
47
+ };
48
+ async function handleGetTcodeUsage(context, args) {
49
+ const { connection, logger } = context;
50
+ try {
51
+ const tcodes = (Array.isArray(args?.tcodes) ? args.tcodes : [])
52
+ .map((t) => String(t).trim().toUpperCase())
53
+ .filter((t) => t && !t.includes(','));
54
+ if (tcodes.length === 0) {
55
+ return (0, utils_1.return_error)(new Error('tcodes must list at least one transaction'));
56
+ }
57
+ if (process.env.SAP_VERSION?.toUpperCase() !== 'ECC') {
58
+ return (0, utils_1.return_error)(new Error('GetTcodeUsage currently routes through the ECC bridge (ZMCP_WL_TCODE_USAGE via OData FunctionImport WlTcodeUsage). Set SAP_VERSION=ECC in .sc4sap/sap.env.'));
59
+ }
60
+ const months = Math.min(36, Math.max(1, Math.trunc(Number(args.months ?? 12)) || 12));
61
+ const rawDest = args.destination !== undefined
62
+ ? String(args.destination)
63
+ : (process.env.SAP_USAGE_RFCDEST ?? '');
64
+ const destination = rawDest.trim().toUpperCase() === 'LOCAL' ? '' : rawDest.trim();
65
+ logger?.info(`GetTcodeUsage: ${tcodes.length} tcodes, months=${months}, destination=${destination || '(local)'}`);
66
+ const fm = await (0, rfcBackend_1.callWlTcodeUsage)(connection, {
67
+ tcodes,
68
+ months,
69
+ rfcdest: destination,
70
+ });
71
+ const used = tcodes.filter((t) => fm.result?.[t] === true);
72
+ const unused = tcodes.filter((t) => fm.result?.[t] !== true);
73
+ return (0, utils_1.return_response)({
74
+ data: JSON.stringify({
75
+ success: fm.subrc === 0,
76
+ path: 'ecc-odata-rfc',
77
+ system: fm.sysid || null,
78
+ destination: destination || null,
79
+ message: fm.message,
80
+ months,
81
+ coverage: fm.coverage,
82
+ complete: fm.coverage >= months,
83
+ usage_known: fm.subrc === 0,
84
+ used,
85
+ unused,
86
+ result: fm.result ?? {},
87
+ }, null, 2),
88
+ });
89
+ }
90
+ catch (error) {
91
+ const errorMessage = error instanceof Error ? error.message : String(error);
92
+ logger?.error(`GetTcodeUsage error: ${errorMessage}`);
93
+ return (0, utils_1.return_error)(new Error(errorMessage));
94
+ }
95
+ }
96
+ //# sourceMappingURL=handleGetTcodeUsage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleGetTcodeUsage.js","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetTcodeUsage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAuCH,kDAsEC;AA1GD,wDAA2D;AAC3D,8CAI4B;AAEf,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,eAAe;IACrB,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAU;IAC3C,WAAW,EACT,uWAAuW;IACzW,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,OAAO;g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AE,CAAC,OAAO;gBACnB,MAAM;gBACN,QAAQ,EAAE,EAAE,CAAC,QAAQ;gBACrB,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,MAAM;gBAC/B,WAAW,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC;gBAC3B,IAAI;gBACJ,MAAM;gBACN,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,EAAE;aACxB,EACD,IAAI,EACJ,CAAC,CACF;SACe,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,EAAE,KAAK,CAAC,wBAAwB,YAAY,EAAE,CAAC,CAAC;QACtD,OAAO,IAAA,oBAAY,EAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -2,7 +2,7 @@ import type { HandlerContext } from '../../../lib/handlers/interfaces';
2
2
  export declare const TOOL_DEFINITION: {
3
3
  readonly name: "GetTransaction";
4
4
  readonly available_in: readonly ["onprem", "cloud"];
5
- readonly description: "[read-only] Retrieve ABAP transaction (t-code) details — program, screen, authorization object, and transaction type (dialog, report, OO).";
5
+ readonly description: "[read-only] Retrieve ABAP transaction (t-code) details from TSTC / TSTCP — program, screen, and kind (program, parameter transaction with its target t-code and parameters such as an SM30 view, variant transaction). Pass transaction_names for many t-codes in one call.";
6
6
  readonly inputSchema: {
7
7
  readonly type: "object";
8
8
  readonly properties: {
@@ -10,17 +10,43 @@ export declare const TOOL_DEFINITION: {
10
10
  readonly type: "string";
11
11
  readonly description: "Name of the ABAP transaction";
12
12
  };
13
+ readonly transaction_names: {
14
+ readonly type: "array";
15
+ readonly items: {
16
+ readonly type: "string";
17
+ };
18
+ readonly description: "Several transactions in one call (e.g. [\"VA01\",\"ZMY_TCODE\"]).";
19
+ };
13
20
  };
14
- readonly required: readonly ["transaction_name"];
15
21
  };
16
22
  };
17
- export declare function handleGetTransaction(context: HandlerContext, _args: any): Promise<{
23
+ export interface TransactionInfo {
24
+ tcode: string;
25
+ found: boolean;
26
+ /** program started (TSTC-PGMNA); for a parameter transaction usually empty */
27
+ program?: string;
28
+ screen?: string;
29
+ /** program = report / dialog / OO entry; parameter = TSTCP '/*' or '/N' start; variant = TSTCP '@' */
30
+ kind?: 'program' | 'parameter' | 'variant';
31
+ /** parameter transaction: the t-code it calls (e.g. SM30) */
32
+ target_tcode?: string;
33
+ /** parameter transaction: NAME=VALUE pairs (e.g. VIEWNAME, UPDATE) */
34
+ parameters?: Record<string, string>;
35
+ /** raw TSTCP-PARAM */
36
+ param?: string;
37
+ }
38
+ /** '/*SM30 VIEWNAME=ZX;UPDATE=X;' → { target: 'SM30', parameters: { VIEWNAME: 'ZX', UPDATE: 'X' } } */
39
+ export declare function parseTransactionParam(param: string): {
40
+ kind: 'parameter' | 'variant' | null;
41
+ target?: string;
42
+ parameters?: Record<string, string>;
43
+ };
44
+ export declare function buildTransactionInfo(names: string[], tstc: Array<Record<string, any>>, tstcp: Array<Record<string, any>>): TransactionInfo[];
45
+ export declare function handleGetTransaction(context: HandlerContext, args: any): Promise<{
18
46
  isError: boolean;
19
47
  content: {
20
48
  type: string;
21
- json: {
22
- message: string;
23
- };
49
+ text: string;
24
50
  }[];
25
51
  }>;
26
52
  //# sourceMappingURL=handleGetTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleGetTransaction.d.ts","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;CAelB,CAAC;AA2BX,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,GAAG;;;;;;;;GA4BX"}
1
+ {"version":3,"file":"handleGetTransaction.d.ts","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetTransaction.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAOvE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;CAoBlB,CAAC;AAEX,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sGAAsG;IACtG,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IAC3C,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAiCD,uGAAuG;AACvG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG;IACpD,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CAcA;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAChC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAChC,eAAe,EAAE,CAwBnB;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG;;;;;;GAkD5E"}
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TOOL_DEFINITION = void 0;
4
+ exports.parseTransactionParam = parseTransactionParam;
5
+ exports.buildTransactionInfo = buildTransactionInfo;
4
6
  exports.handleGetTransaction = handleGetTransaction;
5
- // import { McpError, ErrorCode } from '../../../lib/utils';
6
- const fast_xml_parser_1 = require("fast-xml-parser");
7
- // import { createAdtClient } from '../../../lib/clients';
7
+ const clients_1 = require("../../../lib/clients");
8
+ const legacyTableRead_1 = require("../../../lib/legacyTableRead");
9
+ const handleGetSqlQuery_1 = require("./handleGetSqlQuery");
8
10
  exports.TOOL_DEFINITION = {
9
11
  name: 'GetTransaction',
10
12
  available_in: ['onprem', 'cloud'],
11
- description: '[read-only] Retrieve ABAP transaction (t-code) details — program, screen, authorization object, and transaction type (dialog, report, OO).',
13
+ description: '[read-only] Retrieve ABAP transaction (t-code) details from TSTC / TSTCP — program, screen, and kind (program, parameter transaction with its target t-code and parameters such as an SM30 view, variant transaction). Pass transaction_names for many t-codes in one call.',
12
14
  inputSchema: {
13
15
  type: 'object',
14
16
  properties: {
@@ -16,58 +18,118 @@ exports.TOOL_DEFINITION = {
16
18
  type: 'string',
17
19
  description: 'Name of the ABAP transaction',
18
20
  },
21
+ transaction_names: {
22
+ type: 'array',
23
+ items: { type: 'string' },
24
+ description: 'Several transactions in one call (e.g. ["VA01","ZMY_TCODE"]).',
25
+ },
19
26
  },
20
- required: ['transaction_name'],
21
27
  },
22
28
  };
23
- function _parseTransactionXml(xml) {
24
- const parser = new fast_xml_parser_1.XMLParser({
25
- ignoreAttributes: false,
26
- attributeNamePrefix: '',
27
- parseAttributeValue: true,
28
- trimValues: true,
29
+ const quoteList = (names) => names.map((n) => `'${n.replace(/'/g, "''")}'`).join(',');
30
+ /** SELECT through the ADT data preview, or ZMCP_ADT_DISPATCH TABLE_READ on BASIS < 7.50. */
31
+ async function selectRows(connection, logger, table, fields, where, maxRows) {
32
+ const sql = `SELECT ${fields.join(', ')} FROM ${table} WHERE ${where}`;
33
+ try {
34
+ const response = await (0, clients_1.createAdtClient)(connection, logger)
35
+ .getUtils()
36
+ .getSqlQuery({ sql_query: sql, row_number: maxRows });
37
+ return (0, handleGetSqlQuery_1.parseSqlQueryXml)(response.data, sql, maxRows, logger).rows;
38
+ }
39
+ catch (e) {
40
+ if (!(0, legacyTableRead_1.isLegacyUnsupported)(e))
41
+ throw e;
42
+ const res = await (0, legacyTableRead_1.legacyTableRead)(connection, {
43
+ table,
44
+ fields,
45
+ where,
46
+ maxRows,
47
+ sqlQuery: sql,
48
+ });
49
+ return res.rows;
50
+ }
51
+ }
52
+ /** '/*SM30 VIEWNAME=ZX;UPDATE=X;' → { target: 'SM30', parameters: { VIEWNAME: 'ZX', UPDATE: 'X' } } */
53
+ function parseTransactionParam(param) {
54
+ const p = String(param ?? '').trim();
55
+ if (p.startsWith('@'))
56
+ return { kind: 'variant' };
57
+ const m = /^\/[*N](\S+)\s*(.*)$/i.exec(p);
58
+ if (!m)
59
+ return { kind: null };
60
+ const parameters = {};
61
+ for (const part of m[2].split(';')) {
62
+ const eq = part.indexOf('=');
63
+ if (eq > 0)
64
+ parameters[part.slice(0, eq).trim().toUpperCase()] = part
65
+ .slice(eq + 1)
66
+ .trim();
67
+ }
68
+ return { kind: 'parameter', target: m[1].toUpperCase(), parameters };
69
+ }
70
+ function buildTransactionInfo(names, tstc, tstcp) {
71
+ const byCode = new Map(tstc.map((r) => [String(r.TCODE).toUpperCase(), r]));
72
+ const paramBy = new Map(tstcp.map((r) => [String(r.TCODE).toUpperCase(), String(r.PARAM ?? '')]));
73
+ return names.map((tcode) => {
74
+ const row = byCode.get(tcode);
75
+ if (!row)
76
+ return { tcode, found: false };
77
+ const info = { tcode, found: true, kind: 'program' };
78
+ const program = String(row.PGMNA ?? '').trim();
79
+ const screen = String(row.DYPNO ?? '').trim();
80
+ if (program)
81
+ info.program = program;
82
+ if (screen)
83
+ info.screen = screen;
84
+ const param = paramBy.get(tcode);
85
+ if (param) {
86
+ info.param = param;
87
+ const parsed = parseTransactionParam(param);
88
+ if (parsed.kind)
89
+ info.kind = parsed.kind;
90
+ if (parsed.target)
91
+ info.target_tcode = parsed.target;
92
+ if (parsed.parameters && Object.keys(parsed.parameters).length)
93
+ info.parameters = parsed.parameters;
94
+ }
95
+ return info;
29
96
  });
30
- const result = parser.parse(xml);
31
- // ADT Transaction XML (opr:objectProperties)
32
- if (result['opr:objectProperties']?.['opr:object']) {
33
- const obj = result['opr:objectProperties']['opr:object'];
97
+ }
98
+ async function handleGetTransaction(context, args) {
99
+ const { connection, logger } = context;
100
+ try {
101
+ const names = [
102
+ ...(Array.isArray(args?.transaction_names) ? args.transaction_names : []),
103
+ ...(args?.transaction_name ? [args.transaction_name] : []),
104
+ ]
105
+ .map((n) => String(n).trim().toUpperCase())
106
+ .filter(Boolean);
107
+ const unique = [...new Set(names)];
108
+ if (!unique.length)
109
+ throw new Error('transaction_name or transaction_names is required');
110
+ const where = `TCODE IN (${quoteList(unique)})`;
111
+ const tstc = await selectRows(connection, logger, 'TSTC', ['TCODE', 'PGMNA', 'DYPNO'], where, unique.length + 1);
112
+ const tstcp = await selectRows(connection, logger, 'TSTCP', ['TCODE', 'PARAM'], where, unique.length + 1);
113
+ const transactions = buildTransactionInfo(unique, tstc, tstcp);
114
+ const payload = transactions.length === 1 && !Array.isArray(args?.transaction_names)
115
+ ? { success: true, ...transactions[0] }
116
+ : { success: true, transactions };
34
117
  return {
35
- name: obj.name,
36
- objectType: 'transaction',
37
- description: obj.text,
38
- package: obj.package,
39
- type: obj.type,
118
+ isError: false,
119
+ content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
120
+ };
121
+ }
122
+ catch (error) {
123
+ logger?.error('GetTransaction failed', error);
124
+ return {
125
+ isError: true,
126
+ content: [
127
+ {
128
+ type: 'text',
129
+ text: `ADT error: ${String(error?.message ?? error)}`,
130
+ },
131
+ ],
40
132
  };
41
133
  }
42
- // fallback: return raw
43
- return { raw: result };
44
- }
45
- async function handleGetTransaction(context, _args) {
46
- const { connection, logger } = context;
47
- // try {
48
- // if (!args?.transaction_name) {
49
- // throw new McpError(ErrorCode.InvalidParams, 'Transaction name is required');
50
- // }
51
- // logger?.info(`Fetching transaction info for ${args.transaction_name}`);
52
- // const client = createAdtClient(connection);
53
- // const result = await client.readTransaction(args.transaction_name);
54
- // return result;
55
- // } catch (error) {
56
- // logger?.error(`Failed to fetch transaction ${args?.transaction_name}`, error as any);
57
- // // MCP-compliant error response: always return content[] with type "text"
58
- // return {
59
- // isError: true,
60
- // content: [
61
- // {
62
- // type: "text",
63
- // text: `ADT error: ${String(error)}`
64
- // }
65
- // ]
66
- // };
67
- // }
68
- return {
69
- isError: false,
70
- content: [{ type: 'json', json: { message: 'Not implemented' } }],
71
- };
72
134
  }
73
135
  //# sourceMappingURL=handleGetTransaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleGetTransaction.js","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetTransaction.ts"],"names":[],"mappings":";;;AA8CA,oDA8BC;AA5ED,4DAA4D;AAC5D,qDAA4C;AAE5C,0DAA0D;AAC7C,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,gBAAgB;IACtB,YAAY,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAU;IAC1C,WAAW,EACT,4IAA4I;IAC9I,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,gBAAgB,EAAE;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;SACF;QACD,QAAQ,EAAE,CAAC,kBAAkB,CAAC;KAC/B;CACO,CAAC;AAEX,SAAS,oBAAoB,CAAC,GAAW;IACvC,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC;QAC3B,gBAAgB,EAAE,KAAK;QACvB,mBAAmB,EAAE,EAAE;QACvB,mBAAmB,EAAE,IAAI;QACzB,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjC,6CAA6C;IAC7C,IAAI,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;QACnD,MAAM,GAAG,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC,YAAY,CAAC,CAAC;QACzD,OAAO;YACL,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,UAAU,EAAE,aAAa;YACzB,WAAW,EAAE,GAAG,CAAC,IAAI;YACrB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAC;IACJ,CAAC;IAED,uBAAuB;IACvB,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB,CAAC;AAEM,KAAK,UAAU,oBAAoB,CACxC,OAAuB,EACvB,KAAU;IAEV,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACvC,QAAQ;IACR,qCAAqC;IACrC,uFAAuF;IACvF,QAAQ;IACR,8EAA8E;IAC9E,kDAAkD;IAClD,0EAA0E;IAC1E,qBAAqB;IACrB,oBAAoB;IACpB,4FAA4F;IAC5F,gFAAgF;IAChF,eAAe;IACf,yBAAyB;IACzB,qBAAqB;IACrB,gBAAgB;IAChB,gCAAgC;IAChC,sDAAsD;IACtD,gBAAgB;IAChB,YAAY;IACZ,SAAS;IACT,IAAI;IACJ,OAAO;QACL,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,EAAE,CAAC;KAClE,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"handleGetTransaction.js","sourceRoot":"","sources":["../../../../src/handlers/system/readonly/handleGetTransaction.ts"],"names":[],"mappings":";;;AAkFA,sDAkBC;AAED,oDA4BC;AAED,oDAkDC;AAlLD,kDAAuD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systems (BASIS < 7.50) createAdtClient() returns AdtClientLegacy,
7
7
  * whose utils skip the scope step and address DDIC objects through VIT URIs
8
- * (client library >= 3.15.0). The handler itself does not branch on ECC.
8
+ * (client library >= 3.15.0).
9
+ *
10
+ * BASIS < 7.40 (e.g. 7.31) has no repository information system resource at
11
+ * all, so the search runs in SAP through ZMCP_ADT_DISPATCH action WHERE_USED
12
+ * (cross-reference tables WBCROSSGT / CROSS / D010INC, DDIC usage DD03L /
13
+ * DD04L) instead.
9
14
  */
10
15
  import type { HandlerContext } from '../../../lib/handlers/interfaces';
11
16
  export declare const SUPPORTED_WHERE_USED_TYPES = "class, interface, program, include, functiongroup, function_module, table, structure, dataelement, domain, view, tabletype (ECC), transaction (ECC), messageclass (ECC), package";
@@ -92,6 +97,8 @@ export declare function applyWhereUsedFilters(references: WhereUsedReferenceOut[
92
97
  filtered_out: number;
93
98
  truncated: boolean;
94
99
  };
100
+ /** True on BASIS releases without /sap/bc/adt/repository/informationsystem. */
101
+ export declare function needsDispatchWhereUsed(): boolean;
95
102
  /** Add an actionable hint to well-known ADT where-used failures. */
96
103
  export declare function whereUsedErrorHint(error: unknown): string | undefined;
97
104
  /**