FUNCTION MODULE FOR AUTOMATIC MAIL GENERATION

Hello,
I want to generate an automatic mail of a scheduled report on everyday basis.
the output spool req of scheduled report in generated n saved inside the system.
Could you please help me in generating automatic mail through that saved spool request?
Regards,
Krutika

hi,
use:
DATA: lv_filesize    TYPE i,
        lv_buffer      TYPE string,
        lv_attachment  TYPE i,
        lv_testo       TYPE i.
  DATA: li_pdfdata  TYPE STANDARD TABLE OF tline,
        li_mess_att TYPE STANDARD TABLE OF solisti1,
        li_mtab_pdf TYPE STANDARD TABLE OF tline,
        li_objpack  TYPE STANDARD TABLE OF sopcklsti1,
        li_objtxt   TYPE STANDARD TABLE OF solisti1,
        li_objbin   TYPE STANDARD TABLE OF solisti1,
        li_reclist  TYPE STANDARD TABLE OF somlreci1,
        li_objhead  TYPE soli_tab.
  DATA: lwa_pdfdata  TYPE tline,
        lwa_objpack  TYPE sopcklsti1,
        lwa_mess_att TYPE solisti1,
        lwa_objtxt   TYPE solisti1,
        lwa_objbin   TYPE solisti1,
        lwa_reclist  TYPE somlreci1,
        lwa_doc_chng TYPE  sodocchgi1.
  CONSTANTS: lc_u           TYPE char1  VALUE 'U',
             lc_0           TYPE char1  VALUE '0',
             lc_1           TYPE char1  VALUE '1',
             lc_pdf         TYPE char3  VALUE 'PDF',
             lc_raw         TYPE char3  VALUE 'RAW',
             lc_ordform     TYPE char15 VALUE 'ZORDCONFIRM_01',
             lc_attachment  TYPE char10 VALUE 'ATTACHMENT'.
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = lc_pdf
      max_linewidth         = 132
    IMPORTING
      bin_filesize          = lv_filesize
    TABLES
      otf                   = pv_otfdata
      lines                 = li_pdfdata
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      err_bad_otf           = 4
      OTHERS                = 5.
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  LOOP AT li_pdfdata INTO lwa_pdfdata.
    TRANSLATE lwa_pdfdata USING ' ~'.
    CONCATENATE lv_buffer lwa_pdfdata INTO lv_buffer.
    CLEAR lwa_pdfdata.
  ENDLOOP.
  TRANSLATE lv_buffer USING '~ '.
  DO.
    lwa_mess_att = lv_buffer.
    APPEND lwa_mess_att TO li_mess_att.
    CLEAR lwa_mess_att.
    SHIFT lv_buffer LEFT BY 255 PLACES.
    IF lv_buffer IS INITIAL.
      EXIT.
    ENDIF.
  ENDDO.
Object with PDF.
  REFRESH li_objbin.
  li_objbin[] = li_mess_att[].
  DESCRIBE TABLE li_objbin LINES lv_attachment.
Object with main text of the mail.
  lwa_objtxt = space.
  APPEND lwa_objtxt TO li_objtxt.
  CLEAR lwa_objtxt.
  DESCRIBE TABLE li_objtxt LINES lv_testo.
Create the document which is to be sent
  lwa_doc_chng-obj_name  = text-008.
  lwa_doc_chng-obj_descr = text-008.
  lwa_doc_chng-sensitivty = lc_0.
  lwa_doc_chng-obj_prio = lc_1.
  lwa_doc_chng-doc_size = lv_testo * 225.
Pack to main body.
  CLEAR lwa_objpack-transf_bin.
header
  lwa_objpack-head_start = 1.
The document needs no header (head_num = 0)
  lwa_objpack-head_num   = 0.
body
  lwa_objpack-body_start = 1.
  lwa_objpack-body_num   = lv_testo.
  lwa_objpack-doc_type   = lc_raw.
  APPEND lwa_objpack TO li_objpack.
  CLEAR lwa_objpack.
Create the attachment.
Fill the fields of the packing_list for the attachment:
  lwa_objpack-transf_bin = gc_x .
header
  lwa_objpack-head_start = 1.
  lwa_objpack-head_num   = 1.
body
  lwa_objpack-body_start = 1.
  lwa_objpack-body_num   = lv_attachment.
  lwa_objpack-doc_type   = lc_pdf.
  lwa_objpack-obj_name   = lc_attachment.
  lwa_objpack-obj_descr  = text-008.
  lwa_objpack-doc_size =  lv_attachment * 255.
  APPEND lwa_objpack TO li_objpack.
  CLEAR lwa_objpack.
  lwa_reclist-receiver   = pv_emailid.
  lwa_reclist-rec_type   = lc_u.
  lwa_reclist-notif_del  = gc_x.
  lwa_reclist-notif_ndel = gc_x.
  APPEND lwa_reclist TO li_reclist.
  IF li_reclist IS NOT INITIAL.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = lwa_doc_chng
        put_in_outbox              = gc_x
      TABLES
        packing_list               = li_objpack
        object_header              = li_objhead
        contents_bin               = li_objbin
        contents_txt               = li_objtxt
        receivers                  = li_reclist
      EXCEPTIONS
        too_many_receivers         = 1
        document_not_sent          = 2
        document_type_not_exist    = 3
        operation_no_authorization = 4
        parameter_error            = 5
        x_error                    = 6
        enqueue_error              = 7
        OTHERS                     = 8.
    IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.

