Git Product home page Git Product logo

abap-file-formats-tools's Introduction

Tools for ABAP File Formats

REUSE status

Description

ABAP file formats rely heavily on JSON Schema that are generated out of ABAP types. This repository provides the tooling to generate such JSON Schema.

Contributing

Comments and suggestions for improvements are most welcome.

More details are found at Contributing.

Licensing

Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

Download & Installation

Pull the source code with abapGit into your ABAP system. The latest abapGit build can be downloaded here.

The development of the ABAP file formats tools takes place in the Z namespace. Coding policies are stated and verified by abaplint, see configuration file here, that run on every pull request.

How to Use

This repository mainly consists of two programs:

  • z_generate_json_schema generates JSON Schemas (minimal requirement is v7.54) from ABAP types
  • z_generate_repo generates files and folder hierarchy for uploading and maintaining the abap-file-formats repository (requires ABAP file format framework)

To add more information to the JSON Schema than that provided by the ABAP type, ABAP Doc is parsed. Different possibilities for adding more information via annotations are listed here.

Additionally to the ABAP-file-formats-related annotations, one can also use the following:

Content Media Type

To specify the content media type of the content of a string field, the annotation

"! $contentMediaType 'mediaType'

followed by the media type surrounded by single quotation marks is used. This annotation can only be used for characters like ABAP types, i.e., types that are mapped to JSON type string.

Content Encoding

The encoding used to store the content of a string field can be specified with the annotation

"! $contentEncoding 'encoding'

followed by the encoding surrounded by single quotation marks. Possible values for the encoding are 7bit, 8bit, binary, quoted-printable, base16, base32 and base64. This annotation can also only be used for characters like ABAP types, i.e., types that are mapped to JSON type string.

How to Obtain Support

Feel free to raise issues to ask questions or report bugs.

abap-file-formats-tools's People

Contributors

albertmink avatar burcuka avatar christopher-hermann avatar dependabot[bot] avatar guilhermesaraiva96 avatar huber-nicolas avatar larshp avatar markus1812 avatar schneidermic0 avatar sebastianwolf-sap avatar wurzka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

abap-file-formats-tools's Issues

enable rule dangerous_statement

I've disabled rule dangerous_statement in the config

suggest refactoring and enabling the rule again

suggest that this code, as such, generate the code to memory, where it can be picked up and written as a file to a git repository, from which the dangerous/import can happen

Msg class not merged into standalone report

Replace msg class ZAFF_TOOLS functionality by zcl_aff_log

The change is driven by the internal report z_generate_repo and its standalone version.
It does not affect the functionality of the z_generate_json_schema report, see
image

Delete `METHOD is_callback_class_valid.`

okay, next suggestion: delete METHOD is_callback_class_valid. and just let the code dump if the class is not valid(does not implement the correct interface), the methods in the class are called dynamically anyhow

Originally posted by @larshp in #58 (comment)

Add report that generates files for AFF

For a given ABAP object type, the report writes the folder . This contains:

  • ABAP type defined in the interface
  • Generated JSON Schema
  • Example of the specified file format

This is the central place for SAP internal developers (prerequisite is the AFF framework in the ABAP system) to contribute the file format specification for the ABAP file formats, for now.

To generate the JSON Schema, it is still recommended to use the program https://github.com/SAP/abap-file-formats-tools/blob/main/src/z_generate_json_schema.prog.abap

The npm magic ๐ŸŒน

This works

npm run lint

This does not

npm run test

image

I deleted the node_modules folder and cleaned the npm cache. Still, it does not work.
Suggestions welcome ๐Ÿ‘‹

Fix the log for the `z_generate_repo` report

When calling the AFF framework, we pass a cl_aff_log object. For logging the classes in the customer namespaces, we use zcl_aff_log. Right now, we print only one log.
We want to print both log messages.

All (non-required) components of type enum should have a default

So far, we only write a warning during generation process if one of the following does not apply:

  • The component of type enum is marked as required
  • One component of the structure describing the enum has an (ABAP-) initial value.

The last point may cause confusion since the JSON schema only knows the JSON enum values and not the ABAP values. Hence, if a component - which value corresponds to an initial ABAP value - is missing in the JSON data, it is not clear what value it has.

Therefore, also (non-required) components of type enum with an initial ABAP value should specify a default value.

For sake of completion: Should also required components of type enum specify a default? Actually, a validation against the JSON schema would fail if a required component was missing. So such a component should always be in the JSON data.

MaxLength is currently limited to 255

Currently the max maxLength in the generated json schemas is 255 due to a bug.
For example if the abap type has a field "name type c length 512" the schema generator will put "maxLength":255 into the schema.

I am working on this problem

cl_oo_abap_doc_reader, reading source code of class/intf

zcl_aff_abap_doc_reader takes the source as input in create_instance

cl_oo_abap_doc_reader takes the name of the class/interface as input

to glue it together, we should read the source code, but which method is preferred to read class and intf source code? CL_OO_CLIF_SOURCE ?

SMBC, missing update or bug?

