Hi Experts,
In WEBUI marketing we have a standard functionality as when we execute a campaign element the target group data like cutomer number, name e.t.c will be attached as a .CSV file(Excel) in Attachments assignment block based on the attributes described in mail form , when communication medium is FILE.In my scenario they are using communication medium 'open channel' instead of 'FILE' for which file will not be triggered.So they want us to attach file for 'Open channel' only.
So i thought of attaching the file to the corresponding BOL object in the badi /method CRM_MKT_EXP_CAMP_DAT-EXPORT_CAMPAIGN_DATA as follows. The query objects i am using CMBOLinkQuery , CMBODocumentRefRel are correct and getting data from database when i test them in GENIL_BOL_BROWSER.
DATA: lr_qs TYPE REF TO cl_crm_bol_query_service,
lr_bol_core type ref to cl_crm_bol_core,
ls_cmbo_attr TYPE crmt_cmic_rfolder_attr,
lr_entity_col TYPE REF TO if_bol_entity_col,
lr_cmbo_entity TYPE REF TO cl_crm_bol_entity,
lr_document_entity TYPE REF TO cl_crm_bol_entity,
lv_length TYPE string,
lv_content_type TYPE string,
iv_document type string,
iv_content type xsTRING,
lv_success TYPE crmt_boolean,
lr_transaction TYPE REF TO if_bol_transaction_context,
iv_campaign_guid type CRM_MKTPL_GUID,
iv_filename type string.
iv_document = 'Hi. To test this'.
iv_filename = 'TST.CSV'.
iv_campaign_guid = is_task_info-guid.
lr_bol_core = cl_crm_bol_core=>get_instance( ).
lr_bol_core->start_up( 'ALL' ).
lr_qs = cl_crm_bol_query_service=>get_instance( 'CMBOLinkQuery' ).
ls_cmbo_attr-instid = iv_campaign_guid.
ls_cmbo_attr-typeid = 'BUS2010022'.
ls_cmbo_attr-catid = 'BO'. "#EC NOTEXT
lr_qs->set_properties( ls_cmbo_attr ).
lr_entity_col = lr_qs->get_query_result( ).
lr_cmbo_entity = lr_entity_col->get_current( ).
CHECK lr_cmbo_entity IS BOUND.
lr_document_entity = lr_cmbo_entity->create_related_entity( iv_relation_name = 'CMBODocumentRefRel' ).
CHECK lr_document_entity IS BOUND.
lr_document_entity->set_property_as_string( iv_attr_name = 'FILENAME'
iv_value = iv_filename ).
lv_content_type = 'text/plain;charset=utf-8'.
lr_document_entity->set_property_as_string( iv_attr_name = 'CONTENT_TYPE'
iv_value = lv_content_type ).
lr_document_entity->set_property( iv_attr_name = 'CONTENT'
iv_value = iv_document ).
lv_length = strlen( iv_document ).
lr_document_entity->set_property( iv_attr_name = 'FILE_SIZE'
iv_value = lv_length ).
lr_bol_core->modify( ).
lr_transaction = lr_document_entity->get_transaction( ).
TRY.
lv_success = lr_transaction->save( ).
CATCH cx_crm_bol_duplicate_save.
ENDTRY.
IF NOT lv_success IS INITIAL.
lr_transaction->commit( ).
ENDIF.
But the file is not being attached.Could any body please help me where i went wrong.
Regards,
PavanT.