Skip to content

Table expressions: KEY name COMPONENTS and KEY name INDEX - #2114

Merged
larshp merged 3 commits into
abaplint:mainfrom
flujo-app:fix/table-expression-key
Nov 12, 2026
Merged

larshp merged 3 commits into
abaplint:mainfrom
flujo-app:fix/table-expression-key

Conversation

@flujo-app

Copy link
Copy Markdown
Contributor

A table expression with a key name stopped the transpilation (todo, SimpleName, todo, other INDEX):

DATA tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY WITH UNIQUE SORTED KEY by_name COMPONENTS name.
WRITE tab[ KEY by_name COMPONENTS name = 'b' ]-id.
WRITE tab[ KEY by_name INDEX 1 ]-id.        " the first row in the order of by_name

The key name now goes to the runtime: the search and INDEX go by the rows in the order of that key, primary_key is the primary key, as READ TABLE ... WITH KEY name COMPONENTS already does. A dynamic key transpiles to a runtime error.

Test in test/expressions/table_expression.ts.

itab[ KEY name ... ] stopped the transpilation ("todo, SimpleName",
"todo, other INDEX"). The key name is now passed to the runtime: the search
and INDEX go by the rows in the order of that key, primary_key is the primary
key. A dynamic key transpiles to a runtime error.
@flujo-app
flujo-app requested a review from larshp as a code owner November 11, 2026 17:40
A hashed key has no row numbers, so line_index( itab[ KEY h ... ] ) is -1
when the row is found, as on a 7.40 system, and 0 when it is not.
@flujo-app

Copy link
Copy Markdown
Contributor Author

Added: line_index( itab[ KEY h ... ] ) through a hashed secondary key gives -1 for a found row (a hashed key has no row numbers), 0 when not found, as a 7.40 system printed for a sample of the same shape. Test in test/expressions/table_expression.ts.

flujo-app added a commit to flujo-app/transpiler that referenced this pull request Nov 12, 2026
- line_index through a hashed secondary key gives -1 for a found row

Upstream: abaplint#2114
@larshp
larshp merged commit 799aabd into abaplint:main Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants