Write ABAP Source
sap_write_sourceReplace existing ABAP source code for programs, classes, or function modules with full stateful locking and ETag conflict detection. Optionally activate the object after writing to apply changes immediately.
Instructions
Replace the source code of an EXISTING program, include, class, interface, or function module. This MODIFIES the SAP system.
The tool runs the full stateful flow: lock -> write source -> (optionally activate) -> unlock. It captures the current ETag to avoid overwriting concurrent changes.
Args:
object_type ('program'|'include'|'class'|'interface'|'function').
object_name (string): must already exist (this tool does not create objects).
function_group (string): required for functions.
source (string): the complete replacement source.
transport (string): required for non-local objects; get one from sap_list_transports.
activate (boolean, default false): activate after writing.
response_format ('markdown' | 'json').
Returns (json): { objectType, objectName, sourceUri, bytesWritten, transport?, activated, activationMessages: [{type,text}], message }.
Examples:
"Update class CL_FOO and activate" -> object_type='class', object_name='CL_FOO', source='...', transport='DEVK900123', activate=true. Error Handling:
423 -> object locked by someone else. 412 -> ETag changed (re-read first).
Missing transport on a transportable object -> returns an actionable error; the lock is released automatically.
Activation errors are returned in activationMessages (the source is still written but inactive).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | The full new source code to write (replaces existing source). | |
| activate | No | If true, activate the object after writing. If false, it stays inactive. | |
| transport | No | Transport request (e.g. 'DEVK900123'). Required for transportable (non-local) objects. | |
| object_name | Yes | Object name. The object must already exist. | |
| object_type | Yes | Object kind to write. | |
| function_group | No | Required when object_type='function'. | |
| response_format | No | Output format: 'markdown' (human-readable, default) or 'json' (structured). | markdown |