SAPScript to PDF

Hi Folks,
   I had to create a RFC Function module, which takes invoice number and output type as input parameter and downloads PDF file from the SAPScript document.
    Eg If we go to transaction VF02 and put in the invoice number and go to menu path Billing Document -> Issue Output To -> Screen  and the Output Type is ZC05.   The Function Module should download the PDF file for the SAPScript Document.
     Thanks in Advance.
     Punit

Hai Punit
Check the following Code
REPORT ZRICH_0003.
DATA: ITCPO LIKE ITCPO,
      TAB_LINES LIKE SY-TABIX.
Variables for EMAIL functionality
DATA: MAILDATA   LIKE SODOCCHGI1.
DATA: MAILPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: MAILHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: MAILBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILREC    LIKE SOMLREC90 OCCURS 0  WITH HEADER LINE.
DATA: SOLISTI1   LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
PERFORM SEND_FORM_VIA_EMAIL.
      FORM  SEND_FORM_VIA_EMAIL                                      *
FORM  SEND_FORM_VIA_EMAIL.
  CLEAR:    MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
  REFRESH:  MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
Creation of the document to be sent File Name
  MAILDATA-OBJ_NAME = 'TEST'.
Mail Subject
  MAILDATA-OBJ_DESCR = 'Subject'.
Mail Contents
  MAILTXT-LINE = 'Here is your file'.
  APPEND MAILTXT.
Prepare Packing List
  PERFORM PREPARE_PACKING_LIST.
Set recipient - email address here!!!
  MAILREC-RECEIVER = '[email protected]'.
  MAILREC-REC_TYPE  = 'U'.
  APPEND MAILREC.
Sending the document
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            DOCUMENT_DATA              = MAILDATA
            PUT_IN_OUTBOX              = ' '
       TABLES
            PACKING_LIST               = MAILPACK
            OBJECT_HEADER              = MAILHEAD
            CONTENTS_BIN               = MAILBIN
            CONTENTS_TXT               = MAILTXT
            RECEIVERS                  = MAILREC
       EXCEPTIONS
            TOO_MANY_RECEIVERS         = 1
            DOCUMENT_NOT_SENT          = 2
            OPERATION_NO_AUTHORIZATION = 4
            OTHERS                     = 99.
ENDFORM.
     Form  PREPARE_PACKING_LIST
FORM PREPARE_PACKING_LIST.
  CLEAR:    MAILPACK, MAILBIN, MAILHEAD.
  REFRESH:  MAILPACK, MAILBIN, MAILHEAD.
  DESCRIBE TABLE MAILTXT LINES TAB_LINES.
  READ TABLE MAILTXT INDEX TAB_LINES.
  MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
Creation of the entry for the compressed document
  CLEAR MAILPACK-TRANSF_BIN.
  MAILPACK-HEAD_START = 1.
  MAILPACK-HEAD_NUM = 0.
  MAILPACK-BODY_START = 1.
  MAILPACK-BODY_NUM = TAB_LINES.
  MAILPACK-DOC_TYPE = 'RAW'.
  APPEND MAILPACK.
Creation of the document attachment
This form gets the OTF code from the SAPscript form.
If you already have your OTF code, I believe that you may
be able to skip this form.  just do the following code, looping thru
your SOLISTI1 and updating MAILBIN.
  PERFORM GET_OTF_CODE.
  LOOP AT SOLISTI1.
    MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
    APPEND MAILBIN.
  ENDLOOP.
  DESCRIBE TABLE MAILBIN LINES TAB_LINES.
  MAILHEAD = 'TEST.OTF'.
  APPEND MAILHEAD.
Creation of the entry for the compressed attachment
  MAILPACK-TRANSF_BIN = 'X'.
  MAILPACK-HEAD_START = 1.
  MAILPACK-HEAD_NUM = 1.
  MAILPACK-BODY_START = 1.
  MAILPACK-BODY_NUM = TAB_LINES.
  MAILPACK-DOC_TYPE = 'OTF'.
  MAILPACK-OBJ_NAME = 'TEST'.
  MAILPACK-OBJ_DESCR = 'Subject'.
  MAILPACK-DOC_SIZE = TAB_LINES * 255.
  APPEND MAILPACK.
ENDFORM.
     Form  GET_OTF_CODE
FORM  GET_OTF_CODE.
  DATA: BEGIN OF OTF OCCURS 0.
          INCLUDE STRUCTURE ITCOO .
  DATA: END OF OTF.
  DATA: ITCPO LIKE ITCPO.
  DATA: ITCPP LIKE ITCPP.
  CLEAR ITCPO.
  ITCPO-TDGETOTF = 'X'.
Start writing OTF code
  CALL FUNCTION 'OPEN_FORM'
       EXPORTING
            FORM     = 'ZTEST_FORM'
            LANGUAGE = SY-LANGU
            OPTIONS  = ITCPO
            DIALOG   = ' '
       EXCEPTIONS
            OTHERS   = 1.
  CALL FUNCTION 'START_FORM'
       EXCEPTIONS
            ERROR_MESSAGE = 01
            OTHERS        = 02.
  CALL FUNCTION 'WRITE_FORM'
       EXPORTING
            WINDOW        = 'MAIN'
       EXCEPTIONS
            ERROR_MESSAGE = 01
            OTHERS        = 02.
Close up Form and get OTF code
  CALL FUNCTION 'END_FORM'
       EXCEPTIONS
            ERROR_MESSAGE = 01
            OTHERS        = 02.
  MOVE-CORRESPONDING ITCPO TO ITCPP.
  CALL FUNCTION 'CLOSE_FORM'
       IMPORTING
            RESULT  = ITCPP
       TABLES
            OTFDATA = OTF
       EXCEPTIONS
            OTHERS  = 1.
Move OTF code to structure SOLI form email
  CLEAR SOLISTI1. REFRESH SOLISTI1.
  LOOP AT OTF.
    SOLISTI1-LINE = OTF.
    APPEND SOLISTI1.
  ENDLOOP.
ENDFORM.
Thanks & Regards
Sreeni

