@@ -65,13 +65,80 @@ export class AdkProgram extends AdkMainObject<typeof ProgramKind, ProgramXml> {
6565 }
6666
6767 // ============================================
68- // Static Factory Method
68+ // Static Factory Methods
6969 // ============================================
7070
7171 static async get ( name : string , ctx ?: AdkContext ) : Promise < AdkProgram > {
7272 const context = ctx ?? getGlobalContext ( ) ;
7373 return new AdkProgram ( context , name ) . load ( ) ;
7474 }
75+
76+ /**
77+ * Check if a program exists on SAP
78+ */
79+ static async exists ( name : string , ctx ?: AdkContext ) : Promise < boolean > {
80+ try {
81+ await AdkProgram . get ( name , ctx ) ;
82+ return true ;
83+ } catch {
84+ return false ;
85+ }
86+ }
87+
88+ /**
89+ * Create a new ABAP program on SAP
90+ *
91+ * @param name - Program name (e.g., 'ZMYPROGRAM')
92+ * @param description - Short description
93+ * @param packageName - Package to assign the program to
94+ * @param options - Save options (transport)
95+ * @param ctx - Optional ADK context
96+ */
97+ static async create (
98+ name : string ,
99+ description : string ,
100+ packageName : string ,
101+ options ?: { transport ?: string } ,
102+ ctx ?: AdkContext ,
103+ ) : Promise < AdkProgram > {
104+ const context = ctx ?? getGlobalContext ( ) ;
105+ const prog = new AdkProgram ( context , name . toUpperCase ( ) ) ;
106+ prog . setData ( {
107+ name : name . toUpperCase ( ) ,
108+ type : 'PROG/P' ,
109+ description,
110+ language : 'EN' ,
111+ masterLanguage : 'EN' ,
112+ packageRef : {
113+ name : packageName . toUpperCase ( ) ,
114+ uri : `/sap/bc/adt/packages/${ encodeURIComponent ( packageName . toUpperCase ( ) ) } ` ,
115+ type : 'DEVC/K' ,
116+ } ,
117+ } as unknown as ProgramXml ) ;
118+ await prog . save ( { transport : options ?. transport , mode : 'create' } ) ;
119+ return prog ;
120+ }
121+
122+ /**
123+ * Delete an ABAP program from SAP
124+ *
125+ * @param name - Program name
126+ * @param options - Delete options (transport)
127+ * @param ctx - Optional ADK context
128+ */
129+ static async delete (
130+ name : string ,
131+ options ?: { transport ?: string ; lockHandle ?: string } ,
132+ ctx ?: AdkContext ,
133+ ) : Promise < void > {
134+ const context = ctx ?? getGlobalContext ( ) ;
135+ const prog = new AdkProgram ( context , name . toUpperCase ( ) ) ;
136+ const contract = prog . crudContract ;
137+ await contract . delete ( name . toUpperCase ( ) , {
138+ corrNr : options ?. transport ,
139+ lockHandle : options ?. lockHandle ,
140+ } ) ;
141+ }
75142}
76143
77144// Self-register with ADK registry
0 commit comments