SMBC was updated with https://github.com/SAP/abap-file-formats/pull/416/files

looking at the code

write_tag( `"enumTitles": [` ).
write_enum_properties( enum_properties-titles ).
ENDIF.
DATA(enum_descr) = get_enum_descriptions( element_description = element_description enum_properties = enum_properties ).
write_tag( `"enumDescriptions": [` ).

then whenever the json contains "enumTitles" it will also have "enumDescriptions"

however, this is not the case for https://github.com/SAP/abap-file-formats/blob/main/file-formats/smbc/smbc-v1.json#L147 ?

something looks wrong...

Remove the unit test in standalone report

Adopt the GitHub Action by

sed -i '/CLASS\ ltc_generator\ I/,/ENDCLASS./d' saff_generate_repo.prog.abap
sed -i '/CLASS\ ltc_generator\ D/,/ENDCLASS./d' saff_generate_repo.prog.abap

Delete enum related logic

the abap-file-formats is in 702 syntax, so enums are out of scope?

suggest deleting the related logic in this repository, less code is easier to get running, plus ENUMS in ABAP is a mess...

Schema Validation for AOBJ fails

There is a validation error for AOBJ:

> [email protected] generate
> rm -rf generated && node aff.mjs

AOBJ
formats/generate/node_modules/@abaplint/runtime/build/src/types/character.js:38
            this.value = value.get() + "";
                               ^

TypeError: Cannot read properties of null (reading 'get')
    at Character.set (/home/runner/work/abap-file-formats/abap-file-formats/generate/node_modules/@abaplint/runtime/build/src/types/character.js:38:32)
    at SelectDatabase.select (/home/runner/work/abap-file-formats/abap-file-formats/generate/node_modules/@abaplint/runtime/build/src/statements/select.js:31:75)

Node.js v18.14.2
Error: Process completed with exit code 1.

Copied from https://github.com/SAP/abap-file-formats/actions/runs/4385938716/jobs/7719410914

See SAP/abap-file-formats#506 and SAP/abap-file-formats#507

Generation dumps for file formats with multiple tables with the same field name

If an AFF type contains a nested structure with internal tables in which the nesting consists on the same table name on different nesting levels. The schema generation will dump here:

DO me->table_buffer[ name = table_name ]-number_brackets TIMES.

Reason: All nesting information for tables with the same name is removed from the table_buffer in zcl_aff_writer_json_schema.

DELETE me->table_buffer WHERE name = table_name.

Here is some example code. There is the field or twice on different levels.

  "! <p class="shorttext">Filter Condition</p>
  "! Filter condition
  TYPES ty_value TYPE string.

  TYPES:
    "! <p class="shorttext">OR Filter Conditions</p>
    "! OR filter conditions
    BEGIN OF ty_or,
      "! <p class="shorttext">Filter Condition</p>
      "! Simple filter condition
      value TYPE ty_value,
    END OF ty_or.

  TYPES:
    "! <p class="shorttext">AND Filter Conditions</p>
    "! AND filter conditions
    BEGIN OF ty_and,
      "! <p class="shorttext">Filter Condition</p>
      "! Simple filter condition
      value TYPE ty_value,
      "! <p class="shorttext">OR Filter Conditions</p>
      "! OR filter conditions
      or     TYPE standard table of ty_or with default key,
    END OF ty_and.

  TYPES:
    "! <p class="shorttext">OR Filter Conditions</p>
    "! OR filter conditions on top level
    BEGIN OF ty_or_top,
      "! <p class="shorttext">Filter Condition</p>
      "! Simple filter condition
      value TYPE ty_value,
      "! <p class="shorttext">AND Filter Conditions</p>
      "! AND filter conditions
      and    TYPE standard table of ty_and with default key,
    END OF ty_or_top.

  TYPES:
    "! <p class="shorttext">Filter Values</p>
    "! Filter values
    BEGIN OF ty_filter_values,
      "! <p class="shorttext">Filter Value</p>
      "! Filter value
      value TYPE ty_value,
      "! <p class="shorttext">OR Filter Conditions</p>
      "! OR filter conditions
      or    TYPE standard table of ty_or_top with default key,
      "! <p class="shorttext">AND Filter Conditions</p>
      "! AND filter conditions
      and   TYPE standard table of ty_and with default key,
    END OF ty_filter_values.

Readme fix link to example

          Did you generate the output of the readme file using our program? 

If so, there seems to be an issue with the generator for the readme file.

`<name>.sajt.json` | 1 | [`zif_aff_sajt_v1.intf.abap`](./type/zif_aff_sajt_v1.intf.abap) | [`sajt-v1.json`](./sajt-v1.json) | [`z_aff_example_sajt.sajt.json](./examples/z_aff_example_sajt.sajt.json)

Originally posted by @schneidermic0 in SAP/abap-file-formats#578 (comment)

method is_callback_class_valid, db SELECTs

refactor SELECTs to class like CL_OO_CLASSNAME_SERVICE, not sure exactly what classes will work, dont have access to a system right now

alternatively, can an interface be added? so instead of checking the class, the class implements an interface?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.