Creating Adobe PDF forms in the WebUI of the SAP CRM
The SAP CRM system is in print form in contrast to other SAP systems, such as SAP EWM, currently exclusively on the printing of forms aligned with Smart Forms. In Customizing you can in the SAP CRM standard only forms and methods for printing of smart deposit forms.
Requirement
If you want also in SAP Adobe forms rather than by smart forms use, then are to perform the following tasks
- Instead of a smart forms must be created an Adobe form in the method stored in Customizing.
- The generated form in OTF format to the method for the print screen to pass is to display the form in the WebUI.
The following tutorial explains how to use the SAP CRM forms an Adobe form can generate.
Szenario
CRM a service operation as a ticket is recorded in the SAP. The ticket is completed, a final report is delivered the customer. The final report should be created as a PDF form using the tools of the SAP Adobe forms. Pressure as well as a print screen of the form in the SAP CRM WebUI should be possible.
Maintain a class and a method to create the Adobe Form
In Customizing for looking for the class, which represents the form printout in the actions to the operation. In our case, this was the class CL_DOC_PROCESSING_CRM_ORDER method CRM_SRVORDER_EXEC_SMART_FORM.
Now copy the class CL_DOC_PROCESSING_CRM_ORDER in a Z-class or derived your own Z class as a subclass of the superclass CL_DOC_PROCESSING_CRM_ORDER. Then copy method CRM_SRVORDER_EXEC_SMART_FORM in method CRM_SRVORDER_EXEC_PDF_FORM.
Maintain a function module to create the Adobe form
In the function module Z_FRM_PRINT_FINAL_REPORT the coding is accommodated well to the Adobe form (PDF form) to create. The interface is 1: 1 from the interface to the smart taken shape from the CRM_SRVORDER_EXEC_SMART_FORM method.
FUNCTION z_frm_print_final_report. *"---------------------------------------------------------------------- * "*" Local interface: * "IMPORTING" * "VALUE(PV_FONAM) TYPE FPNAME OPTIONAL" * "VALUE(IS_OUTPUT_OPTIONS) TYPE SSFCOMPOP OPTIONAL" * "VALUE(IS_CONTROL_PARAMS) TYPE SSFCTRLOP OPTIONAL" * "VALUE(ORDERADM_H) TYPE CRMT_OUTPUT_ORDERADM_H_COM OPTIONAL" * "VALUE(ACTIVITY_H) TYPE CRMT_OUTPUT_ACTIVITY_H_COM OPTIONAL" * "VALUE(OPPORT_H) TYPE CRMT_OUTPUT_OPPORT_H_COM OPTIONAL" * "VALUE(ORGMAN_H) TYPE CRMT_OUTPUT_ORGMAN_H_COM OPTIONAL" * "VALUE(PARTNER_H) TYPE CRMT_OUTPUT_PARTNER_H_COMT OPTIONAL" * "VALUE(PRICINGDATA_H) TYPE CRMT_OUTPUT_PRICINGDATA_H_COM" * "OPTIONAL" * "VALUE(SALES_H) TYPE CRMT_OUTPUT_SALES_H_COM OPTIONAL" * "VALUE(SHIPPING_H) TYPE CRMT_OUTPUT_SHIPPING_H_COM OPTIONAL" * "VALUE(PAYPLAN_D_H) TYPE CRMT_OUTPUT_PAYPLAN_D_H_COMT OPTIONAL" * "VALUE(CUMULAT_H) TYPE CRMT_OUTPUT_CUMULAT_H_COM OPTIONAL" * "VALUE(CUSTOMER_H) TYPE CRMT_OUTPUT_CUSTOMER_H_COM OPTIONAL" * "VALUE(ACS_H) TYPE CRMT_ACS_H_COM OPTIONAL" * "VALUE(BILLING_H) TYPE CRMT_OUTPUT_BILLING_H_COMT OPTIONAL" * "VALUE(CANCEL_H) TYPE CRMT_OUTPUT_CANCEL_H_COMT OPTIONAL" * "VALUE(APPOINTMENT_H) TYPE CRMT_OUTPUT_APPOINTMENT_H_COMT" * "OPTIONAL" * "VALUE(BILLPLAN_D_H) TYPE CRMT_OUTPUT_BILLPLAN_D_H_COMT OPTIONAL" * "VALUE(BILLPLAN_H) TYPE CRMT_OUTPUT_BILLPLAN_H_COMT OPTIONAL" * "VALUE(STATUS_D_H) TYPE CRMT_OUTPUT_STATUS_D_H_COMT OPTIONAL" * "VALUE(STATUS_H) TYPE CRMT_OUTPUT_STATUS_H_COMT OPTIONAL" * "VALUE(SRV_SUBJECT_H) TYPE CRMT_OUTPUT_SRV_SUBJECT_H_COMT" * "OPTIONAL" * "VALUE(SRV_SUBJECT_I) TYPE CRMT_OUTPUT_SRV_SUBJECT_H_COMT" * "OPTIONAL" * "VALUE(SRV_REASON_H) TYPE CRMT_OUTPUT_SRV_REASON_H_COMT OPTIONAL" * "VALUE(SRV_RESULT_H) TYPE CRMT_OUTPUT_SRV_RESULT_H_COMT OPTIONAL" * "VALUE(SRV_REFOBJ_H) TYPE CRMT_OUTPUT_SRV_REFOBJ_H_COMT OPTIONAL" * "VALUE(SRV_REFOBJ_I) TYPE CRMT_OUTPUT_SRV_REFOBJ_H_COMT OPTIONAL" * "VALUE(ORDERADM_I) TYPE CRMT_OUTPUT_ORDERADM_I_COMT OPTIONAL" * "VALUE(ORDERADM_I_IN) TYPE CRMT_OUTPUT_ORDERADM_I_IN_COMT" * "OPTIONAL" * "VALUE(ORDERADM_I_QT) TYPE CRMT_OUTPUT_ORDERADM_I_QT_COMT" * "OPTIONAL" * "VALUE(ORGMAN_I) TYPE CRMT_OUTPUT_ORGMAN_I_COMT OPTIONAL" * "VALUE(PRICINGDATA_I) TYPE CRMT_OUTPUT_PRICINGDATA_I_COMT" * "OPTIONAL" * "VALUE(PRICING_I) TYPE CRMT_OUTPUT_PRICING_I_COMT OPTIONAL" * "VALUE(PRODUCT_I) TYPE CRMT_OUTPUT_PRODUCT_I_COMT OPTIONAL" * "VALUE(SALES_I) TYPE CRMT_OUTPUT_SALES_I_COMT OPTIONAL" * "VALUE(SERVICE_I) TYPE CRMT_OUTPUT_SERVICE_I_COMT OPTIONAL" * "VALUE(SCHEDLIN_I) TYPE CRMT_OUTPUT_SCHEDLIN_I_COMT OPTIONAL" * "VALUE(SCHEDLIN_I_CF) TYPE CRMT_OUTPUT_SCHEDLIN_I_CF_COMT" * "OPTIONAL" * "VALUE(SHIPPING_I) TYPE CRMT_OUTPUT_SHIPPING_I_COMT OPTIONAL" * "VALUE(PARTNER_I) TYPE CRMT_OUTPUT_PARTNER_I_COMT OPTIONAL" * "VALUE(ITEM_CSTICS_I) TYPE CRMT_ITEM_CSTICS_TAB OPTIONAL" * "VALUE(CUSTOMER_I) TYPE CRMT_OUTPUT_CUSTOMER_I_COMT OPTIONAL" * "VALUE(BILLING_I) TYPE CRMT_OUTPUT_BILLING_I_COMT OPTIONAL" * "VALUE(CANCEL_I) TYPE CRMT_OUTPUT_CANCEL_I_COMT OPTIONAL" * "VALUE(FINPROD_I) TYPE CRMT_OUTPUT_FINPROD_I_COMT OPTIONAL" * "VALUE(ORDPRP_I) TYPE CRMT_OUTPUT_ORDPRP_I_COMT OPTIONAL" * "VALUE(APPOINTMENT_I) TYPE CRMT_OUTPUT_APPOINTMENT_I_COMT" * "OPTIONAL" * "VALUE(BILLPLAN_D_I) TYPE CRMT_OUTPUT_BILLPLAN_D_I_COMT OPTIONAL" * "VALUE(BILLPLAN_I) TYPE CRMT_OUTPUT_BILLPLAN_I_COMT OPTIONAL" * "VALUE(STATUS_I) TYPE CRMT_OUTPUT_STATUS_I_COMT OPTIONAL" * "VALUE(WORKING_SET_E_S_BBP) TYPE / 1CN / WORKING_SET_E_S_BBP_T" * "OPTIONAL" * "VALUE(LANGUAGE) TYPE SY-LANGU OPTIONAL" * "VALUE(SERVICE_I_ASSI) TYPE CRMT_OUTPUT_SERVICE_I_ASS_COMT" * "OPTIONAL" * "EXPORTING" * "VALUE(ES_RESULT) TYPE SFPJOBOUTPUT" * "VALUE(ES_OUTPUT) TYPE FPFORMOUTPUT" * "VALUE(ET_OTFDATA) TYPE TT_ITCOO" *"---------------------------------------------------------------------- IF pv_fonam IS INITIAL. pv_fonam = 'ZFRM_SRV_ORD_FINAL_REPORT'. ENDIF. * Get function modules - *. PERFORM get_fm_name USING pv_fonam CHANGING gv_fm_name gv_if_type. * JOP_OPEN ----------------------------------------------------------- * PERFORM job_open USING is_output_options. * Print form --------------------------------------------------------- * PERFORM print_form USING gv_fm_name pv_fonam is_output_options is_control_params orderadm_h activity_h opport_h orgman_h partner_h pricingdata_h sales_h shipping_h payplan_d_h cumulat_h customer_h acs_h billing_h cancel_h appointment_h billplan_d_h billplan_h status_d_h status_h srv_subject_h srv_subject_i srv_reason_h srv_result_h srv_refobj_h srv_refobj_i orderadm_i orderadm_i_in orderadm_i_qt orgman_i pricingdata_i pricing_i product_i sales_i service_i schedlin_i schedlin_i_cf shipping_i partner_i item_cstics_i customer_i billing_i cancel_i finprod_i ordprp_i appointment_i billplan_d_i billplan_i status_i working_set_e_s_bbp language service_i_assi CHANGING es_output. * JOB_CLOSE ---------------------------------------------------------- * PERFORM job_close CHANGING es_result. * Convert PDF data in OTF for print view - *. PERFORM convert_pdf_2_otf USING es_output CHANGING et_otfdata. ENDFUNCTION. INCLUDE LZFRM_PRINT_FINAL_REPORTF01. *----------------------------------------------------------------------* *&---------------------------------------------------------------------* * & Form GET_FM_NAME *&---------------------------------------------------------------------* FORM get_fm_name USING pv_fonam TYPE fpname CHANGING gv_fm_name TYPE funcname gv_if_type TYPE fpinterfacetype. CALL FUNCTION 'FP_FUNCTION_MODULE_NAME' EXPORTING Unable to process = pv_fonam IMPORTING e_funcname = gv_fm_name e_interface_type = gv_if_type. FINAL FORM. *&---------------------------------------------------------------------* * & Form JOB_OPEN *&---------------------------------------------------------------------* FORM job_open USING ps_output_options TYPE ssfcompop. gs_outparam-preview = ". gs_outparam-nodialog = 'X'. gs_outparam-reqnew = 'X'. gs_outparam-getpdf = 'X'. gs_outparam-dest = 'LOCA'. CALL FUNCTION 'FP_JOB_OPEN' CHANGING ie_outputparams = gs_outparam EXCEPTIONS Cancel = 1 usage_error = 2 system_error = 3 internal_error = 4 OTHERS = 5. IF sy-subrc < > 0. ENDIF. FINAL FORM. *&---------------------------------------------------------------------* * & Form PRINT_FORM *&---------------------------------------------------------------------* FORM print_form USING gv_fm_name TYPE funcname pv_fonam TYPE fpname is_output_options TYPE ssfcompop is_control_params TYPE ssfctrlop orderadm_h TYPE crmt_output_orderadm_h_com activity_h TYPE crmt_output_activity_h_com opport_h TYPE crmt_output_opport_h_com orgman_h TYPE crmt_output_orgman_h_com partner_h TYPE crmt_output_partner_h_comt pricingdata_h TYPE crmt_output_pricingdata_h_com sales_h TYPE crmt_output_sales_h_com shipping_h TYPE crmt_output_shipping_h_com payplan_d_h TYPE crmt_output_payplan_d_h_comt cumulat_h TYPE crmt_output_cumulat_h_com customer_h TYPE crmt_output_customer_h_com acs_h TYPE crmt_acs_h_com billing_h TYPE crmt_output_billing_h_comt cancel_h TYPE crmt_output_cancel_h_comt appointment_h TYPE crmt_output_appointment_h_comt billplan_d_h TYPE crmt_output_billplan_d_h_comt billplan_h TYPE crmt_output_billplan_h_comt status_d_h TYPE crmt_output_status_d_h_comt status_h TYPE crmt_output_status_h_comt srv_subject_h TYPE crmt_output_srv_subject_h_comt srv_subject_i TYPE crmt_output_srv_subject_h_comt srv_reason_h TYPE crmt_output_srv_reason_h_comt srv_result_h TYPE crmt_output_srv_result_h_comt srv_refobj_h TYPE crmt_output_srv_refobj_h_comt srv_refobj_i TYPE crmt_output_srv_refobj_h_comt orderadm_i TYPE crmt_output_orderadm_i_comt orderadm_i_in TYPE crmt_output_orderadm_i_in_comt orderadm_i_qt TYPE crmt_output_orderadm_i_qt_comt orgman_i TYPE crmt_output_orgman_i_comt pricingdata_i TYPE crmt_output_pricingdata_i_comt pricing_i TYPE crmt_output_pricing_i_comt product_i TYPE crmt_output_product_i_comt sales_i TYPE crmt_output_sales_i_comt service_i TYPE crmt_output_service_i_comt schedlin_i TYPE crmt_output_schedlin_i_comt schedlin_i_cf TYPE crmt_output_schedlin_i_cf_comt shipping_i TYPE crmt_output_shipping_i_comt partner_i TYPE crmt_output_partner_i_comt item_cstics_i TYPE crmt_item_cstics_tab customer_i TYPE crmt_output_customer_i_comt billing_i TYPE crmt_output_billing_i_comt cancel_i TYPE crmt_output_cancel_i_comt finprod_i TYPE crmt_output_finprod_i_comt ordprp_i TYPE crmt_output_ordprp_i_comt appointment_i TYPE crmt_output_appointment_i_comt billplan_d_i TYPE crmt_output_billplan_d_i_comt billplan_i TYPE crmt_output_billplan_i_comt status_i TYPE crmt_output_status_i_comt working_set_e_s_bbp TYPE / 1cn/working_set_e_s_bbp_t language TYPE sy-langu service_i_assi TYPE crmt_output_service_i_ass_comt CHANGING gs_output TYPE fpformoutput. * gs_docparms-country = ps_control_parameters-country. gs_docparms-langu = is_control_params-langu. CALL FUNCTION gv_fm_name EXPORTING / 1bcdwb/docparams = gs_docparms iv_fonam = pv_fonam is_output_options = is_output_options is_control_params = is_control_params orderadm_h = orderadm_h activity_h = activity_h opport_h = opport_h orgman_h = orgman_h partner_h = partner_h pricingdata_h = pricingdata_h sales_h = sales_h shipping_h = shipping_h payplan_d_h = payplan_d_h cumulat_h = cumulat_h customer_h = customer_h acs_h = acs_h billing_h = billing_h cancel_h = cancel_h appointment_h = appointment_h billplan_d_h = billplan_d_h billplan_h = billplan_h status_d_h = status_d_h status_h = status_h srv_subject_h = srv_subject_h srv_reason_h = srv_reason_h srv_result_h = srv_result_h srv_subject_i = srv_subject_i srv_refobj_h = srv_refobj_h srv_refobj_i = srv_refobj_i orderadm_i = orderadm_i orderadm_i_qt = orderadm_i_qt orderadm_i_in = orderadm_i_in orgman_i = orgman_i pricingdata_i = pricingdata_i pricing_i = pricing_i product_i = product_i sales_i = sales_i service_i = service_i schedlin_i = schedlin_i schedlin_i_cf = schedlin_i_cf shipping_i = shipping_i partner_i = partner_i item_cstics_i = item_cstics_i customer_i = customer_i billing_i = billing_i cancel_i = cancel_i finprod_i = finprod_i ordprp_i = ordprp_i appointment_i = appointment_i billplan_d_i = billplan_d_i billplan_i = billplan_i status_i = status_i working_set_e_s_bbp = working_set_e_s_bbp language = language service_i_assi = service_i_assi IMPORTING / 1bcdwb/formoutput gs_output = EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4. IF sy-subrc < > 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. FINAL FORM. *&---------------------------------------------------------------------* * & Form JOB_CLOSE *&---------------------------------------------------------------------* FORM job_close CHANGING es_result TYPE sfpjoboutput. CALL FUNCTION 'FP_JOB_CLOSE' IMPORTING e_result = es_result EXCEPTIONS usage_error = 1 system_error = 2 internal_error = 3 OTHERS = 4. IF sy-subrc < > 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. FINAL FORM.
It is important that when creating the print screen is from JOB_OPEN parameter GETPDF = X is used.
The function module is in method CRM_SRVORDER_EXEC_PDF_FORM where built, where else the creation of smart forms is triggered. The coding for the creation of the smart forms is removed or commented out.
Format the PDF file for display in SAP CRM WebUI
CRM WebUI the function module is used to display the Adobe forms in SAP CONVERT_PDF, where the form in OTF format to PDF is cast. Because we get the Adobe form already as a finished PDF file, the PDF file must be prepared, that the function module CONVERT_PDF as a finished PDF file identifies the file already and not converted. Otherwise you get an error message in the SAP CRM WebUI.
The PDF file as a binary object into an internal table of the format is transformed into routine CONVERT_PDF_2_OTF ITCOO.
*&---------------------------------------------------------------------* * & Form CONVERT_PDF_2_OTF *&---------------------------------------------------------------------* FORM convert_pdf_2_otf USING es_output TYPE fpformoutput CHANGING et_otfdata TYPE tt_itcoo. type: begin of ty_tab, line(72) type c, end of ty_tab. DATA: lt_lines TYPE TABLE OF tline, ls_lines TYPE tline ls_otfdata TYPE itcoo lv_filesize TYPE i, ls_tab type ty_tab, lt_tab type table of ty_tab. DATA: xcontent TYPE xstring. DATA: content TYPE string. DATA: rows OF string, TYPE STANDARD TABLE wa_rows TYPE string. DATA: conv TYPE REF TO cl_abap_conv_in_ce. DATA: lt_content TYPE string_table. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = es_output-pdf * APPEND_TO_TABLE = ' ' IMPORTING OUTPUT_LENGTH = lv_filesize tables binary_tab = lt_tab. loop at lt_tab into ls_tab. move ls_tab to ls_otfdata. Append ls_otfdata to et_otfdata. ENDLOOP. exit. REFRESH lt_lines. CALL FUNCTION 'CONVERT_OTF' EXPORTING format = 'PDF' * MAX_LINEWIDTH = 132 * ARCHIVE_INDEX = ' ' * COPYNUMBER = 0 * ASCII_BIDI_VIS2LOG = ' ' * PDF_DELETE_OTFTAB = ' ' * PDF_USERNAME = ' ' * PDF_PREVIEW = ' ' * USE_CASCADING = ' ' * MODIFIED_PARAM_TABLE = IMPORTING bin_filesize = lv_filesize * bin_file = es_output-pdf TABLES OTF = et_otfdata lines = lt_lines EXCEPTIONS err_max_linewidth = 1 err_format = 2 err_conv_not_possible = 3 err_bad_otf = 4 OTHERS = 5. IF sy-subrc < > 0. * Implement suitable error handling here ENDIF. FINAL FORM.
Result
The Adobe form displays now correctly CRM WebUI in the print view display in the SAP.
More information