Hello Gurus,
I am trying to generate a PDF smartform from the corporate account screen. I am following an example from a consultant who accomplished this in our activities using actions. I have already created the event and added the button in viewset BP_HEAD/ACCOUNTVIEWSET. The attached code attempts to retrieve the smartform from the action for the customer from the webui. I'm getting an error when trying to set LR_ACTIONCONTEXT.
I'm aware that BTHeaderAction is not defined but I'm not sure how to retrieve the available actions as the consultant did. Do I need to create a relation? Is it possible to generate the smartform from an action on the account?
Any tips are greatly appreciated.
DATA: lr_cn TYPE REF TO cl_bsp_wd_context_node,
lr_header TYPE REF TO cl_crm_bol_entity,
lr_actioncontext TYPE REF TO cl_crm_bol_entity,
lv_header_guid TYPE string,
lv_url TYPE string.
DATA:
ls_action TYPE crmt_print_actions,
lr_action_context_coll TYPE REF TO if_bol_entity_col,
lr_action TYPE REF TO if_bol_bo_property_access,
lr_action_entity TYPE REF TO cl_crm_bol_entity,
lv_headerh_guid TYPE crmt_object_guid,
lt_col_def TYPE tableviewcontroltab,
ls_col_def TYPE LINE OF tableviewcontroltab,
lv_title TYPE string,
lr_result TYPE REF TO if_bol_entity_col, "#EC NEEDED
lt_method_param TYPE crmt_name_value_pair_tab,
ls_method_param TYPE LINE OF crmt_name_value_pair_tab,
lv_size TYPE sytabix,
lr_msg_service TYPE REF TO cl_bsp_wd_message_service,
lv_message TYPE string,
lr_action_ppf TYPE REF TO if_action_ppf,
lv_status_ppf TYPE ppfdtstat,
lr_trigger_ppf TYPE REF TO cl_trigger_ppf,
lv_check_status TYPE crmt_boolean.
DATA: ls_params TYPE crmt_gsurlpopup_params,
lr_cn1 TYPE REF TO cl_bsp_wd_context_node,
lr_popup TYPE REF TO if_bsp_wd_popup,
lr_obj TYPE REF TO if_bol_bo_property_access.
***
lr_cn = me->get_context_node( 'HEADER' ). "gc_cn_btadminh ).
CHECK lr_cn IS BOUND.
lr_header ?= lr_cn->collection_wrapper->get_current( ).
CHECK lr_header IS BOUND.
lv_header_guid = lr_header->get_property_as_string( iv_attr_name = 'BP_GUID' ).
lr_actioncontext = lr_header->get_related_entity( iv_relation_name = 'BTHeaderAction' )."#EC NOTEXT
lv_headerh_guid = lv_header_guid.
ls_method_param-value = abap_true.
ls_method_param-name = 'FOR_PREVIEW'. "#EC NOTEXT
INSERT ls_method_param INTO TABLE lt_method_param.
CLEAR ls_method_param.
ls_method_param-name = 'OBJECT_NAME'. "#EC NOTEXT
ls_method_param-value = lr_header->get_name( ).
INSERT ls_method_param INTO TABLE lt_method_param.
ls_method_param-name = 'OBJECT_ID'. "#EC NOTEXT
ls_method_param-value = lr_header->get_key( ).
INSERT ls_method_param INTO TABLE lt_method_param.
CALL FUNCTION 'CRM_STATUS_INIT_EC'
EXPORTING
iv_object_guid = lv_headerh_guid
iv_header_guid = lv_headerh_guid
EXCEPTIONS
OTHERS = 0.
TRY.
CALL METHOD lr_actioncontext->execute
EXPORTING
iv_method_name = 'ACIDetermine' "#EC NOTEXT
it_param = lt_method_param
RECEIVING
rv_result = lr_result.
CATCH: cx_crm_genil_model_error cx_crm_bol_meth_exec_failed.
RETURN.
ENDTRY.
lr_action_context_coll = lr_actioncontext->get_related_entities(
iv_relation_name = 'ACIPreviewActionRel' ). "#EC NOTEXT
lr_action = lr_action_context_coll->get_first( ).
WHILE lr_action IS BOUND.
lr_action->get_property_as_value(
EXPORTING
iv_attr_name = 'TTYPE' "#EC NOTEXT
IMPORTING
ev_result = ls_action-ttypedescr ).
IF ls_action-TTYPEDESCR EQ 'Y_PREVIEW_CALL_REPORT'."ZCL_CONSTANTS=>GC_CALL_REPORT_ACTION.
lr_action->get_property_as_value(
EXPORTING
iv_attr_name = 'GUID' "#EC NOTEXT
IMPORTING
ev_result = ls_action-guid ).
cl_crm_pdf_print=>get_url_by_action_id(
EXPORTING
iv_guid = ls_action-guid
IMPORTING
ev_url = lv_url ).
ls_action-action ?= lr_action.
EXIT.
ENDIF.
lr_action = lr_action_context_coll->get_next( ).
ENDWHILE.
IF lv_url IS NOT INITIAL.
lv_title = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BT_GEN/PRINT_PREVIEW_POPUP_TITLE' )."#EC NOTEXT
lr_popup = me->comp_controller->window_manager->create_popup( iv_interface_view_name = 'GSURLPOPUP/MainWindow'
iv_usage_name = 'CUGSURLPopup'
iv_title = lv_title ).
lr_cn1 = lr_popup->get_context_node( 'PARAMS' ). "#EC NOTEXT
lr_obj = lr_cn1->collection_wrapper->get_current( ).
ls_params-url = lv_url.
ls_params-height = '700'. "#EC NOTEXT
lr_obj->set_properties( ls_params ).
lr_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_plain ).
lr_popup->set_window_width( 700 ).
lr_popup->set_window_height( 700 ).
lr_popup->open( ).
ENDIF.