Loop through matrix before document saved (or get doc number after save)

Hi All,
I would like to loop through the matrix of a document (e.g. an invoice) before it is posted to the database (when the add button is clicked), but I would like to know at that point whether the invoice will definitely be posted.  When you look at ActionSuccess, the items in the matrix are already cleared.
Alternatively I would like to get the number of the invoice that was added so I can loop through the invoice lines records in SQL.
I have looked at quite a number of posts on tjis forum, but none of them has a definite answer to either of the options - or none I could find at least
Your help is appreciated and thanks in advance,
Adele

Hi Adele,
Here some thoughts form Frank and me:
As you mention, it makes basically no sense to process anything in such a document when a user can still cancel the saving (what about approvals???!!!!!).
To do the checks "after save" there are two options:
An easier one which is not 100% reliable from a "data perspective" - and one which is 100% reliable, but is a bit more "dangerous" because you will need to rely on an event to come BeforeAction = True AND BeforeAction = False (remember the "BubbleEvent" etc.)
Option 1.
(Not 100% (99.5%?) reliable is like suggested in some posts, but sometimes basic things are missed:
Use SQL in the ItemEvent handler:
If pVal.ItemUID = "1" And
pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And
pVal.ActionSuccess = True Then
"SELECT DocEntry FROM OINV WHERE UserSign = <internal number of user> AND UpdateDate = '<today>' AND DocTotal = <the value in UI> AND ...<maybe additional criteria as another person can reuse the user code - or a "DI API Add-On" may add a document in parallel>... ORDER BY DocEntry desc"
Theoretically it could happen that through a second connection / application instance a document could be posted at the same time. That's why this way is not 100% reliable...
Re time between "Add" and the SQL to retrieve the data being short (on what e.g. Florian relies on):
Please take in mind that you cannopt really count on the time being that short (milliseconds) when thinking about speed of the client PC, network traffic, users working at the same time with a company database, overall database response when working with a bigger database etc. etc.!!!
Option 2.
In the ItemEvent handler when BeforeAction = True start a global transaction that will block the table. After the ActionSuccess (BeforeAction = False) make a select to the table to get the desired data, and finally end the Transaction by commiting the data.
HTH,
Felipe & Frank

Similar Messages

  • I lost all of my document saved in my previous adobe after I upgrade the itunes, how can I get the lost file?

    I Lost of my document saved in my previous adobe after upgraded itunes, can I get the lost file again?

    Would you provide more information so that we can troubleshoot the problem?
    Are you saying that your PDF documents on your iPad/iPhones are lost because you updated Apple iTunes (not Adobe Reader)?  Do you see anything in the Documents or Recents section of the Adobe Reader home screen?

  • Is there any user exit in IW54 before document saving?

    Dear experts,
    Is there any user exit in IW54 before document saving? I want to check some data before saving.
    thanks
    Lance

    Or BADI NOTIF_EVENT_SAVE (Change When Saving Notification)
    PeteA

  • Get plan number after calling IP01 using BDC

    Hi,
    I am using IP01 by BDC to create maintenance plan.
    Is there any mthode to get  plan number after the call instead of  reading the message table  within call statment.?
    Thanks.

    One possible way is find an implicit enhancement point and fill up the plan number to memory id and in your bdc call program import the same from memory id

  • Loop through all open documents not performing some actions

    I have a loop that imports XML, then Exports each page individually, then has a SaveAs dialog for the indd, then closes the active document.
    The import XML works, the SaveAs works, and the close works but the loop skips over the PDF part. Is it because I need to define myCounter in the for loop within the ExportPDF function? I just included the part from Choose XML to the end of ExportPDF.
    //choose XML
    var FilterXML = "XML File: *.xml";
    var myXML = File.openDialog("Choose XML File", FilterXML);
    //loop for each action below
    for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
    //import XML
    app.activeDocument.importXML(myXML);
    //PDF by page to settings; preset must be "dailies_x1a"
    function myExportPages(myFolder){
    var myPageName, myFilePath, myFile;
    var myDocument = app.activeDocument;
    var myDocumentName = myDocument.name;
    var myBaseName = myBaseNameField.editContents;
    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){
    myPageName = myDocument.pages.item(myCounter).name;
    app.pdfExportPreferences.pageRange = myPageName;
    //The name of the exported files will be the base name + the page name + ".pdf".
    //If the page name contains a colon (as it will if the document contains sections), then remove the colon.
    var myRegExp = new RegExp(":","gi");
    myPageName = myPageName.replace(myRegExp, "_");
    myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
    myFile = new File(myFilePath);
    myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a");

    Nevermind, I found my error. Code should read...
    for(myDocumentCounter = app.documents.length; myDocumentCounter > 0; myDocumentCounter--){
    if(app.documents.length != 0){
    var myFolder = Folder.selectDialog ("Choose a Folder to Save the PDFs");
    if(myFolder != null){
    myExportPages(myFolder);
    else{
    alert("Please open a document and try again.");
    function myExportPages(myFolder){
    var myPageName, myFilePath, myFile;
    var myDocument = app.activeDocument;
    var myDocumentName = myDocument.name;
    var myDialog = app.dialogs.add();
    with(myDialog.dialogColumns.add().dialogRows.add()){
    staticTexts.add({staticLabel:"Please Modify the Base Name if Necissary:"});
    var myBaseNameField = textEditboxes.add({editContents:myDocumentName,
    minWidth:160});
    var myResult = myDialog.show({name:"ExportPages"});
    if(myResult == true){
    var myBaseName = myBaseNameField.editContents;
    //Remove the dialog box from memory.
    myDialog.destroy();
    for(var myCounter = 0; myCounter < myDocument.pages.length;
    myCounter++){
    myPageName = myDocument.pages.item(myCounter).name;
    app.pdfExportPreferences.pageRange = myPageName;
    //The name of the exported files will be the base name + the
    //page name + ".pdf".
    //If the page name contains a colon (as it will if the
    //document contains sections),
    //then remove the colon.
    var myRegExp = new RegExp(":","gi");
    myPageName = myPageName.replace(myRegExp, "_");
    myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".pdf";
    myFile = new File(myFilePath);
    myDocument.exportFile(ExportFormat.pdfType, myFile, false, "dailies_x1a");
    else{
    myDialog.destroy();

  • Unable to save a contact number to my Iphone 4S from a mail document, i dont get to see the save option.

    When i open a mail document and try to save a contact number to my Iphone 4S , i dont get to see the save option. This was possible in IOS 6.
    Any one facing the same problem?

    Sorry, but no one can help you except the previous owner.  They must either give you the ID and password, or erase it and remove it from their account as explained in the article you were reading.  There is no way around it.

  • Get Invoice Number after adding the invoice

    Hi,
       I am adding a service invoice to SBO using the DI api. I am able to create the Invoice successfully. Immedietly after I execute the Invoice.Add line, I would like to get the Docentry that was assigned to the invoice. What is the bst way to do this? Appreciate any help you can give me.\
    See code I am using:
    private void CreateSAPServiceInvoice()
                   SAPbobsCOM.Documents oServiceInvoice;//ChargeBack Invoice.
                   SAPbobsCOM.Documents oPaymentInvoice; //Orig: Invoice
                   SAPbobsCOM.Payments_CreditCards pCC;
                   oServiceInvoice = (SAPbobsCOM.Documents) frmMain.oCompany.GetBusinessObject(
                        SAPbobsCOM.BoObjectTypes.oInvoices);
                   oPaymentInvoice = (SAPbobsCOM.Documents) frmMain.oCompany.GetBusinessObject(
                        SAPbobsCOM.BoObjectTypes.oInvoices);
                   oServiceInvoice.DocType=SAPbobsCOM.BoDocumentTypes.dDocument_Service;
                   oServiceInvoice.CardCode = pmt.CardCode;
                   int x = pmt.Invoices.Count;
                   //Get CC Payment Info
                   pCC = pmt.CreditCards;
                   for (int i=0;i<pCC.Count;i++)
                        pCC.SetCurrentLine(i);
                        this.CBAccountInfo= modcb.cbaccts.Find(pCC.CreditCard);
                        if (this.CBAccountInfo != null)
                             //Service lines
                             oServiceInvoice.Lines.ItemDescription = this.pCBAcct.AccountName;
                             oServiceInvoice.Lines.AccountCode = pCC.CreditAcct;
                             oServiceInvoice.Lines.Price = pCC.CreditSum;
                             oServiceInvoice.Lines.TaxCode="0";
                             oServiceInvoice.Lines.Add();
                   //Add the invoice only if any lines have been added to the
                   //Service Invoice.
                   if (oServiceInvoice.Lines.Count > 0)
                        //Add the invoice
                        int j = oServiceInvoice.Add();
                        if  (j!=0)//If there is an error
                             int ix; string m;
                             frmMain.oCompany.GetLastError(out ix,out m);
                             throw new Exception(ix + ":" + m);          
                        else
                             j =oServiceInvoice.DocNum;

    I think this thread might have some useful information for you.
    After Save Document: How to get DocNum, LineNum

  • Getting IDoc Number after posting it frm Java Program

    Hi All:
    I had written a Java Program to post an IDoc into the SAP System. I was successful in posting an IDoc. My next step is, to get the Idoc number generated by SAP system for the posted IDoc. Using this IDoc number i want to track its status.
    Can anyone please let me know how to get the IDoc Number from SAP from a Java program? I have Transaction ID with me, can i get IDoc Number via Transaction ID?
    Please let me know ur views on this.
    Thanks & Best Regard,
    - - Rajiv

    Hi Rajiv,
       Could you Please help to clear one thing .I am very new to SAP JCO Programming.To remove the dependency of Posting Data to SAP through RFC program which is written by SAP People ,I want to use IDoc,is it possible to use it ? if yes could u please help with Some Java code so i can post Data through Java Code to SAP with IDoc.
    Wait for Your Kind Reply.
    Thanks & Warm regards,
    Kamal

  • Contract getting locked forever after save

    Hi Gurus ,
    This problem is happening only in our production system with some contracts only when we save a contract through VA42.
    contract is getting locked forever. when we see lock entries from SM12, it shows us entries for that contracts in blue. VBLOG table also have some entries for this lock entry. How could i identify that where the problem has occured. from blue entries we can say that it has been locked by some call to function module in update task. is there any way to find out which function module is causing the problem.
    thanks
    Rajpal Sehrawat

    Hi Max,
    thanks for the reply.
    the lock entries in SM12 are in blue which means main program has submitted some function modules in update task and those tasks have not finished. that is why i am able to see entries in VBLOG. why these entries are not getting deleted. and VBLOG table is not showing any error also.
    user comes out of the contract imidiately after save. even he kills his session also.

  • Word document is changing place on desktop after save

    Hi!
    I have more word documents ( .doc ) on my desktop. If i open it, and do some changes, and after saving and closing it, the file changes place on the desktop. If my file was placed on the the right side at
    the desktop, after editing it, it will be moved to the left side. It will always move to the left side. I also noticed that this problem only occurs if my word file is saved as .doc. If i save my file as .docx, then it's fine. I have Windows 7 Professional
    32 bit installed.
    Can someone tell me, how to fix this?
    Thanks,
    kampi

    Hi Luke,
    Yes, i have a wide screen monitor ( Dell 2009W ) with a resoulotion of 1680x1050. However this happens also on a laptop ( Dell Latitude E6510 ) with a resulotion of 1600x900, so i don't think that the resulotion would be the problem. UAC is turned off.
    I tried the clean boot method what you said. I have turned off everything, but the problem was still persist, so i think this could be some problem with word, because if i edit and save a .doc file, then a .tmp file will be created on the place of my original
    file, and in the meantime the original file will moved to another location. It is interesting that on Windows XP this problem doesn't occured, not even a tmp file will be created and the .doc file stays on it position.
    Unfortunetly the second method what you mentioned is not a solution, because then every time a user opens a .doc file, then he/she has to restore his/her icons.
    kampi

  • How to get Spool Number after submtting the program and return

    Hi All,
    Could you please assist me on this issue. I have ABAP program which will create a spool number and this spool number is generated by submitting the same report. Now when try to retrive the spool number from sy-spono it is displaying as 000000 but it suppose to be the spool which is created during submit program. COuld you please assist me on this issue. I have added the part of code for your reference,
    DATA: l_params TYPE pri_params,
    l_valid TYPE string,
    w_spool_nr like sy-spono,
    p_m_werks like marc-werks.
    export p_werks to memory id 'P_WERKS'.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
    IMPORTING
    out_parameters = l_params
    valid = l_valid
    IF sy-subrc <> 0.
    ENDIF.
    import p_werks from memory id 'P_WERKS'.
    p_m_werks = p_werks.
    SUBMIT zmmlist01 with p_werks eq p_m_werks
    to SAP-SPOOL
    spool parameters l_params
    without spool dynpro and return.
    write: sy-SPOno.
    Thanks & Regards,
    Nagaraj Kalbavi

    Hi,
    You can use the code snippet as below :
    SELECT MAX( RQIDENT ) INTO G_SPOOL_NUM
    FROM TSP01
    WHERE RQCLIENT = SY-MANDT AND
    RQOWNER = SY-UNAME.
    Also you can use the FM RSPO_FIND_SPOOL_REQUESTS' and pass the relevant parameters to this FM. This should get you the desired results.
    Hope this would be of some help!!
    Regards,
    Lalit Kabra

  • Problem in getting serial number after BDC of IQ04.

    Hi all,
    I am doing a BDC recording of IQ04 t-code and generating serial number internally passing material number,equipment category
    and no. of serial number to be generated.
    Serial number is getting generated and i am getting BDC message 'Serial numbers generated for material xyz'.
    But my problem is i want to capture that serial number generated.
    I tried get parameter id but it is not working.
    Can anyone help me.
    Thanks,
    Nidhi.

    Its not getting capture in message table of BDC.
    This is only the problem....Because while running std transaction IQ04 also we will get only one message  'Serial numbers generated for material xyz'. So not able to capture it.
    Please suggest.
    Regards,
    Nidhi.

  • Getting spool number after SUBMIT report statement

    Hello Everyone,
    Suppose there is a scenario, when 3 users are sharing same session and executing a program simultaneously.
    In the program, the users are submitting a program to sap spool such that a spool no is generated.
    and based on that spool no, the users read its log...
    How will we identify that which spool no belongs to which particular session so that the the user will read its own loag and not the other person/'s log...

    Hi,
    The program can be submitted as a job which has a unique job number and accordingly spool number will be generated which can read.
    See code e.g below:
    DATA: number TYPE tbtcjob-jobcount,
          name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
          print_parameters TYPE pri_params.
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname          = name
      IMPORTING
        jobcount         = number
      EXCEPTIONS
        cant_create_job  = 1
        invalid_job_data = 2
        jobname_missing  = 3
        OTHERS           = 4.
    IF sy-subrc = 0.
      SUBMIT submitable TO SAP-SPOOL
                        SPOOL PARAMETERS print_parameters
                        WITHOUT SPOOL DYNPRO
                        VIA JOB name NUMBER number
                        AND RETURN.
      IF sy-subrc = 0.
        CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
            jobcount             = number
            jobname              = name
            strtimmed            = 'X'
          EXCEPTIONS
            cant_start_immediate = 1
            invalid_startdate    = 2
            jobname_missing      = 3
            job_close_failed     = 4
            job_nosteps          = 5
            job_notex            = 6
            lock_failed          = 7
            OTHERS               = 8.
        IF sy-subrc <> 0.
        ENDIF.
      ENDIF.
    ENDIF.
    Hope it helps.
    Regards,
    Mansi.

  • PO went through Fax before Final Release

    Hi Guys
    The PO went to the Vendor through Fax before the final release is done. After the first Release the Out put got triggered and the message was sent. Any idea what caused it to do so ?
    Version 4.7
    Will reward every useful answer.
    Thanks
    Ronnie

    The PO Status is Blocked, it still has the final release pending, and also nobody changed the PO. As soon as the first release is done the PO is sent to the vendor through fax.
    Did anyone faced the similar issue in the past?
    Please share your thoughts
    Thanks

  • How to get the only the changed or newly added entries in AFTER SAVE.

    I have created table maintenance generated for a table,I want to get the newly added or changed entries while saving thats why im using AFTER SAVE event for the same,can anyone please tell me how to get the only the changed or newly added entries in AFTER SAVE.

    Hi,
    Welcome you post on the forum.
    I have moved your thread here because it is in English and should not in the language specific forum. What is your system version?
    Thanks,
    Gordon

Maybe you are looking for

  • Pop-up menu feature and IE issues

    I am using Firework MX 2004, Version 7.0 Build 288, to create drop down menus using the "Pop-up Menu" feature. The pop-up menus that I create work great in Netscape and Firefox, but fair in IE 6.0. The pop-up menus appear under certain elements such

  • Help please:  Large photos do not appear in album...

    I am having difficulty viewing the large photos in iphoto. All of the photos appear in the "thumbnail size", but when i want to view them "screen size", only the small size photos appear - when i try to view a larger photo, nothing but white screen..

  • Customer account blocked for posting.

    Hi, I am trying to use transaction F-28 (incoming payments). It is running fine for most of my customers, but there is one one customer for which I get an error saying "Account XYZ 1000 blocked for postings" (Message no. F5351). Can anyone please hel

  • Two Essentials, one Domain Controller, one Member Server....

    Hi is possible to install 2 Essentials Server : one as a Domain controller and one as a member server of the same domain? If it's not possible, the second Essentials could be at least in Workgroup environment? thank you

  • Using mobile camera to send images to the web server at regular intervals

    Hi All, I am developing an application in which the camera is kept on and it takes picture at regular intervals 30 sec to be exact. And that picture is sent to the web server so that can be viewed at the server. Now I am testing this application on N