abap-file-formats icon indicating copy to clipboard operation
abap-file-formats copied to clipboard

ENHO callbackClass

Open larshp opened this issue 3 years ago • 6 comments

as the only type, ENHO contains "! $callbackClass {@link cl_seef_aff_enho_filter_st}, this is something outside this repository, so I cannot really tell what it is

is it required?

https://github.com/SAP/abap-file-formats/blob/main/file-formats/enho/type/zif_aff_enho_v1.intf.abap#L261

larshp avatar Oct 30 '22 11:10 larshp

It is required, because the subschema of the filter_values is complicated (it has "oneOf", "anyOf", "maxItems"...) and can not be generated by the infos provided by if_aff_enho_v1 alone. Also the serialization and deserialization is complicated and therefore we decided to do them in abap coding instead of using a ST for filter_values (technically we call abap class cl_seef_aff_enho_filter_st inside the ENHO Aff ST to de/serialize the filter_values).

huber-nicolas avatar Oct 31 '22 08:10 huber-nicolas

or in other words, the JSON type cannot be mapped to a static ABAP type

eg. just like conditional subschemas cannot be mapped to ABAP types

larshp avatar Oct 31 '22 11:10 larshp

for reference, abapGit serializes structure ENH_BADI_IMPL_DATA

larshp avatar Nov 10 '22 13:11 larshp

my suggestion: string

larshp avatar Feb 02 '23 13:02 larshp

One proposal to change it by @larshp to string ^^

The string can contain IF-condition like foo = 'A' OR ( bar = 1 AND moo = 5 )

schneidermic0 avatar Feb 02 '23 13:02 schneidermic0

Options I see so far:

  1. Change the type of filterValues to type string. The field content is an IF-condition like foo = 'A' OR ( bar = 1 AND moo = 5 )
  2. Provide the callback class as open source so that it can be called by abap-file-formats-tools. It basically just returns the sub schema. See https://github.com/SAP/abap-file-formats/blob/7ae54e0cd5f67a346fb9797fab31bd7c0505c496/file-formats/enho/enho-v1.json#L136-L200
  3. Change the ABAP type so that it can be represented as static structure. Basically, this means, we have a structure with various options on the first level (e.g., simple filter value, an or- or and-combination. It could look like this (or similar)
  "! <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.

schneidermic0 avatar Feb 14 '23 06:02 schneidermic0