Similar Messages

  • Functional module for automatic creation of pur requisition & pur order

    hello,
    what is the functional module for automatic creation of puchase requisition and automatic creation of purchase order which we will assign in action box in service order processing management.
    please let me know as early as possible
    regards,
    rajesh kumar raju

    Hi,
             Please check with following.
    IDOC_INPUT_ACC_PURCHASE_REQUI
    IDOC_INPUT_ACC_PURCHASE_ORDER
    /ISDFPS/OR_PURCHASE_ORDER_CR
    BS01_PURCHASE_DOCUMENT_CREATE
    CO_MP_CREATE_PURCHASE_ORDER
    Thanks & Regards
    Sadhu Kishore

  • Function Module For Sending Mail

    Hi Experts,
    Is there any function module to send a mail from the ABAP program.
    My requirement is to run a report and send the content of the an Internal table as mail.
    Thanks in Advance

    hI,
      Here is the example program
    *& Report ZSENDEMAIL *
    *& Example of sending external email via SAPCONNECT *
    REPORT zsendemail .
    PARAMETERS: psubject(40) type c default 'Hello',
    p_email(40) type c default '[email protected]' .
    data: it_packing_list like sopcklsti1 occurs 0 with header line,
    it_contents like solisti1 occurs 0 with header line,
    it_receivers like somlreci1 occurs 0 with header line,
    it_attachment like solisti1 occurs 0 with header line,
    gd_cnt type i,
    gd_sent_all(1) type c,
    gd_doc_data like sodocchgi1,
    gd_error type sy-subrc.
    data: it_message type standard table of SOLISTI1 initial size 0
    with header line.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Perform populate_message_table.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    PERFORM send_email_message.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *& Form POPULATE_MESSAGE_TABLE
    Adds text to email text table
    form populate_message_table.
    Append 'Email line 1' to it_message.
    Append 'Email line 2' to it_message.
    Append 'Email line 3' to it_message.
    Append 'Email line 4' to it_message.
    endform. " POPULATE_MESSAGE_TABLE
    *& Form SEND_EMAIL_MESSAGE
    Send email message
    form send_email_message.
    Fill the document data.
    gd_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
    gd_doc_data-obj_langu = sy-langu.
    gd_doc_data-obj_name = 'SAPRPT'.
    gd_doc_data-obj_descr = psubject.
    gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
    clear it_packing_list.
    refresh it_packing_list.
    it_packing_list-transf_bin = space.
    it_packing_list-head_start = 1.
    it_packing_list-head_num = 0.
    it_packing_list-body_start = 1.
    describe table it_message lines it_packing_list-body_num.
    it_packing_list-doc_type = 'RAW'.
    append it_packing_list.
    Add the recipients email address
    clear it_receivers.
    refresh it_receivers.
    it_receivers-receiver = p_email.
    it_receivers-rec_type = 'U'.
    it_receivers-com_type = 'INT'.
    it_receivers-notif_del = 'X'.
    it_receivers-notif_ndel = 'X'.
    append it_receivers.
    Call the FM to post the message to SAPMAIL
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    exporting
    document_data = gd_doc_data
    put_in_outbox = 'X'
    importing
    sent_to_all = gd_sent_all
    tables
    packing_list = it_packing_list
    contents_txt = it_message
    receivers = it_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.
    Store function module return code
    gd_error = sy-subrc.
    Get it_receivers return code
    loop at it_receivers.
    endloop.
    endform. " SEND_EMAIL_MESSAGE
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
    wait up to 2 seconds.
    if gd_error eq 0.
    submit rsconn01 with mode = 'INT'
    with output = 'X'
    and return.
    endif.
    endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    Regards

  • Function module for dynamic view generation

    Hi experts,
    I am trying to dynamically convert all the screens used by a module pool program into their
    corresponding views in Web Dynpro environment. Although there is a function module used by the web
    dynpro conversion wizard tool in SE80, this does not generate views dynamically but only
    statically.  Can anybody please tell me a module which can perform this conversion of screens into  views when
    the module pool  program name is specified dynamically at runtime?
    Thanks in advance.............
    Edited by: Adithya K Ramesh on Oct 12, 2010 2:51 PM

    Hi experts,
    I am trying to dynamically convert all the screens used by a module pool program into their
    corresponding views in Web Dynpro environment. Although there is a function module used by the web
    dynpro conversion wizard tool in SE80, this does not generate views dynamically but only
    statically.  Can anybody please tell me a module which can perform this conversion of screens into  views when
    the module pool  program name is specified dynamically at runtime?
    Thanks in advance.............
    Edited by: Adithya K Ramesh on Oct 12, 2010 2:51 PM

  • Error with Function Module for Automatically Reversing FI Documents

    We are trying to use BAPIACREV to automatically reverse a document as part of workflow but get an error with 2 of the import parameters stating they were never transferred:
    1) OBJ_KEY_R
    2) OBJ_SYS
    Does anyone know how to resolve this?

    Hi,
    OBJ_KEY : Reference Key
    This key value must be created while posting the document and this key must be maintained in any of SAP tables
    for example : If the it is Accounting document then all detail found in BKPF and BSEG table, you can find OBJ_KEY in BKPF-AWKEY field.
    OBJ_SYS : Logical system of source document
    Logical system may be maintained in some table.
    for example : If the it is Accounting document then all detail found in BKPF and BSEG table, you can find OBJ_SYS in BKPF-AWSYS field.
    or you can use following FM to get logical system
    CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
    OWN_LOGICAL_SYSTEM = L_V_OWN_LOGICAL_SYSTEM
    EXCEPTIONS
    OWN_LOGICAL_SYSTEM_NOT_DEFINED = 1
    OTHERS = 2

  • Function module for fiscal year

    Hi all,
    can you please suggest me the function module for automatic generation of fiscal year.
    Thanks and regards,
    S.Latha.

    Hi Latha,
    Please find below the code for auto generation of the fiscal year.
      l_date = sy-datum.       "l_date should declared of type sy-datum
    Use the function module to get the period
          CALL FUNCTION 'MC_PERIODE_ZUM_DATUM'
               EXPORTING
                    idate        = l_date
                    iperkz      = l_p         " 'P'
                    iperiv       = l_periv   "V6
               IMPORTING
                    eperid       = l_period
               EXCEPTIONS
                    wrong_period = 1
                    OTHERS       = 2.
    l_fiscal = l_period+0(4).
    l_p - 'P'   i. e. Is the period indicator (Period according to fiscal year variant)
    l_periv - 'V6'  i.e. Is the Fiscal year variant. Here it is V6 which relates country 'US'.
    l_period - gives you the Fiscal period.
    l_fiscal -  The first four digits of l_period gives you the 'Fiscal year'.
    Hope this helps you !.
    Thanks & Regards,
    MM Jaffer.
    Edited by: MohammedJaffer on Aug 10, 2010 12:53 PM

  • Function module for background jobs email

    hi abaper's
                     i hace to create a function module for background jobs this function module have to send an email automatically when a background job is assigned or processed in background.
    thnks n regards
    pardeep kumar

    hi dear
    open this site
    https://weblogs.sdn.sap.com/pub/wlg/781. [original link is broken] [original link is broken] [original link is broken]
    <removed by moderator>
    Edited by: Mike Pokraka on Aug 8, 2008 12:48 PM

  • Is there any function module for getting distribution list name

    Hi all,
    Is there any function module for getting distribution list name when there is same description for two distribution list name.
    or
    help me how to fetch the correct distribution name when there is same description.
    In order to send mails.
    Tell me ASAP.
    thanks
    sagar.

    http://www.sapbrainsonline.com/REFERENCES/FunctionModules/SAP_function_modules_list.html
    list of Fms

  • Function module to send mail from SAP

    Can any one please tell the Function module to send mail from SAP. The scenario is like this,I have a file in local system that i have to send to a particular mail address like [email protected] through a report program.

    Hi shafiq,
    1. There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

  • Function Module for sending an Attachment

    Not able to find the Function Module for sending an Attachment to the email ids.
    Please help.

    Hi bala,
    1. There is some trick involved in attachment
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

  • Function Module For F-04

    Hi
    Is there any function module for F-04 transaction.
    Please help with answers.

    Hi,
    Check the following Exits
    SAPLF051                     Workflow for FI (pre-capture, release for payment)
    RFKORIEX                    Automatic correspondence
    RFEPOS00                   Line item display: Checking of selection conditions
    RFAVIS01                  Customer Exit for Changing Payment Advice Segment Text
    FEDI0001                    Function Exits for EDI in FI
    FARC0002                  Additional Checks for Archiving MM Vendor Master Data
    F180A001                  Balance Sheet Adjustment
    reward if useful
    regards,
    Anji

  • Function module for attachments

    Is there any function module for attaching excel sheet?
    Thanks.....

    Hi,
    I am not clear with ur question.You mean u want to send an attachment through mail.Then check this link
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    Hope this helps u.
    Kindly reward points if this helps u.
    Thanks&Regards,
    Ruthra.R
    Message was edited by: Ruthra

  • Function module for multiple selection.

    Hi
    I have three parameters on selection screen 1. Process order number, 2.Order category and 3. order type.
    My requirement is:
    As i press F4 on order number and select one of the available orders, the other two fields should populate automatically with their correnponding values.
    Is there any Function module for this purpose?
    Thanks in advance,
    Alok

    Hi Alok..
    Check this FM:
    F4IF_INT_TABLE_VALUE_REQUEST
    This FM is used to dsiplay values stored in an internal table as input help.
    This FM is used to program our own custom help if no such input help exists in ABAP dictionary for a particular field.
    The parameter VALUE_TAB is used to pass the internal table containing input values.
    <b>The parameter RETFIELD is used to specify the internal table field whose value will be returned to the screen field or RETURN_TAB.
    </b>  
    If DYNPNR,DYNPPROG and DYNPROFIELD are specified than the user selection is passed to the screen field specified in the DYNPROFIELD. If RETURN_TAB is specified the selectionis returned in a table.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                RETFIELD           = field from int table whose value will be returned
                DYNPPROG        = SY-CPROG
                DYNPNR             = SY-DYNNR
                DYNPROFIELD    = 'screen field'
                VALUE_ORG       = 'S'
           TABLES
                VALUE_TAB        = internal table whose values will be shown.
                RETURN_TAB      = internal table of type DDSHRETVAL
           EXCEPTIONS
                parameter_error    = 1
                no_values_found   = 2
                others                  = 3.
    <b>reward if Helpful</b>

  • Generic function module for delta - which FM ?

    Hi all,
    I want to create a custom generic datasource in R3 which uses a function module for delta extraction. This is straight forward for full extract (copy FM RSAX_BIW_GET_DATA_SIMPLE - I already did this and have a full extraction working to BW). However I need to extract delta - and the above function module does not have example code for that (I have seen some forum posts that it 'can' be used - but this looks like a pseudo get around where the delta field name is passed in I_T_SELECT).
    FM RSVD_BW_GET_DELTA_DATA seems to be an example code of a FM which can allow delta (i.e. manually codes how to fill date/time stamp information). However when I code this and try test in RSA3 it seems to try to populate the delta selection field before calling my function module! I need it to call my function and allow the function to specifiy the date criteria.
    Can anyone help with an example of how this should best  be done ?
    Or can it only be done in a pseudo form using 'RSAX_BIW_GET_DATA_SIMPLE' example FM.
    Note: I have setup the RSO2 datasource to allow delta.
    Also - I have spent several hours searching the forum - but please answer with a link if you think it does answer exactly this problem.
    Thanks for any help
    Martin

    Hi again,
    Have had a few requests for the code I used - I created a new custom function copied from 'RSAX_BIW_GET_DATA_SIMPLE'. AEDAT has been set as the delta date for this data source in transaction RSO2.
    Main sample code is -
    1. Code to receive selection criteria and store in internal ranges -
    FUNCTION zbw_sodetail_get_detail.                                   
    ""Global interface:                                               
    *"   IMPORTING                                                  
    *"       VALUE(I_REQUNR) TYPE  SRSC_S_IF_SIMPLE-REQUNR        
    *"       VALUE(I_DSOURCE) TYPE  SRSC_S_IF_SIMPLE-DSOURCE      
    *"       VALUE(I_MAXSIZE) TYPE  SRSC_S_IF_SIMPLE-MAXSIZE      
    *"       VALUE(I_INITFLAG) TYPE  SRSC_S_IF_SIMPLE-INITFLAG    
    *"       VALUE(I_READ_ONLY) TYPE  SRSC_S_IF_SIMPLE-READONLY   
    *"       TABLES                                                     
    *"              I_T_SELECT TYPE  SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL 
    *"              I_T_FIELDS TYPE  SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL 
    *"              E_T_DATA STRUCTURE  ZBW_SODETAIL OPTIONAL           
    *--- Sales order item create date                                      
       LOOP AT i_t_select INTO l_s_select WHERE fieldnm = 'ERDAT'.         
          MOVE-CORRESPONDING l_s_select TO r_erdat.                        
          APPEND r_erdat.                                                  
       ENDLOOP.                                                                               
    *--- Sales order item change date - DELTA only - auto filled before    
       this function is called.                                          
       C (Initialise Delta) - Low = blank, High = today - safety limit   
       D (Delta) - low = , High =   .       *from roosgendlm             
       LOOP AT i_t_select INTO l_s_select WHERE fieldnm = 'AEDAT'.         
          MOVE-CORRESPONDING l_s_select TO r_aedat.                        
          APPEND r_aedat.                                                  
       ENDLOOP.                                                                               
    2. Code to use selection criteria to get initial or delta. Note that for delta the delta date field to be used is automatically populated with the date of the last delta run (from table roosgendlm) -
       SELECT VBAK~KNUMV
              VBAPVBELN VBAPPOSNR VBAPMATNR VBAPARKTX VBAP~SPART
              VBAPWERKS VBAPERDAT VBAPAEDAT VBAPNETWR VBAP~WAERK
              VBAPABGRU VBAPZPROMISE VBAP~CUOBJ
              VBEP~EDATU
          INTO CORRESPONDING FIELDS OF TABLE ZBW_SODETAIL_ITAB
          FROM VBAK JOIN VBAP ON VBAKVBELN = VBAPVBELN
                    JOIN VBEP ON VBAPVBELN = VBEPVBELN
                             AND VBAPPOSNR = VBEPPOSNR
       WHERE VBAP~VBELN IN R_VBELN        "Order number
         AND VBAP~POSNR IN R_POSNR        "Order item number
         AND VBAP~ERDAT IN R_ERDAT        "Order item date created
        AND ( VBAP~ERDAT IN R_AEDAT OR   "Created date in      Delta range
                  VBAP~AEDAT IN R_AEDAT OR   "Order item change    Delta range
                  VBAK~AEDAT IN R_AEDAT ).   "Order header change  Delta range
    Note that if the data source is called in initial or full extract mode the delta change date (aedat) will automatically be blank.
    I have been using this successfully.
    I hope this helps
    Martin.

  • Function module for sending email

    Hi all,
    Can I know list of function modules for sending emails.
    Other than "SO_DOCUMENT_SEND_API1"
    pls let me know

    Hi Praveen,
    Below is the sample code to send the external mail.
    &**********Reward Points if helpful**********&
    DATA: ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des .
           ld_receiver LIKE  sy-subrc.
      DATA:   it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
              it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
              it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
              w_cnt TYPE i,
              w_sent_all(1) TYPE c,                             "#EC NEEDED
              w_doc_data LIKE sodocchgi1.
      REFRESH it_receivers . CLEAR it_receivers .
      IF v_trip_send = 'X'.
        it_receivers-receiver = it_trip_dload-approver_email .
      ELSE .
        it_receivers-receiver = it_adv_dload-approver_email .
      ENDIF.
      it_receivers-rec_type = c_u .
      APPEND it_receivers. CLEAR it_receivers.
    it_receivers-receiver = " ------> pass your reciever email id.
      IF v_trip_send = 'X' .
        it_receivers-receiver = it_trip_dload-requester_email .
      ELSE .
        it_receivers-receiver = it_adv_dload-requester_email .
      ENDIF .
      it_receivers-rec_type = c_u .
      it_receivers-copy     = 'X' .
      APPEND it_receivers. CLEAR it_receivers.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
    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  = c_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   = c_saprpt.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = c_f.
      CLEAR it_attachment.
      REFRESH it_attachment.
      it_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR it_packing_list.
      REFRESH it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES it_packing_list-body_num.
      it_packing_list-doc_type = c_raw.
      APPEND it_packing_list.
    Create attachment notification
      it_packing_list-transf_bin = c_x.
      it_packing_list-head_start = 1.
      it_packing_list-head_num   = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE it_attachment LINES it_packing_list-body_num.
      it_packing_list-doc_type   =  ld_format.
      it_packing_list-obj_descr  =  ld_attdescription.
      it_packing_list-obj_name   =  ld_attfilename.
      it_packing_list-doc_size   =  it_packing_list-body_num * 255.
      APPEND it_packing_list.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data = w_doc_data
          put_in_outbox = c_x
          commit_work   = c_x
        IMPORTING
          sent_to_all   = w_sent_all
        TABLES
          packing_list  = it_packing_list
          contents_bin  = it_attachment
          contents_txt  = it_message
          receivers     = it_receivers.

