Friday, April 18, 2014
This document demonstrates step by step process how to display a Smartform as PDF doucment in Web Dynpro ABAP. It explains how to create the Web Dynpro Application and the code for displaying Smartform as PDF document.
Summary of steps
- Create one attribute PDF(type xstring )
- Use InteractiveForm UI element in the view
- Bind the pdfSource property of the UI to the attribute PDF
- Call Smartform and Get OTF data.
- Convert OTF data to PDF
Integrating Forms - Web Dynpro for ABAP
Step 1: Create Smart form.
Step 2: Define Form Interface.
Step 3: Design Smart form layout.
Check Step by step tutorial on Smart Forms for Step 1, 2 & Step 2.
Step 4: Creating Web Dynpro ABAP Component
- Create Web Dynpro Component(ZOVH_WD_ADOBE) with window name W_WINDOW with default iview V_VIEW.
- Save as local object or transportable object.
- Double click on V_VIEW->Context tab: Define one attribute ADOBE_FORM(of type XSTRING) for the PDF that comes from Adobe forms.
- Layout tab: Insert screen element ADOBE_FORM(of type InteractiveForm) to display Adobe form in PDF format.
- Goto ADOBE_FORM element properties->Bind PdfSource property with ADOBE_FORM attribute for Context.
- Methods tab->WDDOMODIFYVIEW method. Here we write code to get the PDF format of ADOBE form.
- Call dynamically generated smartform function module(lv_fm_name) using SSF_FUNCTION_MODULE_NAME.
- Call function module lv_fm_name
- Convert OTF to PDF using function module CONVERT_OTF.
- WDMODIFYVIEW code
METHOD wddomodifyview . "Variables DATA: lv_buffer TYPE xstring, lv_string TYPE string, lv_fnam TYPE rs38l_fnam, lv_bytecount TYPE i, l_pdfstring TYPE xstring, l_xline TYPE xstring. "Structures DATA: ls_line TYPE tline, ls_ssfctrlop TYPE ssfctrlop, " Control Parameters ls_output_options TYPE ssfcompop, " Output Options ls_job_output_info TYPE ssfcrescl, " Job Output Info ls_job_output_options TYPE ssfcresop, " Job Output Options ls_p0001 TYPE p0001. "Internal Tables DATA: lt_lines TYPE TABLE OF tline. "Get employee data SELECT SINGLE * FROM pa0001 INTO ls_p0001 WHERE pernr EQ '10008289' AND begda LE sy-datum AND endda GE sy-datum. "Get Dynamically Generated Smartform function module CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = 'ZOVH_SIMPLE_SMARTFORM' IMPORTING fm_name = lv_fnam. "Print Parameters ls_ssfctrlop-no_dialog = 'X'. ls_ssfctrlop-getotf = 'X'. ls_ssfctrlop-preview = 'X'. "Output options ls_output_options-tdnoprev = 'X'. ls_output_options-tdtitle = sy-title. ls_output_options-tdnewid = 'X'. ls_output_options-tddest = 'LOCL'. ls_output_options-tdprinter = 'SAPWIN'. "Smartforms call CALL FUNCTION lv_fnam EXPORTING control_parameters = ls_ssfctrlop output_options = ls_output_options giw_p0001 = ls_p0001 IMPORTING job_output_info = ls_job_output_info job_output_options = ls_job_output_options EXCEPTIONS formatting_error = 1 internal_error = 2 send_error = 3 user_canceled = 4 OTHERS = 5. IF sy-subrc <> 0. * Implement suitable error handling here ELSE. " Convert to PDF CALL FUNCTION 'CONVERT_OTF' EXPORTING format = 'PDF' IMPORTING bin_filesize = lv_bytecount TABLES otf = ls_job_output_info-otfdata lines = lt_lines EXCEPTIONS err_conv_not_possible = 1 err_bad_otf = 2. LOOP AT lt_lines INTO ls_line. lv_string = ls_line. EXPORT my_data = lv_string TO DATA BUFFER lv_buffer. IMPORT my_data TO l_xline FROM DATA BUFFER lv_buffer IN CHAR-TO-HEX MODE. CONCATENATE l_pdfstring l_xline INTO l_pdfstring IN BYTE MODE. ENDLOOP. DATA lo_el_context TYPE REF TO if_wd_context_element. DATA ls_context TYPE wd_this->element_context. DATA lv_pdf TYPE wd_this->element_context-pdf. lv_pdf = l_pdfstring. " get element via lead selection lo_el_context = wd_context->get_element( ). " set single attribute lo_el_context->set_attribute( name = `PDF` value = lv_pdf ). ENDIF. ENDMETHOD.
- Save and active web dynpro component.
Step 5: Creating Web Dynpro ABAP Application
- Create web dynpro Application(ZOVH_WD_ADOBE) for the component.
- Run the application
- Output
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.