Last active
December 17, 2015 15:29
-
-
Save njames/5631783 to your computer and use it in GitHub Desktop.
Two ways of comparing a set of values in ABAP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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