Maybe you are looking for

  • Mac mini not booting up with 8GB memory after 10.7.2 update

    My mac mini is not booting up with 8GB of memory after the 10.7.2 update. It just keeps on beeping and flashing the led. If I take out the upper DIMM (Bank 1) It boots just fine, and it does so with either one of the 4GB DIMMs in Bank 0, so the DIMMs

  • XML - Making use of Parsed Contents

    Hi all, i would like to know how i can make use of XML data - gotten from a URL as a data stream- which i parsed using the SAX parser.... code looks something like this: DefaultHandler handler = new indexParser(); SAXParser saxParser = SAXParserFacto

  • Set up Depreciation Key with specific depreciation date

    Hi Gurus,        Our system is ERP 4.7. I am trying to set up the depreciation key with the specific depreciation date. Here is more detail; I have the tax requirement that the asset will get depreciated at 25% until 03/31/08 and 20% from 04/01/08. I

  • Data transfer process: use values of filter in routine

    Hi, I create a filter in the data transfer process (RSA1). There are two infoobjects (ZABC, ZXYZ) in the filter. I fill the first select-option (parameter) with the value u2018AAAAu2019. At the second line I create the filter routine: form compute_/B

  • Website in IE

    my website looks fine in safari and firefox, but the formatting is funky in IE. how do i adjust that?