Skip to content

feat(adt): add INCL (PROG/I) write support for WriteSource, EditSource, CLI#121

Draft
frd1201 wants to merge 2 commits into
oisee:mainfrom
frd1201:feat/incl-write-support
Draft

feat(adt): add INCL (PROG/I) write support for WriteSource, EditSource, CLI#121
frd1201 wants to merge 2 commits into
oisee:mainfrom
frd1201:feat/incl-write-support

Conversation

@frd1201
Copy link
Copy Markdown

@frd1201 frd1201 commented Apr 23, 2026

Closes #116

Summary

  • New WriteInclude() workflow — full SyntaxCheck → Lock → UpdateSource → Unlock → Activate cycle for ABAP program includes
  • WriteSource / EditSource now accept object_type="INCL" (MCP tools and CLI vsp source write/edit)
  • vsp source edit INCL — CLI surgical string replacement for includes
  • DeployFromFile / ImportFromFile.incl.abap file extension recognized; object name extracted from filename (includes have no declaration statement)
  • Three bug fixes for the shared /includes/ URL segment that caused program includes to be misidentified as class sub-resources:
    • normalizeObjectURLForPackageCheck: was stripping /includes/NAME from program include URLs → SearchObject("PROGRAMS") → "package metadata not found"
    • SyntaxCheck artifactURI: was missing /source/main for program includes → SAP returned wrong content-type
    • EditSourceWithOptions isClassInclude: was missing /source/main in sourceURL → GET/PUT to XML object descriptor endpoint → HTTP 406
  • SyntaxCheck moved before Lock in UpdateFromFile — stateless SyntaxCheck between stateful Lock/Write broke the SAP session (HTTP 423 ExceptionResourceInvalidLockHandle)

Test plan

  • GetSource(object_type="INCL", name="ZZ_FABD1_DUSH8_CICD2") — read works
  • WriteSource(object_type="INCL", name="ZZ_FABD1_DUSH8_CICD2", source="...", mode="upsert") — create and update works
  • EditSource(object_url="/sap/bc/adt/programs/includes/ZZ_FABD1_DUSH8_CICD2", old_string="...", new_string="...") — surgical edit works
  • vsp source read INCL ZZ_FABD1_DUSH8_CICD2 — CLI read works
  • vsp source write INCL ZZ_FABD1_DUSH8_CICD2 < file.abap — CLI write works
  • vsp source edit INCL ZZ_FABD1_DUSH8_CICD2 --old "..." --new "..." — CLI edit works
  • ImportFromFile(file_path="zz_test.incl.abap") — deploy from file works (Updated PROG/I ZZ_FABD1_DUSH8_CICD2, activated)

@frd1201 frd1201 marked this pull request as draft April 23, 2026 20:31
frd1201 and others added 2 commits April 23, 2026 22:32
…e, CLI

Closes oisee#116. ABAP program includes were read-only — GetSource worked but
WriteSource, EditSource, and CLI `source edit/write` rejected object_type=INCL.

Core feature:
- pkg/adt/workflows.go: new WriteInclude() — SyntaxCheck→Lock→UpdateSource→Unlock→Activate
- pkg/adt/workflows_source.go: INCL in whitelist, existence check, create/update routing
- pkg/adt/fileparser.go: .incl.abap extension → ObjectTypeInclude
- internal/mcp/handlers_source.go: INCL in routeSourceAction, WriteSource/ImportFromFile/ExportToFile descriptions
- cmd/vsp/devops.go: INCL in buildObjectURL() + CLI source edit/test/atc commands

Bug fixes (program includes share /includes/ URL segment with class includes,
causing three functions to misidentify them as class sub-resources):
- pkg/adt/client.go: normalizeObjectURLForPackageCheck — don't strip /includes/NAME
  when prefix ends with /programs (was returning /sap/bc/adt/programs → SearchObject("PROGRAMS") → "package metadata not found")
- pkg/adt/devtools.go: SyntaxCheck artifactURI — append /source/main for program includes
  (was sending object descriptor URL → SAP returned wrong content-type)
- pkg/adt/workflows_edit.go: EditSourceWithOptions isClassInclude — require /oo/classes/ in URL
  (was setting sourceURL without /source/main → GET/PUT to XML endpoint → HTTP 406)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two bugs in INCL deploy flow (ImportFromFile / vsp deploy):

1. fileparser.go: .incl.abap files have no declaration statement, so
   the name must be extracted from the filename (same pattern as class
   includes). Without this, ParseABAPFile failed with "could not parse
   object name from file".

2. workflows_deploy.go: SyntaxCheck is stateless and was running after
   Lock (stateful), which broke the SAP session and caused HTTP 423
   ExceptionResourceInvalidLockHandle. Moved SyntaxCheck to before Lock
   so the stateful session is established cleanly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@frd1201 frd1201 force-pushed the feat/incl-write-support branch from c7890ea to 8f6c030 Compare April 23, 2026 20:32
frd1201 added a commit to frd1201/vibing-steampunk that referenced this pull request Apr 23, 2026
Merges PR oisee#121 (pending upstream) into fork/main so the fix is available
locally. Will be removed from fork/main once upstream merges the PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WriteSource in the SAP MCP servers does not currently support ABAP include objects (INCL)

1 participant