怎样将SAP CRM WebClient UI的表格导出成PDF

怎样将SAP CRM WebClient UI的表格导出成PDF

这期内容当中小编将会给大家带来有关怎样将SAP CRM WebClient UI的表格导出成PDF,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

在WebClient for configTable控件中,有一个将整个表内容导出为excel的功能。

Only simple steps are necessary to support export with PDF format as well.
The achievement would be: a new button is added to table toolbar.

Once pressed, a new PDF with all table records are displayed.

Required steps are briefly listed below.

(1) Create a new post exit on class CL_BTSRV_ADVSRL_CNTRL, method PREPARE_TOOLBAR, in order to add a new button for PDF export in table toolbar.

Post exit source code:

CLASSlcl_zexport_buttonDEFINITIONDEFERRED.CLASScl_btsrv_advsrl_cntrlDEFINITIONLOCALFRIENDSlcl_zexport_button.CLASSlcl_zexport_buttonDEFINITION.PUBLICSECTION.CLASS-DATAobjTYPEREFTOlcl_zexport_button."#ECNEEDEDDATAcore_objectTYPEREFTOcl_btsrv_advsrl_cntrl."#ECNEEDEDINTERFACESIPO_ZEXPORT_BUTTON.METHODS:constructorIMPORTINGcore_objectTYPEREFTOcl_btsrv_advsrl_cntrlOPTIONAL.ENDCLASS.CLASSlcl_zexport_buttonIMPLEMENTATION.METHODconstructor.me->core_object=core_object.ENDMETHOD.METHODipo_zexport_button~prepare_toolbar.*"------------------------------------------------------------------------**"DeclarationofPOST-method,donotinsertanycommentshereplease!*"*"methodsPREPARE_TOOLBAR.*"------------------------------------------------------------------------*DATA:ls_buttonTYPEcrmt_thtmlb_button.ls_button-type=cl_thtmlb_util=>gc_icon_accept.ls_button-on_click='EXPORT'.ls_button-text='ExporttoPDF'.ls_button-enabled=abap_true.APPENDls_buttonTOME->CORE_OBJECT->gt_button.ENDMETHOD.ENDCLASS.

(2) add a new event EXPORT and implement the handler in the result view:

Source code of export implementation:

methodEH_ONEXPORT.cl_crm_order_2_pdf=>open_pdf(io_col_wrapper=me->typed_context->btqrsrvord->collection_wrapperio_window_manager=me->comp_controller->window_manager).endmethod.Sourcecodeofmethodopen_pdf:METHODopen_pdf.DATA:lv_queryTYPEstring.CHECKio_col_wrapper->size()>0.DATA(iterator)=io_col_wrapper->get_iterator().DATA(bol)=iterator->get_current().WHILEbolISNOTINITIAL.lv_query=lv_query&&','&&bol->get_property_as_string('GUID').bol=iterator->get_next().ENDWHILE.lv_query='uuid='&&lv_query.DATA(lv_url)=cl_crm_web_utility=>create_url(iv_path='/sap/crm/order_print'iv_query=lv_queryiv_in_same_session='X').DATA(lv_title)='ServiceOrderPDFList'.DATA(lr_popup)=io_window_manager->create_popup(iv_interface_view_name='GSURLPOPUP/MainWindow'iv_usage_name='CUGURLPopup'iv_title=CONV#(lv_title)).DATA(lr_cn)=lr_popup->get_context_node('PARAMS').DATA(lr_obj)=lr_cn->collection_wrapper->get_current().DATA(ls_params)=VALUEcrmt_gsurlpopup_params(url=lv_urlheight='1000').lr_obj->set_properties(ls_params).lr_popup->set_display_mode(if_bsp_wd_popup=>c_display_mode_plain).lr_popup->set_window_width(1000).lr_popup->set_window_height(1000).lr_popup->open().ENDMETHOD.

(3) Since in step 2 the reuse component GSURLPOPUP is utilized to hold rendered PDF as popup, so we need to declare it as component usage in the component of search result view:

(4) In step 2, the ICF service /sap/crm/order_print is declared but not implemented, so we have to create it in this step via tcode SICF.

Still use CL_CRM_ORDER_2_PDF as handler class,

and the main logic for PDF generation is done in method HANDLE_REQUEST of this handler class:

methodIF_HTTP_EXTENSION~HANDLE_REQUEST.CONSTANTSc_linelenTYPEiVALUE255.DATA:wa_data(c_linelen)TYPEx,lt_dataLIKETABLEOFwa_data.DATA:lv_pdf_lengthTYPEi,lv_pdf_xstringTYPExstring,ls_guid_strTYPEstring.DATA(lv_uuid)=server->request->get_form_field('uuid').CALLMETHODme->get_output_dataEXPORTINGiv_uuid=lv_uuidIMPORTINGfpcontent=lv_pdf_xstring.CALLFUNCTION'SCMS_XSTRING_TO_BINARY'EXPORTINGbuffer=lv_pdf_xstringIMPORTINGoutput_length=lv_pdf_lengthTABLESbinary_tab=lt_data.DATA(lv_contenttype)='application/pdf'.ls_guid_str=lv_uuid.CONCATENATEls_guid_str'.pdf'INTODATA(lv_filename).server->response->append_data(data=lv_pdf_xstringlength=lv_pdf_length).CONCATENATE'inline;filename='lv_filenameINTODATA(lv_contentdisposition).CALLMETHODserver->response->set_header_fieldEXPORTINGname='content-disposition'value=lv_contentdisposition.CALLMETHODserver->response->set_header_fieldEXPORTINGname='content-type'value=CONV#(lv_contenttype).CALLMETHODserver->response->set_header_fieldEXPORTINGname='content-filename'value=lv_filename.server->response->delete_header_field(name='Cache-Control').server->response->delete_header_field(name='Expires').endmethod.

(5) Develop an Adobe Form to display the table content.
The table in the Adobe Form must behave as so called “data-driven” way, which means the table content in the PDF must grow according to the actual data passed into the PDF rendering processor.
First create an ABAP interface for Adobe form via tcode SFP:

The signature for this interface:

Once done, create a new Form template PF_CRM_ORDER_LIST via tcode SFP as well:

Key steps which makes the table in the form template be able to automatically grow according to the feed data source:
(1) The body page must be flowed instead of positioned:

(2) The table content row must be bound to a context node which has 0:n occurrence, and the “Repeat Row for Each Data Item” checkbox must be enabled.

As in step 4, I use a SELECT * from CRMD_ORDERADM_H as the data source for this template, which means you can bind any field in ABAP structure CRMD_ORDERADM_H to the table cell in PDF, as illustrated below.

Activate both form interface and form template and the corresponding PDF would be generated now once export button is pressed.

上述就是小编为大家分享的怎样将SAP CRM WebClient UI的表格导出成PDF了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注恰卡编程网行业资讯频道。

发布于 2021-12-29 23:37:49
收藏
分享
海报
0 条评论
51
上一篇:SAP CRM和Twitter以及facebook的社交媒体集成方案是什么 下一篇:SAP CRM WebClient UI和Fiori UI混搭并存的示例分析
目录

    0 条评论

    本站已关闭游客评论,请登录或者注册后再评论吧~

    忘记密码?

    图形验证码