Run time error while closing the CRM Order using BAPI

Hi Experts,
Need your invaluable suggestions here.Apologies for the lengthy mail, intention is to give clear idea of the issue.
I am facing an issue while closing the CRM orders. According to our business process, when an issue is solved we will keep the order in resolved status only. We will not directly close the order from the CRM tool, instead we have created a custom program for the same purpose.
For the custom program we will give input as the order number and execute it, this will close the order.
Here close the order means assigning it to Close status as well assign the reason code.
We have created some reason codes for closed status.
So when the program is run the Order moves from resolved status to closed status along with reason code.
But of late we are facing some problems with this program, it is giving run time error for some CRM orders.
Run time error message : The ABAP/4 Open SQL array insert results in duplicate database records.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught in procedure "CRM_SERVICE_OS_UPD_OST_DU" "(FUNCTION)", nor was it propagated by a RAISING clause.
Please find my code which have used in the custom program
Closing the resolved SOs in the system
    CALL FUNCTION 'CRM_STATUS_CHANGE_EXTERN_OW'
        EXPORTING
          objnr                     = iv_guid
          user_status          = lc_status_closed
       EXCEPTIONS
         object_not_found          = 1
         status_inconsistent       = 2
         status_not_allowed       = 3
         OTHERS                        = 4.
    IF sy-subrc <> 0.
      WRITE :  'Error at maintaining status'.
    ENDIF.
Set reason code
build lt_subject
    ls_subject-ref_guid = iv_guid.
    ls_subject-katalogart = 'A2'.
    ls_subject-codegruppe = 'ZR000003'.
    ls_subject-code       = 'ZR33'.                      " Reason code
    ls_subject-mode       = 'A'.
    APPEND ls_subject TO lt_subject.
build lt_ossset
    ls_osset-ref_guid        = iv_guid.
    ls_osset-subject_profile = 'ZREASON03'.
    ls_osset-profile_type    = 'G'.
    ls_osset-subject         = lt_subject.
    APPEND ls_osset TO lt_osset.
build lt_service_os
    ls_service_os-ref_guid  = iv_guid.
    ls_service_os-ref_kind  = 'A'.
    ls_service_os-osset     = lt_osset.
    APPEND ls_service_os TO lt_service_os.
build lt_input_fields
    REFRESH: lt_input_fields, lt_field_names.
    CLEAR  : ls_input_fields, ls_field_names.
    ls_field_names-fieldname    = 'CODE'.
    APPEND ls_field_names TO lt_field_names.
    ls_field_names-fieldname    = 'CODEGRUPPE'.
    APPEND ls_field_names TO lt_field_names.
    ls_field_names-fieldname    = 'KATALOGART'.
    APPEND ls_field_names TO lt_field_names.
    ls_field_names-fieldname    = 'SERVICE_PROFILE'.
    APPEND ls_field_names TO lt_field_names.
    ls_input_fields-ref_guid    = iv_guid.
    ls_input_fields-ref_kind    = 'A'.
    ls_input_fields-objectname  = 'SERVICE_OS'.
    ls_input_fields-field_names = lt_field_names.
    APPEND ls_input_fields TO lt_input_fields.
     CALL FUNCTION 'CRM_ORDER_MAINTAIN'
      EXPORTING
        it_service_os     = lt_service_os
      CHANGING
        ct_input_fields   = lt_input_fields
      EXCEPTIONS
        error_occurred    = 1
        document_locked   = 2
        no_change_allowed = 3
        no_authority      = 4
        OTHERS            = 5.
    IF sy-subrc <> 0.
      WRITE :  'Error at maintaining reason'.
    ENDIF.
    CALL FUNCTION 'CRM_ORDER_SAVE'
      EXPORTING
        it_objects_to_save   = lt_header_guid
        iv_update_task_local = lv_update_task_local
      IMPORTING
        et_saved_objects     = lt_saved_objects
      EXCEPTIONS
        document_not_saved   = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
      WRITE : 'Error at saving'.
    ELSE.
      WRITE : 'Successfully Closed'.
      COMMIT WORK AND WAIT.
    ENDIF.
