Running 2 consequtive BAPIs

Hi all,
In my OO program, I had the requirement to run 2 consequtive BAPIs to delete the PO line item with BAPI_PO_CHANGE and follow with closing the PR with BAPI_REQUISITION_DELETE. The problem is, the first BAPI will always fail when I run the program normally. But when I try to run in debug mode by stepping into the code line by line, both BAPI were successful. Then, I try to remove 1 of the BAPI and it was again successful.
I have tries COMMIT WORK AND WAIT, BAPI_TRANSACTION_COMMIT and RZL_SLEEP after each of the BAPIs and still it's not working.
Can anyone help me with this? This is very urgent and I will reward with full points if someone can show me the cause of this problem.
THanks in advance.

I have tried only doing a single commit work after the 2nd BAPI, but still not successful. One think I want to add is that both of this BAPI are stored in different method, just that I called them consecutively.
My codes are as below:
IF UPDATE_PO( parameters ) EQ 'X'
    UPDATE_PR( parameters ).
ENDIF.
In method UPDATE_PO, I have
    K_POITEM-PO_ITEM     = P_LINEITEM.
    K_POITEM-DELETE_IND  = V_DELETE.
    APPEND K_POITEM TO I_POITEM.
    K_POITEMX-PO_ITEM    = P_LINEITEM.
    K_POITEMX-PO_ITEMX   = C_X.
    K_POITEMX-DELETE_IND = C_X.
    APPEND K_POITEMX TO I_POITEMX.
    CALL FUNCTION 'BAPI_PO_CHANGE'
      EXPORTING
        PURCHASEORDER = P_PO
      TABLES
        RETURN         = I_PO_RETURN
        POITEM         = I_POITEM
        POITEMX        = I_POITEMX.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
     EXPORTING WAIT = C_X.
In UPDATE_PR, I have
  K_ITEM-PREQ_ITEM = '00010'.
  K_ITEM-CLOSED    = 'X.
  APPEND K_ITEM TO I_ITEM.
  CALL FUNCTION 'BAPI_REQUISITION_DELETE'
    EXPORTING
      NUMBER                      = P_BANFN
    TABLES
      REQUISITION_ITEMS_TO_DELETE = I_ITEM
      RETURN                      = I_RETURN.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
Can anyone spot what is wrong?

