text2tab icon indicating copy to clipboard operation
text2tab copied to clipboard

Transpiler WIP

Open sbcgua opened this issue 4 years ago • 47 comments

sbcgua avatar Oct 14 '21 12:10 sbcgua

@abaplint/transpiler-cli instead of @abaplint/transpiler

larshp avatar Oct 14 '21 14:10 larshp

raise conv_failed.

raising non class based exceptions is not implemented, and I dont think it will be anytime soon

suggest refactoring to a class based exception

larshp avatar Oct 14 '21 15:10 larshp

conv_failed

Hmm, yeah, I don't remember why I did like that in the first place

sbcgua avatar Oct 14 '21 15:10 sbcgua

Nice, it compiles !

sbcgua avatar Oct 14 '21 16:10 sbcgua

image

Looks like an operator is missing ?

    ro_parser.get().mt_components.set(await abap.Classes['ZCL_TEXT2TAB_UTILS'].describe_struct({i_struc: ro_parser.get().mo_struc_descr, i_is_deep: abap.builtin.boolc(abap.compare.initial(i_deep_provider) === false), i_ignore_nonflat: i_ignore_nonflat}));
    if ((abap.compare.initial(i_amount_format)abap.compare.initial(i_amount_format.getOffset({offset: 1, length: 1})))) {
      ro_parser.get().mv_amount_format.set(i_amount_format);
    }

sbcgua avatar Oct 14 '21 17:10 sbcgua

yea, looks like a simple upper/lower case problem

image

larshp avatar Oct 14 '21 17:10 larshp

next problem: Void type: RS38L_FNAM

Perhaps type as TFDIR-FUNCNAME instead, TFDIR will probably be added to open-abap sometime. RS38L_FNAM is a strange data element name

larshp avatar Oct 15 '21 04:10 larshp

Actually funcname DE is a good replacement. Part of SABP pacakge image

TFDIR refers RS38L_FNAM too in fact ...

sbcgua avatar Oct 15 '21 13:10 sbcgua

@larshp Trying to do this again ... May I ask for some assistance ? The message says something wrong with /ui2/cl_json.clas which is not used anyhow ... :/

sbcgua avatar Jul 29 '23 09:07 sbcgua

anyhow, next problem to tackle is VERI_ALPHA, not really sure what to use instead

ideally something that is marked as released, https://abapedia.org/steampunk-2305-api/

larshp avatar Jul 29 '23 10:07 larshp

update didn't help: same error:

$node transpiled/index.mjs
file:///.../text2tab/transpiled/%23ui2%23cl_json.clas.locals.mjs:281
lcl_parser.ty_data_tt = abap.types.TableFactory.construct(new abap.types.Structure({"parent": new abap.types.String({qualifiedName: "LCL_PARSER=>TY_DATA-PARENT"}), "name": new abap.types.String({qualifiedName: "LCL_PARSER=>TY_DATA-NAME"}), "full_name": new abap.types.String({qualifiedName: "LCL_PARSER=>TY_DATA-FULL_NAME"}), "value": new abap.types.String({qualifiedName: "LCL_PARSER=>TY_DATA-VALUE"}), "type": new abap.types.String({qualifiedName: "LCL_PARSER=>TY_DATA-TYPE"})}, "lcl_parser=>ty_data"), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "lcl_parser=>ty_data_tt");
                                                ^

TypeError: Cannot read properties of undefined (reading 'construct')
    at file:///.../text2tab/transpiled/%23ui2%23cl_json.clas.locals.mjs:281:49

... And how do you see from it, that it is about VERI_ALPHA ?

sbcgua avatar Jul 29 '23 10:07 sbcgua

image

:/ I guess the only way is to create own DOMA ...

sbcgua avatar Jul 29 '23 10:07 sbcgua

ALPHA: the xml generation might be bugged and remove the conversion routine

package.json: latest @abaplint/runtime is 2.7.54

larshp avatar Jul 29 '23 10:07 larshp

Added domain/dtel to "deps" but no effect - same error

sbcgua avatar Jul 29 '23 10:07 sbcgua

try updating package.json to latest versions of the dependencies

larshp avatar Jul 29 '23 11:07 larshp

try updating package.json to latest versions of the dependencies

Yes, it's done 957b209

sbcgua avatar Jul 29 '23 12:07 sbcgua

Ah no, sorry (need to get rid of the package json in favor of script, it just makes things worse). But there is now another error

$node transpiled/index.mjs
Void type: FLOAT

sbcgua avatar Jul 29 '23 12:07 sbcgua

OK, now it is some issue with conv_exit

