侯志宇
2014-10-30
促销活动-实际赠品数量修改-实现方法
事物代码:GENIL_MODEL_BROWSER - 一般交互层应用程序的模型浏览器
*"*"本地接口:
*" IMPORTING
*" VALUE(IM_OBJECT_GUID) TYPE CRMT_GENIL_OBJECT_GUID
*" TABLES
*" LT_RETURN TYPE CRMT_GENIL_MESSAGE_TAB OPTIONAL
*" LT_TPM_PRODUCT STRUCTURE CRMS_MKTPL_IB_TPM_PRODUCT OPTIONAL
*"----------------------------------------------------------------------
data: LR_CORE type ref to CL_CRM_BOL_CORE,
LR_GL_MESS_CONT type ref to IF_GENIL_MESSAGE_CONTAINER,
LR_FACTORY type ref to CL_CRM_BOL_ENTITY_FACTORY,
LR_TRANSACTION type ref to IF_BOL_TRANSACTION_CONTEXT,
LR_TRADE type ref to CL_CRM_BOL_ENTITY,
* LR_BTADMINH TYPE REF TO CL_CRM_BOL_ENTITY,
LR_ENTITY type ref to CL_CRM_BOL_ENTITY,
LR_RELATED_ITEM type ref to IF_BOL_ENTITY_COL.
data: "LT_TPM_PRODUCT type table of CRMS_MKTPL_IB_TPM_PRODUCT,
LS_TPM_PRODUCT type CRMS_MKTPL_IB_TPM_PRODUCT,
LA_TPM_PRODUCT type CRMS_MKTPL_IB_TPM_PRODUCT.
data LR_TX_MANAGER type ref to CL_MKTPRJ_TRANSACTION_MGR.
**消息处理
data: LV_SUCCESS type CRMT_BOOLEAN.
*DATA:LT_RETURN TYPE CRMT_GENIL_MESSAGE_TAB,
*data: S_RETURN type CRMT_GENIL_MESSAGE.
check IM_OBJECT_GUID is not initial.
check LT_TPM_PRODUCT[] is not initial .
****修改促销活动
LR_CORE = CL_CRM_BOL_CORE=>GET_INSTANCE( ).
LR_CORE->START_UP( 'CRMD_MKTPL_TPM_OL' ).
LR_TRADE = LR_CORE->GET_ROOT_ENTITY(
IV_OBJECT_NAME = 'Trade'
IV_OBJECT_GUID = IM_OBJECT_GUID ).
check LR_TRADE is bound.
LR_GL_MESS_CONT = LR_CORE->GET_GLOBAL_MESSAGE_CONT( ).
LV_SUCCESS = LR_TRADE->LOCK( ).
if LV_SUCCESS is initial .
if LR_GL_MESS_CONT is bound .
refresh LT_RETURN .
call method LR_GL_MESS_CONT->GET_MESSAGES
exporting
IV_MESSAGE_TYPE = CL_CRM_GENIL_GLOBAL_MESS_CONT=>IF_GENIL_MESSAGE_CONTAINER~MT_ALL
IV_FOR_DISPLAY = ABAP_FALSE
importing
ET_MESSAGES = LT_RETURN[].
delete LT_RETURN where TYPE ne 'E' and TYPE ne 'A' .
endif .
exit.
endif .
*改为修改模式
LR_TRADE->SWITCH_TO_CHANGE_MODE( ).
LR_RELATED_ITEM ?= LR_TRADE->GET_RELATED_ENTITIES( IV_RELATION_NAME = 'TPMProductRel' ).
LR_ENTITY = LR_RELATED_ITEM->GET_FIRST( ) .
while LR_ENTITY is bound .
LR_ENTITY->GET_PROPERTIES( importing ES_ATTRIBUTES = LA_TPM_PRODUCT )."LS_TPM_PRODUCT-ZZFLD0000DW
clear LS_TPM_PRODUCT.
read table LT_TPM_PRODUCT into LS_TPM_PRODUCT with key GUID = LA_TPM_PRODUCT-GUID .
LR_ENTITY->IF_BOL_BO_PROPERTY_ACCESS~SET_PROPERTY( IV_ATTR_NAME = 'ZZFLD0000DW' IV_VALUE = LS_TPM_PRODUCT-ZZFLD0000DW ) .
* LR_ENTITY->IF_BOL_BO_PROPERTY_ACCESS~SET_PROPERTY( IV_ATTR_NAME = 'ZZFLD0000DV' IV_VALUE = '70' ) .
LR_ENTITY = LR_RELATED_ITEM->GET_NEXT( ) .
endwhile .
LR_CORE->MODIFY( ).
LR_TX_MANAGER = CL_MKTPRJ_TRANSACTION_MGR=>GET_INSTANCE( ).
LV_SUCCESS = LR_TX_MANAGER->SAVE_ALL( ).
if LV_SUCCESS = ABAP_TRUE.
if LR_GL_MESS_CONT is bound .
refresh LT_RETURN .
call method LR_GL_MESS_CONT->GET_MESSAGES
exporting
IV_MESSAGE_TYPE = CL_CRM_GENIL_GLOBAL_MESS_CONT=>IF_GENIL_MESSAGE_CONTAINER~MT_ALL
IV_FOR_DISPLAY = ABAP_FALSE
importing
ET_MESSAGES = LT_RETURN[].
clear:LT_RETURN[],LT_RETURN[].
LT_RETURN-TYPE = 'S'.
append LT_RETURN.
endif .
else.
if LR_GL_MESS_CONT is bound .
refresh LT_RETURN .
call method LR_GL_MESS_CONT->GET_MESSAGES
exporting
IV_MESSAGE_TYPE = CL_CRM_GENIL_GLOBAL_MESS_CONT=>IF_GENIL_MESSAGE_CONTAINER~MT_ALL
IV_FOR_DISPLAY = ABAP_FALSE
importing
ET_MESSAGES = LT_RETURN[].
endif .
endif.
endfunction.