Thursday, 4 June 2015

pwb smartform odf

Need to maintain otf format in ext


*&  Form USER_EXIT_INIT_BILL
*&---------------------------------------------------------------------*
*&   Use this form e.g. to sort table XYT_DOC_HEADER or to load
*&   additional data from database
*&   This exit is processed *BEFORE* looping at XYT_DOC_HEADER
*&---------------------------------------------------------------------*
*&   <--> XYT_DOC_HEADER
*&---------------------------------------------------------------------*
form user_exit_init_bill
     tables
        xyt_doc_header structure erdk .

*sort XYT_DOC_HEADER by param1 ascending param2 descending .

 
C-ITCPO-TDGETOTF = 'X'.
C-ITCPO-TDpreview = 'X'.
C-ITCPO-TDnoprev = 'X'.

endform .     

than convert otf to pdf


&---------------------------------------------------------------------*
*&   Form USER_EXIT_ZISU_END_EXITN
*&---------------------------------------------------------------------*
*&   This exit is processed AFTER the hierarchy has been processed.
*&
*&   Use this Exit to check or set
*    final settings in the form, if required.
*&---------------------------------------------------------------------*
FORM USER_EXIT_ZISU_END_EXITN .


DATA : V_BIN_FILESIZE TYPE I.
DATA :I_PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
data :  v_name                   TYPE string,
      v_path                   TYPE string,
      v_fullpath               TYPE string,
      v_filter                 TYPE string,
      v_uact                   TYPE i,
      v_guiobj                 TYPE REF TO cl_gui_frontend_services,
      v_filename               TYPE string,
      v_fm_name                TYPE rs38l_fnam.

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_BIN_FILESIZE
* BIN_FILE =
TABLES
OTF = GT_OTF[]
LINES = I_PDF
.


  CONCATENATE 'smrt' '.pdf' INTO v_name.
  CREATE OBJECT v_guiobj.
  CALL METHOD v_guiobj->file_save_dialog
    EXPORTING
      default_extension  = 'pdf'
      default_file_name  = v_name
      file_filter        = v_filter
    CHANGING
      filename           = v_name
      path               = v_path
      fullpath           = v_fullpath
      user_action        = v_uact.
  IF v_uact = v_guiobj->action_cancel.
    EXIT.
  ENDIF.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    BIN_FILESIZE = V_BIN_FILESIZE
    FILENAME     = v_name "'
    FILETYPE     = 'BIN'
  TABLES
    DATA_TAB     = I_PDF.
IF  sy-subrc = 0.
MESSAGE 'Smartform downloaded' TYPE 'I'.
ENDIF.

ENDFORM .                             " USER_EXIT_ZISU_END_EXITN