Skip to content

Instantly share code, notes, and snippets.

@njames
Last active December 17, 2015 15:29
Show Gist options
  • Save njames/5631783 to your computer and use it in GitHub Desktop.
Save njames/5631783 to your computer and use it in GitHub Desktop.
Two ways of comparing a set of values in ABAP.
METHOD ENABLE_OCA_BUTTONS.
DATA: lv_status TYPE j_estat
, lo_current TYPE REF TO if_bol_bo_property_access
, table_rows TYPE i
.
FIELD-SYMBOLS: <status> type RSDSSELOPT.
* default condition to false and change if in correct status
rv_enabled = abap_false.
DESCRIBE TABLE me->status_range LINES table_rows.
IF table_rows = 0.
* BUILD range object
APPEND INITIAL LINE TO status_range ASSIGNING <status>.
<status>-option = 'EQ'.
<status>-sign = 'I'.
<status>-low = 'E0001'. " new
APPEND INITIAL LINE TO status_range ASSIGNING <status>.
<status>-option = 'EQ'.
<status>-sign = 'I'.
<status>-low = 'E0002'. " inprocess
APPEND INITIAL LINE TO status_range ASSIGNING <status>.
<status>-option = 'EQ'.
<status>-sign = 'I'.
<status>-low = 'E0011'. " on hold
ENDIF.
lo_current = collection_wrapper->find( iv_index = iv_index ).
IF lo_current IS BOUND.
CALL METHOD lo_current->get_property_as_value
EXPORTING
iv_attr_name = 'STATUS'
IMPORTING
ev_result = lv_status.
IF lv_status CS status_range .
rv_enabled = abap_true.
ENDIF.
ENDIF.
ENDMETHOD.
*! verses
METHOD enable_oca_buttons.
DATA: lv_status TYPE j_estat
, lo_current TYPE REF TO if_bol_bo_property_access
.
CONSTANTS: status_set TYPE string VALUE 'E0001 E0002 E0011' " NEW / INPROCESS AND ON HOLD
.
lo_current = collection_wrapper->find( iv_index = iv_index ).
IF lo_current IS BOUND.
CALL METHOD lo_current->get_property_as_value
EXPORTING
iv_attr_name = 'STATUS'
IMPORTING
ev_result = lv_status.
IF status_set CS lv_status .
rv_enabled = abap_true.
ENDIF.
ENDIF.
ENDMETHOD.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment