热门标签 | 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的原创文章,请关注公众号"汪子熙":



推荐阅读
  • 尽管在WPF中工作了一段时间,但在菜单控件的样式设置上遇到了一些基础问题,特别是关于如何正确配置前景色和背景色。 ... [详细]
  • Python Selenium WebDriver 浏览器驱动详解与实践
    本文详细介绍了如何使用Python结合Selenium和unittest构建自动化测试框架,重点解析了WebDriver浏览器驱动的配置与使用方法,涵盖Chrome、Firefox、IE/Edge等主流浏览器。 ... [详细]
  • 本文详细介绍了如何在PyQt5中创建简易对话框,包括对话框的基本结构、布局管理以及源代码实现。通过实例代码,展示了如何设置窗口部件、布局方式及对话框的基本操作。 ... [详细]
  • C/C++ 应用程序的安装与卸载解决方案
    本文介绍了如何使用Inno Setup来创建C/C++应用程序的安装程序,包括自动检测并安装所需的运行库,确保应用能够顺利安装和卸载。 ... [详细]
  • 【MySQL】frm文件解析
    官网说明:http:dev.mysql.comdocinternalsenfrm-file-format.htmlfrm是MySQL表结构定义文件,通常frm文件是不会损坏的,但是如果 ... [详细]
  • 本文详细介绍如何在 Apache 中设置虚拟主机,包括基本配置和高级设置,帮助用户更好地理解和使用虚拟主机功能。 ... [详细]
  • OpenCV中的霍夫圆检测技术解析
    本文详细介绍了如何使用OpenCV库中的HoughCircles函数实现霍夫圆检测,并提供了具体的代码示例及参数解释。 ... [详细]
  • 本文探讨了如何在PHP与MySQL环境中实现高效的分页查询,包括基本的分页实现、性能优化技巧以及高级的分页策略。 ... [详细]
  • td{border:1pxsolid#808080;}参考:和FMX相关的类(表)TFmxObjectIFreeNotification ... [详细]
  • 在尝试加载支持推送通知的iOS应用程序的Ad Hoc构建时,遇到了‘no valid aps-environment entitlement found for application’的错误提示。本文将探讨此错误的原因及多种可能的解决方案。 ... [详细]
  • 页面预渲染适用于主要包含静态内容的页面。对于依赖大量API调用的动态页面,建议采用SSR(服务器端渲染),如Nuxt等框架。更多优化策略可参见:https://github.com/HaoChuan9421/vue-cli3-optimization ... [详细]
  • Java连接MySQL数据库的方法及测试示例
    本文详细介绍了如何安装MySQL数据库,并通过Java编程语言实现与MySQL数据库的连接,包括环境搭建、数据库创建以及简单的查询操作。 ... [详细]
  • Gradle 是 Android Studio 中默认的构建工具,了解其基本配置对于开发效率的提升至关重要。本文将详细介绍如何在 Gradle 中定义和使用共享变量,以确保项目的一致性和可维护性。 ... [详细]
  • 最近遇到了一个关于单链表的编程问题,这是来自福富公司的笔试题目。以往我通常使用C语言来解决这类问题,但这次决定尝试用Java来实现。该题目要求实现一个单链表,并完成特定的方法。 ... [详细]
  • 笔记说明重学前端是程劭非(winter)【前手机淘宝前端负责人】在极客时间开的一个专栏,每天10分钟,重构你的前端知识体系& ... [详细]
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社区 版权所有