Send Mail When Saving The Process Order

Dear Experts,
I want to send a Mail with some details whenever we Create & Save a new Process Order in COR1.
I have written my code at the below location where i have all the required data stored in the IT'S.
Enhancement - PPCO0001
FM - EXIT_SAPLCOBT_001
Include - zxco1u01
I have the below code to send the Mail in the include.
Send the document
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      exporting
        document_data              = wa_doc_chng
        put_in_outbox              = 'X'
        commit_work                = ""
      tables
        packing_list               = it_objpack
        contents_txt               = it_objtxt
        receivers                  = it_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.
  To refresh SAP Work Office so that mail can be recieved immediataly.
      submit rsconn01 with mode = 'INT'
                      with output = ''
                       and return.
    else.
      message 'Problem in sending Email.' type 'I'.
    endif.              "  End of sy-subrc
Here my exporting parameter "commit_work" is blank, i have not passed "X" in it.
When i pass "X" in this, it gives me a dump as below.
Short text
    Invalid COMMIT WORK in a COMMIT WORK or ROLLBACK WORK.
What happened?
    Error in the ABAP Application Program
    The current ABAP program "SAPLSOI1" had to be terminated because it has
    come across a statement that unfortunately cannot be executed.
Error analysis
    The call of a COMMIT WORK in a FORM, that will not be executed until
    the commit or rollback point of the caller using the variant
    PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK is not permitted.
Trigger Location of Runtime Error
    Program                                 SAPLSOI1
    Include                                 LSOI1U32
    Row                                     154
    Module type                             (FUNCTION)
    Module Name                             SO_DOCUMENT_SEND_API1
When i take out "X" from "commit_work", it does not send mail and also the transaction does not give any Dump.
Can you please help out me with this?
Thanks,
Praveen

Hi Antony,
When i write the below code in FM = EXIT_SAPLCOBT_001 and include = zxco1u01, it does not work for sending the mail.
Mail Data.
types: begin of ty_mail,
        tcode type zmail-tcode,
        email type zmail-email,
        end of ty_mail.
IT Creation.
data:  it_mail type standard table of ty_mail.
WA Creation.
data:  wa_mail type ty_mail.
Email Related Internal Tables.
data:  it_reclist        type standard table of somlreci1,     "Recipients
        it_objpack        type standard table of sopcklsti1,
        it_objhead        type standard table of solisti1,
        it_objtxt         type standard table of solisti1 initial size 0 with header line,      "Body of EMail
        it_objbin         type standard table of solisti1,      "Attachment of EMail
        it_contents_hex   like standard table of solix,
        it_objbin1        type standard table of solisti1,      "Attachment of EMail
        it_contents_hex1  like standard table of solix.
Email Related Work Area.
data:  wa_doc_chng       type sodocchgi1.     "attributes of document to send
data:  l_reclist               like line of it_reclist,
        l_objpack               like line of it_objpack,
        l_tab_lines             type i.
data:  lv_answer   type string,
        w_msg1(100) type c,
        w_gamng     type string.
select tcode email from zmail into table it_mail
        where tcode = 'ZQA15'.
   refresh it_objtxt[].
   it_objtxt = '-----------------------------------------------------------------------------------------------------'.
   append it_objtxt.
   concatenate 'Order Number - '  header_table-aufnr into it_objtxt separated by space.
   append it_objtxt.
   concatenate 'Plant - '  header_table-werks into it_objtxt separated by space.
   append it_objtxt.
   concatenate 'Material No. - '  position_table-matnr into it_objtxt separated by space.
   append it_objtxt.
   concatenate 'Material Description - '  header_table-ktext into it_objtxt separated by space.
   append it_objtxt.
   concatenate 'Batch No. - '  position_table-charg into it_objtxt separated by space.
   append it_objtxt.
   w_gamng = header_table-gamng.
   concatenate 'Batch Size - '  w_gamng into it_objtxt separated by space.
   append it_objtxt.
   concatenate 'MFG. Date - '  position_table-verid into it_objtxt separated by space.
   refresh it_reclist[].
   loop at it_mail into wa_mail.
     clear  l_reclist.
     l_reclist-receiver    = wa_mail-email.
     l_reclist-express     = 'X'.
     l_reclist-rec_type    = 'U'.
     l_reclist-no_forward  = 'X'.
     append l_reclist to it_reclist.
     clear wa_mail.
   endloop.
Fill the document data.
   wa_doc_chng-doc_size = 1.
Populate the subject/generic message attributes
   wa_doc_chng-obj_langu = sy-langu.
   wa_doc_chng-obj_name  = 'PO DETAILS'.
   wa_doc_chng-obj_descr = 'PO Details To QC'.
   wa_doc_chng-sensitivty = 'F'.          "  Send mail as a confidential
   wa_doc_chng-no_change  = 'X'.
Describe the body of the message
   if it_objpack is initial.
     l_objpack-transf_bin = space.
     l_objpack-head_start = 1.
     l_objpack-head_num   = 1.
     l_objpack-body_start = 1.
     describe table it_objtxt lines l_objpack-body_num.
     l_objpack-doc_type   = 'RAW'.
     append l_objpack to it_objpack.
     clear  l_objpack.
     clear l_tab_lines.
   endif.
Send the document
   call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
     exporting
       document_data              = wa_doc_chng
       put_in_outbox              = 'X'
       commit_work                = ''
     tables
       packing_list               = it_objpack
       contents_txt               = it_objtxt
       receivers                  = it_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.
  To refresh SAP Work Office so that mail can be recieved immediataly.
     submit rsconn01 with mode = 'INT'
                     with output = ''
                      and return.
   else.
     message 'Problem in sending Email.' type 'I'.
   endif.              "  End of sy-subrc
endif.                "  End of lw_answer
But when i write the same above code in FM = EXIT_SAPLCOZV_001 and include = zxco1u06, it does work fine.
I am not able to understand why it works at one place and does not at the other?
Thanks,
Praveen

Similar Messages

  • ABAP Programming Error when saving the Process Order confirmation in COR6N

    Hello,
    We have an issue related to Process Order confirmation using Tcode COR6N. When we enter all the inputs to confirm( Activity, yield and phase) and click on save it gives ABAP Programming Error (Exception condition "SEQ_NOT_FOUND" raised).
    Any inputs in this regard, would be appreciated.

    Hello
    I can observe that you have implemented the report ZOPSECRE and that an inconsistency was found.
    This repor corrects inconsistent orders which do not have an operation or a sequence, or the two of them.
    The report checks whether there is at least one operation or one sequence and creates both including status objects.
    Therefore, you need to have the default valus for the operation generation defined on OPJG for this order type/plant.
    BR
    Caetano

  • Inserting Pricing condition in Sales order when saving the sales order

    Dear ABAPers,
           My customers requirement is when saving the sales order new pricing condition has to be updated in the line item.for this i am using the User Exit 'USEREXIT_SAVE_DOCUMENT_PREPARE' ( MV45AFZZ).While saving the Sales order i am calculating the Price and updating in the Pricing conditions.
    In XKOMV internal table i am appending the pricing condition.But the problem is ,it is not calculating the taxes and it is Updating in VBAK and VBAP.
    How to do this.
    Thanks & Regards,
    Ashok.

    Dear ABAPers,
    I have Solved this Problem.
    Thanks & Regards,
    Ashok.

  • User Exit or BADI for Tcode IW31 when saving the Service Order

    Dear ABAPers,
            I would like to add one more line in Service order item when saving the Service order in (IW31).Is there User Exit or BAdI.It is very Urgent Please help me.
    Thanks & Regards,
    Ashok.

    Dear ABAPers,
    These Exits does not meet my requirement.
    These Exits are not called at the time of saving Service Order.
    Thank you for your valuable reply.
    My Requirement is when saving the service Order  i want to add the Line itm at runtime.
    It is very urgent requirement.Please help me.
    Thanks & Regards,
    ashok.

  • User Exit or BADI for IW31 when Saving the Service Order

    Dear ABAPers,
            I would like to add one more line in Service order item when saving the Service order in (IW31) at runtime.Is there User Exit or BAdI.It is very Urgent Please help me.
    Thanks & Regards,
    Ashok.

    Hi
    U can go through the tansaction.
      System/ Status
      Double click on program name.
    For badis:
    Search for the Phrase:
      cl_exithandler=>get_instance.
    U will the badi definitions.
    For User exits:
      search for the phrase: CALL CUSTOMER-FUNCTION
      u will get the user exits.
    If it is helpful rewards points.
    Regards
    Pratap.M

  • Ps assembly processing:WBS have not be created when saving the sales order

    In the ps assembly processing, I want to generate a network when I create a sales order.  So I did the following steps:
    1-Use the TCODE cj91 to create a standard WBS "E-000007.1".
    2-Use the TCODE cn01 to create a standard network "10000000" and assign the standard WBS "E-000007.1" to it.
    3-Use the TCODE cn08 to config the Network Parameters from Sales Order like below:
    Material number : 600000-000000-0009
    Order Type      : Z301
    Std network     : 10000000
    Class Type      : 020
    Network Profile : Z0001
    MRP Controller  : 001
    Std WBS element : E-000007.1
    4-Use the TCODE va01 to create a sales order and add an item with the material "600000-000000-0009" and save.
        When the SAP R/3 System is saving the sales order, a WBS ought to be created u2013 based on the assignment of the standard network to the standard project.But I could not found the WBS.I thought I have do all of steps and could not found the reason.
       So I need the experts give me some useful advice and reference to resolve the problem.Thank you.
    Regards
    Yoda

    Hi,
    Maintain strategy group in material master MRP tab....
    If problem still persist then check is there any credit block to that customer...if it is release it in VKM3....
    Once you release it will create automatically.
    Regards

  • Error while saving the process order

    Hi All,
    I changed the quantities of the components and trying to save the process order. But I'm getting a message " "PLEASE REEXPLODE BOM, SINCE THE PROCESS ORDER COMPONENTS HAVE CHANGE". What would be the reason? It is not happening to all the users. Some users can able to save after changing the qty. Some users can't?
    Regards,
    Sureshbabu G.

    Hi,
    "PLEASE REEXPLODE BOM, SINCE THE PROCESS ORDER COMPONENTS HAVE CHANGE"
    I think it is your Develpment and not from SAP Standard One.So it is difficult to trace out the cause, better will be contact your devlopment team to trace out the reason.
    Regards,
    Dhaval

  • Billing Plan Billing Block Change when saving the sales order

    Dear Gurus,
    We have SD Integrated with PS. We create the sales orders and pull the billing plans milestones from WBS.
    Once we generate the billing plans, system will propose the billing block for all the line items of the milestones which normally comes from the billing plan configuration/item category.
    Would like to know the appropriate userexit to change the Billing block to "XX" if some of the requirements are not met when we create or change the sales document.
    Below is what i am able to see but seems to be not helpfull.. please guide..
    User exits in program RV60FUS1
        BILLING_SCHEDULE_DELTA
        For milestone billing a percentage value is fully invoiced for each billing deadline. In the case of deviations between the original item value and any later changes, you can use the user exit to determine whether the difference should be stored in the final invoice or sent to the next deadline.
        USEREXIT_MOVE_FIELD_TO_FPLT
        This user exit allows you to create your own fields in table FPLT.
        USEREXIT_MOVE_FIELD_TO_FPLA
        This user exit allows you to create your own fields in table FPLA.
    Reward points for the right answers..
    Regards
    Ram

    Dear Friend,
    I hope you can make it with the above user exits.Consult your abaper and try it.
    Thank you,

  • Cost error message at the point of saving a Process Order

    Dear Experts,
    Raw Materials R458 and R467 are processed to produce semifinished material S229
    While creating a Process Order for material S229, at the point of saving the process order I get the following error messages:
    1 No cost element segment exists for 21501000 on 07.07.2011
    2 Cost Element Group 2950 does not exist
    At the point of saving, cost gets calculated by the system.
    Which account(s) is this cost posted to?
    Is it the ''Offsetting entry for inventory posting'' account  of the Raw materials R458 and R467? or
    Is it the ''Offsetting entry for inventory posting'' account  of the Semi material S229? or
    Is it the Cost Center to which the Resource is assigned to?
    How can I view this calculated cost value within the particular account?

    Hi,
    1. For error No cost element segment exists for 21501000 on 07.07.2011
    Can you check whether you have maintained valuation type in the accounting tab? Also have you maintained costing tab? If you have maintained then go to OBYC that is in GBB with account key VBR GL may have not maintained. Ask your FICO guy to check this.
    2. For error Cost Element Group 2950 does not exist
    Go to below link
    Cost element group does not exist. S_ALR_87013620 report
    Regards / US

  • I want to send mail when my po is save to numbers of users.

    Hello all gurus,
                          Dose anybody know that how to send mail when saving po give me exits name and is there any function module or other option to send mail to number of users with  some test in body.
    Thanks in advance..

    Hi nainesha,
        Pls search the forum before posting a question.I think it has been already answered in some post . I dont remeber the thread.
    you can go for Badi 'ME_PURCHDOC_POSTED' where u will find all fields in PO.To send mail u can use FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' or BCS methods.As you have nt told wat should be attached , you can have all fields in this Badi.
      Pls close the thread ASAP.
    Br,
    vinod.

  • Different message in va01: Defect in ECC6 server while saving the sales order .

    Hi ABAP gurus,
    I am in to upgrade Project In ECC6 server I am getting the different message when saving the sales order in va01 compare to  old sever(4.7) .
    I have to make it to the same message as it is in the 4.7 server.
    plz help me .
    Regards,
    vanamaala kashavena

    Hi,
    IF xvbap-uepos IS INITIAL AND
            xvbap-zzhrs_conf <> 'X'.
            MESSAGE ID 'ZOTC' TYPE 'E' NUMBER '067' WITH
            'Please select Hours Confirmed in Additional data B'(302) 'for item'(303) xvbap-posnr.
          ENDIF.
    this is the code in the  PARTICULAR INCLUDE PROGRAM .
    this is same in both the system ,but in ecc6 server,in message
    popup it is not giving 'Please select Hours Confirmed in Additional data B' .
    it is giving ORDER QTY FORMAT PERIOD (ITEM NUMBER(0010))
    Regards,
    vanamaala k

  • Send Mail to Customer while saving the Sales Order

    Dear Friends,
    My Requirment is to send the mail to Customer automaticaly when create any Sales Order.
    While sending the mail given three points reqired.
    1.     Send the attachment of Order Conformation along with the mail.
    2.     There must be The title text as "Order Confirmation refrence of your PO <Customer PO No> <PO Date>"
    3.     There must be some body text like some terms and conditions with variables of Order data.
    Can any body help me one this step by step.
    Kindly suggest me how to do this.
    Thanks in Advance.
    D Tarun Kumar
    Moderator message : Spec dumping not allowed, duplicate post. Thread locked.
    Edited by: Vinod Kumar on Jul 12, 2011 11:30 AM

    While saving the sales order through Va01 and Va02 and email has to send

  • ERMS : Send mail on saving Sales Order

    HI,
    How can we send mail through ERMS on saving the Sales Order. I know about ERMS...All setting are done but i don't know on which event this will get trigger.  i have maintained the following rule :
    If
    ICWC_Order:type Equals Home 'ZXX'
    Then
    Forward eMil To ( Forward To = "abc@abclcom"; Forward From = acb@acbcom )
    I know we can call this action in IC webclient through ESCALATION button. But how we can call this action on SAVE ORDER.
    Please Help...
    Regards,
    Ankush

    Hi Ankush
    You can also achieve the same results using actions.
    Here are some details how it works:
    1. Action profile which triggers an email on Order save. Assign the action profile to Transaction
    2. Smartform to put data email
    3. Forward To address can picked up from Partners
    4. From address can be setup in SCOT
    Hope this helps
    Rupesh

  • Error getting when saving the sales document in third party sales order

    in third party sales order,when i am saving the sales order i am gettingthe following error
    subsequent function 'purchase requistion from sales document' not possible due to credit block.earlier i have maintained credit checks for some customers,but for this customer i have not maintained any credit check. i dont know why system is blocking for this customer also.pls help me where i went wrong.
    highly rewarded if help full.
    thank you

    Please go to FD32, check any default risk category and credit limit is maintained for the customer.
    Also check OB45, any default risk category & credit limit is maintained for the credit control area.
    Also, which order type u r creating sales order? for that order type, Goto VOV8, remove the credit grp and credit check settings.
    Also goto XD02, check in sales area data, billing tab, credit control area field, please remove that also.
    Hope it Helpful.
    Reward points if useful..

  • Having problems in sending email..always saved in outbox and cannot send mail bcoz of the server failed

    Having problems in sending email..always saved in outbox and cannot send bcoz of server failed

    The email server you are using to send mail through requires the password, if any is required it needs to be set in the location that I pointed out in the earlier post.
    It is usually the same password you use for receiving emails.
    I don't use either Facebook or Twitter so I am not sure how to help with those.

Maybe you are looking for

  • Ipod Nano USB driver fails continuosly

    Initial problem: Device not found; located error in USB driver, uninstalled driver, rebooted sytem, found new driver - installed properly able to sync. (No hidden drivers listed in que) unconnect/reconnect ipod and USB driver error returns.(Each time

  • How to maintain a history for Name of the Company

    Hi folks! A cliente have need to maintain a history of the Name of the Company (field T001-BUTXT) because they are intending to change the name of their company. It is needed to show the old name in reports until certain date. E.g.: 08/30/08: until t

  • Problem with zoom trigger

    Hi friends, here i have a requirement to Customize Material Transactions Form to Zoom to the form Order Header Form after entering the Sales Order Number against which the Material transaction is happening passing order header_id as parameter (Order

  • Probably a simple fix ...

    why doesnt my page look the same in the browser as it does in dreamweaver? < what it looks like in dreamweaver ... perfect < what it looks like in my browser ... all spread out and messed up there is probably something simple i am doing or not doing

  • Rouding VAT ERROR

    Hello People, I have the MWAI condition type rounding rule defined with ' ' (V_T685A-TXPRF = ' '). In spite of this correct configuration some FI documents (launched with batch-input) are not well calculated and the rounding os the tax is being made