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

No underscore before digits in AFF field names

Open huber-nicolas opened this issue 3 years ago • 2 comments

I run into problems when trying to map a json field name back to the corresponding abap field name. This happens when the abap field name has underscores in front of a digit. For example: element_1. In json this will become "element1" and when mapping "element1" back to abap there are 2 possibilities. It could have been "element1" or "element_1" in abap. So should we forbid underscores in front of digits, so that we can reconstruct the abap field name?

huber-nicolas avatar Aug 01 '22 16:08 huber-nicolas

yea, I think so

but I'm not sure what to_mixed/from_mixed do in this case, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencase_functions.htm

https://github.com/SAP/abap-file-formats/blob/main/docs/json.md#writing-json-schema-with-abap-types

larshp avatar Aug 01 '22 16:08 larshp

I tested it with this coding:

data abap_name type string.
    data json_name type string.
    data reconstructed_abap_name type string.

    abap_name = 'element1'.
    json_name = to_mixed( abap_name ).
    reconstructed_abap_name =  from_mixed( json_name ).
    out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).

    abap_name = 'element_1'.
    json_name = to_mixed( abap_name ).
    reconstructed_abap_name =  from_mixed( json_name ).
   out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).

    abap_name = 'element_1_'.
    json_name = to_mixed( abap_name ).
   json_name = to_mixed( abap_name ).
    reconstructed_abap_name =  from_mixed( json_name ).
    out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).

    abap_name = 'element_1_a'.
    json_name = to_mixed( abap_name ).
    json_name = to_mixed( abap_name ).
    reconstructed_abap_name =  from_mixed( json_name ).
    out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).

The output is this: abap_name = element1 => to_mixed( ) = json_name: element1 => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1 abap_name = element_1 => to_mixed( ) = json_name: element1 => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1 abap_name = element_1_ => to_mixed( ) = json_name: element1_ => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1_ abap_name = element_1_a => to_mixed( ) = json_name: element1A => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1_A

huber-nicolas avatar Aug 01 '22 16:08 huber-nicolas