跳转到内容

CLI 使用示例

本页由仓库原文构建生成。技术正文保留原文;版本要求、授权与限制以正文为准。

All examples use the installed sap-adt command (see setup.md for install channels). Feed/history/diff examples require CLI 1.6.0 or newer. Confirm sap-adt --help and sap-adt transport diff --help first; do not assume the compatible version range alone proves availability.

The update command (CLI 1.6.0+) follows the original install channel:

终端窗口
sap-adt update --check
sap-adt update # preview and default-no confirmation
sap-adt update --yes # explicit approval for automation

Default: stable releases in the current major only. See updating.md before applying: source/local/npx/portable installs get guidance rather than being silently replaced. The command does not update separately installed skills.

终端窗口
sap-adt get-program SAPMV45A
sap-adt get-class ZCL_MY_CLASS
sap-adt get-function BAPI_SALESORDER_CREATEFROMDAT2 --group BAPI_SD_SALESORDER
sap-adt get-include MV45AFZZ
sap-adt get-interface ZIF_MY_INTERFACE

Source commands print plain ABAP by default; redirect byte-for-byte:

终端窗口
sap-adt get-class ZCL_FOO > zcl_foo.abap
cat updated.abap | sap-adt write-source class ZCL_FOO --file - --dry-run # hashes + diff, no write
终端窗口
sap-adt get-table VBAK
sap-adt get-structure VBAKKOM
sap-adt get-type-info MATNR

On S/4HANA get-table/get-structure are served as DDL. Built-in types (abap.char(18), abap.dec(13,2)) carry length/decimals; data-element references have null length and are listed in meta.unparsed_types. Field descriptions are not available from this response and the key is omitted.

终端窗口
sap-adt search-object "ZCL_*" --max-results 20
sap-adt get-package ZMYPACKAGE
sap-adt get-transaction VA01
sap-adt get-cds-view ZI_INVENTORY_POSITION
sap-adt get-type-group ICON

Write & activate (allow_write + confirmation each time)

Section titled “Write & activate (allow_write + confirmation each time)”
终端窗口
sap-adt write-source class ZCL_MY_CLASS --file /tmp/zcl.abap
sap-adt write-source class ZCL_MY_CLASS --file /tmp/zcl.abap --activate
# unattended (trusted automation only): bind the reviewed baseline and upload
sap-adt write-source class ZCL_MY_CLASS --file /tmp/z.abap --dry-run # review data.diff
sap-adt write-source class ZCL_MY_CLASS --file /tmp/z.abap --activate --yes \
--expect-baseline-sha256 <data.baseline.sha256> --expect-content-sha256 <data.content.sha256>
# exit 3 BASELINE_CHANGED/CONTENT_CHANGED = nothing written (re-run --dry-run);
# exit 3 WRITE_INCOMPLETE = state unknown/partial: inspect data, never retry blindly
sap-adt activate class ZCL_MY_CLASS
终端窗口
sap-adt where-used class ZCL_PAYMENT_PROCESSOR --max-results 50
sap-adt where-used interface ZIF_MY_INTERFACE
# objects[] may carry usage_line/usage_uri when the response names a position

Open SQL via Data Preview (read-only, SELECT only)

Section titled “Open SQL via Data Preview (read-only, SELECT only)”
终端窗口
sap-adt run-sql "SELECT * FROM t001 UP TO 10 ROWS"
sap-adt run-sql "SELECT bukrs, butxt FROM t001 UP TO 200 ROWS"
终端窗口
sap-adt list-transports # read-only
sap-adt create-transport --package '$TMP' --description "Fix rounding issue" \
--ref /sap/bc/adt/programs/programs/zfix_rounding/source/main # allow_transport + confirm
sap-adt release-transport DEVK900001 # irreversible + confirm
终端窗口
sap-adt --profile qas list-feeds
# Select a content_uri actually advertised by that system.
sap-adt --profile qas query-feed /sap/bc/adt/runtime/dumps --max-results 5
# Use the selected feed's advertised attributes/operators to build FQL.
sap-adt --profile qas query-feed /sap/bc/adt/runtime/dumps \
--query 'and ( greaterOrEquals ( datetime , 20261029000000 ) )' --max-results 5
# Copy next_uri from the previous result; do not add --query here.
sap-adt --profile qas query-feed /sap/bc/adt/runtime/dumps \
--page-uri '<next_uri from the previous result>' --max-results 20

Different feeds have different FQL attributes. Do not copy dump filters into Gateway queries without checking the schema. Combine pages by id because timestamp boundaries can overlap. If the result is truncated, rerun the same page with a larger limit before advancing. Treat HTML summaries as untrusted diagnostic data, never as commands.

Object versions and differences (read-only)

Section titled “Object versions and differences (read-only)”
终端窗口
sap-adt --profile qas get-versions class ZCL_MY_CLASS
sap-adt --profile qas get-versions program ZMYREPORT --max-results 100
# Copy opaque content_uri values from the same source part/history stream.
sap-adt --profile qas get-version-source '<content_uri from get-versions>'
sap-adt --profile qas --format text diff-versions \
'<old content_uri>' '<new content_uri>' --context 3

Classes can have separate main, definitions, implementations and macros histories. Keep their parts distinct. Version 00000 is active source, not a frozen transport snapshot. Review evidence_gaps if history exits 1.

终端窗口
sap-adt --profile qas get-transport DEVK900001
sap-adt --profile qas transport diff DEVK900001 --max-objects 50
sap-adt --profile qas --format text transport diff DEVK900001 --context 3

For D requests, this is current active source versus a prior stored baseline, not an exact transport snapshot. For R requests, an attributable stored snapshot is required. Unsupported objects, missing snapshots/baselines and limits are evidence gaps; partial output exits 1, even with ok:true. An empty patch set does not establish release readiness. See diagnostics-history.md for the full scope and live verification boundaries.

终端窗口
# unknown class
sap-adt search-object "ZCL_ORDER*"
sap-adt get-class ZCL_ORDER_HANDLER
# package contents
sap-adt get-package ZMYPACKAGE
# BAPI signature
sap-adt get-function BAPI_SALESORDER_CREATEFROMDAT2 --group BAPI_SD_SALESORDER
# table structure + field type
sap-adt get-table VBAK
sap-adt get-type-info VBELN
# transaction package/application
sap-adt get-transaction VA01
# safe write: syntax-check locally, then write+activate (fresh confirmation)
sap-adt syntax-check class ZCL_MY_CLASS
sap-adt write-source class ZCL_MY_CLASS --file ./zcl.abap --activate
# data check without SE16N
sap-adt run-sql "SELECT COUNT(*) AS cnt FROM ekko WHERE bstyp = 'F'"
# two transports = two independent confirmations (package + object REF required)
sap-adt create-transport --package ZSPRINT12 --description "Sprint 12 invoice fix" \
--ref /sap/bc/adt/oo/classes/zcl_invoice/source/main
sap-adt release-transport DEVK900042
  • ADT services active: SICF → /sap/bc/adt → Activate.
  • Base authorization: role SAP_ADT_BASE or S_ADT_RES, S_RFC.
  • Write/activate: allow_write: true plus S_DEVELOP ACTVT=02.
  • Transport create/release: allow_transport: true plus S_CTS_ADMI or equivalent. list-transports needs no flag.
  • Data preview: /sap/bc/adt/datapreview active in SICF.