|
1 | 1 | ---
|
2 |
| -title: File Formats |
| 2 | +title: File Naming and Formats |
3 | 3 | category: serializers
|
4 | 4 | order: 40
|
5 | 5 | ---
|
6 | 6 |
|
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). |
8 | 8 |
|
9 |
| -## CLAS |
| 9 | +## Naming |
10 | 10 |
|
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: |
12 | 36 |
|
13 | 37 | * `zcl_example.clas.abap`
|
14 | 38 | * `zcl_example.clas.locals_def.abap`
|
15 | 39 | * `zcl_example.clas.locals_imp.abap`
|
16 | 40 | * `zcl_example.clas.testclasses.abap`
|
17 | 41 | * `zcl_example.clas.macros.abap`
|
18 | 42 |
|
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. |
20 | 44 |
|
21 | 45 | One XML file `zcl_example.clas.xml` containing:
|
22 | 46 |
|
| 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 | + |
23 | 70 | * VSEOCLASS information
|
24 | 71 | * TPOOL information
|
25 | 72 | * SOTR information
|
26 | 73 | * LINES from DOKU
|
27 | 74 | * Descriptions from SEOCOMPOTX
|
28 | 75 |
|
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