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

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 (124) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/handlers/smartform/high/handleCreateSmartForm.d.ts +71 -0
  3. package/dist/handlers/smartform/high/handleCreateSmartForm.d.ts.map +1 -0
  4. package/dist/handlers/smartform/high/handleCreateSmartForm.js +163 -0
  5. package/dist/handlers/smartform/high/handleCreateSmartForm.js.map +1 -0
  6. package/dist/handlers/smartform/high/handleDeleteSmartForm.d.ts +41 -0
  7. package/dist/handlers/smartform/high/handleDeleteSmartForm.d.ts.map +1 -0
  8. package/dist/handlers/smartform/high/handleDeleteSmartForm.js +76 -0
  9. package/dist/handlers/smartform/high/handleDeleteSmartForm.js.map +1 -0
  10. package/dist/handlers/system/readonly/handleGetJobUsage.d.ts +48 -0
  11. package/dist/handlers/system/readonly/handleGetJobUsage.d.ts.map +1 -0
  12. package/dist/handlers/system/readonly/handleGetJobUsage.js +87 -0
  13. package/dist/handlers/system/readonly/handleGetJobUsage.js.map +1 -0
  14. package/dist/handlers/system/readonly/handleGetSmartFormContent.d.ts +77 -0
  15. package/dist/handlers/system/readonly/handleGetSmartFormContent.d.ts.map +1 -0
  16. package/dist/handlers/system/readonly/handleGetSmartFormContent.js +98 -0
  17. package/dist/handlers/system/readonly/handleGetSmartFormContent.js.map +1 -0
  18. package/dist/handlers/system/readonly/handleGetSmartFormLayout.d.ts +47 -0
  19. package/dist/handlers/system/readonly/handleGetSmartFormLayout.d.ts.map +1 -0
  20. package/dist/handlers/system/readonly/handleGetSmartFormLayout.js +70 -0
  21. package/dist/handlers/system/readonly/handleGetSmartFormLayout.js.map +1 -0
  22. package/dist/handlers/system/readonly/handleGetTcodeUsage.d.ts +56 -0
  23. package/dist/handlers/system/readonly/handleGetTcodeUsage.d.ts.map +1 -0
  24. package/dist/handlers/system/readonly/handleGetTcodeUsage.js +96 -0
  25. package/dist/handlers/system/readonly/handleGetTcodeUsage.js.map +1 -0
  26. package/dist/handlers/system/readonly/handleGetTransaction.d.ts +32 -6
  27. package/dist/handlers/system/readonly/handleGetTransaction.d.ts.map +1 -1
  28. package/dist/handlers/system/readonly/handleGetTransaction.js +112 -50
  29. package/dist/handlers/system/readonly/handleGetTransaction.js.map +1 -1
  30. package/dist/handlers/system/readonly/handleGetWhereUsed.d.ts +8 -1
  31. package/dist/handlers/system/readonly/handleGetWhereUsed.d.ts.map +1 -1
  32. package/dist/handlers/system/readonly/handleGetWhereUsed.js +52 -7
  33. package/dist/handlers/system/readonly/handleGetWhereUsed.js.map +1 -1
  34. package/dist/handlers/system/readonly/handleReloadProfile.d.ts +4 -3
  35. package/dist/handlers/system/readonly/handleReloadProfile.d.ts.map +1 -1
  36. package/dist/handlers/system/readonly/handleReloadProfile.js +13 -5
  37. package/dist/handlers/system/readonly/handleReloadProfile.js.map +1 -1
  38. package/dist/handlers/system/readonly/handleRenderSmartForm.d.ts +65 -0
  39. package/dist/handlers/system/readonly/handleRenderSmartForm.d.ts.map +1 -0
  40. package/dist/handlers/system/readonly/handleRenderSmartForm.js +111 -0
  41. package/dist/handlers/system/readonly/handleRenderSmartForm.js.map +1 -0
  42. package/dist/handlers/system/readonly/runtimeFeedsHelper.d.ts +1 -1
  43. package/dist/handlers/system/readonly/runtimeFeedsHelper.d.ts.map +1 -1
  44. package/dist/handlers/transport/readonly/handleGetTransport.d.ts +3 -0
  45. package/dist/handlers/transport/readonly/handleGetTransport.d.ts.map +1 -1
  46. package/dist/handlers/transport/readonly/handleGetTransport.js +24 -0
  47. package/dist/handlers/transport/readonly/handleGetTransport.js.map +1 -1
  48. package/dist/handlers/transport/readonly/handleListTransports.d.ts +2 -1
  49. package/dist/handlers/transport/readonly/handleListTransports.d.ts.map +1 -1
  50. package/dist/handlers/transport/readonly/handleListTransports.js +17 -7
  51. package/dist/handlers/transport/readonly/handleListTransports.js.map +1 -1
  52. package/dist/lib/handlers/groups/HighLevelHandlersGroup.d.ts.map +1 -1
  53. package/dist/lib/handlers/groups/HighLevelHandlersGroup.js +11 -0
  54. package/dist/lib/handlers/groups/HighLevelHandlersGroup.js.map +1 -1
  55. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.d.ts.map +1 -1
  56. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.js +25 -0
  57. package/dist/lib/handlers/groups/ReadOnlyHandlersGroup.js.map +1 -1
  58. package/dist/lib/legacyLockHint.d.ts +15 -0
  59. package/dist/lib/legacyLockHint.d.ts.map +1 -0
  60. package/dist/lib/legacyLockHint.js +34 -0
  61. package/dist/lib/legacyLockHint.js.map +1 -0
  62. package/dist/lib/legacyTableRead.d.ts +1 -1
  63. package/dist/lib/legacyTableRead.d.ts.map +1 -1
  64. package/dist/lib/legacyTableRead.js +23 -9
  65. package/dist/lib/legacyTableRead.js.map +1 -1
  66. package/dist/lib/legacyTransport.d.ts +78 -0
  67. package/dist/lib/legacyTransport.d.ts.map +1 -0
  68. package/dist/lib/legacyTransport.js +233 -0
  69. package/dist/lib/legacyTransport.js.map +1 -0
  70. package/dist/lib/nativeRfc.d.ts.map +1 -1
  71. package/dist/lib/nativeRfc.js +5 -0
  72. package/dist/lib/nativeRfc.js.map +1 -1
  73. package/dist/lib/odataRfc.d.ts +48 -0
  74. package/dist/lib/odataRfc.d.ts.map +1 -1
  75. package/dist/lib/odataRfc.js +73 -0
  76. package/dist/lib/odataRfc.js.map +1 -1
  77. package/dist/lib/profile.d.ts.map +1 -1
  78. package/dist/lib/profile.js +34 -0
  79. package/dist/lib/profile.js.map +1 -1
  80. package/dist/lib/profileEvents.d.ts +16 -0
  81. package/dist/lib/profileEvents.d.ts.map +1 -0
  82. package/dist/lib/profileEvents.js +29 -0
  83. package/dist/lib/profileEvents.js.map +1 -0
  84. package/dist/lib/rfcBackend.d.ts +2 -0
  85. package/dist/lib/rfcBackend.d.ts.map +1 -1
  86. package/dist/lib/rfcBackend.js +20 -4
  87. package/dist/lib/rfcBackend.js.map +1 -1
  88. package/dist/lib/smartFormContent.d.ts +277 -0
  89. package/dist/lib/smartFormContent.d.ts.map +1 -0
  90. package/dist/lib/smartFormContent.js +1130 -0
  91. package/dist/lib/smartFormContent.js.map +1 -0
  92. package/dist/lib/smartFormLayout.d.ts +83 -0
  93. package/dist/lib/smartFormLayout.d.ts.map +1 -0
  94. package/dist/lib/smartFormLayout.js +236 -0
  95. package/dist/lib/smartFormLayout.js.map +1 -0
  96. package/dist/lib/smartFormRender.d.ts +17 -0
  97. package/dist/lib/smartFormRender.d.ts.map +1 -0
  98. package/dist/lib/smartFormRender.js +112 -0
  99. package/dist/lib/smartFormRender.js.map +1 -0
  100. package/dist/lib/soapRfc.d.ts +17 -0
  101. package/dist/lib/soapRfc.d.ts.map +1 -1
  102. package/dist/lib/soapRfc.js +39 -0
  103. package/dist/lib/soapRfc.js.map +1 -1
  104. package/dist/lib/utils.d.ts +1 -1
  105. package/dist/lib/utils.d.ts.map +1 -1
  106. package/dist/lib/utils.js +1 -1
  107. package/dist/lib/utils.js.map +1 -1
  108. package/dist/lib/zrfcProxy.d.ts.map +1 -1
  109. package/dist/lib/zrfcProxy.js +5 -0
  110. package/dist/lib/zrfcProxy.js.map +1 -1
  111. package/dist/server/BaseMcpServer.d.ts +11 -0
  112. package/dist/server/BaseMcpServer.d.ts.map +1 -1
  113. package/dist/server/BaseMcpServer.js +69 -2
  114. package/dist/server/BaseMcpServer.js.map +1 -1
  115. package/dist/server/StdioServer.d.ts.map +1 -1
  116. package/dist/server/StdioServer.js +9 -0
  117. package/dist/server/StdioServer.js.map +1 -1
  118. package/docs/user-guide/AVAILABLE_TOOLS.md +1039 -204
  119. package/docs/user-guide/AVAILABLE_TOOLS_COMPACT.md +2 -1
  120. package/docs/user-guide/AVAILABLE_TOOLS_HIGH.md +470 -85
  121. package/docs/user-guide/AVAILABLE_TOOLS_LEGACY.md +955 -78
  122. package/docs/user-guide/AVAILABLE_TOOLS_LOW.md +271 -60
  123. package/docs/user-guide/AVAILABLE_TOOLS_READONLY.md +299 -60
  124. package/package.json +19 -19
package/CHANGELOG.md CHANGED
@@ -4,6 +4,44 @@
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [4.8.13] - 2026-10-20
8
+
9
+ ### Added
10
+ - **`GetSmartFormLayout`** (read-only, on-premise and legacy systems): page and window layout of a SmartForm. Per page the format, orientation, next page, CPI / LPI and style; per window its type (MAIN, SECONDARY, ...), position and size as stored (value + unit) and converted to millimetres (CM, MM, IN, PT, TW, and LN / CH through the page LPI / CPI). Reads the active version (a form that was never activated is read from its saved version and `active` is false). `language` takes a 1-character SAP key or a 2-letter ISO code. Layout only: no texts, code or form interface. Runs through `ZMCP_ADT_DISPATCH` action `SSF_LAYOUT`, so it works on the OData backend (BASIS 7.40) and over SOAP RFC (BASIS 7.31). Needs the new `ZMCP_SSF_LAYOUT` FM and the `SSF_LAYOUT` dispatcher branch; without them the tool answers with an install hint.
11
+ - **`GetSmartFormContent`** (read-only, on-premise and legacy systems): what a SmartForm prints, for preview rendering. Per page and window (position in mm) the content tree: text nodes with their lines (paragraph format, inline character formats, `&symbols&`), include texts, templates with line heights and cells (width, border widths, shading colour), loops and tables with header / footer events, graphics, addresses, print conditions; code nodes only as markers, never program lines. Also the form interface and global data with their types (`data`), the SmartStyles as CSS, SE78 graphics with a fixed key as BMP with their printed size, and include texts with a fixed key. Everything is written under the MCP output directory (`smartforms/<form>/`, full result in `<form>.content.json`); `summary: true` answers with an overview (windows, data declarations, `&symbols&`, graphics, files) because the full tree easily exceeds a tool answer. Runs through `ZMCP_ADT_DISPATCH` action `SSF_CONTENT` (FM `ZMCP_SSF_CONTENT`).
12
+ - **`RenderSmartForm`** (on-premise and legacy systems): the output of a SmartForm exactly as SAP prints it, for given interface values. Calls the form's generated function module with GETOTF (no dialog, no print, no spool) and writes the OTF and the PDF under the MCP output directory (`smartforms/<form>/<form>.sap.otf.txt` / `.sap.pdf`). `values` / `values_file` take the interface in internal format; `device` or `families` choose the device type, so the output has the printer fonts the form was made for. The form's own program lines run as in a real print and may read the database — pass invented sample values only. Runs through `ZMCP_ADT_DISPATCH` action `SSF_RENDER` (FM `ZMCP_SSF_RENDER`); without them the tool answers with an install hint.
13
+ - **`CreateSmartForm`** (writes, on-premise and legacy systems, DEV profiles only): creates — or with `overwrite` replaces — a Z/Y SmartForm from Form Builder XML (the format of SMARTFORMS > Utilities > Download and of `GetSmartFormContent`'s form XML). The form is checked and stored active, its function module generated (also for a replaced form); when the check finds errors it is stored inactive and the errors come back. `package_name` defaults to `$TMP`; another package needs `transport_request`. The XML travels raw-deflate compressed in parts of 5000 base64 characters, because the OData `Dispatch` function import carries its parameters in the URL. Runs through `ZMCP_ADT_DISPATCH` action `SSF_UPLOAD_XML` (FM `ZMCP_SSF_UPLOAD`); without them the tool answers with an install hint.
14
+ - **`DeleteSmartForm`** (writes, destructive, DEV profiles only): deletes a Z/Y SmartForm of a local package (`$TMP`, `$…`) with its generated function module — a dry run unless `confirm: true`; transportable forms are refused. Runs through action `SSF_DELETE_FORM` (FM `ZMCP_SSF_DELETE`).
15
+ - **`GetSmartFormContent`** reads more of what decides the print:
16
+ - SmartStyle paragraphs and character formats as stored (value + unit, family, size, tabs), with the SE73 bar-code definition (`barcodeDef`: symbology, module, height) of bar-code formats.
17
+ - Table / template patterns with their outer frame flag (`frame.border`), box sides switched on with thickness 0 (`on`), and the `reference` of a template line type that takes another line's height.
18
+ - Styles named only in output options (template / window STDSTYLE) are read too.
19
+ - The device type and its printer fonts for the form's families (`printer`).
20
+ - Texts with no translation in the logon language are taken from the form's master language, as SAP prints them. This needs `ZMCP_SSF_CONTENT` with `IV_LANGUAGE` for the `FORM` part; an older FM keeps the logon-language texts.
21
+
22
+ ### Fixed
23
+ - `npm run docs:tools` cut a description at the first quote of the other kind (`'… (e.g. "ZMY_FORM")'`, `"… dump's …"`): string values now end at the quote they opened with, escapes are resolved. The user-guide tool lists are regenerated with the full texts.
24
+
25
+ ### Changed
26
+ - Dependencies updated within their major versions: `@modelcontextprotocol/sdk` 1.32.1, `axios` 1.20, `fast-xml-parser` 5.11, `zod` 4.6, `js-yaml` 4.3, `pino` 10.4, `pino-pretty` 13.2, and the dev tooling (Biome 2.5, ts-jest, tsx, express, yaml). `jest` stays on 30.2: 30.5 pulls in `@parcel/watcher`, whose install script fails under the nested `jest` tree on Windows (path over 260 characters).
27
+
28
+ ## [4.8.12] - 2026-10-14
29
+
30
+ ### Changed
31
+ - **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.
32
+
33
+ ### Fixed
34
+ - **`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`.
35
+ - **`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.
36
+ - **`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.
37
+ - **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.
38
+
39
+ ### Added
40
+ - **`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.
41
+ - **`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.
42
+ - **`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).
43
+ - Legacy table reads (`ZMCP_ADT_DISPATCH TABLE_READ`) also allow TSTC, TSTCP, DD03L and DD04L.
44
+
7
45
  ## [4.8.11] - 2026-10-12
8
46
 
9
47
  ### Fixed
@@ -0,0 +1,71 @@
1
+ /**
2
+ * CreateSmartForm — create or replace a SmartForm from Form Builder XML
3
+ * (the format of SMARTFORMS > Utilities > Download, FB_CONVERT_FORM_TO_XML,
4
+ * and the `xml` that GetSmartFormContent stores).
5
+ *
6
+ * SAP side: ZMCP_ADT_DISPATCH action SSF_UPLOAD_XML → FM ZMCP_SSF_UPLOAD,
7
+ * which loads the XML with CL_SSF_FB_SMART_FORM->XML_UPLOAD, checks the form
8
+ * and stores it active (generating its function module) when the check finds
9
+ * no error — otherwise inactive, with the check messages in the result.
10
+ * Companion ABAP source: sc4sap/abap/zmcp_ssf_upload.abap
11
+ */
12
+ import type { HandlerContext } from '../../../lib/handlers/interfaces';
13
+ export declare const SSF_UPLOAD_INSTALL_HINT: string;
14
+ export declare const TOOL_DEFINITION: {
15
+ readonly name: "CreateSmartForm";
16
+ readonly available_in: readonly ["onprem", "legacy"];
17
+ readonly description: "[writes] Create (or, with overwrite, replace) a Z/Y SmartForm from Form Builder XML — the format of SMARTFORMS > Utilities > Download. The form is checked and stored active (function module generated) when the check finds no error; otherwise it is stored inactive and the check errors are returned. SmartStyles and SE78 graphics the XML names must already exist. Needs the ZMCP_SSF_UPLOAD FM and the SSF_UPLOAD_XML dispatcher action.";
18
+ readonly inputSchema: {
19
+ readonly type: "object";
20
+ readonly properties: {
21
+ readonly form_name: {
22
+ readonly type: "string";
23
+ readonly description: "Target SmartForm name, Z* or Y* (e.g. \"ZMY_FORM\").";
24
+ };
25
+ readonly xml_file: {
26
+ readonly type: "string";
27
+ readonly description: "Path of the Form Builder XML file (UTF-8).";
28
+ };
29
+ readonly package_name: {
30
+ readonly type: "string";
31
+ readonly description: "Package. Default $TMP; any other package needs transport_request.";
32
+ };
33
+ readonly transport_request: {
34
+ readonly type: "string";
35
+ readonly description: "Transport request the form is recorded in.";
36
+ };
37
+ readonly overwrite: {
38
+ readonly type: "boolean";
39
+ readonly description: "Replace the form when it exists. Default false (an existing form is refused).";
40
+ };
41
+ readonly activate: {
42
+ readonly type: "boolean";
43
+ readonly description: "Check and store active. Default true; false stores the form inactive without a check.";
44
+ };
45
+ };
46
+ readonly required: readonly ["form_name", "xml_file"];
47
+ };
48
+ };
49
+ /**
50
+ * The XML as the dispatcher takes it: the OData backend carries the params in
51
+ * the URL (~8 KB), so the XML goes raw-deflate compressed (what CL_ABAP_GZIP
52
+ * reads) and base64-encoded, in parts the dispatcher joins on the last one.
53
+ */
54
+ export declare function uploadParts(xml: Buffer, partChars?: number): string[];
55
+ interface CreateSmartFormArgs {
56
+ form_name: string;
57
+ xml_file: string;
58
+ package_name?: string;
59
+ transport_request?: string;
60
+ overwrite?: boolean;
61
+ activate?: boolean;
62
+ }
63
+ export declare function handleCreateSmartForm(context: HandlerContext, args: CreateSmartFormArgs): Promise<{
64
+ isError: boolean;
65
+ content: {
66
+ type: string;
67
+ text: any;
68
+ }[];
69
+ }>;
70
+ export {};
71
+ //# sourceMappingURL=handleCreateSmartForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleCreateSmartForm.d.ts","sourceRoot":"","sources":["../../../../src/handlers/smartform/high/handleCreateSmartForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAQvE,eAAO,MAAM,uBAAuB,QAGwC,CAAC;AAK7E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsClB,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,SAAS,SAAoB,GAC5B,MAAM,EAAE,CAMV;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,mBAAmB;;;;;;GA6D1B"}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ /**
3
+ * CreateSmartForm — create or replace a SmartForm from Form Builder XML
4
+ * (the format of SMARTFORMS > Utilities > Download, FB_CONVERT_FORM_TO_XML,
5
+ * and the `xml` that GetSmartFormContent stores).
6
+ *
7
+ * SAP side: ZMCP_ADT_DISPATCH action SSF_UPLOAD_XML → FM ZMCP_SSF_UPLOAD,
8
+ * which loads the XML with CL_SSF_FB_SMART_FORM->XML_UPLOAD, checks the form
9
+ * and stores it active (generating its function module) when the check finds
10
+ * no error — otherwise inactive, with the check messages in the result.
11
+ * Companion ABAP source: sc4sap/abap/zmcp_ssf_upload.abap
12
+ */
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.TOOL_DEFINITION = exports.SSF_UPLOAD_INSTALL_HINT = void 0;
48
+ exports.uploadParts = uploadParts;
49
+ exports.handleCreateSmartForm = handleCreateSmartForm;
50
+ const crypto = __importStar(require("node:crypto"));
51
+ const fs = __importStar(require("node:fs"));
52
+ const zlib = __importStar(require("node:zlib"));
53
+ const rfcBackend_1 = require("../../../lib/rfcBackend");
54
+ const utils_1 = require("../../../lib/utils");
55
+ exports.SSF_UPLOAD_INSTALL_HINT = 'The SAP side of CreateSmartForm is not installed on this system: it needs FM ZMCP_SSF_UPLOAD ' +
56
+ '(function group ZMCP_ADT_UTILS) and the SSF_UPLOAD_XML branch in ZMCP_ADT_DISPATCH. ' +
57
+ 'Sources and install steps: sc4sap/abap/README.md (zmcp_ssf_upload.abap).';
58
+ /** base64 characters per dispatcher call (URL-encoded it stays below 8 KB). */
59
+ const UPLOAD_PART_CHARS = 5000;
60
+ exports.TOOL_DEFINITION = {
61
+ name: 'CreateSmartForm',
62
+ available_in: ['onprem', 'legacy'],
63
+ description: '[writes] Create (or, with overwrite, replace) a Z/Y SmartForm from Form Builder XML — the format of SMARTFORMS > Utilities > Download. The form is checked and stored active (function module generated) when the check finds no error; otherwise it is stored inactive and the check errors are returned. SmartStyles and SE78 graphics the XML names must already exist. Needs the ZMCP_SSF_UPLOAD FM and the SSF_UPLOAD_XML dispatcher action.',
64
+ inputSchema: {
65
+ type: 'object',
66
+ properties: {
67
+ form_name: {
68
+ type: 'string',
69
+ description: 'Target SmartForm name, Z* or Y* (e.g. "ZMY_FORM").',
70
+ },
71
+ xml_file: {
72
+ type: 'string',
73
+ description: 'Path of the Form Builder XML file (UTF-8).',
74
+ },
75
+ package_name: {
76
+ type: 'string',
77
+ description: 'Package. Default $TMP; any other package needs transport_request.',
78
+ },
79
+ transport_request: {
80
+ type: 'string',
81
+ description: 'Transport request the form is recorded in.',
82
+ },
83
+ overwrite: {
84
+ type: 'boolean',
85
+ description: 'Replace the form when it exists. Default false (an existing form is refused).',
86
+ },
87
+ activate: {
88
+ type: 'boolean',
89
+ description: 'Check and store active. Default true; false stores the form inactive without a check.',
90
+ },
91
+ },
92
+ required: ['form_name', 'xml_file'],
93
+ },
94
+ };
95
+ /**
96
+ * The XML as the dispatcher takes it: the OData backend carries the params in
97
+ * the URL (~8 KB), so the XML goes raw-deflate compressed (what CL_ABAP_GZIP
98
+ * reads) and base64-encoded, in parts the dispatcher joins on the last one.
99
+ */
100
+ function uploadParts(xml, partChars = UPLOAD_PART_CHARS) {
101
+ const b64 = zlib.deflateRawSync(xml).toString('base64');
102
+ const parts = [];
103
+ for (let i = 0; i < b64.length; i += partChars)
104
+ parts.push(b64.slice(i, i + partChars));
105
+ return parts.length ? parts : [''];
106
+ }
107
+ async function handleCreateSmartForm(context, args) {
108
+ const { connection, logger } = context;
109
+ try {
110
+ const formName = String(args?.form_name ?? '')
111
+ .trim()
112
+ .toUpperCase();
113
+ if (!/^[ZY]/.test(formName))
114
+ return (0, utils_1.return_error)(new Error('form_name must start with Z or Y'));
115
+ if (!args?.xml_file)
116
+ return (0, utils_1.return_error)(new Error('xml_file is required'));
117
+ const xml = fs.readFileSync(args.xml_file);
118
+ const devclass = (args.package_name ?? '').trim().toUpperCase() || '$TMP';
119
+ if (!devclass.startsWith('$') && !args.transport_request)
120
+ return (0, utils_1.return_error)(new Error(`package ${devclass} needs transport_request`));
121
+ logger?.info(`CreateSmartForm: ${formName} (${devclass})`);
122
+ const parts = uploadParts(xml);
123
+ const uploadId = crypto.randomBytes(6).toString('hex').toUpperCase();
124
+ let resp;
125
+ try {
126
+ for (let p = 0; p < parts.length; p++)
127
+ resp = await (0, rfcBackend_1.callDispatch)(connection, 'SSF_UPLOAD_XML', {
128
+ form_name: formName,
129
+ xml: parts[p],
130
+ gzip: 'X',
131
+ upload_id: uploadId,
132
+ part: p + 1,
133
+ parts: parts.length,
134
+ devclass,
135
+ transport: (args.transport_request ?? '').trim().toUpperCase(),
136
+ overwrite: args.overwrite ? 'X' : '',
137
+ activate: args.activate === false ? '-' : 'X',
138
+ });
139
+ }
140
+ catch (error) {
141
+ const msg = error instanceof Error ? error.message : String(error);
142
+ if (/Unknown action:\s*SSF_UPLOAD_XML/i.test(msg) ||
143
+ /ZMCP_SSF_UPLOAD[\s\S]*not found/i.test(msg))
144
+ throw new Error(`${exports.SSF_UPLOAD_INSTALL_HINT} (SAP said: ${msg})`);
145
+ throw error;
146
+ }
147
+ // callDispatch throws on subrc <> 0; a form stored inactive because the
148
+ // check failed comes back with subrc 0, active = false and the errors
149
+ const { result, message } = resp ?? {};
150
+ return (0, utils_1.return_response)({
151
+ data: JSON.stringify({
152
+ ...(typeof result === 'object' ? result : {}),
153
+ message: message || undefined,
154
+ }, null, 2),
155
+ });
156
+ }
157
+ catch (error) {
158
+ const errorMessage = error instanceof Error ? error.message : String(error);
159
+ logger?.error(`CreateSmartForm error: ${errorMessage}`);
160
+ return (0, utils_1.return_error)(new Error(errorMessage));
161
+ }
162
+ }
163
+ //# sourceMappingURL=handleCreateSmartForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleCreateSmartForm.js","sourceRoot":"","sources":["../../../../src/handlers/smartform/high/handleCreateSmartForm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEH,kCASC;AAWD,sDA+DC;AAnJD,oDAAsC;AACtC,4CAA8B;AAC9B,gDAAkC;AAElC,wDAAuD;AACvD,8CAI4B;AAEf,QAAA,uBAAuB,GAClC,+FAA+F;IAC/F,sFAAsF;IACtF,0EAA0E,CAAC;AAE7E,+EAA+E;AAC/E,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAElB,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAU;IAC3C,WAAW,EACT,mbAAmb;IACrb,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oDAAoD;aAClE;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,mEAAmE;aACtE;YACD,iBAAiB,EAAE;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,SAAS;gBACf,WAAW,EACT,+EAA+E;aAClF;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,SAAS;gBACf,WAA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AAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,IACE,mCAAmC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAC7C,kCAAkC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAE5C,MAAM,IAAI,KAAK,CAAC,GAAG,+BAAuB,eAAe,GAAG,GAAG,CAAC,CAAC;YACnE,MAAM,KAAK,CAAC;QACd,CAAC;QACD,wEAAwE;QACxE,sEAAsE;QACtE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QACvC,OAAO,IAAA,uBAAe,EAAC;YACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;gBACE,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7C,OAAO,EAAE,OAAO,IAAI,SAAS;aAC9B,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,0BAA0B,YAAY,EAAE,CAAC,CAAC;QACxD,OAAO,IAAA,oBAAY,EAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * DeleteSmartForm — delete a local Z/Y SmartForm (form, generated function
3
+ * module, TADIR entry). Dry run unless `confirm` is true.
4
+ *
5
+ * SAP side: ZMCP_ADT_DISPATCH action SSF_DELETE_FORM → FM ZMCP_SSF_DELETE.
6
+ * Only forms in a local package ($…) are deleted; a transportable form is
7
+ * refused (its deletion belongs on a transport — use SMARTFORMS).
8
+ * Companion ABAP source: sc4sap/abap/zmcp_ssf_delete.abap
9
+ */
10
+ import type { HandlerContext } from '../../../lib/handlers/interfaces';
11
+ export declare const SSF_DELETE_INSTALL_HINT: string;
12
+ export declare const TOOL_DEFINITION: {
13
+ readonly name: "DeleteSmartForm";
14
+ readonly available_in: readonly ["onprem", "legacy"];
15
+ readonly description: "[writes, destructive] Delete a Z/Y SmartForm of a local package ($TMP, $…) with its generated function module. Without confirm: true only reports what would be deleted (dry run). Transportable forms are refused. Needs the ZMCP_SSF_DELETE FM and the SSF_DELETE_FORM dispatcher action.";
16
+ readonly inputSchema: {
17
+ readonly type: "object";
18
+ readonly properties: {
19
+ readonly form_name: {
20
+ readonly type: "string";
21
+ readonly description: "SmartForm name, Z* or Y*.";
22
+ };
23
+ readonly confirm: {
24
+ readonly type: "boolean";
25
+ readonly description: "true = really delete. Default false (dry run).";
26
+ };
27
+ };
28
+ readonly required: readonly ["form_name"];
29
+ };
30
+ };
31
+ export declare function handleDeleteSmartForm(context: HandlerContext, args: {
32
+ form_name: string;
33
+ confirm?: boolean;
34
+ }): Promise<{
35
+ isError: boolean;
36
+ content: {
37
+ type: string;
38
+ text: any;
39
+ }[];
40
+ }>;
41
+ //# sourceMappingURL=handleDeleteSmartForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleDeleteSmartForm.d.ts","sourceRoot":"","sources":["../../../../src/handlers/smartform/high/handleDeleteSmartForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAQvE,eAAO,MAAM,uBAAuB,QAGwC,CAAC;AAE7E,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAmBlB,CAAC;AAEX,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;GA0C/C"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /**
3
+ * DeleteSmartForm — delete a local Z/Y SmartForm (form, generated function
4
+ * module, TADIR entry). Dry run unless `confirm` is true.
5
+ *
6
+ * SAP side: ZMCP_ADT_DISPATCH action SSF_DELETE_FORM → FM ZMCP_SSF_DELETE.
7
+ * Only forms in a local package ($…) are deleted; a transportable form is
8
+ * refused (its deletion belongs on a transport — use SMARTFORMS).
9
+ * Companion ABAP source: sc4sap/abap/zmcp_ssf_delete.abap
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TOOL_DEFINITION = exports.SSF_DELETE_INSTALL_HINT = void 0;
13
+ exports.handleDeleteSmartForm = handleDeleteSmartForm;
14
+ const rfcBackend_1 = require("../../../lib/rfcBackend");
15
+ const utils_1 = require("../../../lib/utils");
16
+ exports.SSF_DELETE_INSTALL_HINT = 'The SAP side of DeleteSmartForm is not installed on this system: it needs FM ZMCP_SSF_DELETE ' +
17
+ '(function group ZMCP_ADT_UTILS) and the SSF_DELETE_FORM branch in ZMCP_ADT_DISPATCH. ' +
18
+ 'Sources and install steps: sc4sap/abap/README.md (zmcp_ssf_delete.abap).';
19
+ exports.TOOL_DEFINITION = {
20
+ name: 'DeleteSmartForm',
21
+ available_in: ['onprem', 'legacy'],
22
+ description: '[writes, destructive] Delete a Z/Y SmartForm of a local package ($TMP, $…) with its generated function module. Without confirm: true only reports what would be deleted (dry run). Transportable forms are refused. Needs the ZMCP_SSF_DELETE FM and the SSF_DELETE_FORM dispatcher action.',
23
+ inputSchema: {
24
+ type: 'object',
25
+ properties: {
26
+ form_name: {
27
+ type: 'string',
28
+ description: 'SmartForm name, Z* or Y*.',
29
+ },
30
+ confirm: {
31
+ type: 'boolean',
32
+ description: 'true = really delete. Default false (dry run).',
33
+ },
34
+ },
35
+ required: ['form_name'],
36
+ },
37
+ };
38
+ async function handleDeleteSmartForm(context, args) {
39
+ const { connection, logger } = context;
40
+ try {
41
+ const formName = String(args?.form_name ?? '')
42
+ .trim()
43
+ .toUpperCase();
44
+ if (!/^[ZY]/.test(formName))
45
+ return (0, utils_1.return_error)(new Error('form_name must start with Z or Y'));
46
+ const confirm = args?.confirm === true;
47
+ logger?.info(`DeleteSmartForm: ${formName} (confirm=${confirm})`);
48
+ let resp;
49
+ try {
50
+ resp = await (0, rfcBackend_1.callDispatch)(connection, 'SSF_DELETE_FORM', {
51
+ form_name: formName,
52
+ confirm: confirm ? 'X' : '',
53
+ });
54
+ }
55
+ catch (error) {
56
+ const msg = error instanceof Error ? error.message : String(error);
57
+ if (/Unknown action:\s*SSF_DELETE_FORM/i.test(msg) ||
58
+ /ZMCP_SSF_DELETE[\s\S]*not found/i.test(msg))
59
+ throw new Error(`${exports.SSF_DELETE_INSTALL_HINT} (SAP said: ${msg})`);
60
+ throw error;
61
+ }
62
+ const { result, message } = resp ?? {};
63
+ return (0, utils_1.return_response)({
64
+ data: JSON.stringify({
65
+ ...(typeof result === 'object' ? result : {}),
66
+ message: message || undefined,
67
+ }, null, 2),
68
+ });
69
+ }
70
+ catch (error) {
71
+ const errorMessage = error instanceof Error ? error.message : String(error);
72
+ logger?.error(`DeleteSmartForm error: ${errorMessage}`);
73
+ return (0, utils_1.return_error)(new Error(errorMessage));
74
+ }
75
+ }
76
+ //# sourceMappingURL=handleDeleteSmartForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleDeleteSmartForm.js","sourceRoot":"","sources":["../../../../src/handlers/smartform/high/handleDeleteSmartForm.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAoCH,sDA4CC;AA7ED,wDAAuD;AACvD,8CAI4B;AAEf,QAAA,uBAAuB,GAClC,+FAA+F;IAC/F,uFAAuF;IACvF,0EAA0E,CAAC;AAEhE,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,YAAY,E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C,CAAC;YACnE,IACE,oCAAoC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAC9C,kCAAkC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAE5C,MAAM,IAAI,KAAK,CAAC,GAAG,+BAAuB,eAAe,GAAG,GAAG,CAAC,CAAC;YACnE,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QACvC,OAAO,IAAA,uBAAe,EAAC;YACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;gBACE,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7C,OAAO,EAAE,OAAO,IAAI,SAAS;aAC9B,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,0BAA0B,YAAY,EAAE,CAAC,CAAC;QACxD,OAAO,IAAA,oBAAY,EAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
@@ -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
@@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