SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Displaying Smartform in PDF format in ESS



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Smartforms, SapScripts, PDF
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 13, 2008 7:11 pm    Post subject: Displaying Smartform in PDF format in ESS Reply with quote

Author: Ira Singhvi

Here is a code using which you can view the smartform in pdf format on the ESS. It is not the print preview , it just opens the smartform
in the PDF format, after which you can save or print.

Code:
DATA: fm_name TYPE rs38l_fnam,
          st_control_parameters TYPE ssfctrlop,
          it_docs TYPE STANDARD TABLE OF docs,
          it_lines TYPE STANDARD TABLE OF tline,
         st_output_options TYPE ssfcompop.

DATA: V_BIN_FILESIZE TYPE I,
           T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
           T_PDF_TAB TYPE TLINE OCCURS 0 WITH HEADER LINE,
           v_guiobj TYPE REF TO cl_gui_frontend_services,
           v_filename TYPE string,
           v_name TYPE string,
           v_path TYPE string,
           v_fullpath TYPE string,
           v_filter TYPE string,
           v_uact TYPE i,
           v_language TYPE sflangu VALUE 'E',
           v_e_devtype TYPE rspoptype.

*Function returns name of the FM of Smart form
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname = 'MYSMARTFORM'
* VARIANT = ' '
* DIRECT_CALL = '
  IMPORTING
    fm_name = fm_name
  EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3.

*Calling the smartform FM
CALL FUNCTION fm_name   "
  EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
    control_parameters = st_control_parameters
* * MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
    output_options = st_output_options
    user_settings = 'X'.

*Convert the OTF to PDF Format
CALL FUNCTION 'CONVERT_OTF_2_PDF'
  IMPORTING
    bin_filesize           = v_bin_filesize
  TABLES
    otf                    = st_job_output_info-otfdata
    doctab_archive         = it_docs
    lines                  = it_lines
  EXCEPTIONS
    err_conv_not_possible  = 1
    err_otf_mc_noendmarker = 2.

CALL SCREEN 200.


Screen 200
Create a custom control in the screen layout and name it HTML_CONTAINER.

In the PBO
Code:
*----------------------------------------------------------------------*
*  MODULE STATUS_0200 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0200 OUTPUT.
  SET PF-STATUS 'TITLE'.
  SET TITLEBAR 'TITLE2'.
  DATA: g_container TYPE REF TO cl_gui_custom_container,
        g_html_container TYPE REF TO cl_gui_custom_container,
        g_dock TYPE REF TO cl_gui_docking_container,
        g_html_control TYPE REF TO cl_gui_html_viewer.
  DATA: init,
        fcode LIKE sy-ucomm,
        ssrept(1), " Sapscript report identifier
        listtab LIKE abaplist OCCURS 1.
  DATA: reptid TYPE sy-repid,
        dynpnr TYPE sy-dynnr,
        assgned_url(255),
        extnsion TYPE i.
  DATA: repid TYPE sy-repid,
        dynnr TYPE sy-dynnr,
        assigned_url(255),
        extension TYPE i.
  reptid = sy-repid.
  dynpnr = sy-dynnr.

  CREATE OBJECT g_html_container
    EXPORTING container_name = 'HTML_CONTAINER'.
  CREATE OBJECT g_html_control
    EXPORTING parent = g_html_container.
  pdf_line_tab[] = it_lines[].
  IF pdf_line_tab[] IS INITIAL.
*no data found display message
    MESSAGE ID 'ZL' TYPE 'I' NUMBER '006'.
    LEAVE PROGRAM.
  ELSE.
    CALL METHOD g_html_control->load_data
      EXPORTING
        type         = 'application'
        subtype      = 'pdf'
      IMPORTING
        assigned_url = url
      CHANGING
        data_table   = pdf_line_tab[].
    CALL METHOD cl_gui_cfw=>flush.
    CALL METHOD g_html_control->show_data
      EXPORTING
        url = url.
  ENDIF.
ENDMODULE                    "STATUS_0200 OUTPUT


In PAI
Code:
*----------------------------------------------------------------------*
*  MODULE USER_COMMAND_0200 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0200 INPUT.
  IF sy-ucomm EQ 'BACK'.
*clearing dock control
    IF NOT g_dock IS INITIAL.
      CALL METHOD g_dock->free.
      CLEAR g_dock.
    ENDIF.
    SET SCREEN 0.
  ENDIF.
ENDMODULE. " USER_COMMAND_0200 INPUT


This is now ready to plug into ESS ..
Create a Transaction code and plug into ESS.
Note : The PDF format will be available to view only in ess not in R/3.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Smartforms, SapScripts, PDF All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.