Skip to content

Refactor formatter samples: move logic to backend, clarify date handling - #703

Merged
oblomov-dev merged 2 commits into
standardfrom
claude/abap2ui5-formatter-analysis-3orq9o
Aug 4, 2026
Merged

oblomov-dev merged 2 commits into
standardfrom
claude/abap2ui5-formatter-analysis-3orq9o

Conversation

@oblomov-dev

Copy link
Copy Markdown
Member

Summary

Restructures two formatter demo samples to better illustrate the separation of concerns between backend and frontend:

  • Sample 453 moves all UI formatting logic (state classification, price rounding, dimension composition, icon/state mapping) from client-side formatter functions into ABAP backend computation
  • Sample 450 is repurposed to demonstrate ABAP date string (DATS/TIMS) conversion, the one legitimate use case for client-side formatters

Key Changes

Sample 453 (z2ui5_cl_demo_app_453):

  • Refactored product data structure: changed weight, price from string to proper types (i, p LENGTH 9 DECIMALS 2)
  • Added computed display fields: weight_state, price_disp, dimensions, status_icon, status_state, delivery_state
  • Introduced products_prepare() method that centralizes all formatting logic:
    • Weight classification by threshold (Success/Warning/Error)
    • Price display formatting via packed field character conversion
    • Dimension string composition
    • Status-to-icon and status-to-state mappings
  • Removed core:require for formatter module and all client-side formatter bindings
  • Updated view bindings to use plain model fields instead of formatter expressions
  • Updated title and description to reflect "thin frontend" philosophy

Sample 450 (z2ui5_cl_demo_app_450):

  • Completely redesigned: replaced product weight table with date/time field examples
  • Now demonstrates ABAP DATS/TIMS string conversion using curated formatter functions
  • Shows proper handling of initial DATS values (00000000 → null)
  • Uses DateAbapDateToDateObject and DateAbapDateTimeToDateObject formatters
  • Updated description to clarify this is the appropriate formatter use case

Navigation (z2ui5_cl_demo_app_g00):

  • Reordered formatter samples in menu: 450 now appears before 457
  • Updated sample 450 label to "ABAP date strings (DATS/TIMS)"
  • Updated sample 453 label to "Simple" (removed from description)

Implementation Details

The refactoring demonstrates that business logic (thresholds, domain vocabulary mappings, string composition) belongs in the backend where the data originates, not in client-side formatters. The only conversion that legitimately requires a formatter is ABAP date string → JavaScript Date object, which sample 450 now exclusively showcases.

https://claude.ai/code/session_012JHCNLVfGJfRFTBwNMntGX

claude and others added 2 commits August 4, 2026 10:46
Both samples referenced curated formatter functions that no longer exist,
so their bindings resolved to nothing:

- 450 bound Formatter.weightState, removed as business logic (parseFloat +
  KG conversion + thresholds). Its subject - wiring the curated module via
  core:require - is already covered by 457, so it now demonstrates what the
  other four do not: the ABAP date-string helpers
  DateAbapDateToDateObject / DateAbapDateTimeToDateObject on the 8/6-char
  DATS/TIMS forms, including an initial 00000000 rendering empty rather
  than a wrong 1899 date. (A field typed d/t is serialized as ISO and takes
  DateCreateObject instead - noted in the class.)
- 453 was the "demo kit pack" demo and bound all five functions that were
  removed for being work ABAP finishes. It now shows the opposite, which is
  the pattern apps should copy: the same table with the state, icon,
  rounded price and dimension string computed in products_prepare and bound
  as plain fields - no core:require, no formatter, no client-side logic.

Descriptions and the generated overview catalog updated accordingly;
abaplint clean on both the standard and the 702 downport.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012JHCNLVfGJfRFTBwNMntGX
@oblomov-dev
oblomov-dev merged commit 687251a into standard Aug 4, 2026
5 of 6 checks passed
@oblomov-dev
oblomov-dev deleted the claude/abap2ui5-formatter-analysis-3orq9o branch August 4, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants