新增能力: - remote-enable 子命令:设置函数模块处理类型为远程启用(bgRFC/RFC 执行体必需)。 实现要点均按实机验证:PUT fmodule:processingType="rfc"(枚举值仅小写 rfc 有效, remoteEnabled/remote/RFC 等均 400);lockHandle 走 query 参数(放 header 报 ParameterNotFound);PUT 后 GET 复核回显;DDIC 结构参数才可远程启用(类本地类型 报"针对 RFC 不允许使用类或接口的类型")。 - create --type functiongroup 透传 --package / --corr_nr(此前 package 被静默写成 $TMP, 导致函数组无法归目标包)。 修复: - activate 请求体补重复引用:ADT CLAS 激活端点对 objectReferences 只有 1 个引用时 返回 HTTP 200 + 空 body 且不执行激活;引用数 ≥2 才真正激活(同对象重复亦可)。 - scanner 剥离 ADT 文件后缀(xxx.clas.abap 解析错误)。 守卫测试: - tests/unit/test_bgrfc_support.py(17 例):函数组 package 透传、processingType 助手、 remote-enable 命令(含 lockHandle 走 query/小写 rfc/错误透传/复核失配判失败)、 函数 URI 组装不得用组名冒充模块名。 - test_activate.py 增加激活请求体引用数守卫;test_repo_guards.py 增加后缀剥离守卫。 测试:tests/unit 676 + tests/test_sapcli.py 69 = 745 全绿 (PYTHONPATH=assets python -m unittest discover -s tests/unit -t tests)
56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
"""remote-enable 命令 — 远程启用函数模块(bgRFC/RFC 执行体)。
|
||
|
||
背景:bgRFC 的执行体必须是远程启用的函数模块(processingType=rfc)。
|
||
本命令封装 ADT 的 GET→改 processingType=rfc→PUT→GET 复核闭环,
|
||
不负责激活、也不负责 TFDIR.FMODE='R' 的最终确认(后者留给调用方 read-table)。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import argparse
|
||
import logging
|
||
|
||
from sapcli.client import ADTClient
|
||
from sapcli.exceptions import InvalidNameError, SapCliError
|
||
|
||
logger = logging.getLogger("sapcli.commands.remote_enable")
|
||
|
||
|
||
def cmd_remote_enable(args: argparse.Namespace, client: ADTClient) -> None:
|
||
"""远程启用函数模块。"""
|
||
name: str = args.name
|
||
corr_nr: str | None = getattr(args, "corr_nr", None)
|
||
|
||
if "/" not in name:
|
||
print(" ✗ remote-enable 需要'函数组/函数模块'格式,例如: ZGROUP/Z_FUNC")
|
||
raise InvalidNameError(
|
||
"remote-enable 需要'函数组/函数模块'格式,例如: ZGROUP/Z_FUNC"
|
||
)
|
||
group, fm = name.split("/", 1)
|
||
group = group.strip()
|
||
fm = fm.strip()
|
||
if not group or not fm:
|
||
print(" ✗ 函数组名和函数模块名不能为空")
|
||
raise InvalidNameError("函数组名和函数模块名不能为空")
|
||
|
||
print("=" * 60)
|
||
print(" SAP ADT 函数模块远程启用(bgRFC/RFC)")
|
||
print("=" * 60)
|
||
print(f" 函数组: {group}")
|
||
print(f" 函数模块: {fm}")
|
||
if corr_nr:
|
||
print(f" 传输请求: {corr_nr}")
|
||
|
||
print("\n → 正在远程启用(processingType=rfc)...")
|
||
ok, msg = client.set_function_remote_enabled(group, fm, corr_nr)
|
||
if not ok:
|
||
print(f" ✗ {msg}")
|
||
raise SapCliError(msg)
|
||
|
||
print(" ✓ 远程启用成功")
|
||
print(" ✓ 复核回显 processingType=rfc")
|
||
print()
|
||
print(" 注意:")
|
||
print(" - 参数类型只允许 DDIC 对象;类本地类型会 500「针对 RFC 不允许使用类或接口的类型」")
|
||
print(" - TFDIR.FMODE='R' 的最终确认请用 read-table 复核(见 SKILL.md)")
|
||
print(" - 此命令只改属性不激活;如需激活再执行 activate")
|