Convert internal table data to pdf format and send mail to Users

Hi all ,
I want to convert the data available in internal table to pdf format and then send it to mail .
Please tell me wht are the fn modules available to convert the data from internal table to pdf and then send it mail .
regards
santosh .

Hi Santosh
Sending mail with attachment report in Background
Content Author: Fernando Faian
I have read the hint about "Sending mail with attachment report".
It's great, but how can I make this function work in background??
I had that needed last year too. See attachment a function group with two functions. The second one has that functionality to send email or fax (SAP office) with attachment objects in background job using SO_ATTACHMENT_INSERT function. 
Pay attention because it’s working with output list from spool converted to pdf. 
=================================================================================
z_send_email_fax_global
FUNCTION-POOL z_gfaian_mail_fax.            "MESSAGE-ID ..
WORK TABLE AREAS
TABLES: tsp01.
INTERNAL TABLES
DATA: lt_rec_tab LIKE STANDARD TABLE OF soos1 WITH HEADER LINE,
      lt_note_text   LIKE STANDARD TABLE OF soli  WITH HEADER LINE,
      lt_attachments LIKE STANDARD TABLE OF sood5 WITH HEADER LINE.
DATA: lt_objcont LIKE STANDARD TABLE OF soli WITH HEADER LINE,
      lt_objhead LIKE STANDARD TABLE OF soli WITH HEADER LINE.
DATA: pdf_format LIKE STANDARD TABLE OF tline WITH HEADER LINE.
TYPES: BEGIN OF y_files,
       file(60) TYPE c,
       END OF y_files.
DATA: lt_files TYPE STANDARD TABLE OF y_files WITH HEADER LINE.
DATA: l_objcont     LIKE soli OCCURS 0 WITH HEADER LINE.
DATA: l_objhead     LIKE soli OCCURS 0 WITH HEADER LINE.
STRUCTURES
DATA: folder_id      LIKE soodk,
      object_id      LIKE soodk,
      link_folder_id LIKE soodk,
      g_document     LIKE sood4,
     g_header_data  LIKE sood2,
      g_folmem_data  LIKE sofm2,
      g_header_data  LIKE sood2,
      g_receive_data LIKE soos6,
      g_ref_document LIKE sood4,
      g_new_parent   LIKE soodk,
      l_folder_id    LIKE sofdk,
      v_email(50).
DATA: hd_dat  like sood1.
VARIABLES
DATA: client  LIKE tst01-dclient,
      name    LIKE tst01-dname,
      objtype LIKE rststype-type,
      type    LIKE rststype-type.
DATA: numbytes TYPE i,
      arc_idx LIKE toa_dara,
      pdfspoolid LIKE tsp01-rqident,
      jobname LIKE tbtcjob-jobname,
      jobcount LIKE tbtcjob-jobcount,
      is_otf.
DATA: outbox_flag LIKE sonv-flag VALUE 'X',
      store_flag  LIKE sonv-flag,
      delete_flag LIKE sonv-flag,
      owner       LIKE soud-usrnam,
      on          LIKE sonv-flag VALUE 'X',
      sent_to_all LIKE sonv-flag,
      g_authority LIKE sofa-usracc,
      w_objdes    LIKE sood4-objdes.
DATA: c_file LIKE rlgrap-filename,
      n_spool(6) TYPE n.
DATA: cancel.
DATA: desired_type  LIKE sood-objtp,
      real_type LIKE sood-objtp,
      attach_type LIKE sood-objtp,
      otf LIKE sood-objtp VALUE 'OTF', " SAPscript Ausgabeformat
      ali LIKE sood-objtp VALUE 'ALI'. " ABAP lists
CONSTANTS
CONSTANTS: ou_fol LIKE sofh-folrg              VALUE 'O',
           c_objtp    LIKE g_document-objtp    VALUE 'RAW',
           c_file_ext LIKE g_document-file_ext VALUE 'TXT'.
=================================================================================
z_send_email_fax2
FUNCTION z_faian_mail_fax2.
""Interface local:
*"  IMPORTING
*"     REFERENCE(SRC_SPOOLID) LIKE  TSP01-RQIDENT
*"     REFERENCE(FAX_MAIL_NUMBER) TYPE  SO_NAME
*"     REFERENCE(HEADER_MAIL) TYPE  SO_OBJ_DES
*"     REFERENCE(OBJECT_TYPE) TYPE  SO_ESCAPE
*"  TABLES
*"      LT_BODY_EMAIL STRUCTURE  SOLI
*"  EXCEPTIONS
*"      ERR_NO_ABAP_SPOOLJOB
Fist part: Verify if the spool really exists
  SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
  IF sy-subrc NE 0.
    RAISE err_no_abap_spooljob. "doesn't exist
  ELSE.
    client = tsp01-rqclient.
    name   = tsp01-rqo1name.
    CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
         EXPORTING
              authority     = 'SP01'
              client        = client
              name          = name
              part          = 1
         IMPORTING
              type          = type
              objtype       = objtype
         EXCEPTIONS
              fb_error      = 1
              fb_rsts_other = 2
              no_object     = 3
              no_permission = 4
              OTHERS        = 5.
    IF objtype(3) = 'OTF'.
      desired_type = otf.
    ELSE.
      desired_type = ali.
    ENDIF.
    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
         EXPORTING
              rqident              = src_spoolid
              desired_type         = desired_type
         IMPORTING
              real_type            = real_type
         TABLES
              buffer               = l_objcont
         EXCEPTIONS
              no_such_job          = 14
              type_no_match        = 94
              job_contains_no_data = 54
              no_permission        = 21
              can_not_access       = 21
              read_error           = 54.
    IF sy-subrc EQ 0.
      attach_type = real_type.
    ENDIF.
    CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
         EXPORTING
              owner     = sy-uname
              region    = ou_fol
         IMPORTING
              folder_id = l_folder_id
         EXCEPTIONS
              OTHERS    = 5.
