给SAP WebClient UI的表格行项目增添PDF预览功能
In CRM UI by default the PDF preview is only available in document header level. For example once PDF Fact Sheet is clicked, the PDF is displayed in a popup window.
Suppose there are lots of document to be previewed as a PDF, you have to enter to overview page of each and preview there. A more efficient way is the preview functionality can be directly available in search result table as “One Click Action(OCA)”. This blog will explain the main required steps.
The example is built based on new Genil model CRMSM developed in CRM EHP3. For detail about this Genil model, please refer to this blog Twitter(also Facebook) is official integrated into CRM 7.0 EHP3.
Let’s have a look at what could be achieved as table line item preview.
Once the OCA in a given table row is clicked,
A new Popup is displayed with rendered PDF there.
Step by step for line item preview enablement
(1) since it is required to display PDF in popup, so component usage for reuse component GSURLPOPUP must be declared in runtime repository.
(2) Define OCA event handler in get_p callback:
Source code of GET_P:
METHOD get_p_thtmlb_oca.
CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_oca.
WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
rv_value = 'PREVIEW'.
ENDCASE.
ENDMETHOD.
(3) Create a new event handler for PREVIEW event:
METHOD eh_onpreview.
DATA: lv_event TYPE REF TO cl_htmlb_event_tableview.
lv_event ?= htmlb_event.
me->typed_context->searchresult->eh_on_one_click_action(
iv_htmlb_event = lv_event
iv_htmlb_event_ex = htmlb_event_ex ).
ENDMETHOD.
The method above EH_ON_ONE_CLICK_ACTION is implemented in context node class:
METHOD eh_on_one_click_action.
DATA: lv_event TYPE string,
lv_index TYPE string,
lr_col TYPE REF TO cl_crm_bol_entity.
SPLIT iv_htmlb_event_ex->event_defined AT '.' INTO lv_event lv_index.
me->get_bo_by_index( conv #( lv_index ) ).
lr_col ?= me->collection_wrapper->get_current( ).
CHECK lr_col IS NOT INITIAL.
CASE lv_event.
WHEN 'PREVIEW'.
mr_owner->open_pdf( lr_col ).
WHEN OTHERS.
ENDCASE.
ENDMETHOD.
Inside this method, the PDF preview task is delegated to method OPEN_PDF:
METHOD open_pdf.
DATA(lv_uuid) = ir_bol->get_property_as_string( 'UUID' ).
CONCATENATE 'uuid=' lv_uuid INTO DATA(lv_query).
DATA(lv_url) = cl_crm_web_utility=>create_url( iv_path = '/sap/crm/social_print'
iv_query = lv_query
iv_in_same_session = 'X' ).
SELECT SINGLE internal_id INTO @DATA(lv_id) FROM crmd_soc_post WHERE uuid = @lv_uuid.
DATA(lv_title) = 'Social Post preview: ' && lv_id.
DATA(lr_popup) = me->comp_controller->window_manager->create_popup( iv_interface_view_name = 'GSURLPOPUP/MainWindow'
iv_usage_name = 'CUGSURLPopup'
iv_title = lv_title ).
DATA(lr_cn) = lr_popup->get_context_node( 'PARAMS' ).
DATA(lr_obj) = lr_cn->collection_wrapper->get_current( ).
DATA(ls_params) = VALUE crmt_gsurlpopup_params( url = lv_url height = '700' ).
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( ).
ENDMETHOD.
(4) Create a new ICF node social_print in tcode SICF:
Create a new handler class ZCL_SOCIAL_PRINT for this node.
(5) Inside the handler class mentioned in step 4, an Adobe print form template ZPF_SOCIAL_POST is used.
As a result you need to create it in tcode SFP. You have two objects to create in this transaction code.
(1) A form interface ZIF_SOCIAL_POST. This interface declares importing signature which will be filled by the PDF consumer with business data. The signature required by this example could be found in below screenshot.
(2). A template file which defines PDF layout. In the design time you specify the mapping relationship between UI elements in the template with their corresponding data nodes created in form interface.
Click Layout tab to open Form Builder, and define data binding there.
For this example, you can just type “fb_xdp_up” in command area and upload the template file locally.
Once uploaded, activate both interface and template.
In the runtime the ABAP data to be displayed is converted to xml format and merged into template by ADS ( Adobe Document Service ). If you meet with any trouble during PDF generation phase, you can debug method CL_FP_PDF_OBJECT~EXECUTE_INTERNAL to find the root cause.
The user parameter FPTRACELEVEL is a convenient way to get detail trace for PDF rendering detail.
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- AkShare-股票数据-破净股统计
- AkShare-股票数据-创新高和新低的股票数量
- AkShare-股票数据-A股个股市盈率、市净率和股息率
- AkShare-股票数据-A股市净率
- AkShare-股票数据-A股市盈率
- AkShare-期货数据-期货交易日历
- AkShare-另类数据-彭博亿万富豪指数
- AkShare-股票数据-券商业绩月报
- AkShare-期货数据-仓单日报-上海期货交易所
- AkShare-期货数据-仓单日报-大连商品交易所
- AkShare-期货数据-仓单日报
- AkShare-股票数据-美港目标价
- AkShare-Websocket-行情数据
- AkShare-股票-市场总貌
- AkShare-使用教程-R语言调用数据接口