Run time error is coming at COMMIT WORK AND WAIT statement.
Please let me know any corrections are required in the above program.
When I analyzed the run time error I have found that it trying to insert the record in CRMD_SRV_OSSET for that CRM order, but already one record is present in the table for the same CRM order number.
For most of the CRM orders there is no entry in this table so they are closing successfully but for a few orders for which there is an entry we are getting the above run time error.
There is nothing wrong with the orders which have an entry already in the table CRMD_SRV_OSSET, I need to close these kind of orders with out run time error.
Kindly provide your feedback.

Hi Dinakar,
You posted this in APO PPDS forum. This question should go to PP forum where someone could answer it.
Please close this thread and open a new thread in PP forum so that you could get help quickly from the relevant experts.
Regards - Pawan

Similar Messages

  • Run time error while saving the production order in CO02

    HI Experts,
    While i am releasing and saving the production order the system is giving the runtime error. Please help.
    Runtime Errors         UNCAUGHT_EXCEPTION
    Exception              CX_SLD_API_EXCEPTION
    Error analysis is
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SLD_API_EXCEPTION', was not
    caught in
    procedure "GET_ACCESS_DATA" "(METHOD)", nor was it propagated by a RAISING
    clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    Internal error in method
    A Quick response is required.
    Regards
    Dinakar Sarma

    Hi,
    Please check below  link for your issue , it may useful
    http://forums.sdn.sap.com/thread.jspa?messageID=10815298#10815298
    Regards,
    Ram

  • Run time error while creating a sales order by va01

    hi ,
         while  i am creating a sales order a runtime error occurs as i fill entry for sole to party and then material and quantity and as i press enter. the run time error is:
    error in current abap program "saplv61z"  had to be terminated because it has come across the statement that unfortunately can not be executed.
    kindly solve my problem.
    thanks.

    Hi Agrawal
    As you are getting run-time error after entering the sold to party and material and the error is in SAPLV61Z ,
    close the session for sometime and open again and then create sales order and then enter sold to party and material and then check wheather you are getting or not. If you are still facing the problem then take the help of the ABAP & BASIS consultant's.
    Regards
    Srinath

  • Getting run time errors while executing the copied SAP programs

    Hi folks,
    i want to copy an sap program.after coping i need to change some coding there.then i have to create a new transaction for that.
    i am just copying the sap program RQEEAL10(transaction-QA32) to Z_RQEEAL10. it has 4 include  programs.i am copying them to z programs like
    RQ00MF10 copied to z_RQ00MF10
    RQALVF14 copied to z_RQALVF14
    RQALVF16 copied to z_RQALVF16
    RQALVTOP copied to z_RQALVTOP.
    now i am executing that program Z_RQEEAL10.but i am getting run time errors as given below.
    <b>runtime error---</b>
    The termination occurred in the ABAP program "Z_RQEEAL10" in           
    "SELECT_FIELDS_MANIP2_F16".                                           
    The main program was "Z_RQEEAL10 ".                                                                               
    The termination occurred in line 257 of the source code of the (Include)
    program "RQALVF16"                                                    
    of the source code of program "RQALVF16" (when calling the editor 2570).
    --Error in ABAP statement when processing an internal table.  
    --When changing or deleting one or more lines of the internal table         
    "\PROGRAM=Z_RQEEAL10\DATA=SELECT_FIELDS" or when inserting in the table   
    "\PROGRAM=Z_RQEEAL10\DATA=SELECT_FIELDS", 0 was used as                  
    the line index. An index less than or equal to zero is not                
    allowed.                                                                               
    The error can occur when using the following options:                     
    1. "INDEX idx" for specifying the line number in the table                
    "\PROGRAM=Z_RQEEAL10\DATA=SELECT_FIELDS"                                 
       where you want to change, insert or delete.                            
    2. "FROM idx" for specifying the start index when deleting a line         
       area from or inserting a line area into the table                      
    "\PROGRAM=Z_RQEEAL10\DATA=SELECT_FIELDS".                                
    3. "TO idx" for specifying the end index when deleting a line             
       area from or inserting a line area into the table                      
    "\PROGRAM=Z_RQEEAL10\DATA=SELECT_FIELDS".                                                                               
    When the program terminated, the table had 2 lines.                       
    these r the runtime errors what i am getting.where is the problem?i have activated all interface & includes.plz advice.
    Thanks & regards

    Hi Madhu,
    I will give you one more check point where you have to give your concentration while copying the standard programs....
    Call Customer-Function (Function Exists) if any in the Program when copied will not get executed. Instead you need to call the FM Directly.
    one more is also here
    You are likely to have some problems with the text-elements and translation that may have been maintained for the original report.
    ~~Guduri

  • Run time error while activating the Transfer Rules

    Hi,
    Error when activating Transfer rules for Infosource :
    0FI_GL_1 -
    (General ledger: Transaction figures)
    Run time error : ASSERTION FAILED
    Transfer rules traffic light is in Green. But when i am trying to activate the Transfer rules, its giving Run time error.
    Thanks,
    Kishore

    Hi,
    As mentioned in the note 939383 , either Import Support Package 08 for SAP NetWeaver 2004s BI (BI Patch08 or SAPKW70008) into your BI system or do correction instructions given in the note.
    It is always better to import the latest patches avialble in service market to avoid this type of problems.
    Also see tha note 1010672 amd check whether it is applicable to your problem.
    With rgds,
    Anil Kumar Sharma .P
    Message was edited by:
            Anil Kumar Sharma

  • Run Time error while activating the cube 0pp_c03

    Hi All,
    I encountered this error while activating the info cube 0pp_c03
      An exception occurred which is explained in detail below.
      The exception, which is assigned to class 'CX_RSR_X_MESSAGE', was not caught
      and
      therefore caused a runtime error.
      The reason for the exception is:
      No text available for this exception
    Regards
    Rohit

    Hi,
    Please check in ST22 for any relevant short dump. the error message is not of much help in anlyzing the problem
    or
    Perform the consistency test with 'RSRV' -->All Elementary Tests --> Master Data --> 'Compare Number Range and Maximum SID for the characteristic 0REQUID'. and correct the error
    Regards,
    Marasa.

  • Error while Closing the Production order.

    Hi ,
      We are doing operation Subcontracting Process. This process works on the basis of Production order, once the Production order generated automatically system generates a Purchase requisition which we are converting to Purchase order  and doing the sub contracting process.
    Now i have received all the material from the Subcontractor ( GRN and MIRO ) has been completed , for the Production order all the confimration and Delivery has also been completed , now i have done Technically completion for that order , now i am closing the Order ( Functions -Restrict processing - close ) , while closing it gives me an error saying that Purchase order still exists .
    Wat is this error ?? why is it coming so ??
    Regards
    Rajesh

    hi,
    You have to ensure that the order is not having any WIP, if you have any WIP for that order you have to complete the order and then only you could abale to clsoe the order.
    Check the WIP for the order thorugh KKAX.
    Regards,
    Rama Mohan

  • Run time error while saving a sales order

    After CIn configuration when i raise the sales order i cannot save it. when i click on the save icon the following runtime error message x302 (v3) with the short dump.. pls guide..
    thanks...

    Hi sanjitdutta,
    Please get in touch with your ABAP team to know wat exactly is teh cause for the short dump. Please post the error description completely.
    Thanks
    Arun
    Edited by: arun subramani on May 16, 2011 7:06 AM

  • Run time error while displaying the list of km folders

    hi
    i am trying to display the list of contents in the km folder using km api but the application is displaing an runtime error
    package com.sap.test;
    error in init method component
    any body know the solution for this problem .
    thanks

    hi there
    public class kmportalcomp extends AbstractPortalComponent
              public String outtxt;
              int depth;
              int rowid = 0;
              int counter = 0;
         public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
              IUserContext userCtx =request.getUser();
              IResourceFactory factory;
              IPortalComponentContext compContext = request.getComponentContext();
              IPortalComponentProfile profile = compContext.getProfile();
              try {IUser serviceUser = WPUMFactory.getServiceUserFactory().getServiceUser("ccadmin_service");
                   String webpath = request.getWebResourcePath();
                   IResourceContext resourceContext = new ResourceContext(serviceUser);
                   response.write(webpath);
                   String fpath;
                   fpath = profile.getProperty("path").trim();
                   depth = Integer.valueOf(profile.getProperty("depth").trim()).intValue();
                   RID rid = RID.getRID(fpath);
                   ICollection folder = (ICollection)ResourceFactory.getInstance().getResource(rid, resourceContext);
                   IResourceList  fileList = folder.getChildren();
                   response.write("d.add(0,-1,'"folder.getName()"');\r\n");
                   rowid = 0;
                   scan_km(response, fileList,0);
                   response.write("document.write(d);\r\n");
                    response.write("//--></script>");
                    response.write("</div>");
                } catch (Exception e) {
                    response.write("Error Occured<br>");
                    response.write(e.toString());
              public void scan_km(IPortalComponentResponse response,IResourceList list,int level) {
                   int currentrowid = rowid;
                   if (level>depth&&depth!=0) {
                         return ;
                     String rid = " ";
                     IResourceList tmpreslist;
                     ICollection tmpcollection;
                     level++;
                     for (int i = 0; i < list.size(); i++) {
                         IResource tmpres = list.get(i);
                         try {
                             if (tmpres.isCollection() && tmpres.getLinkType() == LinkType.NONE ) {
                                  //&& tmpres.getLinkType() == LinkType.NONE
                                  tmpcollection = (ICollection) tmpres;
                                tmpreslist = tmpcollection.getChildren();
                                if (tmpreslist.size()>0) {
                                    rowid++;
                                    response.write("d.add("rowid","currentrowid",'");
                                    response.write(tmpres.getName());
                                    response.write("','');\r\n");
                                    scan_km(response,tmpreslist,level);
                             else {
                                rowid++;
                                String dispname;
                                dispname = tmpres.getDisplayName();
                                if (dispname==null||dispname.equals(""))
                                    dispname = tmpres.getName();
                                rid = "/irj/go/km/docs"+tmpres.getAccessRID();
                                response.write("d.add("rowid","currentrowid",'"dispname"','"rid"');\r\n");
                         } catch (Exception ex) {
    the error is am getting is
    com.sapportals.wcm.repository.enum.LinkType and com.sapportals.wcm.repository.enums.LinkType     kmportalappproject/src.core/com/sap/test     kmportalcomp.java     
    thanks

  • Error while creating the sales order using Proxy

    Hi Folks,
    I am trying to create a Sales Order using Proxy via BAPI "BAPI_SALESORDER_CREATEFROMDAT2" :
    and i got this type of standard error message
    <Message>FB call: insufficient parameters</Message>
    few days back only i used the same bapi for creating the Sales Order and did it successfully...using the same parameters
    I don't have any clue about this type error .
    Kindly guide .
    Regards,

    Hi Nikhil,
    How refreshing the cache and restart the server will help ?
    basically i am testing the scenario at R/3 end only by generating XML template in SPROXY.
    My ECC 6.0 is on sp 12....I am not sure is it configuration related error or a bug ? as i have used the same code in ECC 6.0 with sp 09.
    regards,

  • Run-time error while executing alv grid report

    Hi everyone
    I m trying to run a alv grid report it is giving a run time error while executing the statement CALL METHOD V_ALV->SET_TOOLBAR_INTERACTIVE.
    Actually i added 2 buttons in the toolbar.after that when i execute the report i m getting errors.
    <b>Error Analysis</b>
    An exception occurred that is explained in detail below.                     
    The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not    
    caught in                                                                   
    procedure "TOOLBAR_MENUS_INIT" "(METHOD)", nor was it propagated by a RAISING
    clause.                                                                     
    Since the caller of the procedure could not have anticipated that the        
    exception would occur, the current program is terminated.                    
    The reason for the exception is:                                             
    You attempted to use a 'NULL' object reference (points to 'nothing')         
    access a component (variable: "ME->M_CL_MENU_BUTTON_VARIANT").               
    An object reference must point to an object (an instance of a class)         
    before it can be used to access components.                                  
    Either the reference was never set or it was set to 'NULL' using the         
    CLEAR statement.

    Hi Dinesh,
    Seems you have not initialised ( Instantiated in OO ) the object and / or the parent container.
    Check if you have create object for both the parent as well as the alv object.
    So when you instatntiate the object of ALV you pass the object ( instantiated before hand ) in the parent container position.
    Also you would have to register the events to the object using method. Then only the buttons will finction.
    eg :
    IF G_CUSTOM_CONTAINER IS INITIAL.
        CREATE OBJECT CUSTOM_CONTAINER_1
               EXPORTING CONTAINER_NAME = CONTAINER_1.
        CREATE OBJECT GRID1
               EXPORTING I_PARENT = CUSTOM_CONTAINER_1.
        CALL METHOD ALV_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
             EXPORTING I_STRUCTURE_NAME = 'VBAK
             CHANGING  IT_OUTTAB        = IT_VBAK.
    Reward points if useful.

  • ABAP Run time Error whle executing the Balance sheet report in FGI0

    Hi,
    I am getting the below ABAP Run time error while executing the Balance Sheet report in FGI0.It was working before but now it is giving the error.Kindly help me in solving this.
    Runtime Errors         MESSAGE_TYPE_X
    Date and Time          06/12/2009 15:17:17
    Short text
         The current application triggered a termination with a short dump.
    What happened?
         The current application program detected a situation which really
         should not occur. Therefore, a termination with a short dump was
         triggered on purpose by the key word MESSAGE (type X).
    Error analysis
         Short text of error message:
         RAISE RKD_CONDITION_READ       (internal error)
         Long text of error message:
          Diagnosis
              The program was terminated because a situation occurred which
              should not have arisen.
          Procedure
              Analyze the situation and contact SAP.
         Technical information about the message:
         Message class....... "KH"
         Number.............. 299
         Variable 1.......... "RKD_CONDITION_READ"
         Variable 2.......... " "
         Variable 3.......... " "
         Variable 4.......... " "
    Trigger Location of Runtime Error
        Program                                 SAPLKYPR
        Include                                 LKYPRU31
        Row                                     36
        Module type                             (FUNCTION)
        Module Name                             RKD_CONDITION_READ
    Thanks
    Supriya

    Hello,
    Please refer SAP
    Note 971535 - dump when deleting characteristic with hierarchy
    Regards,
    Ravi

  • Run Time Error in e-commerce crm 5.0 when creating new order

    Hi all,
    I am getting Run Time Error in e-commerce crm 5.0 when creating new order, shopping basket is comming , but while creating order , getting run time error.
    Thanks,
    Nagesh

    Hi nagesh,
    Are you able to resolve the issue. Please let me know the solution.
    I had started a thread with a same problem but in ERP E-commerce.  Points will be rewarded if you provide the solution in the thread below
    Re: Run Time Error in e-commerce crm 5.0 when creating new order
    Thank You
    Ram

  • Run Time Error while Entering Quantity in Sales Order

    Dear All,
    Iam getting Run time Error while iam entering material quantity in sales order.Please  find the screenshot of the same.
    kindly Help Me.Me. Plz note that we had done a system copy two days back to our new server.
    Rgds
    Thomson
    ST22 Screenshot

    Dear All
    Its Resolved Thanks For your Valuable time Support
    INCLUDE LV03VFB4 inside below code trigger error.
    PERFORM VVBBD_AUFBAUEN USING WA_AVBBD
                                        WA_AVBBD-APOMOBILE
                                        DA_SUBRC
                                        DA_UPDKZ
                                        DA_VVBBD_TABIX
                                        0.
    This Was the Error some how 0 was there we are removed the 0 now it is working fine
    Rgds
    Thomson

  • Run time Error while Creating Expense request

    Dear Friends ,
    In   E-Payment ( Expense  Claim )   creation , While clicking on Enter Receipts application is going to run time error for only one user.    
    Run time Error Info :
    Runtime Errors         OBJECTS_OBJREF_NOT_ASSIGNED
    Exception              CX_SY_REF_IS_INITIAL
    Short text
         Access via 'NULL' object reference not possible.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "CL_WDR_P13N_UTILITIES=========CP" had to be
          terminated because it has
         come across a statement that unfortunately cannot be executed.
    Error analysis  
        An exception occurred that is explained in detail below.
       The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
        caught in
       procedure "PRESET" "(METHOD)", nor was it propagated by a RAISING clause.
       Since the caller of the procedure could not have anticipated that the
       exception would occur, the current program is terminated.
       The reason for the exception is:
       You attempted to use a 'NULL' object reference (points to 'nothing')
       access a component (variable: "LR_CONTEXT_ELEMENT").
       An object reference must point to an object (an instance of a class)
       before it can be used to access components.
       Either the reference was never set or it was set to 'NULL' using the
       CLEAR statement.
    How to correct the error 
         Probably the only way to eliminate the error is to correct the program.
       If the error occures in a non-modified SAP program, you may be able to
       find an interim solution in an SAP Note.
       If you have access to SAP Notes, carry out a search with the following
       keywords:
       "OBJECTS_OBJREF_NOT_ASSIGNED" "CX_SY_REF_IS_INITIAL"
       "CL_WDR_P13N_UTILITIES=========CP" or "CL_WDR_P13N_UTILITIES=========CM002"
       "PRESET"
    Information on where terminated
        Termination occurred in the ABAP program "CL_WDR_P13N_UTILITIES=========CP" -
         in "PRESET".
        The main program was "SAPMHTTP ".
        In the source code you have the termination point in line 60
        of the (Include) program "CL_WDR_P13N_UTILITIES=========CM002".
        The termination is caused because exception "CX_SY_REF_IS_INITIAL" occurred in
        procedure "PRESET" "(METHOD)", but it was neither handled locally nor declared
        in the RAISING clause of its signature.
        The procedure is in program "CL_WDR_P13N_UTILITIES=========CP "; its source
         code begins in line
        1 of the (Include program "CL_WDR_P13N_UTILITIES=========CM002 ".
    Regards,
    Suresh .

    Hi Agrawal
    As you are getting run-time error after entering the sold to party and material and the error is in SAPLV61Z ,
    close the session for sometime and open again and then create sales order and then enter sold to party and material and then check wheather you are getting or not. If you are still facing the problem then take the help of the ABAP & BASIS consultant's.
    Regards
    Srinath

Maybe you are looking for

  • Repeating row texts when exporting web report to Excel

    Dear all, When exporting a web report (including a structure/hierarchy) to Excel (via the 'export to excel button), the row texts (e.g. balance sheet texts) appear twice (column A and B)in the Excel result. When using the web context menu 'Export to

  • Aggravated: Unable to Erase Authorization, Here's what I've already tried...

    I need to test out Epub files I create before sending them to market, so I downloaded Adobe Digital Editions for Mac from here: Download | Adobe Digital Editions I followed installation setup I logged in with my existing Adobe ID I downloaded a few b

  • My smart watch just works when it's connected to the charger

    Hi, I bought my smart watch just 2 months ago, and left it in my car charging.. well, the next day when I saw that the battery was fully charged, disconnected the watch and puted it on the armband it doesn't turned on anymore, no vibrations, no displ

  • Triggering outbound idoc from the transaction VL01N

    Hi, I have requirement where in which i need to create outbound idoc of sales and delivery data as soon as VL01n transaction is saved,Pls let me know how we can achived this , the Idoc needs to be triggered immediatly after saving VL01n transaction.

  • How to edit using voice dictation?

    I have iPhone five. I have downloaded iOS eight. Is there a way to edit while using voice dictation on notes?