在ABAP Webdynpro里显示PDF的一种办法
There is a good blog about how to get PDF preview in CRM web client UI. However several development are invovled in that solution. You have to implement your own ICF node to make PDF displayed in UI, and you have to generate the binary code of PDF by yourself.
There is just another approach to achieve the same result but with much less coding by leveraging the standard control “Adobe Interactive form” in ABAP webdynpro. In this way no ICF node implementation, no manual PDF binary code generation, just a few model task.
(1) Create an form interface in tcode SFP.
Choose interface type as ABAP Dictionary-Based Interface.
Just create two parameter NAME and SCORE. Activate the interface.
(2) Create a new form template via tcode SFP.
Click “Context”tab, drag the two parameters from Interface to the right part Context ZPF_EXAMPLE and drop there.
Click tab Layout, design your form layout. Here I create a caption and two text fields. Bind the data source of the two fields to your form context parameter. Here text field NAME is bound to ZPF_EXAMPLE.NAME and Score field bound to ZPF_EXAMPLE.SCORE.
(3) Create a new ABAP webdynpro in SE80. A view MAIN will be created by workbench automatically. Just put a new Adobe Interactive form control into the empty view. You can choose “Insert Element” from context menu and choose “Interactive form”
Specify the form template name ZPF_EXAMPLE to property “templateSource” created in step2.
After that the property “dataSource” is also determined automatically.
Click tab “Context”, now you should see the two parameters defined in form interface is also displayed in context node of view MAIN.
(4) Create a new Webdynpro application and assign two parameter NAME and SCORE to it.
(5) Double click WDDOINIT to implement:
The init method will retrieve name and score from application parameter included in url. The url will be populated from CRM webclient UI side. Till now the development of ABAP webdynpro is finished. You don’t care about the PDF generation and display, it will be handled by ABAP webdynpro framework.
method WDDOINIT .
data(lo_node) = wd_context->get_child_node( 'ZPF_EXAMPLE' ).
DATA: lv_name type string,
lv_score type int4.
lv_name = cl_wd_runtime_services=>get_url_parameter( name = 'NAME' ).
lv_score = cl_wd_runtime_services=>get_url_parameter( name = 'SCORE' ).
lo_node->set_attribute( name = 'NAME' value = lv_name ).
lo_node->set_attribute( name = 'SCORE' value = lv_score ).
endmethod.
(6) The left task would be quite easy for a CRM UI developer: I create a simple view with two input fields for Name and Score, and one hyperlink.
The event handler for hyperlink click:
DATA: lr_popup TYPE REF TO if_bsp_wd_popup,
lr_cn TYPE REF TO cl_bsp_wd_context_node,
lr_obj TYPE REF TO if_bol_bo_property_access,
lt_parameters TYPE tihttpnvp,
ls_params TYPE crmt_gsurlpopup_params.
data(lo_data) = me->typed_context->data->collection_wrapper->get_current( ).
DATA(ls_line) = VALUE ihttpnvp( name = 'NAME' value = lo_data->get_property_as_string( 'NAME' ) ).
APPEND ls_line TO lt_parameters.
ls_line = VALUE ihttpnvp( name = 'SCORE' value = lo_data->get_property_as_string( 'VALUE' ) ).
APPEND ls_line TO lt_parameters.
cl_wd_utilities=>construct_wd_url(
EXPORTING
application_name = 'ZADOBEFORM'
in_parameters = lt_parameters
IMPORTING
out_absolute_url = mv_url ).
lr_popup = me->comp_controller->window_manager->create_popup( iv_interface_view_name = 'GSURLPOPUP/MainWindow'
iv_usage_name = 'GSURLPOPUP'
iv_title = 'Adobe Interactive Form Control' ).
lr_cn = lr_popup->get_context_node( 'PARAMS' ). "#EC NOTEXT
lr_obj = lr_cn->collection_wrapper->get_current( ).
ls_params-url = mv_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( ).
Of course you need to add component GSURLPOPUP via component usage. In the runtime after name and score fields are maintained in CRM UI and hyperlink is clicked, the corresponding PDF will be generated and displayed by ABAP Webdynpro framework.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
- CTreeCtrl 控件使用总结
- 高盛成立交易部门,涉足比特币和加密货币交易
- WordPress主题开发:添加主题更新提醒功能
- WordPress主题开发:添加主题更新提醒功能
- ASP.NET2.0应用中定制安全凭证之实践篇
- Kaggle大神带你上榜单Top2%:点击预测大赛纪实(下)
- WordPress主题后台选项开发框架 Options Framework 介绍
- vc++ 在程序中运行另一个程序的方法
- 为Options Framework主题后台框架添加后台侧边栏
- ClistCtrl用法及总结(由怎样隐藏ListCtrl列表头的排序小三角形这个bug学习到的知识)
- 弹出式模态窗体选择文本控件
- zookeeper 分布式锁服务
- QT Creator 快速入门教程 读书笔记(三)
- WordPress中添加自定义评论表情包的方法(附三套表情包下载)
- 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 数组属性和方法
- 实习第七周
- 有赞 Android 崩溃保护的探索及实践
- 文章翻译:Node.js和Redis入门-安装与命令
- Angular的built-in指令
- 浅谈前端响应式设计(一)
- 浅谈前端响应式设计(二)
- 搭建简易的物联网服务端和客户端-redis+websocket(二十五)
- Angularjs下拉联动(2)
- 大数据开发平台(Data Platform)在有赞的最佳实践
- 【LeetCode两题选手】算法类题目(8.7)
- 树莓派2配置LAMP环境
- 实习第八周
- Office OpenXml SDK 使用 Fallback 图片显示 Ole 元素
- 直播平台在线人数功能
- ZanProxy —— 本地代码调试线上页面,环境再也不是问题