fill out informations about the header of the email
    CLEAR: g_document.
    g_document-foltp     = l_folder_id-foltp.
    g_document-folyr     = l_folder_id-folyr.
    g_document-folno     = l_folder_id-folno.
    g_document-objtp     = c_objtp.
    g_document-objdes    = header_mail.
    g_document-file_ext  = c_file_ext.
    g_header_data-objdes    = header_mail.
    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
         EXPORTING
              method      = 'SAVE'
              office_user = sy-uname
         IMPORTING
              authority   = g_authority
         TABLES
              objcont     = lt_body_email
              attachments = lt_attachments
         CHANGING
              document    = g_document
              header_data = g_header_data
         EXCEPTIONS
              OTHERS      = 1.
    folder_id-objtp = l_folder_id-foltp.
    folder_id-objyr = l_folder_id-folyr.
    folder_id-objno = l_folder_id-folno.
    object_id-objtp = c_objtp.
    object_id-objyr = g_document-objyr.
    object_id-objno = g_document-objno.
    link_folder_id-objtp = l_folder_id-foltp.
    link_folder_id-objyr = l_folder_id-folyr.
    link_folder_id-objno = l_folder_id-folno.
    REFRESH lt_rec_tab.
   CLEAR lt_rec_tab.
   lt_rec_tab-sel        = 'X'.
   lt_rec_tab-recesc     = object_type.   "This field for FAX/MAIL
   lt_rec_tab-recnam     = 'U-'.
   lt_rec_tab-deliver    = 'X'.
   lt_rec_tab-not_deli   = 'X'.
   lt_rec_tab-read       = 'X'.
   lt_rec_tab-mailstatus = 'E'.
   lt_rec_tab-adr_name   = fax_mail_number.
   lt_rec_tab-sortfield  = fax_mail_number.
   lt_rec_tab-recextnam  = fax_mail_number.
   lt_rec_tab-sortclass  = '5'.
   APPEND lt_rec_tab.
      lt_rec_tab-recextnam = fax_mail_number.
      lt_rec_tab-recesc = object_type.
      lt_rec_tab-sndart = 'INT'.
      lt_rec_tab-sndpri = 1.
      APPEND lt_rec_tab.
    lt_files-file = c_file.
    APPEND lt_files.
begin of insertion by faianf01
    hd_dat-objdes = header_mail.
    CALL FUNCTION 'SO_ATTACHMENT_INSERT'
         EXPORTING
              object_id                  = object_id
              attach_type                = attach_type
              object_hd_change           = hd_dat
              owner                      = sy-uname
         TABLES
              objcont                    = l_objcont
              objhead                    = l_objhead
         EXCEPTIONS
              active_user_not_exist      = 35
              communication_failure      = 71
              object_type_not_exist      = 17
              operation_no_authorization = 21
              owner_not_exist            = 22
              parameter_error            = 23
              substitute_not_active      = 31
              substitute_not_defined     = 32
              system_failure             = 72
              x_error                    = 1000.
    IF sy-subrc > 0.
    ENDIF.
end of insertion by faianf01
send email from SAPOFFICE
    CALL FUNCTION 'SO_OBJECT_SEND'
         EXPORTING
              folder_id                  = folder_id
              object_id                  = object_id
              outbox_flag                = outbox_flag
              link_folder_id             = link_folder_id
              owner                      = sy-uname
             check_send_authority       = 'X'
         TABLES
              receivers                  = lt_rec_tab
             note_text                  = lt_note_text
         EXCEPTIONS
              active_user_not_exist      = 35
              communication_failure      = 71
              component_not_available    = 1
              folder_no_authorization    = 5
              folder_not_exist           = 6
              forwarder_not_exist        = 8
              object_no_authorization    = 13
              object_not_exist           = 14
              object_not_sent            = 15
              operation_no_authorization = 21
              owner_not_exist            = 22
              parameter_error            = 23
              substitute_not_active      = 31
              substitute_not_defined     = 32
              system_failure             = 72
              too_much_receivers         = 73
              user_not_exist             = 35.
  ENDIF.
ENDFUNCTION.
=================================================================================
z_send_email_fax
FUNCTION ZCBFS_SEND_MAIL.
""Interface local:
*"  IMPORTING
*"     REFERENCE(SRC_SPOOLID) LIKE  TSP01-RQIDENT
*"     REFERENCE(HEADER_MAIL) TYPE  SO_OBJ_DES
*"  TABLES
*"      LIST_FAX_MAIL_NUMBER STRUCTURE  SOLI
*"  EXCEPTIONS
*"      ERR_NO_ABAP_SPOOLJOB
  DATA: vg_achou(1) TYPE n.
Fist part: Verify if the spool really exists
  vg_achou = 1.
  DO 60 TIMES.
    SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
    IF sy-subrc IS INITIAL.
      CLEAR vg_achou.
      EXIT.
    ELSE.
      WAIT UP TO 1 SECONDS.
    ENDIF.
  ENDDO.
  IF vg_achou = 1.
    RAISE err_no_abap_spooljob. "doesn't exist
  ENDIF.
  client = tsp01-rqclient.
  name   = tsp01-rqo1name.
  CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
       EXPORTING
            authority     = 'SP01'
            client        = client
            name          = name
            part          = 1
       IMPORTING
            type          = type
            objtype       = objtype
       EXCEPTIONS
            fb_error      = 1
            fb_rsts_other = 2
            no_object     = 3
            no_permission = 4
            OTHERS        = 5.
  IF objtype(3) = 'OTF'.
    desired_type = otf.
  ELSE.
    desired_type = ali.
  ENDIF.
  CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
       EXPORTING
            rqident              = src_spoolid
            desired_type         = desired_type
       IMPORTING
            real_type            = real_type
       TABLES
            buffer               = l_objcont
       EXCEPTIONS
            no_such_job          = 14
            type_no_match        = 94
            job_contains_no_data = 54
            no_permission        = 21
            can_not_access       = 21
            read_error           = 54.
  IF sy-subrc EQ 0.
    attach_type = real_type.
  ENDIF.
  CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
       EXPORTING
            owner     = sy-uname
            region    = ou_fol
       IMPORTING
            folder_id = l_folder_id
       EXCEPTIONS
            OTHERS    = 5.
