Executing BAPI Multiple Times

Hello Everyone,
I am trying to execute BAPI_ACC_DOCUMENT_POST multiple times in an application. My requirement is to post multiple documents in one click. The Context is as follows.
--Context
BAPI_ACC_DOCUMENT_POST(model node)---cardinality(0..1)
Accountgl(model node)---cardinality(0..n)
AccountPayable(model node)---cardinality(0..n)
Currencyamount(model node)---cardinality(0..n)
DocumentHeader(model node)---cardinality(0..1)
Output(model node)---cardinality(0..1)
-Document(Value Node)-cardinality(0..n)
I have create the Value node Document and I am trying to get few values from the user and assigning it to the model nodes during runtime. The BAPI should execute depending on the number of rows in the Document Table that the user decides at the runtime.
Could anyone give me some basic idea about how to acheive this requirement. I hope you can understand my requirement and please do let me know if you need any further explanation. I would greatly appreciate your help.
Regards,
Gopal.

Hi Siva,
My issue is resolved by using the following code.
public void onActionPostDocument(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionPostDocument(ServerEvent)
    //$$begin ActionButton(-761385096)
for(int i=0; i<wdContext.nodeDocument().size(); i++){
wdContext.currentDocumentheaderElement().setHeader_Txt(wdContext.nodeDocument().getDocumentElementAt(i).getHeader_Txt());
          wdContext.currentDocumentheaderElement().setRef_Doc_No(wdContext.nodeDocument().getDocumentElementAt(i).getRef_Doc_No());                    wdContext.currentAccountglElement().setGl_Account(wdContext.nodeDocument().getDocumentElementAt(i).getGl_Account());
wdContext.currentAccountglElement().setCostcenter(wdContext.nodeDocument().getDocumentElementAt(i).getCostcenter());
wdContext.currentAccountpayableElement().setVendor_No(wdContext.nodeDocument().getDocumentElementAt(i).getVendor_No());
wdContext.nodeCurrencyamount().setLeadSelection(0);
wdContext.currentCurrencyamountElement().setAmt_Doccur(wdContext.nodeDocument().getDocumentElementAt(i).getAmt_Doccur().negate());
wdContext.currentCurrencyamountElement().setItemno_Acc("0000000001");
wdContext.nodeCurrencyamount().setLeadSelection(1);
wdContext.currentCurrencyamountElement().setAmt_Doccur(wdContext.nodeDocument().getDocumentElementAt(i).getAmt_Doccur());
wdContext.currentCurrencyamountElement().setItemno_Acc("0000000002");
wdThis.wdGetMultipleDocCompController().executeBapi_Acc_Document_Post_Input();                                   
Thanks a lot for your help.
Regards,
Gopal.

Similar Messages

  • Hi i want to execute bapi two times with different paramters....Possible

    Hi,
    i want to execute bapi twice times.Possible please explain where i put which code.Means i put bind code at doinit() method of conpopnent controller and execute bapi code in doinit() iof view. But for second time where i put bind and execute code. 
    Regards,
    Gurprit
    Edited by: GURPRIT BHATIA on Dec 17, 2007 1:24 PM

    Hi Gurprit,
    For executing the bapi second time, you can put the execute bapi code in the action of the button which is on your form. You need not write the bind code again.
    Bye
    Ankur

  • Event Executing Itself Multiple Times

    Hello Experts,
    I have created a validation in the Sales Order Form for checking the Item Gross Profit greater than 0 .
    When user press tab from the UnitPrice column this checking is done but system is executing the event multiple time
    rather than once .It makes the checking very slow each time this check occurs event occur mulitple times.
    Please suggest what to do .
    Thanks & Regards,
    Amit

    Hi,
    Please ensure that u r given necessary conditions before doing validation
    1. pval.BeforeAction = False
    2.Pval.ColumUID = "UrId"
    3.Pval.ItemUId = "UrMatId"
    4.pVal.InnerEvent
    By
    Firos C

  • Can i execute bapi two times if yes then wht code i need to write 2 time.

    Hi,
    I am trying to execute my bapi at wdDoInit() method of view . Same Bapi will execute at  Controller.
    But my view bapi is not running.
    Why this is happeded?
    My code for View is like this
    public void wdDoInit()
        //@@begin wdDoInit()
         IWDMessageManager manager = wdComponentAPI.getMessageManager();
                   try
                               wdContext.currentZcrm_Sales_Orders_InputElement().setRun_Bp("ALL");
                               wdContext.currentZcrm_Sales_Orders_InputElement().setUname("SUNIL103");
                               wdContext.currentZcrm_Sales_Orders_InputElement().modelObject().execute();     
    wdContext.nodeOutput().invalidate();
                   catch(WDDynamicRFCExecuteException e)
                                    manager.reportException(e.getMessage(), false);
        //@@end
    Please help me to trace this thing ,
    Regards,
    Gurprit Bhatia

    Hi,
       Change this code a bit:
    Zcrm_Sales_Orders_Input input = new Zcrm_Sales_Orders_Input();
    wdContext.nodeZcrm_Sales_Orders_Input().bind(input);
    input.setRun_Bp("ALL");
    input.setUname("SUNIL103");
    wdContext.currentZcrm_Sales_Orders_InputElement().modelObject().execute();
    wdContext.nodeOutput().invalidate();
    Regards,
    Satyajit.

  • Processing BAPI multiple times

    Experts
    Looking for an easy solution to this -
    I have abap code that calls a bapi and loads data from an excel spreadsheet with a header and line data. Currentlty the BAPI only processes one record. What is the easiest way of either getting the abap code to run calling multiple data files or to get the abap code to pick mutliple header and line records in the same file.
    thanks

    hi Andrew ,
    maintain only one file , maintain one flad  that s H/L  for each and every row in that file.
    based on there values u have to get header and iitem data.
    like
    loop at i_upload.
    if flag = 'H'.
      header  table with one more unique key to identify items for this header
    else.
    flag = L.
    item table.
    endloop.
    Regards
    Peram

  • Execute BAPI for different input values and dispaly data in a table

    Hi all,
    I have a specific problem about executing BAPI multiple times for different input values and didplay result in a table.
    I am using the code similar to the following logic.
    Bapi_Mydata_Input in = new Bapi_Mydata_Input();
    wdContext.nodeBapi_Mydata_Input().bind(in);
    String in = wdContext.currentperdataElement.getnumber();
    in.setDestination_From(10)
    wdThis.wdGetMydataComponentController().executeBapi_Mydata_Input();
    in.setDestination_From(20)
    wdThis.wdGetMydataComponentController().executeBapi_Mydata_Input();
    in.setDestination_From(30)
    wdThis.wdGetMydataComponentController().executeBapi_Mydata_Input();
    And I want to display the data in a single table. I want the result in a table for Bapi execution based on input parameters passed 10,20 30.
    But I am getting the table data only for the input parameter 30.I mean its actually display the data in table only for the last input parameter.
    So May I ask you all if you know the solution for this problem.PLease advise me with some tips .or sample code is very much appreciated.I promise to award points to the right answer/nice advises.
    Regards
    Maruti
    Thank you in advance.

    Maruti,
    It seems that WDCopyService replaces content of node, rather then adds to content.
    Try this:
    Bapi_Persdata_Getdetailedlist_Input frelan_in = new Bapi_Persdata_Getdetailedlist_Input();
    wdContext.nodeBapi_Persdata_Getdetailedlist_Input().bind(frelan_in);
    final Collection personalData = new ArrayList();
    String fr1 = wdContext.currentE_Lfa1Element().getZzpernr1();
    frelan_in.setEmployeenumber(fr1);
    wdThis.wdGetFreLanReEngCompController().executeBapi_Persdata_Getdetailedlist_Input();
    WDCopyService.copyElements(wdContext.nodePersonaldata(), wdContext.nodeNewPersonaldata());
    for (int i = 0, c = wdContext.nodePersonaldata().size(); i < c; i++)
      personalData.add( wdContext.nodePersonaldata().getElementAt(i).model() );
    String fr2=wdContext.currentE_Lfa1Element().getZzpernr2();
    frelan_in.setEmployeenumber(fr2);
    wdThis.wdGetFreLanReEngCompController().executeBapi_Persdata_Getdetailedlist_Input();
    WDCopyService.copyElements(wdContext.nodePersonaldata(), wdContext.nodeNewPersonaldata());
    for (int i = 0, c = wdContext.nodePersonaldata().size(); i < c; i++)
      personalData.add( wdContext.nodePersonaldata().getElementAt(i).model() );
    wdContext.nodeNewPersonalData().bind( personalData );
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • BW Infopackage calling FM multiple times

    Hi Experts,
    I am trying to extract data from FM using datasource in RSO2,
    I have created infopackage in BW on this datasource now my problem is while executing infopackage (say I have 100 records in ECC) it is calling FM multiple times and getting multiples records of my actual records more than 100 and its status is in yellow and never ending.
    Please help me resolved this issue, Is there any routine required at infopackage level to restrict FM to be called only one time and get only available records or at FM level I have to add any condition, if routine is required then also advise what would be the routine.
    Thanks.

    Hi,
    k,Then there is no issue with the DS.
    Do you see any error message in load monitori screen in Status tab. if not tell me what ever message it shows.
    Also how are you saying that the FM is executing/called multiple time.

  • Same parameter multiple times in Execute SQL Task

    Hi all,
    i have a fairly long parametrized query that needs to be run within an Execute SQL task. It has only 2 unique parameters, but these need to be used multiple within that query. The connection is OLEDB.
    ill simplify my requirement by making up an arbitrary T-SQL "where" clause that will illustrate what i need:
    where
    x = @param1
    and y = @param1
    and z > @param2
    and w > @param2
    moving this into an SSIS execute SQL task will require the following:
    where
    x = ?
    and y = ?
    and z > ?
    and w > ?
    I know i need to specify 4 parameters and remap the same variables multiple times.. like so:
    User:aram1   -> 0
    User:aram1   -> 1
    User:aram2   -> 2
    User:aram2   -> 3
    isnt there a better way? i ask this because in my real task i have 2 params, each is reused 4 and 5 times respectively and it seems stupid to repeat params like this.

    @ _proffy_
    you can pass the same variable or value as parameter multiple times sql task.
    follow the steps below.
    1) type the sql query with parameters in SQL statement tab of sql task editor
    2. in the parameter mapping, select the variables.
      you can select the same variables more than once.
     give the parameter name as 0,1,2,3..... based on variables you require.
    do not forget to chooose the appropriate Datatype.
    ex:
    select * from table1
    where a= ?
    and b=?
    and c= ?
    parameters:
    Var name               param Name
    user::Var1               0   
    user::Var1               1
    user::Var2               2
    so the value becomes a=var1, b= var1 and c= var2

  • Executing same VI multiple times, sending/retrieving data

    I know how to
    execute a single vi multiple times using the invoke node/reentrant method.  But
    I am not sure how to send/get data the running vi's.
    A little background
    on my project.  I have to test up to 64 units for a long period of time.  When
    one of the 64 units is found, I want the test to execute the test.vi then come
    back to my main.vi and wait for the next unit to test to be
    found.
    The test.vi will
    require some information to run so I need to get that data into the test.vi
    along with a way to stop the tests while they are running.  I also want to
    report running data back to the user, so I need to get data from
    test.vi.
    I am using a
    producer/consumer/display loop(s) and I would like to be able to use my display
    queue to collect and sort data from my running test.vi's.
    I may be going about
    this wrong executing test.vi using the invoke node, but I am trying to find away
    that the test vi's will independently execute and run.
    Please let me know
    if I need to clarify my situation.  I have been trying to figure this out for a
    while, so it may make sense in my head, but not on paper.
    Thanks,
    Zac

    If I understand you correctly, you are invoking a reentrant VI to run in up to 64 different instances?  And you need to set up a communications mechanism between each instance and the main VI.
    I would look at a functional global variable or action engine.  (Search on either of those terms and  you will come up with numerous examples).
    Let the FGV store data in its uninitialized shift registers.  If you need a separate queue from each VI instance to the main, then have one shift register be an array of queue references.  Let's say you are ready to invoke the first instance of your VI.  Pass to it and ID value of 0 in its connector pane.  Obtain a queue and store the reference to that in index 0 of the queue array in the FGV.  Every time you need to enqueue or dequeue from queue 0, you use index array to retrieve the reference stored in queue 0.  You would do that whenever you need to work inside the instance of the VI (have it remember that its ID was 0) or in the main VI.
    Next instance of the reentrant VI, you pass it a 1 as its ID.  Let the FGV obtain a queue and store its reference in index 1 of the array.  You could have other values stored in the FGV or other arrays such as an array of booleans that serve as flags to tell the instance of the reentrant VI to stop running.
    Basically the FGV or action engine becomes a storehouse of information for each instance of the reentrant VI.  It will be scalable.  Each time you need to add a new instance of your VI, you store the info in another element of the array stored in the FGV that is based on a ID number you assign as you create each instance.

  • On Execute operation, the bean getter is being called multiple times

    Hi,
    I have a JCR data control, i am trying to write a method that returns predicate, but this method is being called multiple times, when executing the advanced search operation.
      public List<Predicate> getPredicates() {
      ArrayList<Predicate> predicates = new ArrayList<Predicate>();
       // predicates.add(new Predicate("jcr:content/idc:metadata/idc:xScope",Operator.EQUALS,"GLOBAL"));
      DCBindingContainer bc=(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
      JUCtrlListBinding attrBinding=(JUCtrlListBinding)  bc.findCtrlBinding("StateId");
      Object stateId= attrBinding.getSelectedValue();
      if(stateId instanceof Row){
      predicates.add(new Predicate("jcr:content/idc:metadata/idc:xState"
      , Operator.EQUALS
      ,((Row)stateId).getAttribute("StateId").toString()));
      attrBinding=(JUCtrlListBinding)  bc.findCtrlBinding("DistrictId");
      Object districtId=attrBinding.getSelectedValue();
      if(districtId instanceof Row){
          predicates.add(new Predicate("jcr:content/idc:metadata/idc:xDistrict",Operator.EQUALS,((Row)districtId).getAttribute("DistrictId").toString()));
        attrBinding=(JUCtrlListBinding)  bc.findCtrlBinding("Scope");
        Object scopeId=attrBinding.getSelectedValue();
        if(scopeId instanceof Row){
            predicates.add(new Predicate("jcr:content/idc:metadata/idc:xScope",Operator.EQUALS,((Row)scopeId).getAttribute("ScopeType")));
        AttributeBinding tempAttrBinding=(AttributeBinding)bc.findCtrlBinding("CreatedDate");
        Object createdDate=tempAttrBinding.getInputValue();
        if(createdDate!=null){
            predicates.add(new Predicate("jcr:content/jcr:created",Operator.EQUALS,createdDate.toString()));
        if (predicates.size()>0){
          return predicates;
      return Collections.emptyList();
      } The problem is while it's being called multiple times different list's are being returned which is causing the method not to work . The bean is in pageFlowScope .

    That is bc ADF life cicle... Is always executing 2 times...

  • Web Service executing multiple times

    We are noticing an ongoing problem with web services both consumed in SAP as well as web services published in SAP and consumed via .NET applications.  In both cases, we are occasionally seeing examples of a single web service method calls executing multiple times.  For example, one of our methods in our SAP generated web services inserts records into a custom Z table.  We are noticing that for a single invocation of the web service, data records are appearing multiple times in the custom table.  We have placed code inside of the function in SAP to catch these multiple executions, but the code does not recognize the duplicates because most likely, the commit from the previous execution has not yet occurred.  We have time stamped the inserts into the table and can see that they do not have the same time.  Our web services are being created in SE80.  My guess is this is some sort of caching issue.  Has anyone run into a similar problem?  We are using NetWeaver 7.0 and SAP ECC 6.0.
    Edited by: Joseph Sciacca on Sep 9, 2008 4:10 PM
    Edited by: Joseph Sciacca on Sep 9, 2008 7:34 PM

    Hi Developers,
    I have the same question, is it possible to have multiple outgoing parameters?
    When not, does SAP Netweaver knows a IN-OUT parameter? Because I found on the internet that it is possible to have a IN-OUT parameter. But that was with the BEA Weblogic 8.x.
    When not, is then the only solution to return a object? With in this object all the parameters you want.
    Or otherwise is there a other workaround?
    Thanks in advance,
    Marinus Geuze

  • ALV events for data_change  executing multiple times

    Hello Experts,
    I am using the event "data_changed" of cl_gui_alv_grid and its getting triggred multiple times based on
    no. of rows in my ALV grid output.
    For ex: if i have 5 rows and if i input a field in any cell in a new row, in data_changed event is triggered 2 times.
    The  LOOP AT er_data_changed->mt_mod_cells INTO ls_modified is executing 6 times as in above example
    even though is having only 1 entry.
    Can some one pls help me with this?
    Also i see the  toolbar event is often getting excuted multiples no of times making the application slow.
    Please suggest.
    Thanks
    Dan

    Dan,
    Maybe you've placed or doing something wrong, take this report as a pattern "BCALV_EDIT_03".
    Best regards,
    Alexandre

  • For each loop container executing multiple times....

    Hi,
    We are using SQL SERVER version 2005.
    I am having a For each loop container and inside that container there are multiple Sequence containers and inside each sequence containers there are Execute SQL Tasks (which are just stored procedures).
    Now, when i run sequence containers individually they are running perfectly fine.
    But when I run the whole For each loop container, it is just running and running multiple times without ending the process.
    I really couldnt figure out what would be the issue?
    Any ideas????
    Thanks....

    Hi grk666,
    To check whether the values stored in the object type variable are correct, you can disable all the Sequence Containers within the Foreach Loop Container, and add a Script Task with the following code to display the string type variable value (supposing
    you use the string type variable StrVar to store the value retrieved from the object variable):
    MsgBox(Dts.Variables(“StrVar”).Value.ToString())
    It would be helpful if you could post a screenshot to show the package execution at runtime in BIDS.
    Regards,
    Mike Yin
    TechNet Community Support

  • Process request method executing multiple times issue

    Hi ALL,
    In my controller code , process request method is executing multiple times and inserting multiple data into the table, can any body help me how to resolve this issue.
    I have the below code in my process request:
    OAApplicationModule am = (OAApplicationModule) pageContext.getApplicationModule(webBean);
         am.invokeMethod("InsertRecord",null);
         OAMessageLovInputBean oalovinputbean=(OAMessageLovInputBean)webBean.findIndexedChildRecursive("ccustatus") ;
         oalovinputbean.setValue(pageContext,"INPROGRESS");
         String userName = pageContext.getUserName();
          System.out.println("User NAme is :" + userName);
          OAMessageTextInputBean pUserId = (OAMessageTextInputBean)webBean.findChildRecursive("item32");
          pUserId.setValue(pageContext,userName);
          OAMessageTextInputBean pchangedby =  (OAMessageTextInputBean)webBean.findChildRecursive("item34");
          pchangedby.setValue(pageContext,userName);
          if((("on").equals(pageContext.getParameter("rrchkbox"))))
                  String whereclause1=(String)pageContext.getTransactionValue("whereclause");
                  String workordnum=(String)pageContext.getTransactionValue("workordnum");
                  String rrnum =(String)pageContext.getTransactionValue("rrnum");
                  String ponum =(String)pageContext.getTransactionValue("ponum");
                  System.out.println("whereclause test1"+whereclause1);
                  String status=pageContext.getParameter("ccustatus");
                  System.out.println("DEBENDRA LINE STATUS:" + status);
                  Serializable param[] = {whereclause1,workordnum,rrnum,ponum};        
                           // am.invokeMethod("getSearchData1",param);
                           // am.invokeMethod("checkSelectedrow",param);       
                 Serializable vcnt =  am.invokeMethod("processPOData",param);  
    Below code written in AM:
    public void InsertRecord()
            XXDPECONTAINERVOImpl vo = getXXDPECONTAINERVO1();
            vo.setMaxFetchSize(0);
            XXDPECONTAINERVORowImpl row = (XXDPECONTAINERVORowImpl)vo.createRow();
            oracle.jbo.domain.Number empNum = (oracle.jbo.domain.Number)getOADBTransaction().getSequenceValue("XXDPE_CONTAIN_SEQ");
            row.setContainerizationId(empNum);
            vo.insertRow(row);
            row.setNewRowState(row.STATUS_INITIALIZED);
    Please help me out.

    hi,
    PR() will be called whenever your page will load, so the number of times you will load your page all the time your PR will be called and it will call the AM method.
    otherwise put some condition and call the insert method from your PR.
    Regards
    Mahesh

  • Query executing multiple times

    All,
    This question has been come up quite often in the OTN forum and i have not managed to get the answer. The issue is when i enable the logs i can see query getting fired multiple times :
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> ----[Exec query for VO=Kpi, RS=<Default>]----
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> ----[Exec COUNT query for VO=Kpi]----
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> VODef =com.xxx.model.uiView.KpiVO
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> SELECT
    kpi.kpi,
    kpi.kpi_desc,
    kpi.target,
    kpi_pkg.get_kpi_main (kpi.kpi, kpi.sale_type, :bSelectedSalesExecutiveId, :bSelectedBranchId ,:bOperatingUnitId, :bUserRole, :bPersonId, :bKpiRefresh) achieved,
    kpi.percentage,
    kpi.sale_type
    FROM    tableName kpi   
    WHERE  kpi.sale_type = NVL (:bSaleType, kpi.sale_type)
    ORDER BY tag
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> BindVars:(bUserRole=SE,bOperatingUnitId=81,bPersonId=31458,bSaleType=RETAIL,bSelectedBranchId=224,bSelectedSalesExecutiveId=31458,bKpiRefresh=Y)
    <TracingViewObjectSqlQueryExecution> <getQueryHitCount> ***** Query Hit Count = 6 *****
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> VODef =com.xxx.model.uiView.KpiVO
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> SELECT
    kpi.kpi,
    kpi.kpi_desc,
    kpi.target,
    kpi_pkg.get_kpi_main (kpi.kpi, kpi.sale_type, :bSelectedSalesExecutiveId, :bSelectedBranchId ,:bOperatingUnitId, :bUserRole, :bPersonId, :bKpiRefresh) achieved,
    kpi.percentage,
    kpi.sale_type
    FROM    tableName kpi   
    WHERE  kpi.sale_type = NVL (:bSaleType, kpi.sale_type)
    ORDER BY tag
    <TracingViewObjectSqlQueryExecution> <logQueryStatementAndBindParameters> BindVars:(bUserRole=SE,bOperatingUnitId=81,bPersonId=31458,bSaleType=RETAIL,bSelectedBranchId=224,bSelectedSalesExecutiveId=31458,bKpiRefresh=Y)This is one such case. These repetitive nature of the queries getting executed is making my application slow. On the logs i can see the first time query getting executed then waiting for it to finish then the same for the second time. Can any one give some inputs on this ?
    thnks
    Jdev 11.1.1.5

    thnks Frank for your reply.
    Ideally this query is supposed to run when the page is loaded however it has a complex calculation which takes 28 secs to complete. In order to load the page fast we dragged and dropped the collection as a table and added a button which executes the query. So the query gets executed on page load with a condition set as false so that no data is fetched - to speed the page load. However when we press the Refresh button the query gets re executed but as you can see 2 times. I can see the same effect on a nos of tables.

Maybe you are looking for