DETERMINATION
DETERMINATION
控制字段可编辑模式
method /BOBF/IF_FRW_DETERMINATION~EXECUTE.
DATA: lt_header_data TYPE ZTCA90_I_WORK_ORDERS.
" (1) Retrieve the data of the invoice's node instance
io_read->retrieve(
EXPORTING
iv_node = is_ctx-node_key " uuid of the node instance
it_key = it_key " keys given to the determination
IMPORTING
et_data = lt_header_data ). " itab with invoice’s node data
" (2) Create a property helper object
DATA(lo_property_helper) = NEW /bobf/cl_lib_h_set_property( io_modify = io_modify
is_context = is_ctx ).
*--bo
TRY.
DATA(lo_conf) = /bobf/cl_frw_factory=>get_configuration( is_ctx-bo_key ).
CATCH /bobf/cx_frw INTO DATA(lx_frw).
ENDTRY.
lo_conf->get_node(
EXPORTING
iv_node_key = is_ctx-node_key
IMPORTING
es_node = DATA(ls_node) ).
lo_conf->get_property(
EXPORTING
iv_node_cat_key = ls_node-node_cat_key
IMPORTING
et_property = DATA(lt_property) ).
* " (3 ) Set the attribute "comments" to read-only for all paid invoices
LOOP AT lt_header_data INTO DATA(ls_header_data).
IF sy-tabix = 1.
DATA(lt_actions) = ZCA90_CL_YWGD=>CHECK_IS_EDIT( ls_header_data-key ).
READ TABLE lt_actions ASSIGNING FIELD-SYMBOL(<fs_action>) WITH KEY ACTION_ID = 'BTN_SAVE'.
IF sy-subrc = 0
AND ( ls_header_data-appstatus <> '10' AND ls_header_data-appstatus <> '21' )
.
DATA(lv_edit) = 'X'.
ENDIF.
ENDIF.
* IF ls_header_data-appstatus = '10' OR ls_header_data-appstatus = '30'.
*
* ENDIF.
* ls_header_data-actions = escape( val = /ui2/cl_json=>serialize(
* data = lt_actions
* assoc_arrays = abap_true
* assoc_arrays_opt = abap_true )
* format = cl_abap_format=>e_xml_text ).
* io_modify->update(
* EXPORTING
* iv_node = is_ctx-node_key " Node
* iv_key = ls_header_data-key " Key
* is_data = REF #( ls_header_data ) " Data
* ).
*
LOOP AT lt_property ASSIGNING FIELD-SYMBOL(<fs_property>).
IF lv_edit = 'X' and ( <fs_property>-attribute_name EQ 'EXPECTED_RELEASE_DATE' OR <fs_property>-attribute_name EQ 'ANSWER' ).
CALL METHOD lo_property_helper->set_attribute_read_only
EXPORTING
iv_attribute_name = <fs_property>-attribute_name
iv_key = ls_header_data-key
iv_value = abap_false.
ELSEIF lv_edit = 'X'
AND ( <fs_property>-attribute_name EQ 'WORK_TYPE'
OR <fs_property>-attribute_name EQ 'BUSINESS_TYPE'
OR <fs_property>-attribute_name EQ 'BUSINESS_GROUP'
OR <fs_property>-attribute_name EQ 'Z00HRSSDWID'
OR <fs_property>-attribute_name EQ 'Z00HRSSBMID'
OR <fs_property>-attribute_name EQ 'QUESTION'
OR <fs_property>-attribute_name EQ 'MPHONE_NUM'
OR <fs_property>-attribute_name EQ 'TEL_NUM'
OR <fs_property>-attribute_name EQ 'EXPECTED_COMPLETION_DATE')
.
CALL METHOD lo_property_helper->set_attribute_read_only
EXPORTING
iv_attribute_name = <fs_property>-attribute_name
iv_key = ls_header_data-key
iv_value = abap_true.
* ELSEIF ( ls_header_data-appstatus = '10' OR ls_header_data-appstatus = '40' ) AND ( <fs_property>-attribute_name EQ 'WORK_TYPE'
* OR <fs_property>-attribute_name EQ 'BUSINESS_TYPE'
* OR <fs_property>-attribute_name EQ 'Z00HRSSDWID'
* OR <fs_property>-attribute_name EQ 'Z00HRSSBMID'
* OR <fs_property>-attribute_name EQ 'QUESTION'
* OR <fs_property>-attribute_name EQ 'MPHONE_NUM'
* OR <fs_property>-attribute_name EQ 'TEL_NUM'
* OR <fs_property>-attribute_name EQ 'EXPECTED_COMPLETION_DATE'
* ).
*
* CALL METHOD lo_property_helper->set_attribute_read_only
* EXPORTING
* iv_attribute_name = <fs_property>-attribute_name
* iv_key = ls_header_data-key
* iv_value = abap_false.
* ELSEIF lv_same_dw EQ abap_true AND <fs_property>-attribute_name EQ 'EXP_LVL_CODE'.
* CALL METHOD lo_property_helper->set_attribute_enabled
* EXPORTING
* iv_attribute_name = <fs_property>-attribute_name
* iv_key = ls_header_data-key
* iv_value = abap_true.
* ELSE.
* CALL METHOD lo_property_helper->set_attribute_enabled
* EXPORTING
* iv_attribute_name = <fs_property>-attribute_name
* iv_key = ls_header_data-key
* iv_value = abap_false.
ENDIF.
IF <fs_property>-attribute_name EQ 'WORK_TYPE'
OR <fs_property>-attribute_name EQ 'BUSINESS_TYPE'
OR <fs_property>-attribute_name EQ 'BUSINESS_GROUP'.
CALL METHOD lo_property_helper->set_attribute_mandatory
EXPORTING
iv_attribute_name = <fs_property>-attribute_name
iv_key = ls_header_data-key
iv_value = abap_true.
ENDIF.
ENDLOOP.
IF lv_edit = 'X'.
lo_property_helper->set_node_update_enabled(
iv_key = ls_header_data-key
iv_value = abap_true ).
ELSEIF ls_header_data-appstatus = '10' OR ls_header_data-appstatus = '' OR ls_header_data-appstatus = '21'.
IF sy-uname <> ls_header_data-created_by.
lo_property_helper->set_node_update_enabled(
iv_key = ls_header_data-key
iv_value = abap_false ).
ENDIF.
ELSE.
lo_property_helper->set_node_update_enabled(
iv_key = ls_header_data-key
iv_value = abap_false ).
ENDIF.
*
* "删除按钮
* lo_property_helper->set_node_delete_enabled(
* iv_key = ls_header_data-key
* iv_value = abap_false ).
*
** lo_property_helper->set_attribute_read_only(
** iv_attribute_name = zif_ers_i_employee_c=>sc_node_attribute-zers_i_employee-emp_name
** iv_key = ls_header_data-key
** iv_value = abap_false ).
*
ENDLOOP.
endmethod.
修改字段
method /BOBF/IF_FRW_DETERMINATION~EXECUTE.
CONSTANTS: lc_object TYPE /rer/nrobj VALUE 'ZRRE_DOC',
lc_nr TYPE /rer/ps_doc_id VALUE '06'.
" Internal tab for Header Data
" Created using reference to Generated Table Type
DATA(lt_head) = VALUE ZTCA90_I_WORK_ORDERS( ).
" Get Phone Book Head Data
io_read->retrieve(
EXPORTING
iv_node = is_ctx-node_key " Node Name
it_key = it_key " Key Table
IMPORTING
et_data = lt_head " Data Return Struct.
).
DATA: LV_NUM_RANGE(20) TYPE N,
LV_STR TYPE string,
lv_id TYPE string.
lv_id = sy-datum(4).
CALL FUNCTION 'ZF_NUMRANGE_GET'
EXPORTING
NUM_NAME = 'ZCAYWGD'
IV_TYPE = '0'
IV_ID = lv_id
IV_CREATE = 'X'
IV_CREATE_TXT = '运维工单'
IV_COMMIT = 'X'
IMPORTING
NUM_RANGE = LV_NUM_RANGE
* BUZEI =
EXCEPTIONS
NO_MORE_VALID_NUMBER = 1
PARAMETER_ERROR = 2
OTHER_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
LV_STR = LV_NUM_RANGE.
ENDIF.
LOOP AT lt_head REFERENCE INTO DATA(lr_head).
IF lr_head->work_order IS INITIAL. "
lr_head->appstatus = '10'.
lr_head->appdate = sy-datum.
lr_head->created_date = sy-datum.
lr_head->created_time = sy-uzeit.
lr_head->created_by = sy-uname.
DATA: ls_uinfo TYPE ZHR_S_USER_INFO.
ls_uinfo = ZHR_CL_TOOLS_UTILLS=>GET_USER_INTOBY_BY_UID( IV_GLGS = '' IV_UNAME = sy-uname ).
lr_head->z00hrssbmid = ls_uinfo-objid.
ls_uinfo = ZHR_CL_TOOLS_UTILLS=>GET_USER_INTOBY_BY_UID( IV_GLGS = 'X' IV_UNAME = sy-uname ).
lr_head->z00hrssdwid = ls_uinfo-objid.
lr_head->work_order = lr_head->BUSINESS_TYPE && sy-datum(6) && LV_NUM_RANGE+15(5).
io_modify->update(
EXPORTING
iv_node = is_ctx-node_key " Node
iv_key = lr_head->key " Key
is_data = lr_head " Data
).
ENDIF.
ENDLOOP.
" perform modifications to avoid a dump in case the update
" cannot be performed due to foreign locks
io_modify->end_modify(
IMPORTING
eo_message = eo_message ).
endmethod.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Hblog!