RAP Action Bound vs Unbound 차이 #shorts #SAP #ABAP
Moderator
RAP Action이란?
RAP(RESTful Application Programming) 모델에서 Action은 CRUD 외 커스텀 비즈니스 로직을 실행하는 오퍼레이션입니다. OData V4로 노출되며 Fiori Elements 버튼에 자동 연결됩니다.
Bound vs Unbound 차이
Bound Action — 특정 엔티티 인스턴스(키)에 바인딩. 선택된 레코드에만 동작합니다.
Unbound Action — 인스턴스 무관. static action으로 선언, 배치 처리 등 전역 로직에 사용합니다.
Behavior Definition
define behavior for ZRAP_ORDER {
// Bound: 인스턴스 키 필수
action confirmOrder result [1] $self;
// Unbound: static 키워드
static action closePeriod
parameter ZRAP_CLOSE_PARAM
result [1] ZRAP_CLOSE_RESULT;
}
Implementation
" Bound Action
METHOD confirmOrder.
LOOP AT keys ASSIGNING FIELD-SYMBOL().
UPDATE zrap_order SET status = 'C'
WHERE order_uuid = -order_uuid.
APPEND VALUE #( %tky = -%tky ) TO result.
ENDLOOP.
ENDMETHOD.
" Unbound Action
METHOD closePeriod.
UPDATE zrap_order SET status = 'X'
WHERE period = keys-param-target_period.
result = VALUE #( closed_count = sy-dbcnt ).
ENDMETHOD.
핵심 한 줄
인스턴스 키가 필요하면 Bound Action, 필요 없으면 static Unbound Action으로 선언하라.