Converts between standalone SQLScript procedures and AMDP class implementations
Converts SQLScript procedures between standalone, AMDP class, and CDS function formats.
/plugin marketplace add secondsky/sap-skills/plugin install sap-sqlscript@sap-skillsConvert SQLScript code between different formats: standalone procedures to AMDP, AMDP to standalone, and CDS integration patterns.
/sqlscript-convert [file_path] --to amdp
/sqlscript-convert [file_path] --to standalone
/sqlscript-convert [file_path] --to cds-function
--to amdp)Converts a standalone SQLScript procedure or function into an AMDP class with proper:
--to standalone)Extracts SQLScript from an AMDP method into a standalone procedure with:
--to cds-function)Converts an AMDP table function for CDS view consumption with:
Analyze source code:
Generate target code:
Validate result:
## SQLScript Conversion Result
**Source**: [original file]
**Source Type**: [Standalone Procedure/AMDP/Table Function]
**Target Type**: [AMDP/Standalone/CDS Function]
### Type Mappings Used
| Original | Converted | Notes |
|----------|-----------|-------|
| INTEGER | i | ABAP integer |
| NVARCHAR(100) | string | ABAP string |
...
### Tables Referenced
- [table1] - Added to USING clause
- [table2] - Added to USING clause
### Generated Code
#### [Class Definition / Procedure Header]
```abap/sql
[code]
[code]
[How to call the converted code]
## Examples
### Convert Procedure to AMDP
/sqlscript-convert src/procedures/calc_totals.sql --to amdp
### Convert AMDP to Standalone
/sqlscript-convert src/classes/zcl_orders.abap --to standalone
### Convert to CDS Function
/sqlscript-convert src/procedures/get_data.sql --to cds-function
## Type Mapping Reference
### SQLScript to ABAP (for --to amdp)
| SQLScript | ABAP Type | Notes |
|-----------|-----------|-------|
| INTEGER | i | Standard integer |
| BIGINT | int8 | 8-byte integer |
| DECIMAL(p,s) | p LENGTH p DECIMALS s | Packed number |
| DOUBLE | f | Floating point |
| NVARCHAR(n) | c LENGTH n or string | Character |
| DATE | d | Date (YYYYMMDD) |
| TIME | t | Time (HHMMSS) |
| TIMESTAMP | utclong | UTC timestamp |
### ABAP to SQLScript (for --to standalone)
| ABAP Type | SQLScript | Notes |
|-----------|-----------|-------|
| i | INTEGER | Standard integer |
| int8 | BIGINT | 8-byte integer |
| p | DECIMAL | Preserve precision |
| f | DOUBLE | Floating point |
| c, string | NVARCHAR | Use appropriate length |
| d | DATE | Convert from YYYYMMDD |
| t | TIME | Convert from HHMMSS |
| utclong | TIMESTAMP | UTC timestamp |
## Conversion Templates
### Standalone to AMDP Template
**Source (Standalone)**:
```sql
CREATE PROCEDURE "SCHEMA"."GET_ORDERS"(
IN iv_customer_id INTEGER,
OUT et_orders TABLE (id INTEGER, amount DECIMAL(15,2))
)
LANGUAGE SQLSCRIPT
AS
BEGIN
et_orders = SELECT id, amount FROM orders WHERE customer_id = :iv_customer_id;
END;
Target (AMDP):
CLASS zcl_orders DEFINITION PUBLIC FINAL.
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
TYPES: BEGIN OF ty_order,
id TYPE i,
amount TYPE p LENGTH 15 DECIMALS 2,
END OF ty_order,
tt_orders TYPE STANDARD TABLE OF ty_order.
CLASS-METHODS get_orders
IMPORTING VALUE(iv_customer_id) TYPE i
EXPORTING VALUE(et_orders) TYPE tt_orders.
ENDCLASS.
CLASS zcl_orders IMPLEMENTATION.
METHOD get_orders BY DATABASE PROCEDURE
FOR HDB LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING orders.
et_orders = SELECT id, amount
FROM orders
WHERE customer_id = :iv_customer_id;
ENDMETHOD.
ENDCLASS.
When this command is invoked:
Parse source file:
Map types:
Generate target structure:
Identify tables:
Present result:
Optionally save: