To set - Reply to - in Mail Function Module

Hi Friends,
I have one requirement like the mail which is sent from SAP , when i reply to that mail , should be replied to some other email id not the one which comes automatically something like "USERNAME" "<ADR24000000007234DVLXYZ xyz.com>" .
Basically, I want to set "Reply To" kind of thing in Function module to send mails, so that when I reply to recived mail, it should reply to the other mail which i"ll set in reply to.
Hope u got my point.
Thanks in advance.
<removed_by_moderator>
Regards.
Edited by: Julius Bussche on Sep 8, 2008 12:33 PM

Please follow these steps:
1.) tcode = SCOT
2.) double click SMTP
3.) under "SMTP Connection" section, fill in your mail host IP(ex: webmail.sap.com) and the port number(25) and code page = No conversion.
4.) under "Supported address types", make sure Internet is checked, and click on "Set". The Address area has to be *
5.) To test route,
SCOT -->Utilities --> Routing test
RecipientAddr.type = INT
Recipient addr. =
6.) You also need to set the Default Domain.
SCOT --> Settings --> Default Domains (webmail.sap.com)
7.)Now go to tcode SBWP,compose a mail and in the recipient address,enter email id and send.
8.) Come back to SCOT and click on Utilities-->Start send process(Ctrl+F7) and execute.
You will receive the mail in your external mail id.
I dont know as to why we should do step 8,but in my case the mails were sent only after performing step8.
Hope it is helpful to you.
regards,
Rahul

