Skip to content

Commit

Permalink
Add format version to ABAP Object types (#258)
Browse files Browse the repository at this point in the history
* Add format version to ABAP Object types

* Indentation fixed

* Fix Dead Links

* Add Documentation

* Whitespaces

* Apply suggestions from code review; typos

* apply format version type instead of string

Co-authored-by: Albert Mink <[email protected]>
  • Loading branch information
wurzka and albertmink committed Nov 2, 2021
1 parent 09afe36 commit 304b73c
Show file tree
Hide file tree
Showing 61 changed files with 159 additions and 164 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Feel free to raise issues to ask questions or report bugs.

Comments and suggestions for improvements are most welcome.

You feel responsible for an ABAP object type? We will be more than happy if you contribute your object type to this project. Just open a new pull request and create a type like it is specified in [Specification](./docs/specification.md#Type-Specification). Feel free to hand over the type to us, so we can generate the JSON schema for you.
You feel responsible for an ABAP object type? We will be more than happy if you contribute your object type to this project. Just open a new pull request and create a type like it is specified [here](./docs/json.md#writing-JSON-schema-with-ABAP-types). Feel free to hand over the type to us, so we can generate the JSON schema for you.

More details are found at [Contributing](./CONTRIBUTING.md).

Expand Down
20 changes: 12 additions & 8 deletions docs/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For example, the JSON schema file for INTF for the first version is named `intf-
"formatVersion": {
"title": "ABAP File Format Version",
"description": "The ABAP file format version for INTF.",
"type": "string",
"const": "1"
}
```
Expand Down Expand Up @@ -54,14 +55,14 @@ The following changes to file formats are considered as incompatible:

## Writing JSON Schema with ABAP Types

Each JSON schema provided in this repository is automatically generated. For this purpose, an interface corresponds to each object type in which the necessary components of the type are described in the type `ty_main`. The name of the interface follows the pattern `zif_aff_<object_type>_v<version_number>`. `<object_type>` can be either the (R3TR) object type or the (LIMU) sub object type, since R3TR and LIMU object types share the same namespace. `<version_number>` is an increasing integer which starts with `1`.
Each JSON schema provided in this repository is automatically generated. For this purpose, an interface corresponds to each object type in which the necessary components of the type are described in the type `ty_main`. The name of the interface follows the pattern `zif_aff_<object_type>_v<version_number>`. Here, `<object_type>` can be either the (R3TR) object type or the (LIMU) sub object type, since R3TR and LIMU object types share the same namespace. `<version_number>` is an increasing integer which starts with `1`.

The ABAP types are self-contained, so it is possible to work on them in any system (e.g., in an SAP BTP, ABAP environment system).

The JSON schema is generated based on the fields and their ABAP type specification defined in `ty_main`. Each field defined in the structure is transformed to a JSON representation using a camel case notation (e.g, field `abap_language_version` is transformed to the field `abapLanguageVersion` in the JSON schema). The ABAP type information fills the JSON schema fields `type`, `length`, `minimum`, `maximum`.

Fields `format_version` and `header` are mandatory and translate to `formatVersion` and `header` in the JSON schema.
The interface [`zif_aff_types_v1`](../file-formats/zif_aff_types_v1.intf.abap) offers different headers for reuse, but also other often repeated types.
The interface [`zif_aff_types_v1`](../file-formats/zif_aff_types_v1.intf.abap) offers a type for the format version and different headers for reuse, but also other often repeated types.

In order to add more information to the JSON schema than that provided by the ABAP type, ABAP Doc can be used.
The comments are placed directly above the components of the type `ty_main`, but they are also read over several levels as, e.g., in the case of nested structures.
Expand Down Expand Up @@ -165,21 +166,23 @@ Here is the shortened type used to generate the JSON schema for interfaces. It c
"! <p class="shorttext">Interface Properties</p>
"! Interface properties
BEGIN OF ty_main,
"! <p class="shorttext">ABAP File Format Version</p>
"! The ABAP file format version for INTF
"! $required
format_version TYPE string,
format_version TYPE zif_aff_types_v1=>ty_format_version,
"! <p class="shorttext">Header</p>
"! Header
"! $required
header TYPE zif_aff_types_v1=>ty_header_60_src,
header TYPE zif_aff_types_v1=>ty_header_60_src,
"! <p class="shorttext">Proxy Interface</p>
"! Interface is a proxy interface
proxy TYPE abap_bool.
proxy TYPE abap_bool.
END OF ty_main.
```
With the specification of the component `header` and its used types in the interface [`zif_aff_types_v1`](../file-formats/zif_aff_types_v1.intf.abap)
With the specification of the component `format_version` and `header` as well as its used types in the interface [`zif_aff_types_v1`](../file-formats/zif_aff_types_v1.intf.abap)
```abap
"! <p class="shorttext">ABAP File Format Version</p>
"! The ABAP file format version
TYPES ty_format_version TYPE string.
"! $values {@link zif_aff_types_v1.data:co_abap_language_version_src}
"! $default {@link zif_aff_types_v1.data:co_abap_language_version_src.standard}
TYPES ty_abap_language_version_src TYPE c LENGTH 1.
Expand Down Expand Up @@ -234,6 +237,7 @@ This leads to the following generated JSON schema:
"formatVersion": {
"title": "ABAP File Format Version",
"description": "Format version",
"type": "string",
"const": "1"
},
"header": {
Expand Down
2 changes: 1 addition & 1 deletion file-formats/chkc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

File | Cardinality | Definition | Schema | Example
:--- | :--- | :--- | :--- | :---
`<name>.chkc.json` | 1 | [`zif_aff_chkc_v1.intf.abap`](./type/zif_aff_chkc_v1.intf.abap)| [`chkc.json`](./chkc.json) | [`z_aff_example_chkc.chkc.json`](./examples/z_aff_example_chkc.chkc.json)
`<name>.chkc.json` | 1 | [`zif_aff_chkc_v1.intf.abap`](./type/zif_aff_chkc_v1.intf.abap)| [`chkc-v1.json`](./chkc-v1.json) | [`z_aff_example_chkc.chkc.json`](./examples/z_aff_example_chkc.chkc.json)
13 changes: 7 additions & 6 deletions file-formats/chkc/chkc.json → file-formats/chkc/chkc-v1.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"$comment": "This file is autogenerated, do not edit manually, see https://github.com/SAP/abap-file-formats for more information.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chkc/chkc.json",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chkc/chkc-v1.json",
"title": "ATC Check Category",
"description": "ATC check category properties",
"type": "object",
"properties": {
"$schema": {
"title": "Schema",
"description": "Format version",
"type": "string"
"formatVersion": {
"title": "ABAP File Format Version",
"description": "The ABAP file format version",
"type": "string",
"const": "1"
},
"header": {
"title": "Header",
Expand Down Expand Up @@ -63,7 +64,7 @@
}
},
"required": [
"$schema",
"formatVersion",
"header"
]
}
2 changes: 1 addition & 1 deletion file-formats/chkc/examples/z_aff_example_chkc.chkc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chkc/chkc.json",
"formatVersion": "1",
"header": {
"description": "Example CHKC for ABAP file formats",
"originalLanguage": "EN"
Expand Down
4 changes: 1 addition & 3 deletions file-formats/chkc/type/zif_aff_chkc_v1.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ INTERFACE zif_aff_chkc_v1
"! <p class="shorttext">ATC Check Category</p>
"! ATC check category properties
BEGIN OF ty_main,
"! <p class="shorttext">Schema</p>
"! Format version
"! $required
schema TYPE string,
format_version TYPE zif_aff_types_v1=>ty_format_version,
"! <p class="shorttext">Header</p>
"! Header
"! $required
Expand Down
2 changes: 1 addition & 1 deletion file-formats/chkc/type/zif_aff_chkc_v1.intf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/intf/intf.json",
"formatVersion": "1",
"header": {
"description": "CHKC AFF Types",
"originalLanguage": "EN"
Expand Down
2 changes: 1 addition & 1 deletion file-formats/chko/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

File | Cardinality | Definition | Schema | Example
:--- | :--- | :--- | :--- | :---
`<name>.chko.json` | 1 | [`zif_aff_chko_v1.intf.abap`](./type/zif_aff_chko_v1.intf.abap) | [`chko.json`](./chko.json) | [`z_aff_example_chko.chko.json`](./examples/z_aff_example_chko.chko.json)
`<name>.chko.json` | 1 | [`zif_aff_chko_v1.intf.abap`](./type/zif_aff_chko_v1.intf.abap) | [`chko-v1.json`](./chko-v1.json) | [`z_aff_example_chko.chko.json`](./examples/z_aff_example_chko.chko.json)
13 changes: 7 additions & 6 deletions file-formats/chko/chko.json → file-formats/chko/chko-v1.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"$comment": "This file is autogenerated, do not edit manually, see https://github.com/SAP/abap-file-formats for more information.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chko/chko.json",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chko/chko-v1.json",
"title": "ATC Check",
"description": "ATC check object properties",
"type": "object",
"properties": {
"$schema": {
"title": "Schema",
"description": "Format version",
"type": "string"
"formatVersion": {
"title": "ABAP File Format Version",
"description": "The ABAP file format version",
"type": "string",
"const": "1"
},
"header": {
"title": "Header",
Expand Down Expand Up @@ -109,7 +110,7 @@
}
},
"required": [
"$schema",
"formatVersion",
"header",
"category",
"implementingClass"
Expand Down
2 changes: 1 addition & 1 deletion file-formats/chko/examples/z_aff_example_chko.chko.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chko/chko.json",
"formatVersion": "1",
"header": {
"description": "Example CHKO for ABAP file formats",
"originalLanguage": "EN"
Expand Down
6 changes: 2 additions & 4 deletions file-formats/chko/type/zif_aff_chko_v1.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ INTERFACE zif_aff_chko_v1
description TYPE c LENGTH 255,
"! <p class="shorttext">Hidden Flag</p>
"! The parameter is hidden
hidden TYPE abap_bool,
hidden TYPE abap_bool,
END OF ty_parameter.

TYPES:
Expand All @@ -29,10 +29,8 @@ INTERFACE zif_aff_chko_v1
"! <p class="shorttext">ATC Check</p>
"! ATC check object properties
BEGIN OF ty_main,
"! <p class="shorttext">Schema</p>
"! Format version
"! $required
schema TYPE string,
format_version TYPE zif_aff_types_v1=>ty_format_version,
"! <p class="shorttext">Header</p>
"! Header
"! $required
Expand Down
2 changes: 1 addition & 1 deletion file-formats/chko/type/zif_aff_chko_v1.intf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/intf/intf.json",
"formatVersion": "1",
"header": {
"description": "CHKO AFF Types",
"originalLanguage": "EN"
Expand Down
2 changes: 1 addition & 1 deletion file-formats/chkv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

File | Cardinality | Definition | Schema | Example
:--- | :--- | :--- | :--- | :---
`<name>.chkv.json` | 1 | [`zif_aff_chkv_v1.intf.abap`](./type/zif_aff_chkv_v1.intf.abap)| [`chkv.json`](./chkv.json) | [`z_aff_example_chkv.chkv.json`](./examples/z_aff_example_chkv.chkv.json)
`<name>.chkv.json` | 1 | [`zif_aff_chkv_v1.intf.abap`](./type/zif_aff_chkv_v1.intf.abap)| [`chkv-v1.json`](./chkv-v1.json) | [`z_aff_example_chkv.chkv.json`](./examples/z_aff_example_chkv.chkv.json)
13 changes: 7 additions & 6 deletions file-formats/chkv/chkv.json → file-formats/chkv/chkv-v1.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"$comment": "This file is autogenerated, do not edit manually, see https://github.com/SAP/abap-file-formats for more information.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chkv/chkv.json",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/chkv/chkv-v1.json",
"title": "ATC Check Variant Properties",
"description": "ATC check variant properties",
"type": "object",
"properties": {
"$schema": {
"title": "Schema",
"description": "Format version",
"type": "string"
"formatVersion": {
"title": "ABAP File Format Version",
"description": "The ABAP file format version",
"type": "string",
"const": "1"
},
"header": {
"title": "Header",
Expand Down Expand Up @@ -199,7 +200,7 @@
}
},
"required": [
"$schema",
"formatVersion",
"header"
]
}
2 changes: 1 addition & 1 deletion file-formats/chkv/examples/z_aff_example_chkv.chkv.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://github.com/SAP/abap-file-formats/file-formats/chkv/chkv.json",
"formatVersion": "1",
"header": {
"description": "Example CHKV for ABAP file formats",
"originalLanguage": "EN",
Expand Down
4 changes: 1 addition & 3 deletions file-formats/chkv/type/zif_aff_chkv_v1.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ INTERFACE zif_aff_chkv_v1
"! <p class="shorttext">ATC Check Variant Properties</p>
"! ATC check variant properties
BEGIN OF ty_main,
"! <p class="shorttext">Schema</p>
"! Format version
"! $required
schema TYPE string,
format_version TYPE zif_aff_types_v1=>ty_format_version,
"! <p class="shorttext">Header</p>
"! Header
"! $required
Expand Down
2 changes: 1 addition & 1 deletion file-formats/chkv/type/zif_aff_chkv_v1.intf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/intf/intf.json",
"formatVersion": "1",
"header": {
"description": "AFF: ATC check variant v1",
"originalLanguage": "EN"
Expand Down
2 changes: 1 addition & 1 deletion file-formats/clas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The files correspond to the tabs in ABAP Development Tools, enriched with metada

File | Cardinality | Definition | Schema | Example
:--- | :--- | :--- | :--- | :---
`<name>.clas.json` | 1 | [`zif_aff_clas_v1.intf.abap`](./type/zif_aff_clas_v1.intf.abap) | [`clas.json`](./clas.json) | [`z_aff_example_clas.clas.json`](./examples/z_aff_example_clas.clas.json)
`<name>.clas.json` | 1 | [`zif_aff_clas_v1.intf.abap`](./type/zif_aff_clas_v1.intf.abap) | [`clas-v1.json`](./clas-v1.json) | [`z_aff_example_clas.clas.json`](./examples/z_aff_example_clas.clas.json)
`<name>.clas.abap` | 1 | [ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclass.htm) | - | [`z_aff_example_clas.clas.abap`](./examples/z_aff_example_clas.clas.abap)
`<name>.clas.definitions.abap` | 0...1 | | - | [`z_aff_example_clas.clas.definitions.abap`](./examples/z_aff_example_clas.clas.definitions.abap)
`<name>.clas.implementations.abap` | 0...1 | | - | [`z_aff_example_clas.clas.implementations.abap`](./examples/z_aff_example_clas.clas.implementations.abap)
Expand Down
13 changes: 7 additions & 6 deletions file-formats/clas/clas.json → file-formats/clas/clas-v1.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"$comment": "This file is autogenerated, do not edit manually, see https://github.com/SAP/abap-file-formats for more information.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/clas/clas.json",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/clas/clas-v1.json",
"title": "Class Properties",
"description": "Class properties",
"type": "object",
"properties": {
"$schema": {
"title": "Schema",
"description": "Format version",
"type": "string"
"formatVersion": {
"title": "ABAP File Format Version",
"description": "The ABAP file format version",
"type": "string",
"const": "1"
},
"header": {
"title": "Header",
Expand Down Expand Up @@ -331,7 +332,7 @@
}
},
"required": [
"$schema",
"formatVersion",
"header"
]
}
2 changes: 1 addition & 1 deletion file-formats/clas/examples/z_aff_example_clas.clas.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/clas/clas.json",
"formatVersion": "1",
"header": {
"description": "Example class for ABAP file formats",
"originalLanguage": "EN"
Expand Down
4 changes: 1 addition & 3 deletions file-formats/clas/type/zif_aff_clas_v1.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ INTERFACE zif_aff_clas_v1 PUBLIC.
"! <p class="shorttext">Class Properties</p>
"! Class properties
BEGIN OF ty_main,
"! <p class="shorttext">Schema</p>
"! Format version
"! $required
schema TYPE string,
format_version TYPE zif_aff_types_v1=>ty_format_version,
"! <p class="shorttext">Header</p>
"! header
"! $required
Expand Down
2 changes: 1 addition & 1 deletion file-formats/clas/type/zif_aff_clas_v1.intf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/intf/intf.json",
"formatVersion": "1",
"header": {
"description": "AFF: Interface v1",
"originalLanguage": "EN"
Expand Down
2 changes: 1 addition & 1 deletion file-formats/ddls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

File | Cardinality | Definition | Schema | Example
:--- | :--- | :--- | :--- | :---
`<name>.ddls.json` | 1 | [`zif_aff_ddls_v1.intf.abap`](./type/zif_aff_ddls_v1.intf.abap) | [`ddls.json`](./ddls.json) | [`z_aff_example_ddls.ddls.json`](./examples/z_aff_example_ddls.ddls.json)
`<name>.ddls.json` | 1 | [`zif_aff_ddls_v1.intf.abap`](./type/zif_aff_ddls_v1.intf.abap) | [`ddls-v1.json`](./ddls-v1.json) | [`z_aff_example_ddls.ddls.json`](./examples/z_aff_example_ddls.ddls.json)
`<name>.ddls.cds` | 1 | [CDS](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds.htm) | | [`z_aff_example_ddls.ddls.cds`](./examples/z_aff_example_ddls.ddls.cds)
`<name>.ddls.objectdependencies.json` | 1 | | | [`z_aff_example_ddls.ddls.objectdependencies.json`](./examples/z_aff_example_ddls.ddls.objectdependencies.json)
13 changes: 7 additions & 6 deletions file-formats/ddls/ddls.json → file-formats/ddls/ddls-v1.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"$comment": "This file is autogenerated, do not edit manually, see https://github.com/SAP/abap-file-formats for more information.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/ddls/ddls.json",
"$id": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/ddls/ddls-v1.json",
"title": "Object Type DDLS",
"description": "DDLS object type",
"type": "object",
"properties": {
"$schema": {
"title": "Schema",
"description": "Format version",
"type": "string"
"formatVersion": {
"title": "ABAP File Format Version",
"description": "The ABAP file format version",
"type": "string",
"const": "1"
},
"header": {
"title": "Header",
Expand Down Expand Up @@ -145,7 +146,7 @@
}
},
"required": [
"$schema",
"formatVersion",
"header",
"sourceOrigin",
"sourceType"
Expand Down
2 changes: 1 addition & 1 deletion file-formats/ddls/examples/z_aff_example_ddls.ddls.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://github.com/SAP/abap-file-formats/blob/main/file-formats/ddls/ddls.json",
"formatVersion": "1",
"header": {
"description": "Example DDLs for ABAP file formats",
"originalLanguage": "EN"
Expand Down
Loading

0 comments on commit 304b73c

Please sign in to comment.