Skip to content

Commit ef4c32d

Browse files
authored
Add details about file formats and naming (#218)
1 parent 0bb487b commit ef4c32d

File tree

3 files changed

+70
-8
lines changed

3 files changed

+70
-8
lines changed

src/development-guide/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Development related information
2222
- [Overview](serializers/overview.md)
2323
- [Serializer Class](serializers/serializers.md)
2424
- [New Serializers](serializers/task-list.md)
25-
- [File Formats](serializers/file-formats.md)
25+
- [File Naming and Formats](serializers/file-formats.md)
2626

2727
### Testing
2828

src/development-guide/serializers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ dir:
1212
- [Overview](overview.md)
1313
- [Serializer Class](serializers.md)
1414
- [New Serializers](task-list.md)
15-
- [File Formats](file-formats.md)
15+
- [File Naming and Formats](file-formats.md)
Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,91 @@
11
---
2-
title: File Formats
2+
title: File Naming and Formats
33
category: serializers
44
order: 40
55
---
66

7-
All files for an object are located in the same folder, each folder corresponds to a package. Sub-packages are organized under parent packages(directories) according to the logic described in the [Repository Settings](/user-guide/repo-settings/dot-abapgit.md)
7+
All files for an object are located in the same folder, each folder corresponds to a package. Sub-packages are organized under parent packages (directories) according to the logic described in the [Repository Settings](/user-guide/repo-settings/dot-abapgit.md).
88

9-
## CLAS
9+
## Naming
1010

11-
Files corresponding to the editable parts in source-based class builder or ABAP in Eclipse:
11+
In general, the names of files containing the object definitions are derived from the TADIR entry i.e. object type and object name. Filenames are lower case and adhere to the following patterns:
12+
13+
- `<object_name>.<object_type>.<extension>`: Object metadata. Supported extensions: `xml` or `json`
14+
- `<object_name>.<object_type>.<extra>.<extension>`: Additional object data. Typical extensions: `abap`, `html`, `js`, etc.
15+
- `<object_name>.<object_type>.i18n.<language>.<extension>`: Language-specific translation files: Supported extensions: `po` or `properties`
16+
17+
## Codepage, EOL, EOF, Indentation
18+
19+
Metadata, ABAP coding, and translation files are stored in `UFT-8` with leading [Byte-order-mark (xEF BB BF)](https://en.wikipedia.org/wiki/Byte_order_mark), linefeed (x0A) as end-of-line character and a final newline character. Indentation is set to 2 and uses spaces, not tabs. See [.editorconfig](https://github.com/abapGit/abapGit/blob/main/.editorconfig) for details.
20+
21+
## Formats
22+
23+
### Classic abapGit Format
24+
25+
Each object is represented by at least one XML file, which contains the object metadata. Depending on the object type, other files may be added like a file with `abap` extension for source code.
26+
27+
The XML file contains a root `<abapGit>` tag which specifies the [serializer class](overview.html) and version used by abapGit to convert the object to files and vice versa (see example below).
28+
29+
Translations are either included in the XML file or stored in a separate `i18n.<language>.po` file.
30+
31+
#### Example
32+
33+
Here's an example for an ABAP OO Class, object type `CLAS` (See also [test repo](https://github.com/abapGit-tests/CLAS_full)).
34+
35+
The following files correspond to the editable parts in source-based class builder or ABAP in Eclipse:
1236

1337
* `zcl_example.clas.abap`
1438
* `zcl_example.clas.locals_def.abap`
1539
* `zcl_example.clas.locals_imp.abap`
1640
* `zcl_example.clas.testclasses.abap`
1741
* `zcl_example.clas.macros.abap`
1842

19-
Files do not exist if empty, ie. the developer did not choose to implement it
43+
Files do not exist if empty, i.e. the developer did not choose to implement them.
2044

2145
One XML file `zcl_example.clas.xml` containing:
2246

47+
```xml
48+
*<?xml version="1.0" encoding="utf-8"?>
49+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
50+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
51+
<asx:values>
52+
<VSEOCLASS>
53+
<CLSNAME>ZCL_ABAPGIT_FACTORY</CLSNAME>
54+
<LANGU>E</LANGU>
55+
<DESCRIPT>abapGit - Factory</DESCRIPT>
56+
<STATE>1</STATE>
57+
<CLSCCINCL>X</CLSCCINCL>
58+
<FIXPT>X</FIXPT>
59+
<UNICODE>X</UNICODE>
60+
</VSEOCLASS>
61+
</asx:values>
62+
</asx:abap>
63+
</abapGit>
64+
65+
*:
66+
```
67+
68+
Example XML data:
69+
2370
* VSEOCLASS information
2471
* TPOOL information
2572
* SOTR information
2673
* LINES from DOKU
2774
* Descriptions from SEOCOMPOTX
2875

29-
See example [https://github.com/abapGit-tests/CLAS_full](https://github.com/abapGit-tests/CLAS_full)
76+
### SAP ABAP File Format
77+
78+
Newer object types are represented by a JSON file and follow the [ABAP File Format (AFF)](https://github.com/SAP/abap-file-formats).
79+
80+
Object types supporting AFF are registered [here](https://github.com/abapGit/abapGit/blob/main/src/objects/aff/zcl_abapgit_aff_registry.clas.abap#L48).
81+
82+
Translations are stored in separate `i18n.<language>.properties` files (see [AFF properties file](https://github.com/SAP/abap-file-formats/blob/main/docs/properties.md)).
83+
84+
## Source Code Reference
85+
86+
[zcl_abapgit_filename_logic](https://github.com/abapGit/abapGit/blob/main/src/objects/core/zcl_abapgit_filename_logic.clas.abap)
87+
- `file_to_object`: Get object from filename and path
88+
- `object_to_file`: Get filename from object
89+
- `detect_object_definition`: Return flags to detect if filename represents an object definition i.e. has an `xml` or `json` extension
90+
- `is_obj_definition_file`: Return boolean flag, if the filename represents an object definition or not (metadata)
91+

0 commit comments

Comments
 (0)