fill out informations about the header of the email
  CLEAR: g_document.
  g_document-foltp     = l_folder_id-foltp.
  g_document-folyr     = l_folder_id-folyr.
  g_document-folno     = l_folder_id-folno.
  g_document-objtp     = c_objtp.
  g_document-objdes    = header_mail.
  g_document-file_ext  = c_file_ext.
  g_header_data-objdes    = header_mail.
  CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
       EXPORTING
            method      = 'SAVE'
            office_user = sy-uname
       IMPORTING
            authority   = g_authority
       TABLES
            attachments = lt_attachments
       CHANGING
            document    = g_document
            header_data = g_header_data
       EXCEPTIONS
            OTHERS      = 1.
  folder_id-objtp = l_folder_id-foltp.
  folder_id-objyr = l_folder_id-folyr.
  folder_id-objno = l_folder_id-folno.
  object_id-objtp = c_objtp.
  object_id-objyr = g_document-objyr.
  object_id-objno = g_document-objno.
  link_folder_id-objtp = l_folder_id-foltp.
  link_folder_id-objyr = l_folder_id-folyr.
  link_folder_id-objno = l_folder_id-folno.
  REFRESH lt_rec_tab.
  LOOP AT LIST_FAX_MAIL_NUMBER.
    lt_rec_tab-recextnam = LIST_FAX_MAIL_NUMBER-LINE.
    lt_rec_tab-recesc = 'U'.
    lt_rec_tab-sndart = 'INT'.
    lt_rec_tab-sndpri = 1.
    APPEND lt_rec_tab.
  ENDLOOP.
  lt_files-file = c_file.
  APPEND lt_files.
  hd_dat-objdes = header_mail.
  CALL FUNCTION 'SO_ATTACHMENT_INSERT'
       EXPORTING
            object_id                  = object_id
            attach_type                = attach_type
            object_hd_change           = hd_dat
            owner                      = sy-uname
       TABLES
            objcont                    = l_objcont
            objhead                    = l_objhead
       EXCEPTIONS
            active_user_not_exist      = 35
            communication_failure      = 71
            object_type_not_exist      = 17
            operation_no_authorization = 21
            owner_not_exist            = 22
            parameter_error            = 23
            substitute_not_active      = 31
            substitute_not_defined     = 32
            system_failure             = 72
            x_error                    = 1000.
  IF sy-subrc > 0.
  ENDIF.
send email from SAPOFFICE
  CALL FUNCTION 'SO_OBJECT_SEND'
       EXPORTING
            folder_id                  = folder_id
            object_id                  = object_id
            outbox_flag                = outbox_flag
            link_folder_id             = link_folder_id
            owner                      = sy-uname
       TABLES
            receivers                  = lt_rec_tab
            note_text                  = lt_note_text
       EXCEPTIONS
            active_user_not_exist      = 35
            communication_failure      = 71
            component_not_available    = 1
            folder_no_authorization    = 5
            folder_not_exist           = 6
            forwarder_not_exist        = 8
            object_no_authorization    = 13
            object_not_exist           = 14
            object_not_sent            = 15
            operation_no_authorization = 21
            owner_not_exist            = 22
            parameter_error            = 23
            substitute_not_active      = 31
            substitute_not_defined     = 32
            system_failure             = 72
            too_much_receivers         = 73
            user_not_exist             = 35.
ENDFUNCTION.
Regards,
Sree

