* _______ _______ _______ _______ _______ _______ ______ _______ _______ ______ _______ * | _ | _ | _ | | | _ | || _ | _ | _ | | _ | * | |_| | |_| | |_| | _ | | |_| | _ | |_| | |_| | | || | |_| | * | | | | |_| | | | | | | | | |_||_| | * | | _ || | ___| _| | |_| | | _ || __ | | * | _ | |_| | _ | | | |_| _ | | _ | |_| | | | | _ | * |__| |__|_______|__| |__|___| |_______|__| |__|______||__| |__|_______|___| |_|__| |__| * www.abapcadabra.com * *------------------------------------------------------------------------------------------- * program : ZABAPCADABRA_SMARTFORM_2_PDF * title : Create a smartform, transform to PDF and save - with aliasses * functional area : Cross modules * environment : 4.7 * program Function : A demonstration report for creating alias hyperlink references * in a PDF document. Thus where the hyperlink output states the * text SAP, the text would be underlined and clicking on the * text would open a web browser to http://www.sap.com/ * Documentation : Search for "PDF with alias" on AbapcadabrA.com * Previous version : This is the initial version * Developer name : Wim Maasdam * Development date : 17/06/2015 * Version : 0.1 *--------------------------------------------------------------------- * Change list: * Date Description * 17/06/2015 Initial release *--------------------------------------------------------------------- REPORT ZABAPCADABRA_SMARTFORM_2_PDF. CLASS lcl_smartform DEFINITION. PUBLIC SECTION. types: BEGIN OF ty_url, "<= definition copied from LHRRCF00_CALLBACKTOP name(80), url TYPE string, END OF ty_url. data: gw_job_output_info TYPE ssfcrescl, gw_output_options TYPE ssfcompop, gw_control_parameters TYPE ssfctrlop, gv_fm_name TYPE rs38l_fnam, gt_urls type standard table of ty_url. METHODS: constructor importing smartform type TDSFNAME language type SFLANGU default sy-langu, set_url importing name type any url type any, get_funmod_name returning value(function_module) type rs38l_fnam, convert_and_save_as_pdf. ENDCLASS. CLASS lcl_smartform IMPLEMENTATION. method constructor. * Prepare device type for the gw_output_options clear: gw_output_options. CALL FUNCTION 'SSF_GET_DEVICE_TYPE' EXPORTING i_language = language i_application = 'SAPDEFAULT' IMPORTING e_devtype = gw_output_options-tdprinter. * Default settings - directly produce output clear: gw_control_parameters. gw_control_parameters-no_dialog = 'X'. gw_control_parameters-getotf = 'X'. * Determine the function module name CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = smartform IMPORTING fm_name = gv_fm_name EXCEPTIONS OTHERS = 4. clear: gt_urls[]. endmethod. method set_url. data: lw_url type ty_url. * Prepare an alias url. Whenever the alias text is incorporated on the Smartform * output, it will be changed into a link. lw_url-name = name. lw_url-url = url. APPEND lw_url TO gt_urls. endmethod. method get_funmod_name. * First pass the url's to SF_URL: if not gt_urls[] is initial. CALL FUNCTION 'HR_RCF_SF_URL_REFRESH_GT'. CALL FUNCTION 'HR_RCF_SF_URL_PREPARE_CALLBACK' TABLES pt_url = gt_urls. gw_output_options-urlcall = 'HR_RCF_SF_URL_CALLBACK'. endif. function_module = gv_fm_name. endmethod. method convert_and_save_as_pdf. data: lv_bin_filesize TYPE i, lt_docs TYPE STANDARD TABLE OF docs, lt_lines TYPE STANDARD TABLE OF tline, lv_guiobj TYPE REF TO cl_gui_frontend_services, lv_name TYPE string, lv_path TYPE string, lv_fullpath TYPE string, lv_uact TYPE i. CALL FUNCTION 'CONVERT_OTF_2_PDF' IMPORTING bin_filesize = lv_bin_filesize TABLES otf = gw_job_output_info-otfdata doctab_archive = lt_docs lines = lt_lines EXCEPTIONS OTHERS = 4. CHECK sy-subrc = 0. * Fetch a filename to store the .pdf file in: CONCATENATE 'smrt' '.pdf' INTO lv_name. CREATE OBJECT lv_guiobj. CALL METHOD lv_guiobj->file_save_dialog EXPORTING default_extension = 'pdf' default_file_name = lv_name CHANGING filename = lv_name path = lv_path fullpath = lv_fullpath user_action = lv_uact. IF lv_uact = lv_guiobj->action_cancel. EXIT. ENDIF. * Download as file in the front end (presentation server) CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING bin_filesize = lv_bin_filesize filename = lv_fullpath filetype = 'BIN' TABLES data_tab = lt_lines EXCEPTIONS OTHERS = 22. endmethod. ENDCLASS. START-OF-SELECTION. data: go_smartform type ref to lcl_smartform, gv_funmod type rs38l_fnam. create object go_smartform EXPORTING smartform = 'ZWIMTEST'. "<= your Smartform here ! * The name's listed below should be available as hyperlink in the Smartform. Turn a text into a * hyperlink as follows: <%W>SAP go_smartform->set_url( exporting name = 'SAP' url = 'http://www.sap.com/' ). gv_funmod = go_smartform->get_funmod_name( ). CALL FUNCTION gv_funmod EXPORTING control_parameters = go_smartform->gw_control_parameters output_options = go_smartform->gw_output_options IMPORTING job_output_info = go_smartform->gw_job_output_info EXCEPTIONS OTHERS = 4. go_smartform->convert_and_save_as_pdf( ).