热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

给SAPWebClientUI的表格行项目增添PDF预览功能

InCRMUIbydefaultthePDFpreviewisonlyavailableindocumentheaderlevel.ForexampleoncePDFFactShe

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.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":



推荐阅读
  • 作为一名专业的Web前端工程师,掌握HTML和CSS的命名规范是至关重要的。良好的命名习惯不仅有助于提高代码的可读性和维护性,还能促进团队协作。本文将详细介绍Web前端开发中常用的HTML和CSS命名规范,并提供实用的建议。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 本文详细介绍了如何构建一个高效的UI管理系统,集中处理UI页面的打开、关闭、层级管理和页面跳转等问题。通过UIManager统一管理外部切换逻辑,实现功能逻辑分散化和代码复用,支持多人协作开发。 ... [详细]
  • 本文详细介绍了 Apache Jena 库中的 Txn.executeWrite 方法,通过多个实际代码示例展示了其在不同场景下的应用,帮助开发者更好地理解和使用该方法。 ... [详细]
  • andr ... [详细]
  • 本文详细探讨了VxWorks操作系统中双向链表和环形缓冲区的实现原理及使用方法,通过具体示例代码加深理解。 ... [详细]
  • 本文由瀚高PG实验室撰写,详细介绍了如何在PostgreSQL中创建、管理和删除模式。文章涵盖了创建模式的基本命令、public模式的特性、权限设置以及通过角色对象简化操作的方法。 ... [详细]
  • 基因组浏览器中的Wig格式解析
    本文详细介绍了Wiggle(Wig)格式及其在基因组浏览器中的应用,涵盖variableStep和fixedStep两种主要格式的特点、适用场景及具体使用方法。同时,还提供了关于数据值和自定义参数的补充信息。 ... [详细]
  • Scala 实现 UTF-8 编码属性文件读取与克隆
    本文介绍如何使用 Scala 以 UTF-8 编码方式读取属性文件,并实现属性文件的克隆功能。通过这种方式,可以确保配置文件在多线程环境下的一致性和高效性。 ... [详细]
  • 使用GDI的一些AIP函数我们可以轻易的绘制出简 ... [详细]
  • 装饰器是一种用于在不修改原函数代码的情况下,动态地添加功能的工具。它允许你在函数执行前后插入额外的逻辑,从而增强或改变函数的行为。 ... [详细]
author-avatar
梦回大唐2502907957
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有