Similar Messages

  • How to get more detailed info while running a BAPI in test mode

    Hi friends
    I am trying to test 'BAPI_QUOTATION_CREATEDATA2' by opening the BAPI with 'se37' and then clicking on the button Test/Execute (F8) and entering all the data required.
    However, I get a message as follows.
    '555 The sales document is not yet complete: Edit data'
    While creating the QUOTE manually using 'va21' I get more detailed messages like what kind of data is missing 'whether valid to date is missing ..etc.etc.'.
    However, while testing thro' bapi, all it says is that sales document is not complete.
    Is there a way to see more detailed info as to what information is missing, so that I can put them before running.
    Your feedback or suggesions will be highly appreciated.
    Thansk
    Ram

    Thanks Rob
    Actually it says
    W  V1   555  The sales document is not yet complete: Edit data.
    As I said, I am running the BAPI manually by opening the BAPI using SE37 and then clicking on the F8 button. This inreturn will give me an opportunity to click on different object trees to enter the sample data. So I have entered everything that I thought was needed. But still it keeps complaining that the info is not complete but no further details.
    Hope there is some log file or something that I can see to get more details.
    Thanks
    Ram

  • How to run a BAPI in background mode?

    Dear friends,
    I have a requirement [In the UI user can choose two options - run online or run backgroud] to run a BAPI (BAPI_SALESORDER_CHANGE) in background mode (background job)  , does anybody know how to implement it?
    Thanks a lot!!

    Hi
    You can define 2 radio button one foreground and otherfor background then
    for background use FM BP_JOB_CREATE or BKK_UPT_DISP_JOBS_START  or DB2_SCHEDULE_JOB_IMMED
    Regards
    Shiva

  • How to run the BAPI after creation or Modification ?

    HI Abapers,
    How to run the BAPI after creation or Modification ? What is the step by step procedure to run the the BAPI?
    Immediate reply is highely appriciable.
    Regards,
    Chow.

    Hi
    If you have done with BAPI creation correctly Run it similar to the fun mdule which we run in SE37 calling this BAPi in the program with CALL FUNCTION and passing the necessary parameters
    see the sample bapi code how it is called in Program
    data : w_resb_header like bapirkpfc.
    data: begin of itab_resb occurs 0.
    include structure bapiresbc.
    data: end of itab_resb.
    data: begin of itab_bapi_return occurs 0.
    include structure bapireturn.
    data: end of itab_bapi_return.
    data : w_resb_no like bapirkpfc-res_no.
    w_resb_header-plant = p_werks.
    w_resb_header-res_date = sy-datum.
    w_resb_header-created_by = sy-uname.
    w_resb_header-cost_ctr = '0000010001'.
    w_resb_header-move_type = '201'.
    w_resb_header-gr_rcpt = w_room_time.
    w_resb_header-part_acct = 'OR'.
    *ITEM DATA
    loop at i_details.
    itab_resb-material = i_details-matnr.
    itab_resb-plant = i_details-werks.
    itab_resb-store_loc = i_details-lgort.
    itab_resb-quantity = i_details-qty.
    itab_resb-unit = i_details-meins.
    append itab_resb.
    clear itab_resb.
    clear i_details.
    endloop.
    call function 'BAPI_RESERVATION_CREATE'
    exporting
    reservation_header = w_resb_header
    NO_COMMIT =
    MOVEMENT_AUTO =
    importing
    reservation = w_resb_no
    tables
    reservation_items = itab_resb
    return = itab_bapi_return
    call function 'BAPI_TRANSACTION_COMMIT'
    exporting
    wait = 'X'
    IMPORTING
    RETURN =    .
    wait up to 5 seconds.
    w_resb_no contains your reservations numnber
    Regards
    Anji

  • How to Run Multiple BAPI's

    Hi All,
    i was trying to run multiple BAPI's using Jco. but no luck. it giving error message like "Employee/person not locked yet".
    the BAPI's i'm trying are
    1. BAPI_EMPLOYEET_ENQUEUE
    2. BAPI_ABSENCE_REQUEST
    3. BAPI_TRANSACTION_COMMIT
    4. BAPI_EMPLOYEET_DEQUEUE
    i'm using connection pooling to get connection.
    the code
    JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
    JCoFunction function = destination.getRepository().getFunction("BAPI_EMPLOYEET_ENQUEUE");
    function.getImportParameterList().setValue("NUMBER", "00000002");
    function.execute(destination);
    function = destination.getRepository().getFunction("BAPI_ABSENCE_REQUEST");
    function.getImportParameterList().setValue("EMPLOYEENUMBER", "00000002");
    function.getImportParameterList().setValue("VALIDITYBEGIN", c.getTime());
    function.getImportParameterList().setValue("VALIDITYEND", c1.getTime());
    function.getImportParameterList().setValue("ABSENCETYPE", "0014");
    function = destination.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
    function.execute(destination);
    function = destination.getRepository().getFunction("BAPI_EMPLOYEET_DEQUEUE");
    function.getImportParameterList().setValue("NUMBER", "00000002");
    function.execute(destination);
    i don't know where i'm going wrong. Plx help me out.
    thanks in Advance.
    Ravi.

    Hi.
    I found the correct form to use.
    BAPI_EMPLOYEE_ENQUEUE
    BAPI_PERSDATA_CHANGE
    BAPI_EMPLOYEE_DEQUEUE
    In a java file need use JCoContext to generate a group functions to will be execute
    try {
    JCoContext.begin(destination);
         if (JCoContext.isStateful(destination))
              bloqFunction.execute(destination);
              cambFunction.execute(destination);
              desbFunction.execute(destination);
    } finally {
    JCoContext.end(destination);
    Declarated:
    JCoFunction bloqFunction = destination.getRepository().getFunction(
                        "BAPI_EMPLOYEE_ENQUEUE");
    JCoFunction cambFunction = destination.getRepository().getFunction(
                                            "BAPI_PERSDATA_CHANGE");
    JCoFunction desbFunction = destination.getRepository().getFunction(
                                            "BAPI_EMPLOYEE_DEQUEUE");
    I hope help with this.

  • When I run the BAPI "BAPI_PBSRVAPS_GETDETAIL" .It gives me a short dump.

    When I run the BAPI "BAPI_PBSRVAPS_GETDETAIL" .It gives me a short dump.
    Can anybody help me with this?

    This is the content of the dump.
    Runtime Errors         OBJECTS_OBJREF_NOT_ASSIGNED
    Except.                CX_SY_REF_IS_INITIAL
    Date and Time          05/17/2007 11:21:29
    Short text
         Access via 'NULL' object reference not possible.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "/SAPAPO/SAPLADVF" 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 "/SAPAPO/ADVF_CELL_INPUT" "(FUNCTION)", 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: "C_S_ACTVIEW-AGC_CHILD1-APOGRID").
         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.
    Missing RAISING Clause in Interface
        Program                                 /SAPAPO/SAPLADVF
        Include                                 /SAPAPO/LADVFU06
        Row                                     1
        Module type                             (FUNCTION)
        Module Name                             /SAPAPO/ADVF_CELL_INPUT
    Trigger Location of Exception
        Program                                 /SAPAPO/SAPLADVF
        Include                                 /SAPAPO/LADVFU06
        Row                                     81
        Module type                             (FUNCTION)
        Module Name                             /SAPAPO/ADVF_CELL_INPUT
    Source Code Extract
    Line  SourceCde
       51 *#TR# (1) Check arguments: Read only mode must be 0, 1 or 2 and row and column must be provi
       52   if f_argument2 is initial or f_argument3 is initial.
       53     break-point id /SAPAPO/ADV__EXECUTION. clear f_argument. f_calc_error = true. exit.
       54   endif.
       55
       56
       57 *#TR# (1a) Calculate line number of the cell (line + line offset)
       58   l_line = f_argument2 + i_line_offset.
       59
      60 *#TR# (1b) Set L_CELL_READONLY depending on the read only mode F_ARGUMENT
      61   case f_argument.
      62     when 0. l_cell_readonly = /sapapo/cl_agc_base=>gs_c_agc_readonly_values-read_only.
      63     when 1. l_cell_readonly = /sapapo/cl_agc_base=>gs_c_agc_readonly_values-read_write.
      64     when 2. l_cell_readonly = /sapapo/cl_agc_base=>gs_c_agc_readonly_values-stateless.
      65     when others.
      66       break-point id /SAPAPO/ADV__EXECUTION. clear f_argument. f_calc_error = true. return.
      67   endcase.
      68
      69 *#TR# (1c) The input status of cells set to read only by the data view definition (history)
      70   if f_argument3 < g_s_cols_properties-first_input_column.
      71     return.
      72   endif.
      73
      74 *#TR# (1d) Note 1005813: The old APOGRID does not support the read only mode
      75 *#TR# /SAPAPO/CL_AGC_BASE=>GS_C_AGC_READONLY_VALUES-READ_WRITE. For compatibility reasons, w
      76 *#TR# read only mode /SAPAPO/CL_AGC_BASE=>GS_C_AGC_READONLY_VALUES-STATELESS
      77
      78 *#TR# Determine version of APOGRID to check, if new or old APOGRID is used. The version is b
      79 *#TR# reasons
      80   if g_agc_grid_version is initial.
    >>>>     c_s_actview-agc_child1-apogrid->get_control_version(
      82       IMPORTING
      83         apogrid           = l_apogrid
      84       EXCEPTIONS
      85         cntl_system_error = 1
      86         cntl_error        = 2
      87         others            = 3
      88           ).
      89     if sy-subrc <> 0.
      90       break-point id /sapapo/adv__execution. clear f_argument. f_calc_error = true. exit.
    91     endif.
    92
    93     g_agc_grid_version = l_apogrid.
    94   endif.
    95
    96 *#TR# If the old grid is used change read only mode if necessary
    97   if g_agc_grid_version < 200
    98     and l_cell_readonly = /sapapo/cl_agc_base=>gs_c_agc_readonly_values-read_write.
    99
    100     l_cell_readonly = /sapapo/cl_agc_base=>gs_c_agc_readonly_values-stateless.

  • When I run a BAPI ,  then What is the out put?

    When I run a BAPI ,  then What is the out put format ?
    Is there anyone in Chennai regarding this ?

    the BAPI i am creating will fetch the sales order header data (along with partner details) and item data  and put it in the JMS que (JAVA MESSAGE SERVICE)  ....
    Can we use more than one internal table  where i will put the data
    i.e
    1.  for header data
    2. for partner (because the partners will be repeated
    3. for  item data
    and the BAPI will fetch the data from SAP tables and put it in these tables....and we can fetch the data by an integrator software and finally put it in the JMS queue.....

  • Option for running a BAPI outside of SAP

    Hi everyone
    I'd like to call a BAPI from outside of SAP and am interested in what options there are to do this. 
    I believe that Delphi and PHP can be used.  Are there any others?
    Cheers

    You can use a number of languages. The main thing is that you need the RFC library (librfc32.dll on Windows) to communicate with SAP. There are wrappers in Perl, Python, Ruby etc. If you have SAP GUI installed on Windows, you can even write VB scripts to call RFCs in SAP because of the COM-exposed functions.
    (Remember that the term BAPI refers to Business API, which may not always represent a remote-enabled function module. What you want to do is call RFC function modules from outside SAP).
    Google for "SAP RFC <language name>" to see if a specific language has the wrappers/bindings for calling SAP RFC function modules.

  • PO creation via BAPI is not into database after run BAPI_PO_CREATION1

    Dear friends ,
    I have done an case to test PO creation via BAPI_PO_CREATION1.
    I run the BAPI and the PO number is presented to me.
    But the PO is not in the database.
    Should I done another step to write this PO into the database?
    best regards,
    Ale

    *Confirm the document creation by calling database COMMIT
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = 'X'
    IMPORTING
      RETURN        =
    end-of-selection.
    *Output the messages returned from BAPI call
    LOOP AT RETURN.
    WRITE / RETURN-MESSAGE.
    ENDLOOP.

  • Return Messages for a BAPI run in Background

    Hi all,
    I am running a BAPI( BAPI_SALESORDER_CHANGE ) in Background task, It works fine and updates the Sales order but i dont get any return messages.But based on the return messages i need to show up on the report which orders got updated and which are not.....
    Can anyone help me how can i get the return messages when i run a BAPI in background task......

    Thanks for the quick response....I think you got me wrong...I am not running the program as a background job....I am running only the bapi in background task as below.....
                CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
                   IN BACKGROUND TASK AS SEPARATE UNIT
                     EXPORTING
                          salesdocument    = v_vbeln
                          order_header_in  = it_bapisdh1
                          order_header_inx = it_bapisdh1x
                     TABLES
                          return           = it_return
                          partnerchanges   = it_bapiparnrc.
    When the bapi runs as a background task i dont get any return messages in it_return but the sales order gets updated....
    But i will have to capture the return messages as well....How can i achieve that ?

  • Problems with running BAPI   BAPI_SALESORDER_CREATEFROMDAT2

    Hi all,
    I’ve got a problem running BAPIs in SD invironment.
    I’m creating contract releases in SD via BAPI.
    First I run BAPI BAPISORDER_GETDETAILEDLIST in my program to get detaildata of the contract.
    Then I run the BAPI   BAPI_SALESORDER_CREATEFROMDAT2 filled with contract reference data and in addition with order data to create the contract release.This works properly so far. On both sides in the contract and in he contract release I find the correct document flow. Means: in document flow of the contract I find all the releases created . Also I find the contract in the documentflow of the releases.
    But…something does not work: In the contract the released values are not updated. When I create a release manually, the release values are accumulated  in the contract in field  ‘value released’ under flag ‘item detail’. But this does not work, when the leases are created via BAPI. However I checked several parameters in the BAPIS but I cannot find something that leads to an update .
    Can somebody help me and can tell me what is to be done to get this field updated? Thanks in advance.
    same in German...
    Ich habe ein Problem mit BAPIs im SD.
    Ich erzeuge Abrufe zum Kontrakt im SD mittels BAPIs.
    Zuerst lasse ich den BAPI BAPISORDER_GETDETAILEDLIST laufen, um mittels Kontraktnummer alle Daten zum Kontrakt zu bekommen. Dann lasse ich den BAPI   BAPI_SALESORDER_CREATEFROMDAT2 gefüllt mit SD-Abrufdaten und den Referenzdaten des Kontraktes laufen Dies funktioniert soweit sehr gut. Sowohl im Kontrakt als auch im Abruf sind jeweils die übergeordneten bzw. untergeordneten Vertiebsbelege zu sehen. Die Referenz wird also hergestellt. Jedoch wird im Kontrakt nicht die Abrufwerte aufsummiert. Normalerweise wird bei manueller Erstellung der Abrufe im Kontrakt die jeweilgen abgerufenen Werte gegen den Kontraktwert aufsummiert (Feld abgerufene Werte im Kontrakt unter Reiter ‚Positionsdetail‘. Ich habe alle möglichen Parameter im BAPI geprüft und getestet aber nichts gefunden, was mir die abgerufenen Werten aufsummiert.
    Kann mir dazu einen Tip geben, was ich tun kann, damit auch die Werte richtig referenzieren ? Danke im Voraus.

    the usage of exactly this BAPIs in the way I described  is in according to SAP note 370988.
    BAPI_SALES_DEL_SCHEDULE_CREATE ist for SD schedule agreements and not for SD contracts and does not offer Input parameters for e.g.  adding price conditions what is needed for my task.
    The field in contract I mentioned e.g. in Transaction VA42 VA43 is filled / gets its Information out of Infostructure/table S135. The BAPI seems not be able to fill this structure while creating the contract release.
    I'm looking for example an input parameter I did not found already or any other option that leads to an update of infostructure S135 while creating/posting a release via BAPI.

  • Questions on BPS BAPI calls and PDF forms

    I will need to create a button on a BPS form and that button is supposed to call a BAPI.  One of the buttons will create a PDF of the form (using the contents of the form) and print said form to a 'default' printer.  The issue is that not all cFolder users will have an ECC logon name.  What am I to do in this instance?  Will I need to pass some type of credentials to the ECC backend in order to run this BAPI?
    Also, how can I get the contents of the form(s) to the BAPI?  I assume that I will need to create the PDF in the code of the BAPI.  Please be patient with me as this is my first time to work with cFolders and/or BPS.
    Regards,
    Davis

    Hi Davis,
    Well, if you are able to log on the BPS application (thus, a Web Interface if I'm not mistaken) then it means that some user is logged on the ABAP-side. It is either a "personal" user or a technical (common) user, that is used for anonymous access.
    You will certainly be able to track down this user with the SM04 transaction.
    You should be able to add a button to the BPS page. One idea would be to call an URL with an ICF service behind that will be able to process the parameters contained in this URL.
    It will be this very ICF service that will call the BAPI.
    Try these links
    http://help.sap.com/saphelp_nw04s/helpdata/en/55/33a83e370cc414e10000000a114084/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ea8db790-0201-0010-af98-de15b6c1ee1a
    Hope this helps.
    Best regards,
    Guillaume

  • Tables TCURM and T001K inconsistent Error While Creating Materials by BAPI

    Hi I am Using the BAPI
    BAPI_MATERIAL_SAVEDATA to create Material Masters I am creating all views for a Material.
    When I repeatedly run the BAPI for Multiple runs to create the Materials for Multiple plants and multple sales Views
    I get an Error Message when it is tryng to create accounting and costing View
    The error is Tables
    TCURM and T001K inconsistent; notify your systems administrator
    I dont get this message if I create one Material.
    I get this error message only when I repeat the loop and try to create Materials for different valvation areas..
    Please some one give ur views ..
    I promise All replies will be rewarded..
    Thanks
    Martin

    Rob,
    This is the peculiar behavious of SAP.
    As i am trying to create the materials by using the BAPI with in Visual Basic.
    The error can be simulated by using online data entry
    i did a research on it and i found that the error can be overcome if we create the accouting view first and later oher views and this occurs if we try to create accouting views for other valuation areas are plants when we set the MRP_VIEW = "X" and ACCOUNT_VIEW = "X" and COST_VIEW = "X"
    i dont know the exact reason for all this...
    Thanks
    Martin

  • BAPI for creation of Production Order with Ref to sales order

    Hi all,
    we are using BAPI_PRODORD_CREATE  for creating Production Order with ref to sales order.
    As per the Business Scenario, we are not creating any masters like BOM and Routing, instead
    we are creating Routing directly into the Production Order under operation overview screen.
    during creation of routing system is generating a default operation.
    the following is the error results after running the Bapi.
    "No routing selected"
    Best Regards.
    GTNRNR.

    Hi GTNRNR,
    with out creation of BOM you created routing and in routing for the operations which components did you allocated so that can be used to manufacture the final product. Can you be please specific?
    Regards,
    Madhu.G

  • Field "Mat Slip" (MTSNR) of MB03 is empty after i run BAPI_GOODSMVT_CREATE

    Hello,
    I'm doing BAPI_GOODSMVT_CREATE for moviment '315'.
    After i run the BAPI, when i go to MB03, the field "Mat. Slip" is empty and does not appear on the screen!
    I'm using the following parameters:
    code= '04'
    ITEM:
    t_saida-matnr TO t_bapiitem-material,
    t_saida-werks TO t_bapiitem-plant,
    t_saida-lgort TO t_bapiitem-stge_loc,
    t_saida-move_type TO t_bapiitem-move_type,
    t_saida-erfmg TO t_bapiitem-entry_qnt,
    t_saida-meins TO t_bapiitem-entry_uom,
    t_saida-ummat TO t_bapiitem-move_mat,
    t_saida-umwrk TO t_bapiitem-move_plant,
    t_saida-umlgo TO t_bapiitem-move_stloc,
    t_saida-sgtxt TO t_bapiitem-item_text.
    HEADER:
    t_bapiheader-pstng_date = sy-datum.
    t_bapiheader-doc_date = sy-datum.
    And when i run the same process with MIGO, the field appears.
    Best Regards,
    Reginaldo Borges

    Hi,
    You have to fill in the header:
    t_bapiheader-REF_DOC_NO = 123456.   " your nota!
    Best regards,
    Leandro Mengue

Maybe you are looking for

  • 0FI_AP_4 Not extracting  data for items not due

    Dear SAP Forum, Please note when we are trying to pull the 0FIA_P_4 data into SAP BI system, there are certain records like items not due - records ( in tcode fbl1n)   are not populating  in the standard DataSource . I need to display these records i

  • Thinkpad yoga - limited connection - intel 7260AC (with solution that worked for me)

    limited connection issue i'm new to the forum, sorry for bad english i've a brand new rhinkpad yoga, with win 8.1 and intel ac 7260 wifi card first of all the solution that worked for me is moving from WEP to WPA2 protection with the router the probl

  • Far fewer print settings in this version?

    In the previous iPhoto, I was easily able to select different printing layouts that would print a bunch of photos on a single page in such a way that they were laid out nicely, filling the available space and all the right way up. Can't seem to find

  • Push button :  Can it be marked as selected ?

    Hi Guys, There are 2 pushbuttons in my screen that are going to work as a pair. My question is u2013 once the user chooses on of the buttons how can I display that one as u201Cchosenu201D one ?? Like in checkbox we have tick mark to be shown as u201C

  • Icons too large

    Icons on my phone all at once chahged to be 5 times larger. How can I return them to normal size. Thanks