ZCL_TEXT2TAB_PARSER: running ltcl_text2tab_parser_test->create
ZCL_TEXT2TAB_PARSER: running ltcl_text2tab_parser_test->apply_conv_exit
<ref *1> kernel_cx_assert [Error]
    at cl_abap_unit_assert.assert_equals (file:///C:/Users/at/Documents/devs/Abap/text2tab/transpiled/cl_abap_unit_assert.clas.mjs:355:32)
    at async ltcl_text2tab_parser_test.apply_conv_exit (file:///C:/Users/at/Documents/devs/Abap/text2tab/transpiled/zcl_text2tab_parser.clas.testclasses.mjs:312:5)
    at async run (file:///C:/Users/at/Documents/devs/Abap/text2tab/transpiled/index.mjs:45:9) {
  me: ABAPObject {
    qualifiedName: undefined,
    RTTIName: undefined,
    value: [Circular *1]
  },
  previous: ABAPObject {
    qualifiedName: 'CX_ROOT',
    RTTIName: '\\CLASS=CX_ROOT',
    value: undefined
  },
  textid: Character {
    constant: false,
    length: 32,
    extra: {},
    value: '                                '
  },
  get_longtext: [AsyncFunction: if_message$get_longtext],
  get_text: [AsyncFunction: if_message$get_text],
  actual: String { value: '123', qualifiedName: 'STRING' },
  expected: String { value: '0000000123', qualifiedName: 'STRING' },
  msg: String {
    value: "Expected '0000000123', got '123'",
    qualifiedName: 'STRING'
  },
  EXTRA_CX: {
    INTERNAL_FILENAME: 'cl_abap_unit_assert.clas.abap',
    INTERNAL_LINE: 349
  }
}

sbcgua avatar Jul 29 '23 12:07 sbcgua

reproduced in unit test in https://github.com/open-abap/open-abap-core/pull/720

larshp avatar Jul 29 '23 12:07 larshp

try again

larshp avatar Jul 29 '23 12:07 larshp

Void type: SYS_CALLS, suggest using type abap_callstack instead

larshp avatar Jul 29 '23 12:07 larshp

Hmmm

  actual: String { value: '', qualifiedName: 'STRING' },
  expected: String { value: '', qualifiedName: 'STRING' },

sbcgua avatar Jul 30 '23 15:07 sbcgua

the code calls fail(), so there is no actual and expected,

suggest adding the error code to the text in: image

larshp avatar Jul 30 '23 16:07 larshp

anyhow, looks like there is a bug in cl_abap_datfm=>conv_date_ext_to_int,

https://github.com/open-abap/open-abap-core/blob/main/src/date_time/cl_abap_datfm.clas.abap

image

larshp avatar Jul 30 '23 16:07 larshp

add the error code to the message in fail() ?

larshp avatar Aug 01 '23 05:08 larshp

There is no code, but I added the input field/value pair. It's easy to identify the case now:

test_parse_negative( f = 'TDATE' v = '40.01.2015' err = 'XU' ). " Incorrect day Critical Assertion Error: 'Parse field negative wrong code: TDATE = 40.01.2015 [DU]'

cl_abap_datfm=>conv_date_ext_to_int

Hmm, I'm passing the YYYYMMDD to it and requesting to use format YYYY.MM.DD. It work in abap, it kinds of ignore the absence of separators. And the main idea is that it validates the date.

I would probably try to adjust it ... if there were any guide on how to add to open-abap (I mean running unit test in particular) - https://github.com/open-abap/open-abap-core/blob/main/README.md

sbcgua avatar Aug 01 '23 17:08 sbcgua

npm install && npm test

cl_abap_datfm: think I fixed it this morning, https://github.com/open-abap/open-abap-core/pull/726

there is a abaplint typing bug, which I might have time to look at tomorrow morning

larshp avatar Aug 01 '23 17:08 larshp

Yeah, some compilation stuff

Error: check_syntax, Not a structure, type unknown, FieldChain, zcl_text2tab_serializer.clas.abap:369
check_syntax, Not a structure, type unknown, FieldChain, zcl_text2tab_serializer.clas.abap:371
unknown_types, Contains unknown, Type error, not a table type is_context-components, zcl_text2tab_serializer.clas.abap:170

sbcgua avatar Aug 01 '23 17:08 sbcgua

this parts, https://github.com/sbcgua/text2tab/blob/29dbdb0d359d3f297176c5562b61cebdde398e5e/src/zcl_text2tab_parser.clas.abap#L615-L640, sets sy-subrc, suggest replacing with a normal variable, or raising directly where the error occurs

this will also make the code more Steampunk compatible

larshp avatar Aug 06 '23 14:08 larshp

nice, next fix = https://github.com/abaplint/transpiler/pull/1291

larshp avatar Aug 07 '23 05:08 larshp