Similar Messages

  • Converting from SAPSCRIPT to PDF

    Sir,
    I am converting form from sapscript to pdf. The form is converting but the ouput font in pdf is seen in bigger size so the alignment is getting distorted. Kindly advise solution. I am in 4.6C
    Thanks & Regards

    Hi
    See the sample code and do accordingly
    REPORT zzz_jaytest .
    Types Declaration
    TYPES : BEGIN OF ty_pa0001,
    pernr TYPE pa0001-pernr,
    bukrs TYPE pa0001-bukrs,
    werks TYPE pa0001-werks,
    END OF ty_pa0001.
    Internal Table Declaration
    DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
    i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
    i_content_txt TYPE soli_tab, "Content
    i_content_bin TYPE solix_tab, "Content
    i_objhead TYPE soli_tab,
    Work Area Declaration
    w_pa0001 TYPE ty_pa0001, "For pa0001 Details
    w_res TYPE itcpp, "SAPscript output
    "parameters
    w_otf TYPE itcoo, "For OTF
    w_pdf TYPE solisti1, "For PDF
    w_transfer_bin TYPE sx_boolean, "Content
    w_options TYPE itcpo, "SAPscript output
    "interface
    Variable Declaration
    v_len_in TYPE so_obj_len,
    v_size TYPE i.
    Constants Declaration
    CONSTANTS : c_x TYPE c VALUE 'X', "X
    c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
    c_otf TYPE sx_format VALUE 'OTF', "OTF
    c_pdf TYPE sx_format VALUE 'PDF', "PDF
    c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
    c_bin TYPE char10 VALUE 'BIN', "BIN
    c_name TYPE string VALUE 'C:\ZZZ_JAYTEST.PDF',"Downloading
    "File Name
    c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
    START-OF-SELECTION.
    Selecting the records from pa0001
    SELECT pernr bukrs werks FROM pa0001
    INTO TABLE i_pa0001 UP TO 10 ROWS.
    Setting the options
    w_options-tdcopies = 1 ."Number of copies
    w_options-tdnoprev = c_x."No print preview
    w_options-tdgetotf = c_x."Return of OTF table
    w_options-tddest = c_locl."Spool: Output device
    Opening the form
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    form = c_form
    device = c_printer
    language = sy-langu
    OPTIONS = w_options
    IMPORTING
    RESULT = w_res.
    LOOP AT i_pa0001 INTO w_pa0001.
    Writting into the form
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    element = 'MAIN'
    window = 'MAIN'.
    ENDLOOP.
    Closing the form
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = w_res
    TABLES
    otfdata = i_otf
    EXCEPTIONS
    unopened = 1
    bad_pageformat_for_print = 2
    send_error = 3
    spool_error = 4
    codepage = 5
    OTHERS = 6.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Converting OTF data to single line
    LOOP AT i_otf INTO w_otf.
    CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
    INTO w_pdf.
    APPEND w_pdf TO i_content_txt.
    ENDLOOP.
    Converting to PDF Format
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = c_otf
    format_dst = c_pdf
    devtype = c_printer
    CHANGING
    transfer_bin = w_transfer_bin
    content_txt = i_content_txt
    content_bin = i_content_bin
    objhead = i_objhead
    len = v_len_in
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    v_size = v_len_in.
    Downloading the PDF File
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    bin_filesize = v_size
    filename = c_name
    filetype = c_bin
    TABLES
    data_tab = i_content_bin.
    If you r using this function module check it once....
    call function 'CONVERT_OTF'
    EXPORTING
    format = 'PDF'
    max_linewidth = 132
    IMPORTING
    bin_filesize = v_len_in
    TABLES
    otf = i_otf
    lines = i_tline
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    others = 4.
    Fehlerhandling
    if sy-subrc <> 0.
    endif.
    or u can use the standard program RSTXPDFT4 to download the script into PDF format onto a particular location
    follow this link for sample program.
    http://searchsap.techtarget.com/tip/0,289483,sid21_gci1121833,00.html
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Mailing the sapscript thru pdf file

    Hi,
    I want to send a sapscript thru pdf file, however, I have a problem with the parameters to set in my open_form when my DEVICE = 'MAIL' and I have to fetch the otf file in the close_form.
    Can you help with the parameter I need to set up in the open form? What are the required parameters for this function?
    Thanks a lot!
    rgds,
    Mark

    Hi Mark Rennel Barrios  ,
            Here below is the Code for that Functionality :
    REPORT ZGRESS1PRINT .
    Tables: qmel,makt,qmfe.
    parameters: input like QMEL-QMNUM.
        data var like makt-maktx.
    DATA: BEGIN OF OPTIONS OCCURS 0.
            INCLUDE STRUCTURE ITCPO.
    DATA: END OF OPTIONS.
    DATA:  VAFILESIZE(10).
    DATA: VAFILENAME(100) value 'test.pdf'.
    DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE.
    DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
    DATA: DOC_CHNG LIKE SODOCCHGI1.
    DATA: TAB_LINES LIKE SY-TABIX.
    DATA: IOTF LIKE ITCOO OCCURS 0 WITH HEADER LINE.
    DATA: ILINES1 LIKE TLINE OCCURS 0 WITH HEADER LINE.
            OPTIONS-TDDEST = 'LP01'.
            OPTIONS-TDIMMED = 'X'.
            OPTIONS-TDNEWID = 'X'.
            OPTIONS-TDNOPREV = 'X'.
            OPTIONS-TDLIFETIME = 2.
            OPTIONS-TDGETOTF = 'X'.
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
       DEVICE                            = 'PRINTER'
       DIALOG                            =  'X'
       FORM                              = 'ZGRESS1'
       OPTIONS                           =  OPTIONS
    EXCEPTIONS
       CANCELED                          = 1
       DEVICE                            = 2
       FORM                              = 3
       OPTIONS                           = 4
       UNCLOSED                          = 5
       OTHERS                            = 11
    IF SY-SUBRC <> 0.
    Write:/ 'Error while open the form'.
    ENDIF.
      CALL FUNCTION 'START_FORM'
           EXPORTING
                FORM   = 'ZGRESS1'
           EXCEPTIONS
                OTHERS = 1.
      IF SY-SUBRC <> 0.
        WRITE 'Error in start_form'.
        EXIT.
      ENDIF.
    select * from qmel where qmnum = input.
    select single maktx into (makt-maktx) from makt where matnr = qmel-matnr
    and spras = 'EN'.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT  = 'ITEM1'
                FUNCTION = 'SET'
                TYPE     = 'BODY'
                WINDOW   = 'MAIN'
           EXCEPTIONS
                OTHERS   = 1.
      IF SY-SUBRC <> 0.
        WRITE 'Error in write_form printing top element of main'.
        EXIT.
      ENDIF.
    ENDSELECT.
    select * from qmfe where qmnum = input.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                ELEMENT  = 'ITEM2'
                FUNCTION = 'SET'
                TYPE     = 'BODY'
                WINDOW   = 'MAIN'
           EXCEPTIONS
                OTHERS   = 1.
      IF SY-SUBRC <> 0.
        WRITE 'Error in write_form printing top element of main'.
        EXIT.
      ENDIF.
    ENDSELECT.
        CALL FUNCTION 'END_FORM'
           EXCEPTIONS
                OTHERS = 1.
      IF SY-SUBRC <> 0.
        WRITE 'Error in end_form'.
        EXIT.
      ENDIF.
      CALL FUNCTION 'CLOSE_FORM'
           TABLES
                      OTFDATA = IOTF
           EXCEPTIONS
                OTHERS = 1.
      IF SY-SUBRC <> 0.
        WRITE 'Error in close_form'.
        EXIT.
      ENDIF.
            CALL FUNCTION 'CONVERT_OTF'
                EXPORTING
                     FORMAT                = 'PDF'
                IMPORTING
                       BIN_FILESIZE          = VAFILESIZE
                 TABLES
                      OTF                   = IOTF
                      LINES                 = ILINES1
                EXCEPTIONS
                     ERR_MAX_LINEWIDTH     = 1
                     ERR_FORMAT            = 2
                     ERR_CONV_NOT_POSSIBLE = 3
                     OTHERS                = 4
            IF SY-SUBRC <> 0.
            ENDIF.
            DOC_CHNG-OBJ_NAME = 'SAPSACRIPTMAIL'.
            DOC_CHNG-OBJ_DESCR = 'SAP_SACRIPT_MAIL.'.
            OBJTXT-LINE = 'This is a TestMail for Greetson'.
            APPEND OBJTXT.
            DESCRIBE TABLE OBJTXT LINES TAB_LINES.
            READ TABLE OBJTXT INDEX TAB_LINES.
            DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
            CLEAR OBJPACK-TRANSF_BIN.
            OBJPACK-HEAD_START = 1.
            OBJPACK-HEAD_NUM = 0.
            OBJPACK-BODY_START = 1.
            OBJPACK-BODY_NUM = TAB_LINES.
            OBJPACK-DOC_TYPE = 'RAW'.
            APPEND OBJPACK.
            CALL FUNCTION 'QCE1_CONVERT'
                 TABLES
                      T_SOURCE_TAB         = ILINES1
                      T_TARGET_TAB         = OBJBIN
                 EXCEPTIONS
                      CONVERT_NOT_POSSIBLE = 1
                      OTHERS               = 2.
            IF SY-SUBRC <> 0.
            ENDIF.
            DESCRIBE TABLE OBJBIN LINES TAB_LINES.
            OBJPACK-TRANSF_BIN = 'X'.
            OBJPACK-HEAD_START = 1.
            OBJPACK-HEAD_NUM = 1.
            OBJPACK-BODY_START = 1.
            OBJPACK-BODY_NUM = TAB_LINES.
            OBJPACK-DOC_TYPE = 'PDF'.
            OBJPACK-OBJ_NAME = 'test'.
            OBJPACK-OBJ_DESCR = VAFILENAME.
            OBJPACK-DOC_SIZE = TAB_LINES * 255.
            APPEND OBJPACK.
            OBJHEAD = 'test.PDF'.
            APPEND OBJHEAD.
            CLEAR OBJHEAD.
          VAFILENAME = 'Greetson'.
    Creating the recipient list(ERS).
              RECLIST-RECEIVER = '<e-mail address>'.
              RECLIST-REC_TYPE = 'U'.
              APPEND RECLIST.
              CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
                   EXPORTING
                        DOCUMENT_DATA              = DOC_CHNG
                        PUT_IN_OUTBOX              = 'X'
                   TABLES
                        PACKING_LIST               = OBJPACK
                        OBJECT_HEADER              = OBJHEAD
                        CONTENTS_BIN               = OBJBIN
                        CONTENTS_TXT               = OBJTXT
                        RECEIVERS                  = RECLIST
                   EXCEPTIONS
                        TOO_MANY_RECEIVERS         = 1
                        DOCUMENT_NOT_SENT          = 2
                        OPERATION_NO_AUTHORIZATION = 4
                        OTHERS                     = 99.
             IF SY-SUBRC <> 0.
            ENDIF.
            REFRESH RECLIST.
    Hope it helps.
    Thanks,
    Greetson

  • How to convert Sapscript into PDF in WDA

    Hi All,
    I have a requirement in Webdynpro in which I need to convert the Sap Script into PDF.
    Can you please tell me how to proceed ?
    Thanks in advance.
    Regards,
    Swapnil

    Hi,
    Check this document: Convert SAPScript to PDF file and instead of using gui_download/cl_gui* as mentioned in that doc, use CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE to open the PDF in WDA. You can refer that in this doc: Opening a Smartform in Web Dynpro ABAP
    Regards,
    Kiran

  • Sapscript 2 PDF conversion :when converted doesnt show printpreview

    Dear all
    Sapscript 2 PDF conversion :
      I hav used OTF under table parameter in Close_form & now it  doesnt show print preview(getting values OTF ) . Why ?
    How 2 get both print preview and PDF ?
    Thnx
    moni

    Hello,
    This may help you:
    itcpo-tdnoprint = ' '. "For Print option
    itcpo-tdgetotf = 'X'.  "to Get OTF
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
                device   = 'PRINTER'
                dialog   = 'X' " for the Print dialog
                form     = <formname>
                language = 'E'
                options  = itcpo
           IMPORTING
                result   = itcpp
           EXCEPTIONS
                canceled = 1
                device   = 2
                form     = 3
                options  = 4
                unclosed = 5
                mail_options = 6 
                archive_error = 7
                invalid_fax_number = 8
                more_params_needed_in_batch = 9
                spool_error = 10.
    Regds, Murugesh AS

  • Convert SapScripts into PDF

    I need to convert a few QM custom sapscript into PDF.
    I need to accomplish this and make the usability easier for the users
    I know we can do these 2 things
    1. I know we can use the standard sap program RSTXPDFT4 to convert the spool to PDF.
    2. Change the Print Program "Open Form" FM to get the OTF and converting the OTF to PDF.
    If I take the "changing the print program" route, i need to change all print programs. Which will be more effort.
    So i want to build a custom program, which take the inspection lot and file location as input, the program needs to generate the output programatically, get the spool, and run the program RSTXPDFT4.
    I need to figure out 1. how to issue the output from a program 2. how to get the spool number.
    Any help appreciated.
    Thanks,
    Gopi.

    Hi Gopi,
    Please go through this program,this is for smartform but you can use this in your script driver program.
    *& Report  YMSL_ORDER_ACCEPTANCE
    REPORT  YMSL_ORDER_ACCEPTANCE.
    *********Variable Declarations *****************************
    DATA: GV_FORM_NAME TYPE RS38L_FNAM, " Used to store the function module generated by Smartform
          GV_BIN_FILESIZE TYPE I, " Store the file size
          GV_POS TYPE I,
          GV_LEN TYPE I,
          GV_TAB_LINES TYPE I,
          gv_desc_lines type i.
    ********Constants *******************************************
    DATA : GC_TEXT(11) TYPE C VALUE 'Form Output',
           GC_TST(3) TYPE C VALUE 'TST',
           GC_TESTING(20) TYPE C VALUE 'Order Acceptance'.
    *********Work Area Declarations *****************************
    DATA: GS_DOCDATA TYPE SODOCCHGI1, " Data of an object which can be changed
          GS_CTRLOP TYPE SSFCTRLOP, " Smart Forms: Control structure
          GS_OUTOPT TYPE SSFCOMPOP, " SAP Smart Forms: Smart Composer (transfer) options
          GS_OTFDATA TYPE SSFCRESCL, " Smart Forms: Return value at end of form printing
          GS_RECLIST TYPE SOMLRECI1, " SAPoffice: Structure of the API Recipient List
          GS_PDF_TAB TYPE TLINE, " Workarea for SAP Script Text Lines
          GS_OBJBIN TYPE SOLISTI1, " SAPoffice: Single List with Column Length 255
          GS_OBJPACK TYPE SOPCKLSTI1. " SAPoffice: Description of Imported Object Components
    DATA : w_doc_chng typE sodocchgi1.
    *********Internal tables Declarations *****************************
    DATA : I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    DATA: GT_RECLIST TYPE TABLE OF SOMLRECI1, " SAPoffice: Structure of the API Recipient List
          GT_PDF_TAB TYPE TABLE OF TLINE, " SAPscript: Text Lines
          GT_OTF TYPE TABLE OF ITCOO, " OTF Structure
          GT_OBJBIN TYPE TABLE OF SOLISTI1, " SAPoffice: Single List with Column Length 255
          GT_OBJPACK TYPE TABLE OF SOPCKLSTI1. " SAPoffice: Description of Imported Object Components
    DATA : BEGIN OF IT_ADR6 OCCURS 0,
              SMTP_ADDR TYPE ADR6-SMTP_ADDR,
            END OF IT_ADR6.
    DATA : W_FILE_NAME TYPE STRING,
          W_FILE_PATH TYPE STRING,
          W_FULL_PATH TYPE STRING.
    CLEAR : GV_FORM_NAME,
            GS_CTRLOP,
            GS_OUTOPT,
            GS_OTFDATA,
            GV_BIN_FILESIZE,
            GV_POS,
            GV_LEN,
            GV_TAB_LINES.
    SELECTION-SCREEN:  BEGIN OF SCREEN 1001 AS WINDOW  TITLE scr_ttl .
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TXT_B1 NO INTERVALS.
    SELECTION-SCREEN BEGIN OF LINE .
    SELECTION-SCREEN COMMENT 1(15) TX_VBELN.
    PARAMETER : P_VBELN TYPE VBAK-VBELN .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B1.
    *SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TXT_B2 .
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: R_OUT RADIOBUTTON GROUP R1 DEFAULT 'X' USER-COMMAND RAD11 .
    SELECTION-SCREEN COMMENT 5(20) TXT_OUT.  "  roles by t-code
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETER R_PDF RADIOBUTTON GROUP R1 .
    SELECTION-SCREEN COMMENT 5(20) TXT_PDF.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETER R_MAIL RADIOBUTTON GROUP R1 .
    SELECTION-SCREEN COMMENT 5(15) TXT_MAIL.
    *SELECTION-SCREEN END OF LINE.
    *SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 20(7) TXT_MAL1.
    PARAMETER : P_MAIL TYPE ADR6-SMTP_ADDR MODIF ID M1.
    SELECTION-SCREEN END OF LINE.
    *SELECTION-SCREEN END OF BLOCK B2.
    SELECTION-SCREEN: END OF SCREEN 1001 .
    CALL SELECTION-SCREEN 1001 STARTING AT 20 5 ENDING AT 105 10.
    *SET PF-STATUS 'STATUS'.
    INITIALIZATION.
      TX_VBELN = 'Order'.
      TXT_B1 = 'Selection Criteria '.
    TXT_B2 = 'Output Criteria '.
      scr_ttl = 'Order Acceptance'.
      TXT_OUT = 'Print Output'.
      TXT_PDF = 'Save To PDF'.
      TXT_MAIL = 'Mail the Output'.
      TXT_MAL1 = 'E-mail'.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF R_MAIL <> 'X'.
          IF SCREEN-GROUP1 = 'M1'.
           SCREEN-INVISIBLE =  1.
            SCREEN-INPUT = 0. " Disable for input.
            MODIFY SCREEN.
          ENDIF.
        ENDIF.
      ENDLOOP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MAIL.
      PERFORM TABLE_HELP.
    START-OF-SELECTION..
    IF P_VBELN IS NOT INITIAL.
        PERFORM GET_SF.
        IF R_PDF = 'X' .
          PERFORM CONVERT_OTF.
          PERFORM SAVE_DIALOG.
          PERFORM DOWNLOAD.
        ELSEIF R_MAIL = 'X'.
          IF P_MAIL IS NOT INITIAL.
           PERFORM CONVERT_OTF.
           PERFORM SEND_MAIL.
          ELSE.
            MESSAGE 'Please Enter Email Address' TYPE 'S'.
            CALL TRANSACTION 'YMSL20'.
            LEAVE LIST-PROCESSING.
          ENDIF.
        ENDIF.
    ELSE.
       MESSAGE 'Please Enter Order No' TYPE 'S'.
         CALL TRANSACTION 'YMSL20'.
         LEAVE LIST-PROCESSING.
    *ENDIF.
    END-OF-SELECTION.
    *&      Form  TABLE_HELP
    FORM TABLE_HELP .
      IF R_MAIL = 'X'.
        SELECT SMTP_ADDR FROM ADR6 INTO TABLE IT_ADR6.
        SORT IT_ADR6.
        DELETE ADJACENT DUPLICATES FROM IT_ADR6 COMPARING ALL FIELDS.
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
        DDIC_STRUCTURE         = ' '
            RETFIELD               = 'IT_ADR6-SMTP_ADDR'
        PVALKEY                = ' '
           DYNPPROG               = SY-REPID
           DYNPNR                 = SY-DYNNR
           DYNPROFIELD            = 'EMAIL'
        STEPL                  = 0
           WINDOW_TITLE           = 'SELECT MAIL ADDRESS'
        VALUE                  = ' '
           VALUE_ORG              = 'S'
        MULTIPLE_CHOICE        = ' '
        DISPLAY                = ' '
        CALLBACK_PROGRAM       = ' '
        CALLBACK_FORM          = ' '
        MARK_TAB               =
      IMPORTING
        USER_RESET             =
          TABLES
            VALUE_TAB              = IT_ADR6
        FIELD_TAB              =
        RETURN_TAB             =
        DYNPFLD_MAPPING        =
      EXCEPTIONS
        PARAMETER_ERROR        = 1
        NO_VALUES_FOUND        = 2
        OTHERS                 = 3
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
    ENDFORM.                    " TABLE_HELP
    *&      Form  GET_SF
    FORM GET_SF .
    *u2022 Generate Function Module name
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME           = 'Z_CHK'
        IMPORTING
          FM_NAME            = GV_FORM_NAME
        EXCEPTIONS
          NO_FORM            = 1
          NO_FUNCTION_MODULE = 2
          OTHERS             = 3.
      IF SY-SUBRC  <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *u2022 Assigning values to Form Control Structure and Form Composer
      IF R_OUT <> 'X'.
        GS_CTRLOP-GETOTF = 'X'.
        GS_CTRLOP-NO_DIALOG = 'X'.
        GS_OUTOPT-TDNOPREV = 'X'.
      ENDIF.
    */1BCDWB/SF00000368
    CALL FUNCTION  GV_FORM_NAME "'/1BCDWB/SF00000368'
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = GS_CTRLOP
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
       OUTPUT_OPTIONS             = GS_OUTOPT
       USER_SETTINGS              = 'X'
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
       JOB_OUTPUT_INFO            = GS_OTFDATA
      JOB_OUTPUT_OPTIONS         =
    EXCEPTIONS
      FORMATTING_ERROR           = 1
      INTERNAL_ERROR             = 2
      SEND_ERROR                 = 3
      USER_CANCELED              = 4
      OTHERS                     = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION GV_FORM_NAME
       EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
         CONTROL_PARAMETERS         = GS_CTRLOP
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
         OUTPUT_OPTIONS             = GS_OUTOPT
         USER_SETTINGS              = 'X'
         TEMP_VBELN                 =  P_VBELN
      IMPORTING
      DOCUMENT_OUTPUT_INFO       =
         JOB_OUTPUT_INFO            = GS_OTFDATA
      JOB_OUTPUT_OPTIONS         =
      EXCEPTIONS
        FORMATTING_ERROR           = 1
        INTERNAL_ERROR             = 2
        SEND_ERROR                 = 3
        USER_CANCELED              = 4
        OTHERS                     = 5
    IF SY-SUBRC <> 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " GET_SF
    *&      Form  CONVERT_OTF
    FORM CONVERT_OTF .
    *u2022 Assigning the OTFDATA to OTF Structure table
      CLEAR GT_OTF.
      GT_OTF[] = GS_OTFDATA-OTFDATA[].
    *u2022 Convert the OTF DATA to SAP Script Text lines
      CLEAR GT_PDF_TAB.
      CALL FUNCTION 'CONVERT_OTF'
       EXPORTING
         FORMAT                      = 'PDF'
         MAX_LINEWIDTH               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
      PDF_DELETE_OTFTAB           = ' '
       IMPORTING
         BIN_FILESIZE                = GV_BIN_FILESIZE
      BIN_FILE                    =
        TABLES
          OTF                         = GT_OTF
          LINES                       = GT_PDF_TAB
       EXCEPTIONS
         ERR_MAX_LINEWIDTH           = 1
         ERR_FORMAT                  = 2
         ERR_CONV_NOT_POSSIBLE       = 3
         ERR_BAD_OTF                 = 4
         OTHERS                      = 5
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *t_otf[] = t_otf_from_fm-otfdata[].
    Function Module CONVERT_OTF is used to convert the OTF format to PDF
    *CALL FUNCTION 'CONVERT_OTF'
    *EXPORTING
    *FORMAT = 'PDF'
    *MAX_LINEWIDTH = 132
    ARCHIVE_INDEX = ' '
    COPYNUMBER = 0
    ASCII_BIDI_VIS2LOG = ' '
    PDF_DELETE_OTFTAB = ' '
    *IMPORTING
    *BIN_FILESIZE = W_bin_filesize
    BIN_FILE =
    *TABLES
    *otf = T_OTF
    *lines = T_pdf_tab
    *EXCEPTIONS
    *ERR_MAX_LINEWIDTH = 1
    *ERR_FORMAT = 2
    *ERR_CONV_NOT_POSSIBLE = 3
    *ERR_BAD_OTF = 4
    *OTHERS = 5
    *IF sy-subrc <> 0.
    *MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    ENDFORM.                    " CONVERT_OTF
    *&      Form  SAVE_DIALOG
    FORM SAVE_DIALOG .
    To display File SAVE dialog window
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
       EXPORTING
       WINDOW_TITLE = 'Download to PDF '
    DEFAULT_EXTENSION = '(*.PDF)'
       DEFAULT_FILE_NAME = 'file.pdf'
       FILE_FILTER = 'PDF Format(*.PDF)'
       INITIAL_DIRECTORY = 'C:\Documents and Settings\Administrator\Desktop'
    WITH_ENCODING =
       PROMPT_ON_OVERWRITE = 'X'
      CHANGING
      FILENAME = W_FILE_NAME
      PATH = W_FILE_PATH
      FULLPATH = W_FULL_PATH
    USER_ACTION =
    FILE_ENCODING =
      EXCEPTIONS
      CNTL_ERROR = 1
      ERROR_NO_GUI = 2
      NOT_SUPPORTED_BY_GUI = 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.
    ENDFORM.                    " SAVE_DIALOG
    *&      Form  DOWNLOAD
    FORM DOWNLOAD .
    Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
    presentation server
      CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE = GV_BIN_FILESIZE
      FILENAME = W_FULL_PATH
      FILETYPE = 'BIN'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = ' '
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
      TABLES
      DATA_TAB = GT_PDF_TAB
    FIELDNAMES =
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DOWNLOAD
    *&      Form  SEND_MAIL
    FORM SEND_MAIL .
    ***changes by rajan
    *DATA : v_first TYPE USER_ADDR-NAME_FIRST,
         V_LAST   TYPE USER_ADDR-NAME_LAST.
    DATA : detail TYPE STRING.
    *SELECT SINGLE NAME_FIRST NAME_LAST FROM
    USER_ADDR INTO (V_FIRST,V_LAST)
    WHERE BNAME = syst-UNAME.
    CONCATENATE v_first V_LAST INTO detail SEPARATED BY space.
    data : v_po_no TYPE vbkd-bstkd,
          v_po_date TYPE vbkd-bstdk.
    data : day TYPE STRING,
           month type STRING,
           year  TYPE STRING.
    data : date TYPE STRING.
    SELECT SINGLE BSTKD BSTDK
      FROM VBKD
      INTO (v_po_no,v_po_date)
      WHERE VBELN = P_VBELN.
    day = v_po_date+6(2).
    month = v_po_date+4(2).
    year = v_po_date+0(4).
    CONCATENATE day '/' month '/' year INTO date.
      CONCATENATE 'Please Find attached Order Acceptance against your P.O.No.' v_po_no 'dated' date  '.' INTO detail SEPARATED BY space.
    **u2022 Assigning the Description of the object sent in the mail
    CLEAR GS_DOCDATA.
    GS_DOCDATA-OBJ_NAME = GC_TST.
    GS_DOCDATA-OBJ_DESCR = GC_TESTING.
    *u2022 Assigning the email id to Structure of the API Recipient List table
      CLEAR : GT_RECLIST, GS_RECLIST.
      GS_RECLIST-RECEIVER =  P_MAIL.       "
      GS_RECLIST-REC_TYPE = 'U'."'G' ."'O'. "'B'. "'U'.
      APPEND GS_RECLIST TO GT_RECLIST.
    mail body rajan
      I_OBJTXT = 'Dear Sir/Madam.'.
      APPEND I_OBJTXT.
      I_OBJTXT = detail.
      APPEND I_OBJTXT.
      I_OBJTXT = ''.
      APPEND I_OBJTXT.
      I_OBJTXT = 'Thanks.'.
      APPEND I_OBJTXT.
      I_OBJTXT = 'Best Regards,'.
      APPEND I_OBJTXT.
      I_OBJTXT = 'For Bilcare Ltd.'.
      APPEND I_OBJTXT.
      DESCRIBE TABLE i_objtxt LINES gv_desc_lines.
    *DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      CLEAR I_OBJTXT.
      READ TABLE I_OBJTXT INDEX gv_desc_lines.
      if sy-subrc = 0.
    Document information.
    GS_DOCDATA-obj_name = 'ord_accept'.
    GS_DOCDATA-expiry_dat = sy-datum + 10.
    GS_DOCDATA-obj_descr = 'Order Acceptance'.
    GS_DOCDATA-sensitivty = 'F'. "Functional object
    GS_DOCDATA-doc_size = gv_desc_lines * 255.
    CLEAR Gs_OBJPACK-transf_bin.
    Start line of object header in transport packet
       GS_OBJPACK-TRANSF_BIN = 'X'.
        GS_OBJPACK-doc_size = gv_desc_lines * 255.
        GS_OBJPACK-HEAD_START = 1.
        GS_OBJPACK-HEAD_NUM = 0.
        GS_OBJPACK-BODY_START = 1.
        GS_OBJPACK-BODY_NUM = gv_desc_lines.
        GS_OBJPACK-DOC_TYPE = 'RAW'.
       GS_OBJPACK-OBJ_NAME = 'ORDER_ACCEPTANCE'.
       GS_OBJPACK-OBJ_DESCR = 'ORDER_ACCEPTANCE.PDF'.
        APPEND GS_OBJPACK TO GT_OBJPACK.
    GS_OBJPACK-HEAD_START = 1.
       GS_OBJPACK-HEAD_NUM = 0.
       GS_OBJPACK-BODY_START = 1.
    GS_OBJPACK-doc_type = 'RAW'.
    *APPEND GS_OBJPACK TO GT_OBJPACK.
      ENDIF.
    *u2022 Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
      CLEAR : GS_OBJBIN, GS_PDF_TAB.
      LOOP AT GT_PDF_TAB INTO GS_PDF_TAB.
        GV_POS = 255 - GV_LEN.
        IF GV_POS > 134. "length of pdf_table
          GV_POS = 134.
        ENDIF.
        GS_OBJBIN+GV_LEN = GS_PDF_TAB(GV_POS).
        GV_LEN = GV_LEN + GV_POS.
        IF GV_LEN = 255. "length of out (contents_bin)
          APPEND GS_OBJBIN TO GT_OBJBIN.
          CLEAR: GS_OBJBIN, GV_LEN.
          IF GV_POS < 134.
            GS_OBJBIN = GS_PDF_TAB+GV_POS.
            GV_LEN = 134 - GV_POS.
          ENDIF.
        ENDIF.
      ENDLOOP.
      IF GV_LEN > 0.
        APPEND GS_OBJBIN TO GT_OBJBIN.
      ENDIF.
    *u2022 Filling the details in SAPoffice: Description of Imported Object Components table
      DESCRIBE TABLE GT_OBJBIN LINES GV_TAB_LINES.
      CLEAR GS_OBJBIN.
      READ TABLE GT_OBJBIN INTO GS_OBJBIN INDEX GV_TAB_LINES.
        IF SY-SUBRC = 0.
        GS_OBJPACK-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255 + STRLEN( GS_OBJBIN ).
        GS_OBJPACK-TRANSF_BIN = 'X'.
        GS_OBJPACK-HEAD_START = 1.
        GS_OBJPACK-HEAD_NUM = 0.
        GS_OBJPACK-BODY_START = 1.
        GS_OBJPACK-BODY_NUM = GV_TAB_LINES.
        GS_OBJPACK-DOC_TYPE = 'PDF'.
        GS_OBJPACK-OBJ_NAME = 'ORDER_ACCEPTANCE'.
        GS_OBJPACK-OBJ_DESCR = 'Order Acceptance'.
        APPEND GS_OBJPACK TO GT_OBJPACK.
      ENDIF.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA                    = GS_DOCDATA
         PUT_IN_OUTBOX                    = 'X'
         COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
        TABLES
          PACKING_LIST                     = GT_OBJPACK
      OBJECT_HEADER                    =  I_OBJTXT
         CONTENTS_BIN                     = GT_OBJBIN
         CONTENTS_TXT                     = I_OBJTXT
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
          RECEIVERS                        = GT_RECLIST
       EXCEPTIONS
         TOO_MANY_RECEIVERS               = 1
         DOCUMENT_NOT_SENT                = 2
         DOCUMENT_TYPE_NOT_EXIST          = 3
         OPERATION_NO_AUTHORIZATION       = 4
         PARAMETER_ERROR                  = 5
         X_ERROR                          = 6
         ENQUEUE_ERROR                    = 7
         OTHERS                           = 8
      IF SY-SUBRC <> 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
       WRITE 'Sent Successfully'.
        MESSAGE 'Sent Successfully' TYPE 'I'.
         CALL TRANSACTION 'YMSL20'.
         LEAVE LIST-PROCESSING.
      ENDIF.
      SUBMIT RSCONN01
      WITH MODE EQ 'INT'
      AND RETURN.
    ENDFORM.                    " SEND_MAIL
    Thanks
    Ankur Sharma

  • Conversion SAPSCRIPT to PDF and send per mail

    Hi all,
    I would like to send a sapscript per mail as PDF attachment. I checked on the forum and followed some threads for that, but I still have a problem :
    - I'm using the open_form function with ITCPO-TDGETOTF = 'X'
    - in the CLOSE_FORM i get the OTF data in the internal table it_otf
    CALL FUNCTION 'CLOSE_FORM'
    TABLES
       OTFDATA                        = it_otf
    - than I'm using the function: (it_otf as input it_pdf as output table): 
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       FORMAT                      = 'PDF'
       MAX_LINEWIDTH               = 132
        PDF_DELETE_OTFTAB           = 'X'
    IMPORTING
        BIN_FILESIZE                = W_bin_filesize
        BIN_FILE                    = g_binfile
      TABLES
        OTF                         = it_otf
        LINES                       = it_pdf
    this function dumps with the message : "*255" nicht als Zahl interpretierbar
    what' wrong ?
    thank you in advance for your help.

    Hi Fred,
    I'm with this issue and doing exactly what you said, but it is not working.
    Below my code. Is it missing something?
    1 - tb_otf is retrieving the correct values.
    CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
             RESULT  = RESULT
           tables
             otfdata = tb_otf.
    2 - c_binfile is populated correctly but nothing happens with table lt_otf 
    CALL FUNCTION 'CONVERT_OTF'
         EXPORTING
           FORMAT                      = 'PDF'
           MAX_LINEWIDTH               = 132
           PDF_DELETE_OTFTAB           = ' '
         IMPORTING
           BIN_FILESIZE                = L_SIZE
           BIN_FILE                    = c_binfile
         TABLES
           OTF                         = tb_otf
           LINES                       = lt_otf.
    3 - lt_solix is populated correctly
    DATA : BEGIN OF lt_solix OCCURS 0,
             line TYPE x LENGTH 255,
             END OF lt_solix.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
       EXPORTING
         buffer                = c_binfile
       TABLES
         binary_tab            = lt_solix.
    4 - data packing all right
    *   E-mail body
        CLEAR lt_packing_list.
        REFRESH lt_packing_list.
        lt_packing_list-transf_bin = ''.
        lt_packing_list-head_start = 1.
        lt_packing_list-head_num   = 0.
        lt_packing_list-body_start = 1.
        lt_packing_list-body_num   = l_numbytes.
        lt_packing_list-doc_type   = 'RAW'.
        lt_packing_list-obj_name   = 'BODY'.
        lt_packing_list-obj_descr  = 'CORPO'.
        lt_packing_list-doc_size   = l_numbytes.
        APPEND lt_packing_list.
    *   E-mail attachment
        lt_packing_list-transf_bin = 'X'.
        lt_packing_list-head_start = 1.
        lt_packing_list-head_num   = 0.
        lt_packing_list-body_start = 1.
        lt_packing_list-body_num   = l_numbytes.
        lt_packing_list-doc_type   = 'PDF'.
        lt_packing_list-obj_descr  = nast-objky.
        lt_packing_list-obj_name   = 'PICTURE'.
        lt_packing_list-doc_size   = l_numbytes.
        APPEND lt_packing_list.
    5 - send e-mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
             document_data              = wa_document_data
             put_in_outbox              = 'X'
            commit_work                = 'X'
          TABLES
            packing_list               = lt_packing_list
            object_header              = lt_object_header
    *        contents_bin               = lt_objbin
    contents_HEX = lt_solix
            contents_txt               = lt_contents_txt
            receivers                  = lt_receivers
          EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            OTHERS                     = 8.
    When I check SOST transaction I see the e-mail but the body content I cant see and the attachment I cant open.
    The same logic was working in version 5.0 (now we're in 6.0). But it was using content_bin parameter which is obsolete now, from now we need to use to content_hex parameter.
    Please, could you help me?
    Thanks

  • Convert SAPSCRIPT to PDF and send to FAX

    Hi All,
    Currently i am having customized sapscript.
    1.) I have to convert it to PDF. How to convert to PDF.
    2.) Then i need to send PDF to FAX. How.
    What are the code required to change and add.
    What is OTF output, which is easier to fax. PDF or OTF output.
    With Regards,
    Vinoth

    Hi Code,
    Refer this sample code.
    DATA: t_otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
          t_pdf LIKE tline OCCURS 100 WITH HEADER LINE,
          t_opt like itcpo occurs 0 with header line.  
    data:
       w_flag     type i,                   " Temporary flag
      w_control  type ssfctrlop,           " Control parameters
      w_output   type ssfcompop,           " Output options
      w_return   type ssfcrescl,           " Job output info
      w_filesize type sood-objlen,         " Bin file size
      w_string   type string,              " To convert from 132 to 255
      w_msg      type i,                   " Message length
      w_docdata  type sodocchgi1,          " Document data
      w_objbin   type i,                   " Contents bin
      w_sender   type soextreci1-receiver. " Sender
    t_opt-TDGETOTF = 'X'.
    append t_opt.
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
       APPLICATION                       = 'TX'
       FORM                              = 'ZTEST_SCRIPT1'
       LANGUAGE                          = SY-LANGU
       OPTIONS                           = t_opt 
    EXCEPTIONS
       CANCELED                          = 1
       DEVICE                            = 2
       FORM                              = 3
       OPTIONS                           = 4
       UNCLOSED                          = 5
       MAIL_OPTIONS                      = 6
       ARCHIVE_ERROR                     = 7
       INVALID_FAX_NUMBER                = 8
       MORE_PARAMS_NEEDED_IN_BATCH       = 9
       SPOOL_ERROR                       = 10
       CODEPAGE                          = 11
       OTHERS                            = 12
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
       ELEMENT                        = 'TEXT'
       FUNCTION                       = 'SET'
       TYPE                           = 'BODY'
       WINDOW                         = 'HEADER'
    * IMPORTING
    *   PENDING_LINES                  =
    * EXCEPTIONS
    *   ELEMENT                        = 1
    *   FUNCTION                       = 2
    *   TYPE                           = 3
    *   UNOPENED                       = 4
    *   UNSTARTED                      = 5
    *   WINDOW                         = 6
    *   BAD_PAGEFORMAT_FOR_PRINT       = 7
    *   SPOOL_ERROR                    = 8
    *   CODEPAGE                       = 9
    *   OTHERS                         = 10
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'CLOSE_FORM'
    * IMPORTING
    *   RESULT                         =
    *   RDI_RESULT                     =
    TABLES
       OTFDATA                        = t_otf
    EXCEPTIONS
       UNOPENED                       = 1
       BAD_PAGEFORMAT_FOR_PRINT       = 2
       SEND_ERROR                     = 3
       SPOOL_ERROR                    = 4
       CODEPAGE                       = 5
       OTHERS                         = 6
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       format                      = 'PDF'
    *   MAX_LINEWIDTH               = 132
    *   ARCHIVE_INDEX               = ' '
    *   COPYNUMBER                  = 0
    *   ASCII_BIDI_VIS2LOG          = ' '
    *   PDF_DELETE_OTFTAB           = ' '
    * IMPORTING
    *   BIN_FILESIZE                =
    *   BIN_FILE                    =
      TABLES
        otf                         = t_otf
        lines                       = t_line
    EXCEPTIONS
       ERR_MAX_LINEWIDTH           = 1
       ERR_FORMAT                  = 2
       ERR_CONV_NOT_POSSIBLE       = 3
       ERR_BAD_OTF                 = 4
       OTHERS                      = 5
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
        loop at t_line.
          concatenate w_string t_line into w_string.
        endloop.                           " LOOP AT T_LINE
    *" convert the 132 line character to 255 character ....................
        do.
          t_attach = w_string.
          append t_attach.
          shift w_string left by 255 places.
          if w_string is initial.
            exit.
          endif.                           " IF W_STRING IS INITIAL
        enddo.                             " DO
        t_objbin[] = t_attach[].
    *" Body of the mail..................................................
        clear t_message. refresh t_message.
        t_message = 'This is a mail from SAP ECC6'.
        append t_message.
        t_message = 'Thanks and Regards'.
        append t_message.
        t_message = 'Sravanthi'.
        append t_message.
        describe table t_message lines w_msg.
    *" Document data.......................................................
        w_docdata-obj_name = 'SAPRPT'.
        w_docdata-expiry_dat = sy-datum + 10.
        w_docdata-obj_descr = 'This mail from Sravanthi'.
        w_docdata-sensitivty = 'F'.
        w_docdata-doc_size = w_msg * 255.
        w_docdata-obj_langu = sy-langu .
    *" Fill the packing list...............................................
        clear t_packing_list. refresh t_packing_list.
        t_packing_list-transf_bin = space.
        t_packing_list-head_start = 1.
        t_packing_list-head_num = 0.
        t_packing_list-body_start = 1.
        t_packing_list-body_num = w_msg.
        t_packing_list-doc_type = 'RAW'.
        append t_packing_list.
        t_packing_list-transf_bin = 'X'.
        describe table t_objbin lines w_objbin.
    *" doc_size = (lines in pdf table) * 255...............................
        t_packing_list-doc_size = w_objbin * 255.
        t_packing_list-body_num = w_objbin.
        t_packing_list-doc_type = 'PDF'.
        t_packing_list-obj_name = 'smart'.
        t_packing_list-obj_descr = 'test'.
        append t_packing_list.
    *" Fill the receiver parameters........................................
        if p_mail eq 'X'.
          clear t_receivers.
          t_receivers-receiver = p_mailid.
          t_receivers-rec_type = 'U'.
          append t_receivers.
    *" Fax.................................................................
        elseif p_fax eq 'X'.
          clear t_receivers.
          t_receivers-receiver = p_faxno.
          t_receivers-rec_type = 'F'.
          t_receivers-com_type = 'FAX'.
          append t_receivers.
        endif.                             " IF P_MAIL EQ 'X'
        w_sender = 'SAPDEV02'.
    *  FUNCTION MODULE SO_DOCUMENT_SEND_API1                              *
    *  This function module enables you send a new document including any *
    *  existing attachments. The document and the attachments are         *
    *  transferred in the same table. They are created when sent and can  *
    *  also be placed in the sender's outbox.                             *
        call function 'SO_DOCUMENT_SEND_API1'
          exporting
            document_data              = w_docdata
            put_in_outbox              = 'X'
            sender_address             = w_sender
            commit_work                = 'X'
          tables
            packing_list               = t_packing_list
            contents_bin               = t_objbin
            contents_txt               = t_message
            receivers                  = t_receivers
          exceptions
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7.
        if sy-subrc ne 0.
          write:/ 'Error When Sending the File', sy-subrc.
        else.
          write:/ 'Mail sent'.
        endif.
      elseif p_fax eq 'X'.
      endif.
    Regards,
    Sravanthi

  • Sending SAPSCRIPT in PDF through email

    Hi everybody,
    I'm trying to send via email a sapscript. I red more posts regarding this issue but nothing seems to run correctly.
    Some posts refers to a sample program ZRICH_0003.
    I've just copied the code and replaced the form's name with one of mine and run it.
    The function SO_NEW_DOCUMENT_ATT_SEND_API1 return with error code 2 (document not sent). I really don't know why. I've just run it in two different SAP (4.7 and 5.0)
    Both didn't work. Both systems are UNIX. Must I do something in customizing or some RFC definition?
    Is there anybody that have a simple program that uses this function? 
    Thanks in advance
    Fabrizio

    i have tried the same thing. first generating spool & then convering sppol to PDF.
    REPORT  ZPO_PDF NO STANDARD PAGE HEADING
      LINE-SIZE 254.
    converts list to PDF - send via mail as attachment
    TABLES: adrp,  "Persons (central address administration)
            bhdgd, "Common data area batch heading routine
            bsik,  "Accounting: Secondary Index for Vendors
            usr21. "Assign user name address key
    General data definition
    TYPE-POOLS: icon.
    TYPE-POOLS: slis.
    DATA: d_linsz            LIKE sy-linsz.
    Constants
    CONSTANTS: c_yes(1)        TYPE c VALUE 'X'.
    Structures
    DATA: e_variant  TYPE disvariant.
    Selection-screen
      DATA: le_parameters LIKE pri_params.
      DATA: l_valid(1) TYPE c.
      DATA: lt_pdf TYPE TABLE OF tline WITH HEADER LINE.
      DATA: l_spool_c LIKE tsp01_sp0r-rqid_char.
      DATA: l_spool_i LIKE tsp01-rqident,
            _RECEIVER LIKE bsik-xref3.
    Get the SPOOL number
    PARAMETERS:
      spoolno LIKE TSP01-RQIDENT.
      l_spool_i =  spoolno.
    DATA: NUMBYTES TYPE I,
          ARC_IDX LIKE TOA_DARA,
          pdfspoolid like tsp01-rqident,
          jobname like tbtcjob-jobname,
          jobcount like tbtcjob-jobcount,
          is_otf.
    DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
          EXPORTING
            SRC_SPOOLID                    = l_spool_i
            NO_DIALOG                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
          IMPORTING
            PDF_BYTECOUNT                  = numbytes
            PDF_SPOOLID                    = pdfspoolid
          OTF_PAGECOUNT                  =
            BTC_JOBNAME                    = jobname
            BTC_JOBCOUNT                   = jobcount
          TABLES
            PDF                            = lt_pdf
          EXCEPTIONS
            ERR_NO_OTF_SPOOLJOB            = 1
            ERR_NO_SPOOLJOB                = 2
            ERR_NO_PERMISSION              = 3
            ERR_CONV_NOT_POSSIBLE          = 4
            ERR_BAD_DSTDEVICE              = 5
            USER_CANCELLED                 = 6
            ERR_SPOOLERROR                 = 7
            ERR_TEMSEERROR                 = 8
            ERR_BTCJOB_OPEN_FAILED         = 9
            ERR_BTCJOB_SUBMIT_FAILED       = 10
            ERR_BTCJOB_CLOSE_FAILED        = 11.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Build the mail
      PERFORM build_mail
        TABLES lt_pdf
        USING _receiver.
    FORM prepare_print_format USING parameters LIKE priparams.
      DATA: BEGIN OF lt_report_source OCCURS 0,
              line(72) TYPE c,
            END OF lt_report_source.
      DATA: l_string_linsz TYPE string.
      DATA: l_tabix LIKE sy-tabix.
      DATA: BEGIN OF lt_sentencia OCCURS 0,
              line(72) TYPE c,
            END OF lt_sentencia.
      DATA: lt_tsp1d TYPE TABLE OF tsp1d WITH HEADER LINE.
      READ REPORT sy-repid INTO lt_report_source.
      CHECK sy-subrc = 0.
      CLEAR: l_tabix.
      WHILE NOT l_string_linsz CS '.'.
        ADD 1 TO l_tabix.
        READ TABLE lt_report_source
          INDEX l_tabix.
        TRANSLATE lt_report_source-line TO UPPER CASE.
        IF l_string_linsz CS 'REPORT'
          OR lt_report_source-line CS 'REPORT'.
          CONCATENATE l_string_linsz
                      lt_report_source-line
            INTO l_string_linsz
            SEPARATED BY space.
          CONDENSE l_string_linsz.
        ENDIF.
      ENDWHILE.
      TRANSLATE l_string_linsz USING '. '.
      CLEAR: lt_report_source.
      REFRESH: lt_report_source.
      FREE: lt_report_source.
      SPLIT l_string_linsz AT space INTO TABLE lt_sentencia.
      LOOP AT lt_sentencia
        WHERE line CS 'LINE-SIZE'.
        l_tabix = sy-tabix.
        EXIT.
      ENDLOOP.
      ADD 1 TO l_tabix.
      READ TABLE lt_sentencia
        INDEX l_tabix.
      SELECT *
        INTO CORRESPONDING FIELDS OF TABLE lt_tsp1d
        FROM tsp1d
        WHERE type = 'L'
          AND outcolumns >= lt_sentencia-line.
      SORT lt_tsp1d
        BY outcolumns.
      READ TABLE lt_tsp1d
        INDEX 1.
      parameters-linct = lttsp1d-outrows.
      parameters-linsz = ltsentencia-line.
      parameters-paart = lttsp1d-papart.
    ENDFORM.                    " prepare_print_format
    FORM build_mail     TABLES tpdf STRUCTURE tline
                        USING _receiver TYPE c.
      DATA: l_length_t_pdf TYPE i.
      DATA: l_string TYPE xstring.
      DATA: l_string_bck TYPE string.
      DATA: l_length_string TYPE i.
      DATA: l_length_objbin TYPE i.
      DATA: l_max_tabix TYPE i.
      DATA: l_dif TYPE i.
      DATA: l_hex_null TYPE x VALUE '00'.
      DATA: lt_objtxt           LIKE solisti1   OCCURS 10 WITH HEADER LINE.
      DATA: l_tab_lines         LIKE sy-tabix.
      DATA: le_doc_chng         LIKE sodocchgi1.
      DATA: lt_objpack          LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA: lt_objhead          LIKE solisti1   OCCURS 1 WITH HEADER LINE.
      DATA: lt_reclist          LIKE somlreci1  OCCURS 5 WITH HEADER LINE.
      DATA: lt_contents_bin     LIKE solisti1   OCCURS 0 WITH HEADER LINE.
    Mail text
    (...here you should fill table lt_objtxt-line)
      lt_objtxt-line = 'First line of text'.
      append lt_objtxt.
      lt_objtxt-line = 'Second line'.
      append lt_objtxt.
      DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
      READ TABLE lt_objtxt INDEX l_tab_lines.
      le_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255
                             + STRLEN( lt_objtxt ).
      le_doc_chng-obj_descr = 'PO in PDF By mail'.
      CLEAR lt_objpack-transf_bin.
      lt_objpack-head_start = 1.
      lt_objpack-head_num   = 0.
      lt_objpack-body_start = 1.
      lt_objpack-body_num   = l_tab_lines.
      lt_objpack-doc_type   = 'RAW'.
      APPEND lt_objpack.
    Attached file, in PDF-format
      DESCRIBE FIELD tpdf LENGTH l_length_t_pdf.
      CLEAR: l_string_bck,
             l_string.
      LOOP AT tpdf.
        CONCATENATE l_string_bck tpdf INTO l_string_bck.
        l_dif = l_length_t_pdf - STRLEN( tpdf ).
        DO l_dif TIMES.
          CONCATENATE l_string_bck l_hex_null INTO l_string_bck.
        ENDDO.
        CONCATENATE l_string tpdf INTO l_string.
      ENDLOOP.
      sy-subrc = 0.
      WHILE sy-subrc = 0.
        REPLACE l_hex_null WITH space INTO l_string_bck.
      ENDWHILE.
      l_length_string = strlen( l_string_bck ).
      DESCRIBE FIELD lt_contents_bin LENGTH l_length_objbin.
      l_max_tabix = ceil( l_length_string / l_length_objbin * '1.0' ).
      DO l_max_tabix TIMES.
        lt_contents_bin = l_string_bck.
        APPEND lt_contents_bin.
        IF sy-tabix <> l_max_tabix.
          l_string_bck = l_string_bck+l_length_objbin.
        ENDIF.
      ENDDO.
      DESCRIBE TABLE lt_contents_bin LINES l_tab_lines.
      APPEND lt_objhead.
      lt_objpack-transf_bin = c_yes.
      lt_objpack-head_start = 1.
      lt_objpack-head_num   = 1.
      lt_objpack-body_start = 1.
      lt_objpack-body_num   = l_tab_lines.
      lt_objpack-doc_type   = 'PDF'.
      lt_objpack-doc_size   = ( l_tab_lines - 1 ) * 255.
      LOOP AT lt_contents_bin.
      ENDLOOP.
      lt_objpack-doc_size = lt_objpack-doc_size + STRLEN( lt_contents_bin ).
      APPEND lt_objpack.
    lt_reclist-receiver = 'testmailgmail.com'.
      lt_reclist-rec_type = 'U'.
      APPEND lt_reclist.
    Finally! we send the mail
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data                    = le_doc_chng
          put_in_outbox                    = c_yes
        TABLES
          packing_list                     = lt_objpack
          object_header                    = lt_objhead
          contents_bin                     = lt_contents_bin
         contents_hex                     =
          contents_txt                     = lt_objtxt
          receivers                        = lt_reclist
        EXCEPTIONS
          too_many_receivers               = 1
          document_not_sent                = 2
          document_type_not_exist          = 3
          operation_no_authorization       = 4
          parameter_error                  = 5
          x_error                          = 6
          enqueue_error                    = 7
          OTHERS                           = 8.
    ENDFORM.                    " build_mail

  • SAPscript to PDF in SAP 4.0B - Logo Not appearing correctly

    Hi Gurus,
    I have an issue where I am converting a Sapscript to a PDF using CONVERT_OTF Function Module. The PDF is being generated correctly but the logos are appearing in other places or not appearing at all. The SAP Version is SAP 4.0B (Really old one) so the function modules available to convert from OTF Data to PDF are very limited.
    I searched the web and SDN and found several threads but all of them in version 4.6x on wards.
    Any idea why this is going on and how can I solve it?
    Thanks & Regards,
    Ernesto.

    Hi,
    While calling FM CONVERT_OTFSPOOLJOB_2_PDF, pass import parameter Country Key to SRC_SPOOLID.
    i.e. SRC_SPOOLID-RQTELELAN.
    I feel this should solve the problem.
    Best regards,
    Prashant

  • Sapscript as PDF-Attachment in Workflow

    Hi Experts,
    I am trying to create a new workflow for releasing purchase orders.
    If the workitem passes all the controlling steps of the management, it should be sent automatically as PDF via email to our vendor.
    The problem is, how to get the PDF as an attachment? We are using SAPscript for our PO formular  (and of course the PDF-Attachment should look like the printed version).
    I was already looking in the internet for a solution, but it is really hard to find some answers for this problem.
    Many thanks for your help,
    Christoph

    Hi all,
    many thanks for your help.
    The workflow should run in this way. The purchaser creates an order --> supervisor gets a SAP Mail (workflow user decision step) to accept it --> the supervisor of the supervisor then gets a SAP mail to accept it --> PDF is sent to the vendor (only if everybody signed this PO before).
    I will try following now: I will create a new workflow task to execute a method (for getting the PO as a PDF attachment) and a new workflow container item to store the attachment.
    As next WF step I will use the standard send mail step.
    Are I am right with this soulution (nothing programmed yet, still not so sure how to do it - but hope to find a solution to manage this).
    Many thanks for your help again.
    Chris

  • SAPScript to PDF in Webdynpro for Java

    Hi All,
    I have to display Form16 for an employee in pdf format in portal. Form16 is available as SAPscript.
    ECC 6.0
    Report Program:HINCF160
    We can run transaction 'HRESSIN_F16' in se93 to see Form16, How can we get the same to Webdynpro,
    If we use an RFC which Function module to be called to get the data in pdf format
    Regards
    Sarath

    Hi,
    maybe this could help you:
    Regarding Copying of Data From Excel file to Web Dynpro Java Table
    Import data from excel/csv file in web dynpro
    Regards, Bernd

  • Custom sapscript to PDF and email

    Hi all,
    I have a requirement to create a new sapscript that can be converted to PDF and emailed. I have done this for regular reports but have no idea about doing it for sapscript.
    Does anybody know how I can do this?
    I've search the forums here but I haven't found a definate solution.
    Cheers,
          Tony

    Here is a sample program.
    REPORT ZRICH_0003.
    DATA: ITCPO LIKE ITCPO,
          TAB_LINES LIKE SY-TABIX.
    * Variables for EMAIL functionality
    DATA: MAILDATA   LIKE SODOCCHGI1.
    DATA: MAILPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: MAILHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: MAILBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILREC    LIKE SOMLREC90 OCCURS 0  WITH HEADER LINE.
    DATA: SOLISTI1   LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    PERFORM SEND_FORM_VIA_EMAIL.
    *       FORM  SEND_FORM_VIA_EMAIL                                      *
    FORM  SEND_FORM_VIA_EMAIL.
      CLEAR:    MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
      REFRESH:  MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    * Creation of the document to be sent File Name
      MAILDATA-OBJ_NAME = 'TEST'.
    * Mail Subject
      MAILDATA-OBJ_DESCR = 'Subject'.
    * Mail Contents
      MAILTXT-LINE = 'Here is your file'.
      APPEND MAILTXT.
    * Prepare Packing List
      PERFORM PREPARE_PACKING_LIST.
    * Set recipient - email address here!!!
      MAILREC-RECEIVER = '[email protected]'.
      MAILREC-REC_TYPE  = 'U'.
      APPEND MAILREC.
    * Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = MAILDATA
                PUT_IN_OUTBOX              = ' '
           TABLES
                PACKING_LIST               = MAILPACK
                OBJECT_HEADER              = MAILHEAD
                CONTENTS_BIN               = MAILBIN
                CONTENTS_TXT               = MAILTXT
                RECEIVERS                  = MAILREC
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                OPERATION_NO_AUTHORIZATION = 4
                OTHERS                     = 99.
    ENDFORM.
    *      Form  PREPARE_PACKING_LIST
    FORM PREPARE_PACKING_LIST.
      CLEAR:    MAILPACK, MAILBIN, MAILHEAD.
      REFRESH:  MAILPACK, MAILBIN, MAILHEAD.
      DESCRIBE TABLE MAILTXT LINES TAB_LINES.
      READ TABLE MAILTXT INDEX TAB_LINES.
      MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
    * Creation of the entry for the compressed document
      CLEAR MAILPACK-TRANSF_BIN.
      MAILPACK-HEAD_START = 1.
      MAILPACK-HEAD_NUM = 0.
      MAILPACK-BODY_START = 1.
      MAILPACK-BODY_NUM = TAB_LINES.
      MAILPACK-DOC_TYPE = 'RAW'.
      APPEND MAILPACK.
    * Creation of the document attachment
    * This form gets the OTF code from the SAPscript form.
    * If you already have your OTF code, I believe that you may
    * be able to skip this form.  just do the following code, looping thru
    * your SOLISTI1 and updating MAILBIN.
    <b>  PERFORM GET_OTF_CODE.
      LOOP AT SOLISTI1.
        MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
        APPEND MAILBIN.
      ENDLOOP.</b>
      DESCRIBE TABLE MAILBIN LINES TAB_LINES.
      MAILHEAD = 'TEST.OTF'.
      APPEND MAILHEAD.
    ** Creation of the entry for the compressed attachment
      MAILPACK-TRANSF_BIN = 'X'.
      MAILPACK-HEAD_START = 1.
      MAILPACK-HEAD_NUM = 1.
      MAILPACK-BODY_START = 1.
      MAILPACK-BODY_NUM = TAB_LINES.
      MAILPACK-DOC_TYPE = 'OTF'.
      MAILPACK-OBJ_NAME = 'TEST'.
      MAILPACK-OBJ_DESCR = 'Subject'.
      MAILPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND MAILPACK.
    ENDFORM.
    *      Form  GET_OTF_CODE
    FORM  GET_OTF_CODE.
      DATA: BEGIN OF OTF OCCURS 0.
              INCLUDE STRUCTURE ITCOO .
      DATA: END OF OTF.
      DATA: ITCPO LIKE ITCPO.
      DATA: ITCPP LIKE ITCPP.
    <b>  CLEAR ITCPO.
      ITCPO-TDGETOTF = 'X'.</b>
    * Start writing OTF code
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
                FORM     = 'ZTEST_FORM'
                LANGUAGE = SY-LANGU
                OPTIONS  = ITCPO
                DIALOG   = ' '
           EXCEPTIONS
                OTHERS   = 1.
      CALL FUNCTION 'START_FORM'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                WINDOW        = 'MAIN'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
    * Close up Form and get OTF code
      CALL FUNCTION 'END_FORM'
           EXCEPTIONS
                ERROR_MESSAGE = 01
                OTHERS        = 02.
      MOVE-CORRESPONDING ITCPO TO ITCPP.
      CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
                RESULT  = ITCPP
    <b>       TABLES
                OTFDATA = OTF</b>
           EXCEPTIONS
                OTHERS  = 1.
    * Move OTF code to structure SOLI form email
    <b>  CLEAR SOLISTI1. REFRESH SOLISTI1.
      LOOP AT OTF.
        SOLISTI1-LINE = OTF.
        APPEND SOLISTI1.
      ENDLOOP.</b>
    ENDFORM.
    Please make sure to award points for helpful answers and Welcome to SDN!!!
    Regards,
    Rich Heilman

  • Convert SAPScript to PDF

    Hello Everyone,
    I recently posted the following question on Webdynpro ABAP forum regarding displaying SAPScript in Enterprise Portal using ABAP WD. But, they refered me to post the question in this forum to get help.
    Display SAPScript in Portal
    Could anyone help me in finding out the way to display a SAPScript in Portal. I would greatly appreciate your help.
    Regards,
    Gopal.

    Hi,
      Try the following steps.
    1. FM "CLOSE_FORM" will return you SAP Script in OTF format.
    2. Call FM "CONVERT_OTF" to convert OTF into PDF format. Call the FM as below.
        CALL FUNCTION 'CONVERT_OTF'
           EXPORTING
                format                = 'PDF'
           IMPORTING
                bin_filesize          = cf_filesize
           TABLES
                otf                   = it_otf
                lines                 = lt_lines
           EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                OTHERS                = 4.
       You will get the PDF file in table LT_LINES. This can be downloaded in PDF format by using FM GUI_DOWNLOAD.
    Thanks,
    Punit

  • Convert SAPScript to PDF - sample report needed

    Hi Experts,
    I need a sample report which convert SAPScript form to PDF. I tried several samples in this forum but it did not work.
    Thanks!
    - Anthony -

    Hi,
    Check with the [Convert SAP script to PDF|http://www.sdn.sap.com/irj/scn/index;jsessionid=(J2EE3417400)ID0384864750DB01011562107177693234End?rid=/library/uuid/49e15474-0e01-0010-9cba-e62df8244556&overridelayout=true]
    Hope this helps you.
    Regards,
    Rajani

  • Convert sapscripts to pdf

    hi,
    I want to convert SAPscript to Adobe PDF format and also want to store that PDF file to my local drive.
    I dont want to do it by program RSTXPDFT4. it should generate the PDF file automatically.
    If any one knows please help me.

    put like this
      call function 'CLOSE_FORM'
        importing
          result                   = result
          rdi_result               = rdi
        tables
          otfdata                  = otf_table
        exceptions
          unopened                 = 1
          bad_pageformat_for_print = 2
          others                   = 3.
      if sy-subrc <> 0.
    *  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    call function 'CONVERT_OTF'
    exporting
       format                      = 'PDF'
    *   MAX_LINEWIDTH               = 132
    *   ARCHIVE_INDEX               = ' '
    *   COPYNUMBER                  = 0
    *   ASCII_BIDI_VIS2LOG          = ' '
      importing
        bin_filesize                = len_out
    *   BIN_FILE                    =
      tables
        otf                         = otf_table
        lines                       = pdf
    * EXCEPTIONS
    *   ERR_MAX_LINEWIDTH           = 1
    *   ERR_FORMAT                  = 2
    *   ERR_CONV_NOT_POSSIBLE       = 3
    *   ERR_BAD_OTF                 = 4
    *   OTHERS                      = 5
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    clear: file.
    call function 'GUI_DOWNLOAD'
      exporting
        bin_filesize                    = len_out
        filename                        = 'C:/TESTING07.PDF'
        filetype                        = 'BIN'
    *   APPEND                          = ' '
    *   WRITE_FIELD_SEPARATOR           = ' '
    *   HEADER                          = '00'
    *   TRUNC_TRAILING_BLANKS           = ' '
    *   WRITE_LF                        = 'X'
    *   COL_SELECT                      = ' '
    *   COL_SELECT_MASK                 = ' '
    *   DAT_MODE                        = ' '
    *   CONFIRM_OVERWRITE               = ' '
    *   NO_AUTH_CHECK                   = ' '
    *   CODEPAGE                        = ' '
    *   IGNORE_CERR                     = ABAP_TRUE
    *   REPLACEMENT                     = '#'
    *   WRITE_BOM                       = ' '
    *   TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *   WK1_N_FORMAT                    = ' '
    *   WK1_N_SIZE                      = ' '
    *   WK1_T_FORMAT                    = ' '
    *   WK1_T_SIZE                      = ' '
    * IMPORTING
    *   FILELENGTH                      =
      tables
        data_tab                        = pdf
    *   FIELDNAMES                      =
    * EXCEPTIONS
    *   FILE_WRITE_ERROR                = 1
    *   NO_BATCH                        = 2
    *   GUI_REFUSE_FILETRANSFER         = 3
    *   INVALID_TYPE                    = 4
    *   NO_AUTHORITY                    = 5
    *   UNKNOWN_ERROR                   = 6
    *   HEADER_NOT_ALLOWED              = 7
    *   SEPARATOR_NOT_ALLOWED           = 8
    *   FILESIZE_NOT_ALLOWED            = 9
    *   HEADER_TOO_LONG                 = 10
    *   DP_ERROR_CREATE                 = 11
    *   DP_ERROR_SEND                   = 12
    *   DP_ERROR_WRITE                  = 13
    *   UNKNOWN_DP_ERROR                = 14
    *   ACCESS_DENIED                   = 15
    *   DP_OUT_OF_MEMORY                = 16
    *   DISK_FULL                       = 17
    *   DP_TIMEOUT                      = 18
    *   FILE_NOT_FOUND                  = 19
    *   DATAPROVIDER_EXCEPTION          = 20
    *   CONTROL_FLUSH_ERROR             = 21
    *   OTHERS                          = 22
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Regards
    Prabhu

Maybe you are looking for

  • Stange error when using dbms_metadata.get_ddl in PL/SQL procedure

    Basic info: Oracle 10.2.0.4.0 on linux. I'm trying to extract ddl of indexes that I drop and recreate frequently during monthly loads and store it in a table. This statement works on the command line: insert into saved_indexes select index_name,dbms_

  • Java.lang.NoClassDefFoundError in Mac OS X

    Just getting started developing in mac OS X and have run into the following error Exception in thread "main" java.lang.NoClassDefFoundError: testprogram while trying to run a simple hello world program from the bash shell: public class testprogram {

  • Room Creation Translation

    I must translate some texts from the Room Creation Wizard. I can find the bundle with them in the PAR file "com.sap.netweaver.coll.appl.ui.room.par", but when I add the iview "pcd:portal_content/com.sap.pct/Collaboration/iViews/com.sap.netweaver.coll

  • My itunes won't recognize my iphone and i don't know how to install the 10.6.3 itunes on my phone or whatever. helppppp.

    my itunes won't recognize my iphone and i don't know how to install the 10.6.3 itunes on my phone or whatever. helppppp.

  • Date comparison in UNIX

    Hi All, Can some one please suggest me, how to compare the date in unix. I'm using below command but its not comparing the dates correctly bankdate=25-JUL-2009 start_date=01-JUL-2009 end_date=31-JUL-2009 echo bankdate="${bankdate}" echo start_date="$