Similar Messages

  • How to Convert internal table data into text output and send mail in ABAP

    Hi All,
    Good Morning.
    Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
    But thought of doing it without excel.
    I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!.  Instead I  want to send this output to User's mails as Normal mail body with No attachments.
    Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
    as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
    Best Regards
    Dileep VT

    here's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
    notice we use gt_text as "mail body"
    TRY.
    *     -------- create persistent send request ------------------------
           gv_send_request = cl_bcs=>create_persistent( ).
    *     -------- create and set document -------------------------------
    *     create text to be sent
           wa_line = text-001.
           APPEND wa_line TO gt_text.
           CLEAR wa_line.
           APPEND wa_line TO gt_text.
           LOOP AT gt_fail ASSIGNING <fs_fail>.
             MOVE <fs_fail>-retry_count TO gv_count.
             CONCATENATE text-002
                         <fs_fail>-setting_id
                         text-003
                         gv_count
                         INTO wa_line SEPARATED BY space.
             APPEND wa_line TO gt_text.
             CLEAR wa_line.
           ENDLOOP.
           APPEND wa_line TO gt_text.
           wa_line = text-007.
           APPEND wa_line TO gt_text.
    *     create actual document
           gv_document = cl_document_bcs=>create_document(
                           i_type    = 'RAW'
                           i_text    = gt_text
                           i_length  = '12'
                           i_subject = 'Failed Precalculation Settings!' ).
    *     add document to send request
           CALL METHOD gv_send_request->set_document( gv_document ).
    *     --------- set sender -------------------------------------------
           gv_sender = cl_sapuser_bcs=>create( sy-uname ).
           CALL METHOD gv_send_request->set_sender
             EXPORTING
               i_sender = gv_sender.
    *     --------- add recipient (e-mail address) -----------------------
           LOOP AT s_email INTO wa_email.
             MOVE wa_email-low TO gv_email.
             gv_recipient = cl_cam_address_bcs=>create_internet_address(
                                               gv_email ).
             CALL METHOD gv_send_request->add_recipient
               EXPORTING
                 i_recipient = gv_recipient
                 i_express   = 'X'.
           ENDLOOP.
    *     ---------- set to send immediately -----------------------------
           CALL METHOD gv_send_request->set_send_immediately( 'X' ).
    *     ---------- send document ---------------------------------------
           CALL METHOD gv_send_request->send(
             EXPORTING
               i_with_error_screen = 'X'
             RECEIVING
               result              = gv_sent_to_all ).
           IF gv_sent_to_all = 'X'.
             WRITE text-004.
           ENDIF.
           COMMIT WORK.
    *   exception handling
         CATCH cx_bcs INTO gv_bcs_exception.
           WRITE: text-005.
           WRITE: text-006, gv_bcs_exception->error_type.
           EXIT.
       ENDTRY.
    with the following declarations
    * TABLES                                                               *
    TABLES:
       adr6,
       rsr_prec_sett.
    * INTERNAL TABLES & WORK AREAS                                         *
    DATA:
       gt_fail          TYPE SORTED TABLE OF rsr_prec_sett
                             WITH UNIQUE KEY setting_id run_date,
       gt_text          TYPE bcsy_text,
       wa_fail          LIKE LINE OF gt_fail,
       wa_line(90)      TYPE c.
    FIELD-SYMBOLS:
       <fs_fail>        LIKE LINE OF gt_fail.
    * VARIABLES                                                            *
    DATA:
       gv_count(4)      TYPE n,
       gv_send_request  TYPE REF TO cl_bcs,
       gv_document      TYPE REF TO cl_document_bcs,
       gv_sender        TYPE REF TO cl_sapuser_bcs,
       gv_recipient     TYPE REF TO if_recipient_bcs,
       gv_email         TYPE adr6-smtp_addr,
       gv_bcs_exception TYPE REF TO cx_bcs,
       gv_sent_to_all   TYPE os_boolean.
    * SELECTION-SCREEN                                                     *
    SELECT-OPTIONS:
       s_email          FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
    DATA:
       wa_email         LIKE LINE OF s_email.

  • How to convert internal table data to PDF format

    HI,
         I have an internal table data having one field with 255 chars. length.I want to send that intenal table data as attachemnt with external mail. i am thinking of converting that data into PDF format and use the FM to send the mail. How to convert internal table data to PDF format.
    Kishore

    In which format is your data in the internal table currently. Is it returned by a smartform/script or its just data fetched from some database table into an internal table. Since its obvious that the data should appear in the PDF with some Layout, you should be using smartform to format the data properly. See the Link
    Smartform to PDF to EMAIL
    This shows convertion of smartform to pdf and send it through email
    Regards,
    Abhishek

  • How to convert internal table data into excel format?

    Hi all,
    I want to convert internal table data in excel format and then
    send it as email attachment in workflow.
    Please tell me how do i perform this.
    Regards,
    Arpita.

    Hi Arpita,
    Try this sample code::
    Send mail
    maildata-obj_name = 'TEST'.
    maildata-obj_descr = 'Test Subject'.
    loop at htmllines.
    mailtxt = htmllines.
    append mailtxt.
    endloop.
    mailrec-receiver = 'your receiver mail id'.
    mailrec-rec_type = 'U'.
    append mailrec.
    call function 'SO_NEW_DOCUMENT_SEND_API1'
    exporting
    document_data = maildata
    document_type = 'EXL'
    put_in_outbox = 'X'
    tables
    object_header = mailtxt
    object_content = mailtxt
    receivers = mailrec
    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.
    endif.
    Hope it will help you.
    Regards,
    NIkita

  • Convert internal table output to pdf format

    Hi all,
    my query is given below.
    <removed by moderator>
    i need to convert internal table output to Pdf. format
    the Pdf file generating.
    when i am opening the pdf. file shows error like there was an error opening this document . this file cannot be opened because it has no pages.
    please help me.
    thanks in advance.
    Regards,
    Karthikeyan Krishan
    Moderator message: please post only relevant code parts, your posts must contain less than 5000 characters each to preserve formatting.
    Edited by: Thomas Zloch on Mar 30, 2011 12:57 PM

    Hi,
    Check this link where I send data in RAW format as attachment using cl_bcs.
    Open PDF File stored in AL11 and send by email using CL_BCS.
    Regards,
    Ernesto

  • To convert Sap Script output to PDF format and send it via email.

    Hi Friends,
    Could any one please tell me, how to convert the Sap Script output to PDF format and send it via email. If any one have the code, kindly mail me to [email protected]
    Thanks & Regards,
    John

    Plese check this sample code from other thread.
    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.
    The extension is put the it_mailpack-obj_name parameter of 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

  • To convert Smart Form output to PDF format and send it via email.

    Hi Friends,
    Could any one please tell me, how to convert the Smart Forms output to PDF format and send it via email to customer. If any one have the code, kindly mail me to [email protected]
    Thanks & Regards,
    John

    Refer the links -
    how to convert smartform into pdf and send through mail
    Smartform as PDF attachment to a mail.
    smartform pdf and mail
    smartform to pdf to mail
    Regrads,
    Amit
    Reward all helpful replies.

  • Convert XSTRING to PDF Format and Send it as an attachment with work-item

    I have an Adobe Form data available in the ECC system in XSTRING format. In one of my ABAP methods (used by a custom workflow task), i want to convert the XSTRING data in PDF format and send it as an attachment with a work-item. How best can this be done?
    Appreciate any ideas,
    Saurabh

    Hi Saurabh,
    if u want to download pdf which is in xstring format to u r local system
    u can try the following code.
    data: data_tab type table of x255.
    call function 'SCMS_XSTRING_TO_BINARY'
    exporting
    buffer = XString data
    tables
    binary_tab = data_tab.
    cl_gui_frontend_services=>gui_download(
    exporting
    filename = filename
    filetype = 'BIN'
    changing
    data_tab = data_tab ).
    cl_gui_frontend_services=>execute(
    exporting
    document = filename ).
    Regards,
    Chandru

  • How to Convert internal table data into xml and xml data into internal tab

    Hi Guys,
          I have a requirement  that  i have to convert the internal table data into xml format and viceversa . for my requirement  i came to know that i have to use Transformations concept.  i done the converting the data from internal table into xml data by using standard Tranformations. My Question is 
    1) Can i use same Transformation to convert the xml data into abap internal table. if it is possible then how ???
    2) Is it possible using the standard Transformation  or I have to go for XSLT approach
    Please help me out from this guys,
    Thanks and Regards
    Koti

    Hi Koti,
    This is possible. There is a link. With the help of this link you can convert ABAP data to XML and vice versa.
    Link: http://www.heidoc.net/joomla/index.php?option=com_content&view=article&id=15:sapxslt&catid=22:sap-xslt&Itemid=31

  • 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.

  • Download internal table data in excel format

    Hi ,
      i have a requirement where i need to download the internal table data in excel format .. I tried using the FM SAP_CONVERT_TO_XLS_FORMAT  but this downloads to excel sheet  same as .txt file foemat without columns ...   i need to have the data in excel sheet with column heading and separated by each coulmn which should be similar as a general sheet with column names and the respective data in the columns . Appreciate any inputs .
    Thanks,
    Latha.

    Hi,
    you can this in Debugging mode,
    say,once you got entire data into ITAB
    salect the TABLE option and provide the table name
    now on the top most you can see excel icon,you click
    on that,now system will prompts you for to the file to be saved.
    Regards,
    Vijaya.

  • Convert spool in the text format and send mail

    Hi All
    Can anyone tell me
    how to convert the spool into the text format and send that in email as an attachment..
    Points will be rewarded
    URGENT

    Hi,
    Read spool using FM  RSPO_RETURN_ABAP_SPOOLJOB
    CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
        EXPORTING
          rqident                  = v_rqident   "Spool Number
      FIRST_LINE                 = 1
      LAST_LINE                  =
        TABLES
          buffer                     = i_spool "Internal table output
    You will get spool in internal table and then its your game, play the way you want.
    Regards,
    Mandeep

  • Payslip in PDF Format and send to mail

    Hi,
    I created one Payslip in SMARTFORMS,
    Now i want to convert into PDF Format and send as mail....
    How to do Pls help me...
    with regards
    suresh
    Edited by: rsnaidu on Jun 28, 2011 3:28 PM

    Please check this link...
    [http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm]
    -Muktar

  • ALV output converted into PDF format and send that PDF to user through mail

    Hi Experts,
    I have report earlier its output was in alv grid.
    Now i want that ALV output converted into PDF format.And that PDF output send to user through mail.
    Can u please tell how to do?
    My code is here(output is displaying in ALV grid).
    INCLUDE <icon>.
    TYPE-POOLS: slis, kkblo.
    TABLES : zmsd_freight_hdr, zmsd_freight_det, zmsd_blinfo, zmsd_diheader.
    TABLES : lfa1.
    DATA : t_hdr   LIKE   zmsd_freight_hdr   OCCURS 0 WITH HEADER LINE,
           T_DET   LIKE   ZMSD_FREIGHT_DET   OCCURS 0 WITH HEADER LINE,
           t_bl    LIKE   zmsd_blinfo        OCCURS 0 WITH HEADER LINE,
           t_di    LIKE   zmsd_diheader      OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF t_det OCCURS 0.
            INCLUDE STRUCTURE zmsd_freight_det.
    DATA    type(30).
    DATA: END OF t_det.
    DATA: v_target2(30),
          v_zsammg LIKE t_det-zsammg,
          v_gsttotal LIKE t_det-zamount.
    DATA : BEGIN OF t_data OCCURS 0,
             zsammg       LIKE  zmsd_freight_hdr-zsammg,
             zdidbl       LIKE  zmsd_freight_hdr-zdidbl,
             zvkorg       LIKE  zmsd_freight_hdr-zvkorg,
             zinvno       LIKE  zmsd_freight_hdr-zinvno,
             zttlamt      LIKE  zmsd_freight_hdr-zttlamt,
             zstatus      LIKE  zmsd_freight_hdr-zstatus,
             ztype        LIKE  zmsd_freight_hdr-ztype,
             zconfirm     LIKE  zmsd_freight_hdr-zconfirm,
             zconfirmdate LIKE  zmsd_freight_hdr-zconfirmdate,
             erdat        LIKE  zmsd_freight_hdr-erdat,
             ernam        LIKE  zmsd_freight_hdr-ernam,
             erzet        LIKE  zmsd_freight_hdr-erzet,
             aedat(10),
             aenam        LIKE  zmsd_freight_hdr-aenam,
             aezet        LIKE  zmsd_freight_hdr-aezet,
             zline        LIKE  zmsd_freight_det-zline,
             zfptype      LIKE  zmsd_freight_det-zfptype,
             zchrcode     LIKE  zmsd_freight_det-zchrcode,
             zcurcode     LIKE  zmsd_freight_det-zcurcode,
             zqty         LIKE  zmsd_freight_det-zqty,
             zuom         LIKE  zmsd_freight_det-zuom,
             zrate        LIKE  zmsd_freight_det-zrate,
             zamount      LIKE  zmsd_freight_det-zamount,
             zexrate      LIKE  zmsd_freight_det-zexrate,
           zccode       LIKE  zmsd_blinfo-zccode,      "MADK991565
             zccode       like  ZMSD_FREIGHT_HDR-zfcode, "MADK991565
             zbldate(10),
             zbl          LIKE  zmsd_blinfo-zbl,
             type(3),
             waerk        LIKE  zmsd_freight_det-zcurcode,
             zamountl     LIKE  zmsd_freight_det-zamount,
           END OF t_data.
    DATA : w_layout      TYPE   slis_layout_alv,
           w_catalog     TYPE   slis_fieldcat_alv,
           t_catalog     TYPE   slis_t_fieldcat_alv,
           w_sort        TYPE   slis_sortinfo_alv,
           t_sort        TYPE   slis_t_sortinfo_alv.
    DATA   V_ZINVNO    like   T_HDR-ZINVNO.                   "MADK991565
    DATA : v_count  TYPE  i.
    SELECTION-SCREEN BEGIN OF BLOCK a0 WITH FRAME TITLE text-001.
    PARAMETERS     :  p_zvkorg LIKE zmsd_freight_hdr-zvkorg  OBLIGATORY .
    SELECT-OPTIONS :  s_zdidbl FOR  zmsd_freight_hdr-zdidbl             ,
                      s_zccode FOR  lfa1-lifnr                          ,
                      s_status FOR  zmsd_freight_hdr-zstatus            ,
                      s_ztype  FOR  zmsd_freight_hdr-ztype              ,
                      s_erdat  FOR  zmsd_freight_hdr-erdat              ,
                      s_ernam  FOR  zmsd_freight_hdr-ernam              ,
                      s_zconfd FOR  zmsd_freight_hdr-zconfirmdate       .
    PARAMETERS     :  p_zconf  AS   CHECKBOX                            .
    SELECTION-SCREEN END OF BLOCK a0.
    SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-002.
    PARAMETERS     :  p_hdr    RADIOBUTTON GROUP rad DEFAULT 'X'        ,
                      p_det    RADIOBUTTON GROUP rad                    .
    SELECTION-SCREEN END OF BLOCK a1.
    INITIALIZATION.
    AT SELECTION-SCREEN.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM process.
      PERFORM display.
    END-OF-SELECTION.
      PERFORM fm_get_num_pages.
    AT USER-COMMAND.
    AT LINE-SELECTION.
    TOP-OF-PAGE.
      PERFORM fm_top_of_page USING '7010' sy-title space.
    FORM get_data.
      SELECT   *
        FROM   zmsd_freight_hdr
        INTO   TABLE t_hdr
       WHERE   zvkorg        EQ  p_zvkorg
         AND   zdidbl        IN  s_zdidbl
         AND   zstatus       IN  s_status
         AND   ztype         IN  s_ztype
         AND   erdat         IN  s_erdat
         AND   ernam         IN  s_ernam
         AND   zconfirmdate  IN  s_zconfd
         AND   ZFCODE        IN  S_ZCCODE.                      "MADK991565
      IF p_zconf = 'X'.
        DELETE t_hdr WHERE zconfirm NE 'C'.
      ENDIF.
      CHECK NOT t_hdr[] IS INITIAL.
      SELECT   *
        FROM   zmsd_blinfo
        INTO   TABLE t_bl
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_bl BY zsammg.
      SELECT   *
        FROM   zmsd_diheader
        INTO   TABLE t_di
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_di BY zsammg.
    IF P_DET = 'X'. "MADK933361
      SELECT   *
        FROM   zmsd_freight_det
        INTO   TABLE t_det
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg  =  t_hdr-zsammg
       AND ZINVNO =  T_HDR-ZINVNO .                           "MADK991565
    SORT t_det BY zsammg zline.                            "MADK991565
       SORT T_DET BY ZSAMMG ZINVNO ZLINE.                     "MADK991565
    ENDIF. "MADK933361
    ENDFORM.
    FORM process.
      REFRESH t_data.
      CLEAR v_gsttotal.                                         "MADK933361
      LOOP AT t_hdr.
    Start of MADK933361
        CLEAR: v_target2.
        v_zsammg = t_hdr-zsammg.
        V_ZINVNO = T_HDR-ZINVNO.                                "MADK991565
       AT NEW zsammg.                                         "MADK991565
         AT NEW ZINVNO.                                         "MADK991565
          PERFORM get_gst_value.
        ENDAT.
    End of MADK933361
        PERFORM move_header.
        CHECK t_data-zccode IN s_zccode.
        IF p_det = 'X'.
    CSF Project Changes Starts   DEV34    MADK985782
        LOOP AT T_DET WHERE ZSAMMG = T_HDR-ZSAMMG..
          LOOP AT t_det WHERE zsammg = t_hdr-zsammg AND
                              zinvno = t_hdr-zinvno.
    CSF Project Changes Ends     DEV34    MADK985782
            PERFORM move_header.
            CHECK t_data-zccode IN s_zccode.
            MOVE-CORRESPONDING t_det TO t_data.
            t_data-zamountl = t_data-zamount * t_data-zexrate.
            APPEND t_data.
            CLEAR t_data.
          ENDLOOP.
        ELSE.
          APPEND t_data.
          CLEAR t_data.
        ENDIF.
        AT END OF zsammg.
          CLEAR v_gsttotal.
        ENDAT.
    *Start of changes for  IS090901289-PIA MADK991565
        AT END OF ZINVNO.
          CLEAR V_GSTTOTAL.
        ENDAT.
    *End of changes for  IS090901289-PIA MADK991565
      ENDLOOP.
    ENDFORM.
    FORM move_header.
      MOVE-CORRESPONDING t_hdr TO t_data.
      t_data-zttlamt = t_data-zttlamt + v_gsttotal.             "MADK933361
      t_data-waerk = 'SGD'.
      IF NOT t_hdr-aedat IS INITIAL.
        WRITE: t_hdr-aedat TO t_data-aedat.
      ELSE.
        CLEAR : t_data-aedat.
      ENDIF.
      READ TABLE t_bl WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
      IF sy-subrc EQ 0.
      t_data-zccode  = t_bl-zccode.   "MADK991565
        T_DATA-ZCCODE = T_HDR-ZFCODE.   "MADK991565     
        IF NOT t_bl-zbldate IS INITIAL.
          WRITE: t_bl-zbldate TO t_data-zbldate.
        ENDIF.
        t_data-zbl     = t_bl-zbl.
        t_data-type    = 'DBL'.
      ELSE.
        READ TABLE t_di WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
        IF sy-subrc EQ 0.
        t_data-zccode  = t_di-zdiforcode.     "MADK991565
          T_DATA-ZCCODE = T_HDR-ZFCODE.         "MADK991565
          t_data-type    = 'DI'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM display.
      IF t_data[] IS INITIAL.
        MESSAGE s398(00) WITH 'No Data Selected'.
        EXIT.
      ENDIF.
      DATA : l_repid LIKE sy-repid.
      l_repid = sy-repid.
      REFRESH t_catalog.
      CLEAR   t_catalog.
      w_layout-cell_merge = 'X'.
      PERFORM map_fields.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = l_repid
                i_callback_user_command = 'ALV_USER_COMMAND'
                is_layout               = w_layout
                it_fieldcat             = t_catalog[]
                i_grid_title            = sy-title
                i_save                  = 'A'
                it_sort                 = t_sort[]
           TABLES
                t_outtab                = t_data
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.
    FORM map_fields.
    Sort Order
      CLEAR v_count.
      PERFORM sf USING 'ZDIDBL'   'X'  'X'.
    Fields to be displayed
      CLEAR v_count.
      IF p_hdr = 'X'.
        PERFORM af USING :
       DESCRIPTION       FIELD        LEN   RTABLE             RFIELD
        'DI/DBL         ' 'ZDIDBL'     '14' '                ' '        ',
        'Type           ' 'TYPE'       '04' '                ' '        ',
        'Forwarder Code ' 'ZCCODE'     '14' '                ' '        ',
        'BL Number      ' 'ZBL'        '14' '                ' '        ',
        'BL Date        ' 'ZBLDATE'    '10' '                ' '        ',
        'Invoice Number ' 'ZINVNO'     '15' '                ' '        ',
        'Extraction     ' 'ZSTATUS'    '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type   ' 'ZTYPE'      '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation   ' 'ZCONFIRM'   '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date   ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount   ' 'ZTTLAMT'    '18' '                ' '        ',
        'Created On     ' 'ERDAT'      '10' '                ' '        ',
        'Created By     ' 'ERNAM'      '10' '                ' '        ',
        'Changed On     ' 'AEDAT'      '10' '                ' '        ',
        'Changed By     ' 'AENAM'      '10' '                ' '        '.
      ELSE.
        PERFORM af USING :
       DESCRIPTION         FIELD     LEN   RTABLE             RFIELD
        'DI/DBL           ' 'ZDIDBL'   '14' '                ' '        ',
        'Type             ' 'TYPE'     '04' '                ' '        ',
        'Forwarder Code   ' 'ZCCODE'   '14' '                ' '        ',
        'BL Number        ' 'ZBL'      '14' '                ' '        ',
        'BL Date          ' 'ZBLDATE'  '10' '                ' '        ',
        'Invoice Number   ' 'ZINVNO'   '15' '                ' '        ',
        'Extraction       ' 'ZSTATUS'  '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type     ' 'ZTYPE'    '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation     ' 'ZCONFIRM' '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date     ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount     ' 'ZTTLAMT'  '18' '                ' '        ',
        'Freight Payment  ' 'ZFPTYPE'  '14' '                ' '        ',
        'Charge Code      ' 'ZCHRCODE' '10' '                ' '        ',
        'Currency         ' 'ZCURCODE' '08' '                ' '        ',
        'Quantity         ' 'ZQTY'     '13' '                ' '        ',
        'UoM              ' 'ZUOM'     '04' '                ' '        ',
        'Rate             ' 'ZRATE'    '15' '                ' '        ',
        'Amt(Foreign Curr)' 'ZAMOUNT'  '16' '                ' '        ',
        'Exchange Rate    ' 'ZEXRATE'  '13' '                ' '        ',
        'Amt(Local Curr)  ' 'ZAMOUNTL' '16' '                ' '        ',
        'Created On       ' 'ERDAT'    '10' '                ' '        ',
        'Created By       ' 'ERNAM'    '10' '                ' '        ',
        'Changed On       ' 'AEDAT'    '10' '                ' '        ',
        'Changed By       ' 'AENAM'    '10' '                ' '        '.
      ENDIF.
    ENDFORM.
    FORM af USING text
                  field
                  len
                  table
                  reffield.
      v_count = v_count + 1.
      w_catalog-col_pos       = v_count.
      w_catalog-fieldname     = field.
      w_catalog-ref_tabname   = table.
      w_catalog-ref_fieldname = reffield.
      w_catalog-seltext_s     = text.
      w_catalog-seltext_m     = text.
      w_catalog-seltext_l     = text.
      w_catalog-outputlen     = len.
      IF field = 'ZTTLAMT' OR field = 'ZAMOUNTL'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'WAERK'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
    IF FIELD = 'ZRATE' OR FIELD = 'ZAMOUNT'.
      IF field = 'ZAMOUNT'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'ZCURCODE'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
      IF field = 'ZQTY' OR field = 'ZRATE'.
        w_catalog-no_zero     = 'X'.
        w_catalog-datatype  =  'DEC'.
      ENDIF.
      APPEND w_catalog TO t_catalog.
      CLEAR  w_catalog.
    ENDFORM.
    FORM sf    USING   fieldname  sortup  group.
      v_count = v_count + 1.
      CLEAR w_sort.
      w_sort-fieldname = fieldname.
      w_sort-spos      = v_count.
      w_sort-up        = sortup.
      w_sort-group     = group.
      APPEND w_sort TO t_sort.
    ENDFORM.
    FORM alv_user_command USING  in_ucomm    LIKE sy-ucomm
                                 in_selfield TYPE slis_selfield.
      DATA: lfs_data LIKE t_data.
      IF in_ucomm = '&IC1'.
        READ TABLE t_data INDEX in_selfield-tabindex INTO lfs_data.
        CHECK NOT lfs_data-zdidbl IS INITIAL.
        IF lfs_data-type = 'DBL'.
          DATA: l_zdbl LIKE zmsd_diheader-zdinum.
          l_zdbl = in_selfield-value.
          EXPORT l_zdbl TO MEMORY ID 'VBL'.
          CALL TRANSACTION 'ZMSD_BL01'.
        ENDIF.
        IF lfs_data-type = 'DI'.
          DATA: v_dinum LIKE zmsd_diheader-zdinum.
          v_dinum = in_selfield-value.
          EXPORT v_dinum TO MEMORY ID 'VDI'.
          CALL TRANSACTION 'ZMSD_DI01'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM get_gst_value.
      LOOP AT t_det WHERE zsammg = v_zsammg
         AND ZINVNO = V_ZINVNO.                              "MADK991565
        CHECK t_data-zccode IN s_zccode.
        t_det-zamount  = t_det-zamount * t_det-zexrate.
        SELECT SINGLE  y0mmtarget2
                INTO   v_target2
                FROM   y0mmipstranslate
                WHERE  y0mmdatatype = '70' AND
                       y0mmsource = t_det-zchrcode.
        SELECT SINGLE y0mmtarget1
               INTO   t_det-type
               FROM   y0mmipstranslate
               WHERE  y0mmdatatype = '76' AND
                      y0mmsource = v_target2.
        IF t_det-type NE '3Z'.
          v_gsttotal    = v_gsttotal +
                               ( t_det-zamount * 5 / 100 ).
        ENDIF.
      ENDLOOP.
    Regards,
    Raj.

    Hello,
    Following is the procedure to convert alv output to spool and then it to PDF Format.
    After we display the ALV, we can check whether it is running in the background using system field u2018sy-batchu2018. Then,we call an function module named u2018GET_JOB_RUNTIME_INFOu2019 to get the current job information. Then go to spool request table tbtcp to get the spool id.
    Get current job details
      CALL FUNCTION u2018GET_JOB_RUNTIME_INFOu2019
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                               AND jobcount = gd_jobcount
                               AND stepcount = gd_stepcount
                               AND listident <> u20180000000000u2032
                               ORDER BY   jobname
                                                   jobcount
                                                   stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
    Finally, we can call function module u2018CONVERT_ABAPSPOOLJOB_2_PDFu2018 to convert spool reqeust(which is stored in OTF format) to PDF format. Then we can call either function module u2018SO_DOCUMENT_SEND_API1u2032 or SAP BCS (Business Communication Service) to send the pdf as an email attachment.
    CALL FUNCTION u2018CONVERT_ABAPSPOOLJOB_2_PDFu2019
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount = gd_bytecount
           TABLES
                pdf = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 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
                OTHERS                   = 12.
    Regards,
    Sayali
    Edited by: Sayali Paradkar on Apr 20, 2010 12:51 PM

  • Convert Smartform in PDF format and send to SAP Workplace

    Hi to all.
    I need help of somebody expert in SMARTFORM's.
    I need to convert a smartform into PDF format and to send as attachement for SAP workplace
    of the user.
    I developed the next code.
    IT is to function and to send the mail for SAP workplace, but it happens that smartform
    contains images (logos) and tables, when the user tries to open the file pdf in inbox gives
    to error - "An unrecognized token ' q0 ' was found".
    I tried to call a smartform only with text and functioned well.
    Somebody can help me?
    My code:
    Begin ***********************************************
    REPORT zteste_nsa_send_pdf_sap_office.
    DATA: t_print LIKE zeps_fm04 OCCURS 0 WITH HEADER LINE,
          v_size TYPE i.
    DATA: ls_bil_invoice TYPE lbbil_invoice.
    TABLES: nast.
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
    i_tline TYPE TABLE OF tline WITH HEADER LINE,
    i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
    i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    wa_objhead TYPE soli_tab,
    w_ctrlop TYPE ssfctrlop,
    w_compop TYPE ssfcompop,
    w_return TYPE ssfcrescl,
    wa_doc_chng TYPE sodocchgi1,
    w_data TYPE sodocchgi1,
    wa_buffer TYPE string,"To convert from 132 to 255
    Variables declarations
    v_form_name TYPE rs38l_fnam,
    v_len_in LIKE sood-objlen,
    v_len_out LIKE sood-objlen,
    v_len_outn TYPE i,
    v_lines_txt TYPE i,
    v_lines_bin TYPE i.
    START-OF-SELECTION.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZFPS_FICHA_VALORIZACAO'
        IMPORTING
          fm_name            = v_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.
      w_ctrlop-getotf    = 'X'.
      w_ctrlop-no_dialog = 'X'.
      w_compop-tdnoprev  = 'X'.
      CALL FUNCTION v_form_name
        EXPORTING
          control_parameters = w_ctrlop
          output_options     = w_compop
          user_settings      = 'X'
          is_bil_invoice     = ls_bil_invoice
          is_nast            = nast
          is_repeat          = 'X'
        IMPORTING
          job_output_info    = w_return
        TABLES
          t_list             = t_print
        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.
      i_otf[] = w_return-otfdata[].
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
          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.
      IF sy-subrc EQ 0.
      ENDIF.
    Convert PDF from 132 to 255.
      LOOP AT i_tline.
        TRANSLATE i_tline USING '~'.
        CONCATENATE wa_buffer i_tline INTO wa_buffer.
      ENDLOOP.
      TRANSLATE wa_buffer USING '~'.
      DO.
        i_record = wa_buffer.
        APPEND i_record.
        SHIFT wa_buffer LEFT BY 255 PLACES.
        IF wa_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    SEND MAIL
      REFRESH:  i_reclist,
                i_objtxt,
                i_objbin,
                i_objpack.
      CLEAR wa_objhead.
    Object with PDF.
      i_objbin[] = i_record[].
    Object with main text of the mail.
      i_objtxt = 'Fichas de Valorização e Esquemas Tipo'.
      APPEND i_objtxt.
    Document information.
      wa_doc_chng-obj_name   = 'SMART'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr  = 'Ficha de Valorização'.
      wa_doc_chng-sensitivty = 'F'. "Functional object
      wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
    Pack to main body as RAW.
    Obj. to be transported not in binary form
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      READ TABLE i_objtxt INDEX v_lines_txt.
      CLEAR i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num   = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num   = v_lines_txt.
      i_objpack-doc_type   = 'RAW'.
      APPEND i_objpack.
    Packing as PDF.
    Obj. to be transported in binary form
      DESCRIBE TABLE i_objbin LINES v_lines_bin.
      READ TABLE i_objbin INDEX v_lines_bin.
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num   = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num   = v_lines_bin.
      i_objpack-doc_type   = 'PDF'.
      i_objpack-obj_name   = 'SMART'.
      CONCATENATE 'Ficha_Valorizacao' '.pdf' INTO i_objpack-obj_descr.
      i_objpack-doc_size = ( v_lines_bin - 1 ) * 255 + STRLEN( i_objbin ).
      APPEND i_objpack.
    e-mail receivers.
      CLEAR i_reclist.
      i_reclist-receiver = sy-uname.
      i_reclist-rec_type = 'B'.
      i_reclist-express  = 'X'.
      APPEND i_reclist.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_chng
          put_in_outbox              = 'X'
          commit_work                = ' '
        TABLES
          packing_list               = i_objpack
          object_header              = wa_objhead
          contents_bin               = i_objbin
          contents_txt               = i_objtxt
          receivers                  = i_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 EQ 0.
      ENDIF.
    End  *************************************************
    Thanks very much to all and Happy New year...
    Nelson

    Please check this link...
    [http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm]
    -Muktar

Maybe you are looking for

  • How do I move multiple dimension members up one level in planning?

    I can't figure out how to select multiple members. I hope I don't have to cut and paste them individually.

  • Will GargeBand run on an iBook G3?

    Hi everyone, I'm thinking of getting an iBook G3 but I'd like to use it for recording. Has anyone tried running Garage Band on an iBook and if so what's the minimum RAM and processor speed needed?

  • OCR: acrobat 9 or readiris?

    Hi all, I have to OCR many PDF and make them searchable. I've both Acrobat 9 and Readiris 11, anyone know of any important difference between the OCR process of the two software (which one is better to use?). Many thanks!

  • Help required in exectuting the Planning Function

    Hello All, I need help in fulfilling the following requirement through planning functions in IP: I have 4 keyfigures as Actual Value,Actual Quan,Plan Value and Plan Quan. Now what I want to do is to COPY: 1)Actual Value>>> PLan Value and then revalua

  • First Text field in page submits when Enter key is hit. Don't want Submit

    Hi, I have searched and can't find this answer I got before... The Text field does not have the Submit always when pressed included, just a standard Text Item. because it is the first text field in the page.. or maybe it was because its the only text