Similar Messages

  • How to set lowercase/uppercase checkbox in function module/RFC

    Hi2All
    I m importing username and id in a RFC. i want this username as it is when we pass it in function module. if we set the check box lowercase/uppercase option when executing function module, it will keep all input as it is (means will not convert all inputs to CAP) .
    So how can i keep this chechboc checked forever for my RFC?
    Bye....!!!

    Hi,
    I don't think that's possible. I cannot able to find any SET/GET parameter assigned to it. If you are calling RFC from some other application, then you need to send your data as capital letters, or if it is custom RFC , then you can code into your code to convert small to capital letters. or if you are using a SAP standard then write wrapper function module.

  • Sending mail function module problem in WAS.

    We have one custom function module Z_SEND_MAIL_ALL
    which is sending mails successfully with in the SAP 4.7 E system.
    Our function module Z_SEND_MAIL_ALL uses internally function modules like SO_OBJECT_SEND and SO_OBJECT_INSERT...
    Now we copied the same function module Z_SEND_MAIL_ALL into another system which is running in WAS server and
    when we run the function module it seems it is sending as attachment, however when I try to open the attachement...it gives dump. I clicked debugger.
    It shows  while CALL FUNCTION 'TABLE_DECOMPRESS' execution...
    it gives exception ( Error in compressed table ) as below  ...
    <b>raise COMPRESS_ERROR.</b>....
    I don't understand what is the problem ?
    Is it because of WAS is fully unicode compliance,  these function modules are not working . or is there any thing else I can do ....
    YOUR help is highly appreciated and respected.

    You have to declare the table using any specific type.
    The type table in the FM is generic so you can pass any type you need.
    For instance:
    TYPES: BEGIN OF ty_fields,
             fieldname LIKE dfies-fieldname,
           END OF ty_fields,
    TYPES: TY_T_GLU1              LIKE GLU1                     OCCURS 0,
           ty_t_fields            type ty_fields                occurs 0.
      DATA: lt_info_struct_fields TYPE ty_t_fields WITH HEADER LINE,
            lt_matching_fields    TYPE ty_t_fields WITH HEADER LINE.
        CALL FUNCTION 'AS_API_INFOSTRUC_FIND'
             EXPORTING
                  i_fieldcat         = ft_fieldcat-fieldcat
                  i_fields           = ft_fields_filled[]
             IMPORTING
                  e_infostruc        = lv_info_struct_name
                  e_all_fields       = lt_info_struct_fields[]
                  e_matching_fields  = lt_matching_fields[]
             EXCEPTIONS
                  no_infostruc_found = 1.

  • TC: VTRC - Set up Meta Data (Customize function module)

    For few business requirements we have decided to customize the standard function module in "meta data setup" in VTRC transaction. During the analysis i have put the break point in the function module. System is not stopping at that point when i am executing transactions in foreground.
    I came to know that we have to activate few settings, so that system will stop at that break point level. Could any body let me know what are these settings?
    Thanks & Regards

    hi
    which include you are trying to put breakpoint.
    are you getting the message breakpoint set or not?
    are you executing the transaction in same session/window in which breakpoint is set?
    Regards
    Jitesh

  • Reg : Setting a attribute value through function module

    Hi guys,
           I got a RFC to To read the attribute of a particular work item ( SWI_READ_CONTAINER_ATTRIBUTE ) simillarly Is there any function module to write the attribute?
    Thanks,
    Mugundhan

    Hi Mugundhan ,
    if you want to pass Value to workflow container variable while starting the workflow
    use function module SAP_WAPI_START_WORKFLOW and pass value to the Table parameter input_container 
               wa_container-element = 'TEMP_AGENT' .
                 wa_container-value   = 'SAPUSER' .
             APPEND wa_container TO lt_container .
    if you want to update the workflow container .
    using the function module SWW_WI_FIND_FATHER_WIS  to get father workitem here only all the container variable available .
    then pass father workitem to the function module SWW_WI_CONTAINER_READ,  this function module will return the container values in table parameter wi_container   
    using  the function module you can update the workflow container variable
      CALL FUNCTION 'SWC_ELEMENT_SET'
                        EXPORTING
                          element       = 'TMP_AGENT'
                          field         =  'SAPUSER;
                        TABLES
                          container     = lt_container
                        EXCEPTIONS
                          type_conflict = 1
                          OTHERS        = 2.
    thanks and Regards
    Krishnan R

  • Function module to read the directory list and also run in background

    Hi All,
    I need to read few files from a folder in the server and upload the data in the file using a BDC. This process has to happen in the background as I am going to schedule the program. I had used the function module "EPS_GET_DIRECTORY_LISTING" to list the file names, it is working properly but when I schedule the program this function module does not work, the jobs gets finished in 0 secs. I am suspecting that it is not running in back ground. Can any one suggest me the function module which runs in background to read the files or an alternate method.
    Ajeetha

    Thanks for the reply.
    Sorry, this function module is working properly, why I assumed it is not working is that the background job got completed in 0 secs which made me feel that the function module is not working. Also I am subsequently copying the file to another folder and deleting it from the source folder, actually thiese two functionalities are not working in background. which added to my conclusion that all the function modules are not working in background. I am using two methods to copy and delete files, they are
    CL_GUI_FRONTEND_SERVICES=>FILE_COPY,
    CL_GUI_FRONTEND_SERVICES=>FILE_DELETE.
    as these are not working in background, now I need to replace them with a method or function module which will run in background.
    As I have mentioned earlier, my main objective is to upload the data in the file using a bdc. If I am not able to delete the file in the source folder,  then duplicate upload will happen which I have to avoid. So, if someone could help me to find a way to delete the file will be of great help to me.
    Ajeetha

  • Function module works correctly in debugger, but hangs otherwise.

    I am having an issue with a standard function module that 'hangs' when ran.  If i look in sm37, the calling job will just continuously run.  If i look in SM50, there aren't any sql statements which are bringing back large results, it seems to be running a large number of sequential reads against a certain table.  The odd thing is, if i break in this function module, then press F8 to continue, the function module successfully executes and the job finishes. 
    The function module in question is ISU_DUNNING_DEACT_INSTPL_0350, which i have attached to a dunning activity.  This function module SHOULD deactivate any active installment plans for the dunned account.  The FM is odd, as it calls another FM and does a hard EXIT, even though there is code below this line that it can never access. 
    If I set a breakpoint in the function module, and run FPVB (dunning transaction), it will break into the function module.  I can then press F8, the FM completes successfully, then the job completes.  If i do NOT break it (just run in background as normal), the job just continuously runs.  SM50 reveals reads to the BUT000 table (even though i cannot find any calls to this table in the fm).
    Any ideas?

    Nishikant,
    Thanks very much for the help. 
    I did this, and I can see where its getting stuck.  The following entries are repeated indefinitely (until i stop it )
          374 BUT000     FETCH       1      0
            3 BUT000     REOPEN             0 SELECT WHERE "CLIENT" = '120' AND "PARTNER" = '0007024125'
          420 BUT000     FETCH       1      0
            3 BUT000     REOPEN             0 SELECT WHERE "CLIENT" = '120' AND "PARTNER" = '0007024125'
          365 BUT000     FETCH       1      0
            3 BUT000     REOPEN             0 SELECT WHERE "CLIENT" = '120' AND "PARTNER" = '0007024125'
    If i double click the SQL statement, i see these details
    SQL Statement
      SELECT
        "CLIENT"
      FROM
        "BUT000"
      WHERE
    "CLIENT" = :A0 AND "PARTNER" = :A1
    Variable
    A0(CH,3)  = 120
    A1(CH,10) = 0007024125
    I caught it in SM50 where the read was, and it says the select exists in Function Pool SAPLBPT1.  I have done a search in this for anything containing BUT000, but have found nothing.  Any suggestions on how to find where this is occurring, or what might be going on?

  • BW/ABAP- Function module is called infinitely by Datasource Extractor.

    Hi All,
    A quick ABAP question related to Function Modules and BW data source extractors.
    I’ve written a function module to select data from a database and simply output the data as a table. I then created a text Datasource using transaction rso2 and set it to Extraction by Function Module.
    When I test this using transaction rsa6, I can manipulate the number of calls to my function module using the Display Extra Calls field.
    However, when I test this using transaction rsa1, my function module seems to be called infinite times. So, the number of records being retrieved is increasing exponentially and finally ends with a dump.
    My question: Do I need to include something in my code such that the Function Module by itself will only be called once?
    Or is there some configuration for the Datasource that will limit my function module call to once only.
    Tried so far
    • Introducing a static variable in the function module that exits as soon as the value is greater than 1.
    o Is there another way out?
    Regards,
    Preethi.

    You need to raise the EXEPTION NO_MORE_DATA afte the last record is populated in the output table. Otherwise the program goes into an infinite loop.
    * From now on records get fetched from the database or gets read from the internal table
        FETCH NEXT CURSOR v_cursor
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE <internal table>
                   PACKAGE SIZE i_s_if-maxsize.
        IF sy-subrc <> 0.
          CLOSE CURSOR v_cursor.
          RAISE no_more_data.
        ENDIF.
    * Populate the Output Data Structure into table E_T_DATA and you need to raise the EXEPTION NO_MORE_DATA and close the cursor to avoid any memory leaks

  • Debugging Outbound Function module in EDI

    Hello All,
    I have a query regarding debugging function module which is used for creation of outbound Idoc for Purchase Order.
    We have a Z process code which is assigned to a Z function module which creates an IDOC while a PO is created in the system.
    But If I set break points in the Function module, the execution does stop there.
    Can any one please tell me how to debug outbound processing Functioon module while PO is created.
    Regards
    Arindam

    Hi,
    There are 2 ways to to debug an outbound idoc triggered by an output type. One way is to set the output timing to 1, and save the purchase order and then execute RSNAST00 which will take the control to the breakpoint.
    You can also debug the idoc with the output timing set as 4.
    Here the idoc is triggered in update mode. Hence any breakpoints you may have set before will not reflect. Hence you need to activate update debugging.
    Below are the steps for the same..
    1. Add the output type in purchase order.
    2. Enter '/h' to activate debugging in transaction window.
    3. Save purchase order.
    4. The process enters debugging mode.
    5. In Settings tab, select checkbox for Update Debugging.
    6. Click F8.
    7. The control will appear to go out and re-enter debugging mode.
    8. Now from the menu bar, in breakpoints option, choose Breakpoint At Function Module option, and give the name of the function module which is processing the idoc.
    9. Once breakpoint set, click F8.
    10. The control will now go to the function module. You can then debug the FM.
    Hope this information is helpful.

  • Need to create a validation Function Module

    Hi,
    I need to create a Validation Function Module.
    I have a ITAB into which data comes.
    FIELD-SYMBOLS : <ITAB> TYPE ANY ,
                                  key      TYPE ANY,
                                  char  TYPE ANY.
    <ITAB> = local_file.
    there is a field KEY whose sum when becomes equal to 10.000 for every CHAR,system should show a popup in the below FM
    CALL FUNCTION 'POPUP_WITH_WARNING_ALV'
      EXPORTING
        TEXTLINE1       = LT_POPUPTEXT
      TEXTLINE2       = ' '
      TITEL           = 'Warnung'
    Please let me know if the requirement is not clear.
    Thank U very Much.

    Hi annapurna ,
    In your case even the KEY value is the most useful one right,
    If so go about this way,
    have another field flag set it when the sum of the KEY values exceeds 10.
    Loop in an internla table.
    Now the internal table will have all the data including the flag and now based on the flag (whether set or not) call the function module popup which should retrieve those matnr field where flag is set.
    Display the error message saying that the KEY value fr this matnr exceeds 10.
    Revert for further clarification.
    Thanks and Regards
    Srikanth.P

  • Virtual Remote function module

    Hi
    I have a Virtual function module coded on top of a multiprovider, I need to know where do we need make a setting to link this Virtual Function module to queries run on my multiprovider.

    yes.. I have written code.. The thing is I would like to know if there are 2  RFM's on top of this Multiprovider for testing purpose I would like to test with 2 of them..
    I would like to know how can I make the query understand that take the second RFM for time being and switch over again.
    How do I ?

  • WWI issue: function module with symbol doesn't work in conditional output

    Hi,
    I have created a function module to be used in combination with a symbol that represents the quantity of a composition item in a composition. In some cases a average quantity is not filled and the function module calculates the quantity based on the lower and upper limit of the composition item. This function works perfectly if managed in customising with a symbol or called with a symbol in WWI. When displaying the result of the symbol in a WWI word template it shows the expected value.
    However when I use the symbol with a function module (or the customised symbol with function module) in a conditional output expression, the value it represents in the expression is always equal to zero. It seems that a symbol value that is calculated using a functional module is not calculated properly when used in a conditional output expression. Setting a break in the functional module always shows the correct value, but the value as I already told, is not seen by the conditional output expression. Within the expression the value is always equal to zero.
    Does anyone know if this is a known issue in WWI? Is there any solution to handle this problem? I hope anyone can help.
    Thanks,
    Paul

    Dear Paul,
    only some add on high level ideas:
    if you look at:
    Example: Layout of an Abridged Material Safety Data Sheet - Basic Data and Tools (EHS-BD) - SAP Library
    you find the standard example of SAP for master and slave group:
    2  <11BRG003 (M,SAP_EHS_1012_004;*)> ¶
    3  <03EHS_L_TEXT(CED
      -SDB-01.002)> ¤
    <03EHS_L_TEXT(CED-
    SDB-02-07)> ¤
    <03EHS_L_TEXT(CED-
    SDB-02-05)> ¤
    4  <11BRG002 (S:POS;*)> ¿
    5 <01GESTRIDENT(I:NAM,
    6  IUPAC,;*)> <11ERG002>¤
    7
    8
    9
    <11BRG002 (S:POS; *)> ¿
    <01G1023001R2(C;*)
    ><11ERG002>¤
    <11BRG002 (S:POS;*)> ¿
    <01GESTVPRECL>
    <01GESTVCOMPL(N:" ZZ9,9")>
    <01GESTVCOMPE>
    <11ERG002> ¤
    10  <11ERG003>¶
    The "issue" is that you need to analyse by "line" of POS group; or precisely: it is easy to print lower, upper and average value if it exists.
    In conditional output this example is shown in SAP help:
    <15BIF001(AND:01G1013005VA GE 1)><01G1013005VA(;*/TL)[D:Value]>
    <15CIF001><03EHS_L_TEXT(CUST-100000000000031)[D:Density is less than 1]>
    <15EIF001>
    I believe you need a "clever" nesting together with your customer symbol
    E.g. you need first "test" the contents of the three values and decide about result
    The easiest way could be to use a "table" structure as above.
    Just use column header "lower"; "average"; "upper" value. Then you need to ask your self in which situation what need to printed.
    If you use the table structure and you print just what is there and leave simply lower / upper limit "field" empty if it does not exists (what is bad with this?) you need only this "conditional" output topic done for average value. You could check for: if value > 0.0001 then print the value (as then there is a value); if not use the report symbol in which you calculate something. In my opinion it is worth to try it.
    It is known that you can check "numeric values by using conditional output. I belive tis cintional one des work as well with the "composition" values (lwoer, upper, average),
    May be this approach might help.
    The "stack" examples which are discussed in SAP help and in the links shown are related to "characteristic" values of classes and not for composition ones.
    C.B.
    PS: If this really works you can clearly extend your solution. E.g. if lower value is empty may be print "0", If upper valus is empty may be print "100" etc. (or prepare a further costumer symbol calculating something).

  • Function Module to send a mail

    I have a pdf file. I need to send this pdf file through mail by using a program. Can anybody tell what is the function module used for this?

    refer this threads:
    The below sample code is for 4.6C.Try this out.
    Internal Table declarations
    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.
    call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
    formname = 'ZZZ_TEST1'
    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'
    IMPORTING
    job_output_info = w_return
    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
    IMPORTING
    bin_filesize = v_len_in
    TABLES
    otf = i_otf
    lines = i_tline
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    others = 4.
    Fehlerhandling
    if sy-subrc <> 0.
    endif.
    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.
    Attachment
    refresh:
    i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    clear wa_objhead.
    i_objbin[] = i_record[].
    Create Message Body
    Title and Description
    i_objtxt = 'test with pdf-Attachment!'.
    append i_objtxt.
    describe table i_objtxt lines v_lines_txt.
    read table i_objtxt index v_lines_txt.
    wa_doc_chng-obj_name = 'smartform'.
    wa_doc_chng-expiry_dat = sy-datum + 10.
    wa_doc_chng-obj_descr = 'smartform'.
    wa_doc_chng-sensitivty = 'F'.
    wa_doc_chng-doc_size = v_lines_txt * 255.
    Main Text
    wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
    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.
    Attachment
    (pdf-Attachment)
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 0.
    i_objpack-body_start = 1.
    Länge des Attachment ermitteln
    describe table i_objbin lines v_lines_bin.
    read table i_objbin index v_lines_bin.
    i_objpack-doc_size = v_lines_bin * 255 .
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'smart'.
    i_objpack-obj_descr = 'test'.
    append i_objpack.
    clear i_reclist.
    i_reclist-receiver = [email protected]'.
    i_reclist-rec_type = 'U'.
    append i_reclist.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = wa_doc_chng
    put_in_outbox = 'X'
    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.
    Kindly reward points by clicking the star on the left of reply,if it helps.
    prssastry

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

  • Issue while mail triggering using function module SO_NEW_DOCUMENT_SEND_API1

    Hi all,
    I have requirement to send mails from BADI.For that i used following function modules-SO_NEW_DOCUMENT_SEND_API1
    and
    SO_NEW_DOCUMENT_ATT_SEND_API1,
    Both of these two function module requires to use COMMIT WORK statement.
    But if we use COMMIT WORK statement in BADI a run time error is occuring as its not allowed in BADI.
    Can anybody provide solution for this  or provide another function module.
    Thank you.

    commit work not allowed in BADI.It gives runtime error
    Information on commit work.
    becos for commit work. sy-subrc will allways sets to zero.
    you can better use commitwork and wait. it sets sy-subrc.
    To avoid runtime error / dump you can check the sy-subrc value. if its not equal to zero. just
    Roll back work.
    Plz look at the piece of code below
    commit work and wait.
    if sy-subrc eq 0.
    exit.
    else.
    rollback work.
    wa_error-msg = "Failed to update the status in the database "
    append wa_error to it_error.
    exit.
    endif.
    Also check the badi signature. there you have a internal table to store the error messages.
    if commit work fails then add the appropriate error message to the internal table .
    Hope this gives you some idea on commit work.
    But as everyone says, commit work is not required for that function module . i too agree with that.
    if you try to update any database after you successfully send the file . then i think commit work statement is necessary for you.
    Thanks,
    Uma

Maybe you are looking for