How to convert script output to excel and send through mail in the report

I need a solution for Converting script into EXCEL  and sending Excel as a attachment to the mail. In my current Program I am getting OTF data from script and converting into PDF using Function module ' CONVERT_OTF'
And sending PDF as a mail attachment using Function module 'SO_NEW_DOCUMENT_SEND_API1' it is working fine but
My current requirement is I need to send Excel as a mail attachment instead of PDF.
Hope it is clear for you, please give me possible solutions with sample code..

hi
good
CONSTANTS: CON_CRET TYPE X VALUE '0D',  "OK for non Unicode
             CON_TAB TYPE X VALUE '09'.   "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
   con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
   con_cret type c value cl_abap_char_utilities=>CR_LF.
  CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
         INTO IT_ATTACH SEPARATED BY CON_TAB.
  CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.
  APPEND  IT_ATTACH.
  LOOP AT IT_EKPO INTO WA_CHAREKPO.
    CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
                WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
           INTO IT_ATTACH SEPARATED BY CON_TAB.  " Check here
    CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.  " Check here
    APPEND  IT_ATTACH.
  ENDLOOP.
thanks
mrutyun^

Similar Messages

  • Smartform output to pdf and send through mail

    Hi,
    I am able to save the output of the smartform as pdf file and able to send the pdf as attachment in mail.
    But the problems are -
    1 - As i have set the field - 'X' TO ls_control_param-getotf.
         I am unable to view the print preview of the billing document and no spool is getting displayed. I want to see the print preview and create a spool and also generate a pdf file.
    2- I am using the FM SO_DOCUMENT_SEND_API1 to send the mail of the pdf file. But i am getting the message like
        "Cannot extract the embedded font 'FranklinGothalicITCBook'. Some charactersmay not display or print correctly" followed by "An error exists on this page. Acrobat may not display the page correctly".
    Pls help me in resolving the issues.
    Thanks,
    Raju

    Hi
    I was worked on similar type of requirement. For your reference, please check the below piece of code which i have developed for my requirement.
    FORM ENTRY USING RETCODE
                     US_SCREEN.
    *Check if Nast key is initial or not
      IF NAST-OBJKY IS NOT INITIAL.
    *if nast-objkey is not initial than we need to get the smartform name
    *which is ZSF_PURCHASE_ORDER01
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            FORMNAME           = C_FORM
          IMPORTING
            FM_NAME            = G_FNAME
          EXCEPTIONS
            NO_FORM            = 1
            NO_FUNCTION_MODULE = 2
            OTHERS             = 3.
    *if sy-subrc ne 0 than we need to update the nast entry with error
        IF SY-SUBRC <> 0.
          RETCODE = 1.
          PERFORM NAST_PROTOCOL_UPDATE.
          EXIT.
        ENDIF.
    *check if we need to take a print out
        CLEAR W_CTRLOP.
        IF SY-UCOMM = 'PREVOUTPUT'.
          NAST-NACHA = '1'.
        ENDIF.
    OUTPUT TO PRINTER
        IF NAST-NACHA = C_1.                 " Output to Printer
          W_COMPOP-TDDEST     = NAST-LDEST.
          W_COMPOP-TDNEWID    = 'X'.
          W_COMPOP-TDIMMED    = 'X'.
          W_COMPOP-TDDELETE   = 'X'.
          W_COMPOP-TDLIFETIME = 1.
          W_COMPOP-TDFINAL    = 'X'.
         W_CTRLOP-NO_DIALOG  = 'X'.
          W_CTRLOP-DEVICE     = 'PRINTER'.
          W_CTRLOP-PREVIEW    = 'X'.
    *Smartform is called and print program is done
          CALL FUNCTION G_FNAME
            EXPORTING
              CONTROL_PARAMETERS = W_CTRLOP
              OUTPUT_OPTIONS     = W_COMPOP
              USER_SETTINGS      = ' '
              WA_NAST            = NAST
            EXCEPTIONS
              FORMATTING_ERROR   = 1
              INTERNAL_ERROR     = 2
              SEND_ERROR         = 3
              USER_CANCELED      = 4
              OTHERS             = 5.
    *if print program is successful we need to update the nast entry
          IF SY-SUBRC EQ 0.
            RETCODE = 0.
            IF US_SCREEN EQ 'X'.
              PERFORM NAST_PROTOCOL_UPDATE.
            ELSEIF SY-SUBRC NE 0.
    *if print program is not successful than we need to update the nast
    *entry
              RETCODE = 1.
              PERFORM NAST_PROTOCOL_UPDATE.
              EXIT.
            ENDIF.
          ENDIF.
    OUTPUT TO MAIL
        ELSEIF NAST-NACHA = C_5.                " External Mail
    We need to get the smartform into OTF file format
          W_CTRLOP-GETOTF     = 'X'.
          IF  NAST-TCODE = 'ZLE'.
            W_COMPOP-TDDEST = 'LOCL'.
          ENDIF.
          CALL FUNCTION G_FNAME
            EXPORTING
              CONTROL_PARAMETERS = W_CTRLOP
              OUTPUT_OPTIONS     = W_COMPOP
              USER_SETTINGS      = ' '
              WA_NAST            = NAST
            IMPORTING
              JOB_OUTPUT_INFO    = WA_RETURN
            EXCEPTIONS
              FORMATTING_ERROR   = 1
              INTERNAL_ERROR     = 2
              SEND_ERROR         = 3
              USER_CANCELED      = 4
              OTHERS             = 5.
    *update the nast entry accordingly
          IF SY-SUBRC EQ 0.
            RETCODE = 0.
            IF US_SCREEN EQ 'X'.
              PERFORM NAST_PROTOCOL_UPDATE.
            ELSEIF SY-SUBRC NE 0.
              RETCODE = 1.
              PERFORM NAST_PROTOCOL_UPDATE.
              EXIT.
            ENDIF.
          ENDIF.
    *convert the smartform data into OTF file
          DATAB[] = WA_RETURN-OTFDATA[].
          CALL FUNCTION 'CONVERT_OTF'
            EXPORTING
              FORMAT                = 'PDF'
              MAX_LINEWIDTH         = 134
             ARCHIVE_INDEX         = ' '
              ASCII_BIDI_VIS2LOG    = 'X'
              PDF_DELETE_OTFTAB     = ' '
            IMPORTING
              BIN_FILESIZE          = BINFILESIZE
            TABLES
              OTF                   = DATAB[]
              LINES                 = PDFTAB[]
            EXCEPTIONS
              ERR_MAX_LINEWIDTH     = 1
              ERR_FORMAT            = 2
              ERR_CONV_NOT_POSSIBLE = 3
              ERR_BAD_OTF           = 4
              OTHERS                = 5.
    *if file conversion fails we need to update the nast entry
          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 'SX_TABLE_LINE_WIDTH_CHANGE'
            EXPORTING
              LINE_WIDTH_SRC              = 134
              LINE_WIDTH_DST              = 255
              TRANSFER_BIN                = 'X'
            TABLES
              CONTENT_IN                  = PDFTAB[]
              CONTENT_OUT                 = PDF[]
            EXCEPTIONS
              ERR_LINE_WIDTH_SRC_TOO_LONG = 1
              ERR_LINE_WIDTH_DST_TOO_LONG = 2
              ERR_CONV_FAILED             = 3
              OTHERS                      = 4.
    *if conversion fails update the nast entry accordingly
          IF SY-SUBRC <> 0.
            RETCODE = 1.
            PERFORM NAST_PROTOCOL_UPDATE.
            EXIT.
          ENDIF.
    Hope it helps...

  • Sending SAP Script output as a PDF attachment through mail

    Dear Guru,
    I am using SAP 4.0B version, DATABASE Oracle 8i, OS is sun solaris 7.5.
    I want to send SAP script output as a
    PDF attachement through mail.Please suggest a solution.
    Regards,
    Rajesh

    Hi Rajesh,
    In your print program, while calling OPEN_FORM, pass options-TDGETOTF = 'X'. This is used for returning print output in OTF format.
    Then in CLOSE_FORM, get the table OTFDATA returned from the function module. for example
    DATA: OTF_DATA LIKE ITCOO OCCURS 0 WITH HEADER LINE.
        CALL FUNCTION 'CLOSE_FORM'
          IMPORTING
            RESULT  = RESULT
          TABLES
            OTFDATA = OTF_DATA.
    now you can convert this OTF data to PDF using function module CONVERT_OTF
    Then send this data as attachment to a mail using function module SO_NEW_DOCUMENT_ATT_SEND_API1
    Regards,
    Komal.

  • Attaching HTML file and sending through mail

    Hi
    My Requirement is
    I want to attach HTML File and send through mail id's.
    But there are number of html files
    user can select any  one file.
    it has to attach and send to the mail id.

    Hi V,
    check the link:
    http://wiki.sdn.sap.com/wiki/display/Snippets/SendEmailwithHTMLattachment.

  • How to convert Xstring to PDF format and send pdf to multiple user

    Hi to all
    can any one provide me saple code to convert Xstring to PDF format and send pdf to multiple user
    i have searched the SDN , but cant get any proper soulution.
    I shall be thankful to you for this.
    Regards
    Pavneet Rana

    Use function module 'SCMS_XSTRING_TO_BINARY' to convert from XString to a Binary table. Just like this:
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          buffer          = lv_xstring_pdf
          append_to_table = ' '
        TABLES
          binary_tab      = lt_doc_content.
    To send the email in an OO way you should user class CA_SEND_REQUEST_BCS. Take a look to program BCS_EXAMPLE_6 or any of the test programs in package SBCOMS.

  • ME23N Script convert to PDF and send thru mail to the user created by

    Hi,
    I have created a custom PO SAP scirpt for the tcode ME23N and configured the same in tcode NACE Application 'EF' , output type 'NEU'
    But the client requirement is to send  this SAP Scipt PO converted to pdf & then send thru email to the user who created PO (ME23N)?
    How do u get this functionality please let me know?
    Regards,
    Anil

    Hello,
    that is easy, you only need to keep the steps to do in mind:
    1) find a suitable point to place in your code to do all this for you
    2) create a FM that will convert your form into PDF (search a little, this has been done like zillion times here)
    3) create a FM that will send the PDF stream (hex data which is accepted by the BCS class as the attachment data)
    4) check the email customizing in your system
    5) run and enjoy
    All the parts has been done here many times, shouldn´t be a problem.
    Otto

  • Converting alv list  to excel and send to sapoffice or mail in batch mode

    Hi every one.
    I have the alv list and then I can send to sapoffice or mail in batch mode.
    If I open the list in Sapoffice I can save the list in XLS format or if I open the list by mail, I can select all the content (because is a html file), select the copy option and then open EXCEL and paste the content.
    Can I use an option to convert the alv list to an excel format and then send to mail or sapconnect in batch mode?

    if your requirement is to send a Excel sheet by Email then use this sample program.
    *& Report  ZEMAIL_ATTACH                                               *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
          Build data table for .xls document
    FORM build_xls_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      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.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_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
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    - Guru

  • Invoice output triggered once but sending multiple mails from the output

    Hello Experts,
    Need your help with a tricky issue in our system.
    We have an output type defined to send invoice output as email. Lately we have an issue with this.
    If we trigger the output in foreground it works fine. But when we create the invoices from batchjob it is triggering multiple emails for the same invoice. When we check the output in invoice it was triggered only once. Even in NAST also we have only one entry for these invoices. This issue is happening randomly not for all the invoices created through batch.
    To nailed down the issue we have added code to update the application log in the output program. It wil update the application log in SLG1 transaction when ever the output program was called. Surprisingly even for the cases where the mail triggered multiple times we have only one entry in the log. It means even though the mail sent multiple times, it is calling the output porgam only once.
    We are not able to replicate this issue even after mulitple trails.
    Please suggest how we can find the root cause for this issue. All the ideas are welcome.
    Thanks,
    Srini

    Hi
    The problem could be in SO_DOCUMENT_SEND_API1 or in the program called to send the mail
    SO_DOCUMENT_SEND_API1 places the mail in SOST (how many messages you can see there?)
    If you see only one message the problem could be in the program to send the mail
    Max

  • Convert  Script output into PDF and save into Unix Directory

    Hi,
      I had Sales Order Acknowledgement Output and wants to converted to PDFs and then these PDFs to be placed in Unix Directory
    on their way to Docs Library.
    I am using the following code
      CALL FUNCTION 'CLOSE_FORM'
        IMPORTING
          RESULT   = itcpp
        TABLES
          otfdata  = lt_otf  " OTF Data
        EXCEPTIONS
          unopened = 1
          OTHERS   = 2.
    After this form ,  table ltf_otf is empty, So i am not converting into PDF .
    So i need the logic to convert to PDF , and most importantly logic to save into UNIX Directory.
    Thanks

    Hi,
    If you are using the Function Module "OPEN_FORM" to open the form for printing then in this function module there is an IMPORTING parameter OPTIONS which is of type ITCPO to this parameter "OPTIONS-TDGETOTF" needs to be passed as 'X' which will give you the OTF output in the FM "CLOSE_FORM".
    After this call the FM "CONVERT_OTF" and pass the FORMAT as "PDF" which will give you the PDF output in LINES table Parameter. Most important please pass some dummy variable to BIN_FILESIZE variable.
    Now by using OPEN DATASET file name FOR OUTPUT IN BINARY MODE and the LOOP the PDF table and use the TRANSFER statement to place the data in the UNIX File and then Finally use the CLOSE DATASET file name.
    Hope will help to address your issue.
    Regards,
    SRinivas

  • How to convert smartform into pdf and send through mail

    Hi Guru,
    I want to send smartform to mail after converting into pdf format.
    if anyof u gives solution its greate.
    Thanks & Regards,
    Lakshmi..

    Hi,
    i can help you till
    downloading the smartform as pdf format
    check this
    DATA: GIT_BSIK LIKE BSIK OCCURS 0 WITH HEADER LINE.
    Variable declarations
    DATA:
    W_FORM_NAME TYPE TDSFNAME VALUE 'ZFII_EDD001',
    W_FMODULE TYPE RS38L_FNAM,
    W_CPARAM TYPE SSFCTRLOP,
    W_OUTOPTIONS TYPE SSFCOMPOP,
    W_BIN_FILESIZE TYPE I, " Binary File Size
    W_FILE_NAME TYPE STRING,
    W_FILE_PATH TYPE STRING,
    W_FULL_PATH TYPE STRING.
    Internal tables declaration
    Internal table to hold the OTF data
    DATA:
    T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    Internal table to hold OTF data recd from the SMARTFORM
    T_OTF_FROM_FM TYPE SSFCRESCL,
    Internal table to hold the data from the FM CONVERT_OTF
    T_PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE.
    This function module call is used to retrieve the name of the Function
    module generated when the SMARTFORM is activated
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
        FORMNAME = W_FORM_NAME
        VARIANT = ' '
        DIRECT_CALL = ' '
        IMPORTING
        FM_NAME = W_FMODULE
        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.
    Calling the SMARTFORM using the function module retrieved above
    GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
    format of the output
    W_CPARAM-NO_DIALOG = 'X'.
    W_CPARAM-PREVIEW = SPACE. " Suppressing the dialog box
    " for print preview
    W_CPARAM-GETOTF = 'X'.
    Printer name to be used is provided in the export parameter
    OUTPUT_OPTIONS
    W_OUTOPTIONS-TDDEST = 'ZPC_'.
          CALL FUNCTION W_FMODULE
          EXPORTING
          ARCHIVE_INDEX =
          ARCHIVE_INDEX_TAB =
          ARCHIVE_PARAMETERS =
          CONTROL_PARAMETERS = W_CPARAM
          MAIL_APPL_OBJ =
          MAIL_RECIPIENT =
          MAIL_SENDER =
          OUTPUT_OPTIONS = W_OUTOPTIONS
          USER_SETTINGS = 'X'
          IMPORTING
          DOCUMENT_OUTPUT_INFO =
          JOB_OUTPUT_INFO = T_OTF_FROM_FM
          JOB_OUTPUT_OPTIONS =
               TABLES
                ITAB                       = GIT_BSIK
          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.
    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.
    *To display File SAVE dialog window
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
    WINDOW_TITLE =
    DEFAULT_EXTENSION =
    DEFAULT_FILE_NAME =
    FILE_FILTER =
    INITIAL_DIRECTORY =
    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.
    Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
    presentation server
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = W_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 = T_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.
    thanks & regards,
    Venkatesh

  • Open a command window and send some keystroke to the opened command window

    Hi All,
    I am trying to open command prompt and send some key stroke to that command prompt. Here I am using Robot to send keystroke. But the problem is, the keystrokes are not sent to the prompt. I guess I need to activate progamitically the command prompt to accept the keystrokes . Please find the code below ( as I did).
    try
    String command = "cmd.exe /c start";
    Process child = Runtime.getRuntime().exec(command);
    Robot robot = new Robot();
    Thread.sleep(5000);
    String lol = "indranil";
    for(int i=0;i<lol.length();i++)
    robot.keyPress(lol.charAt(i));
    int g = lol.length() - 1;
    robot.keyRelease(lol.charAt(g));
    catch (Exception e) {}
    I guess I am doing some mistake here while sending the keystroke/openning the command prompt. Can anyone please help me how can I open a command window and send some keystroke to the opened command window. I am in fix.
    Thanks,
    Indranil

    The first thing to do is read the API and examples for the Robot class.
    Also check out this thread with a similar discussion: [http://forums.sun.com/thread.jspa?threadID=5385677]
    The short spoonfed answer - keyPress() and keyReleaseI() do not take chars. Read up on KeyEvent

  • How to Convert file to excel and send it via email

    Hi experts.
    Can anyone tell me how to convert a spool data in to excel format and the send it through e-mail......
    We have a function module for converting spool data to pdf and send it through mail ie FM CONVERT_ABAPSPOOLJOB_2_PDF,
    but is there any FM for Excel ....
    Kindly help me.....
    Thanks
    Naveen

    you can send a file as an exel attachment in mail,
    step 1:
       send file data to an internal table.
    step 2:
       loop through the internal table(itab).
        concatinate itab-field1
                          abap_char_utilities=>horizontal tab
                         itab-field2
                         abap_char_utilities=>horizontal tab
                        abap_char_utilities=>vertical tab
            into t_attachment-line
    append t_attachment
    step 3:
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.  
      w_doc_data-doc_size =
      ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
    Describe the body of the message
      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.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'XLS'.
       t_packing_list-doc_size = t_packing_list-body_num * 255.
      t_packing_list-obj_name   = 'Attachment'.
      t_packing_list-obj_descr  = 'mail xls'
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
        MOVE: mail id TO t_receivers-receiver,
        'U' TO t_receivers-rec_type,
        APPEND t_receivers.
      CALL  FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = t_packing_list
          contents_bin               = t_attachment
          contents_txt               = it_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
          OTHERS                     = 8.
    check the FM and creat the internal table types
    by this way you can send excel as an attachment 
    but problem in sending EXCEL attachment is if the data crosses the limit of excle file the file will not open.

  • How to Download displayed output to Excel Using Bsp Application

    Hi Experts,
    please give me some idea because I am New In BSP.
    How to Download displayed output to Excel Using Bsp Application.
    If any sample code please do send me.
    In my condition I am getting data in  2-3 table view formats on one page and i want download that in Excel.
    please help me.
    Regards & Thanks,
    Yogesh

    Hi,
    This is more a question for the BSP forum.
    Anyway, as such it's realy easy since you can use HTML in order to import to Excel. All you need to do is add
    runtime->server->response->set_header_field( name = 'Contnet-Type'
    value = 'application/vnd.ms-excel' ).
    runtime->server->response->delete_header_field( name = 'Cache-Control' ).
    runtime->server->response->delete_header_field( name = 'Expires' ).
    runtime->server->response->delete_header_field( name = 'Pragma' ).
    Also check threads like
    Download BSP data into Excel
    export bsp-table to excel
    Export BSP Table to Excel
    Eddy
    PS. Reward useful answers and earn points yourself

  • How to  send ALV output data into Excel sheet format via Mail to the user?

    Hi friends,
    I have a doubt ie,
    How to  send ALV output data into Excel sheet format via Mail to the user?
    regards
    Moosa

    Hi,
    Provide the output internal table to the objbin in the below FM
    Send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = i_docdata
                put_in_outbox              = c_x
           TABLES
                packing_list               = i_objpack
                object_header              = i_objhead
                contents_bin               = i_objbin
                contents_txt               = i_objtxt
                receivers                  = i_reclist
    and specify the document type
      i_objpack-doc_type   = 'XLS'.
    and try.
    Regards,
    Nandha

  • How to convert script o/p to pdf o/p

    Hi All,
        I have a requirement where i need to convert script output to pdf output. What is the function moodule available ? Please help me in this regard asap.
    Regards
    Lakshmi

    Hi,
    Try this sample code and reward points by clicking the star on the left of reply,if it helps you.
    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.

Maybe you are looking for

  • Abap macro parameter number limit?

    Is there any number of macro parameter restriction? I am using "set_column" to populate field-category for ALV report. Every is fine until I add ls_fcat-no_out    = &10.  I wonder the max parameter no. is 9? Then what can I do for this case?   DEFINE

  • HP PSC 2355xi All in one won't respond

    I have tried everything that HP has suggested pretty sure it's not the power source. It comes on but will not go through setup my computer does not acknowledge it I have tried everything some times when unplugging it and plugging it back in I get a b

  • Outlook 2013: Default contact list when I click on People

    Hi All, A question about the "People" pane in Outlook 2013. Is there a option to select a default contact list ? Many thanks in advance.

  • [svn:bz-4.6_Apache] 24055: Added changelog for donation to Apache.

    Revision: 24055 Revision: 24055 Author:   [email protected] Date:     2013-05-28 02:22:00 -0700 (Tue, 28 May 2013) Log Message: Added changelog for donation to Apache. Modified Paths:     blazeds/branches/4.6_Apache/apps/samples-spring/WEB-INF/src/sp

  • After software update usb mouse no longer works.

    After software update Microsoft usb mouse no longer works. System Profiler "sees" usb mouse. I took my macbook to the Genius Bar at Apple and they were not able to help. Pretty lame....