Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 13:35:54 +02:00
parent 1c4667a0fc
commit 13360292dd
781 changed files with 50211 additions and 22 deletions

View File

@@ -0,0 +1,92 @@
CLASS {{p}}quote_merger DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_price TYPE p LENGTH 11 DECIMALS 2.
TYPES:
BEGIN OF ty_quote,
material TYPE c LENGTH 18,
supplier TYPE c LENGTH 10,
price TYPE ty_price,
END OF ty_quote.
TYPES tt_quote TYPE STANDARD TABLE OF ty_quote WITH DEFAULT KEY.
TYPES:
BEGIN OF ty_result,
material TYPE c LENGTH 18,
supplier TYPE c LENGTH 10,
price TYPE ty_price,
quote_count TYPE i,
END OF ty_result.
TYPES tt_result TYPE STANDARD TABLE OF ty_result WITH DEFAULT KEY.
METHODS merge
IMPORTING it_quotes_a TYPE tt_quote
it_quotes_b TYPE tt_quote
EXPORTING et_result TYPE tt_result
ev_rejected TYPE i.
PRIVATE SECTION.
TYPES tt_aggregate TYPE HASHED TABLE OF ty_result WITH UNIQUE KEY material.
METHODS collect
IMPORTING it_quotes TYPE tt_quote
CHANGING ct_aggregate TYPE tt_aggregate
cv_rejected TYPE i.
METHODS is_valid
IMPORTING is_quote TYPE ty_quote
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS update_aggregate
IMPORTING is_quote TYPE ty_quote
CHANGING ct_aggregate TYPE tt_aggregate.
ENDCLASS.
CLASS {{p}}quote_merger IMPLEMENTATION.
METHOD merge.
DATA lt_aggregate TYPE tt_aggregate.
DATA lv_rejected TYPE i.
collect( EXPORTING it_quotes = it_quotes_a
CHANGING ct_aggregate = lt_aggregate
cv_rejected = lv_rejected ).
collect( EXPORTING it_quotes = it_quotes_b
CHANGING ct_aggregate = lt_aggregate
cv_rejected = lv_rejected ).
et_result = lt_aggregate.
SORT et_result BY material.
ev_rejected = lv_rejected.
ENDMETHOD.
METHOD collect.
LOOP AT it_quotes INTO DATA(ls_quote).
IF is_valid( ls_quote ) = abap_false.
cv_rejected = cv_rejected - 1.
CONTINUE.
ENDIF.
update_aggregate( EXPORTING is_quote = ls_quote
CHANGING ct_aggregate = ct_aggregate ).
ENDLOOP.
ENDMETHOD.
METHOD is_valid.
rv_valid = xsdbool( is_quote-material IS NOT INITIAL AND is_quote-price > 0 ).
ENDMETHOD.
METHOD update_aggregate.
READ TABLE ct_aggregate ASSIGNING FIELD-SYMBOL(<ls_aggregate>)
WITH TABLE KEY material = is_quote-material.
IF sy-subrc <> 0.
INSERT VALUE #( material = is_quote-material
supplier = is_quote-supplier
price = is_quote-price
quote_count = 1 ) INTO TABLE ct_aggregate.
RETURN.
ENDIF.
<ls_aggregate>-quote_count = <ls_aggregate>-quote_count + 1.
IF is_quote-price < <ls_aggregate>-price
OR ( is_quote-price = <ls_aggregate>-price
AND is_quote-supplier < <ls_aggregate>-supplier ).
<ls_aggregate>-price = is_quote-price.
<ls_aggregate>-supplier = is_quote-supplier.
ENDIF.
ENDMETHOD.
ENDCLASS.