FUNCTION ZFM_GET_ATTACHMENT_CONTENT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IS_ORDER) TYPE ZSA_ORDER_SALE OPTIONAL
*" EXPORTING
*" VALUE(EV_CONTENT) TYPE SDOKCNTBINS
*"----------------------------------------------------------------------
data:
lv_object_id type crmt_object_id,
lv_content_s type string,
lr_core type ref to cl_crm_bol_core,
lr_factory type ref to cl_crm_bol_entity_factory,
lv_header_guid type crmt_object_guid,
lt_params type crmt_name_value_pair_tab,
ls_params type crmt_name_value_pair,
lr_cmbo type ref to cl_crm_bol_entity,
lr_cmdocument type ref to cl_crm_bol_entity,
lr_doc type ref to cl_crm_bol_entity,
lv_content_length type i,
lv_content_length_s type string,
lv_content_utf8 type string,
lv_cmbo type ref to if_bol_entity_col,
lv_doc type ref to if_bol_entity_col,
ls_cmbo type crmt_cmic_doc_attr ,
ls_doc type crmt_cmic_doc_attr ,
lr_transaction type ref to if_bol_transaction_context.
data ls_orderadm_h type crmd_orderadm_h.
data lv_relation_name type crmt_relation_name.
DATA: LOIO LIKE SKWF_IO.
DATA: PHIO LIKE SKWF_IO.
DATA: FILE_CONTENT TYPE SDOKCNTBINS.
data: file_content_BINARY type sdokcntbins.
DATA:FILE_CONTENT_ASC TYPE TABLE OF SDOKCNTASC.
DATA FILE_TYPE TYPE SDOKFILACIS.
* ev_success = 'E'.
********************************************************************
CHECK IS_ORDER IS NOT INITIAL.
select single * into ls_orderadm_h
from crmd_orderadm_h
where object_id = IS_ORDER-OBJECT_ID
AND PROCESS_TYPE = IS_ORDER-PROCESS_TYPE.
if sy-subrc = 0.
lr_core = cl_crm_bol_core=>get_instance( ).
if lr_core is bound.
if lr_core->get_entity_manager( ) is not bound.
try.
lr_core->start_up( iv_appl_name = 'CM'
iv_display_mode_support = abap_false ).
catch:
cx_crm_genil_general_error.
endtry.
endif.
lr_factory = lr_core->get_entity_factory( 'CMBO' ).
if lr_factory is bound.
ls_params-name = 'INSTID'.
ls_params-value = ls_orderadm_h-guid. "- order header GUID
append ls_params to lt_params.
ls_params-name = 'TYPEID'.
ls_params-value = ls_orderadm_h-object_type.
append ls_params to lt_params.
ls_params-name = 'CATID'.
ls_params-value = 'BO'.
append ls_params to lt_params.
lr_cmbo = lr_factory->create( lt_params ).
if lr_cmbo is bound.
lv_cmbo
= lr_cmbo->get_related_entitIES( iv_relation_name = 'CMBODocumentRefRel' ).
lr_cmdocument ?= lv_cmbo->get_first( ).
while lr_cmdocument is bound.
clear ls_doc.
call method lr_cmdocument->if_bol_bo_property_access~get_properties
importing
es_attributes = ls_doc.
clear: loio,phio.
loio-objid = ls_doc-loio_objid.
loio-class = ls_doc-loio_class.
phio-objid = ls_doc-phio_objid.
phio-class = ls_doc-phio_class.
call method cl_crm_documents=>get_with_table
exporting
loio = LOIO
phio = PHIO
* as_is_mode =
text_as_stream = 'X'
* raw_mode =
importing
file_access_info = FILE_TYPE
file_content_ascii = FILE_CONTENT_ASC
file_content_binary = FILE_CONTENT_BINARY
* error =
* bad_ios =
.
lr_cmdocument ?= lv_cmbo->get_NEXT( ).
ENDWHILE.
endif.
endif.
endif.
endif.
*endif.
ENDFUNCTION.
阅读(1110) | 评论(0) | 转发(0) |