How to retrieve workbook's "Last Refreshed" value using VBA?

Does anyone know how to retrieve a BEx workbook's "Last Refreshed" value using VBA?
What I've done is expand upon a colleague's existing Excel VBA solution to automatically log into SAP BEx and batch process (and also schedule) the running of multiple BEx reports. As each BEx report in the queue is processed, the results of the run are written to a "Results" worksheet -- indicating whether that BEx report was processed successfully or not. I'm pretty much done, and everything works like a charm.
Except I have one little problem remaining: during the processing of each BEx report, the SAP BEx status dialog appears, giving the user the ability to cancel the processing of that particular report, if they so desire. If the user cancels, I want my "Results" worksheet to indicate that for that report.
At first, I thought, okay, I'll just test the return value when calling the SAPBEX.XLA's SAPBEXrefresh function. That function's return value is supposed to return the number of errors that occurred after each time SAPBEXrefresh is fired -- normally it's 0 if everything runs okay. So surely, if the user cancels, there's got to be some sort of error and the return value of SAPBEXrefresh would be > 0, right? Nope, no such luck!
Which brings me back to my question in this post -- I found out through my company's SAP consultant that, if the user hits cancel in the SAP BEx dialog, the "Last Refreshed" value will not change. Therefore, he told me, simply test the value of the "Last Refreshed" value before and after each BEx reports' run. If the "Last Refreshed" value doesn't change, then presto, you know the user canceled.
This is where I'm stuck. How do you programmatically get the "Last Refreshed" value? Obviously, you could write VBA code to find the first cell in the BEx report with the text "Last Refreshed" and then get the value in the adjoining cell. The problem with that is, what if, for some stupid reason, there's another cell somewhere in the BEx report with the text, "Last Refreshed". There's no way I can be sure that I've really found the "Last Refreshed" value plugged in by BEx.
I've been looking extensively in this forum for an answer, but haven't found any. It seems like there are a lot of SAP BEx experts here, and if anyone can help me out here, I would greatly appreciate it.
Thank you.

Well, it was a little circuitous, but I figured out the solution to my own question.
I recalled I had read about the sapbexDebugPrint macro in sapbex.xla in one of Peter Knoer's posts in this forum. So I thought, maybe I can use that to get the before and after refresh values of "Last Refreshed" in the workbook. Well, I was half-right: I could only use sapbexDebugPrint to get the workbook's after-refresh values of "Last Refreshed".
But it didn't matter!
As long as the after-refresh value of the workbook's "Last Refreshed" value was later than the after-refresh value of the previous workbook in the processing queue, I knew the refresh was successful and the user didn't cancel. There were some other logic permutations I had to factor in, but basically that was the answer.
Here are snippets of my code from the main procedure, for anyone's who interested:
            '   **** Refresh query ************************************
            ' Get the previous "Last Refreshed" value
            ' We're going to need to compare this to the "Last Refreshed" value
            ' after running SAPBEXrefresh function to trap the possibility of
            ' the user canceling via the SAPBEx status dialog box
            PrevLastRefr = GetLastRefreshed()
            ' Reactivate the source workbook, just in case
            SourceWorkbook.Activate
             RefreshRetVal% = Application.Run("SAPBEX.XLA!SAPBEXrefresh", True, , False)
            If RefreshRetVal% <> 0 Then
                blnProcessingErr = True
            End If
            ' Get the current "Last Refreshed" value and compare it to the previous value
            CurrLastRefr = GetLastRefreshed()
            If CurrLastRefr = "NOT FOUND" Then
                ' Refresh canceled
                blnProcessingCanceled = True
            Else    ' We found a valid current "Last Refreshed" value
                If PrevLastRefr = "NOT FOUND" Then
                    ' Refresh okay
                    blnProcessingCanceled = False
                Else
                    If CDate(CurrLastRefr) > CDate(PrevLastRefr) Then
                        ' Current "Last Refreshed" value is later than previous value,
                        ' so refresh okay
                        blnProcessingCanceled = False
                    Else
                        ' Refresh canceled
                        blnProcessingCanceled = True
                    End If
                End If
            End If
            ' Reactivate the source workbook, just in case
            SourceWorkbook.Activate
And here's my function which retrieves the "Last Refreshed" value by calling sapbexDebugPrint macro in sapbex.xla:
Function GetLastRefreshed() As Variant
' Get the SAP BEx "Last Refreshed" value by calling
' SAPBEx.xla's sapbexDebugPrint procedure and creating
' the special diagnostic workbook.
On Error GoTo GetLastRefreshed_Error
    Dim TextCell As Range
    Dim TextCellAddr$
    Dim TextCellRow%, TextCellCol%
    Dim LastRefreshedVal As Variant
    Dim NumWorkbooks%
    ' Initialize
    GetLastRefreshed = "NOT FOUND"
    LastRefreshedVal = "NOT FOUND"
    ' Turn off screen updating until the end
    Application.ScreenUpdating = False
    ' Get the number of currently open workbooks
    NumWorkbooks% = Workbooks.Count
    ' Call the SAPBEx.xla's sapbexDebugPrint procedure
    ' This'll create a diagnostic workbook with all the information
    ' about the BEx query that was previously refreshed
    Application.Run "SAPBEX.XLA!sapbexDebugPrint"
    ' Let's double-check that the diagnostic workbook actually
    ' got created
    ' If there's any error at this point or if the number of workbooks
    ' isn't more than it was a moment ago, raise custom error
    If (Err.Number <> 0) Or (Not (Workbooks.Count > NumWorkbooks%)) Then
        Err.Raise vbObjectError + 513, , "sapbexDebugPrint failed to create the diagnostic workbook"
    End If
    ' We'll need to look at a worksheet named "E_T_TXT_SYMBOLS"
    ' in the diagnostic workbook
    ' If this worksheet doesn't exist, then we know that there
    ' was no previously refreshed query during this session
    ' (We could loop through the collection of worksheets in the workbook
    ' to see if that worksheet actually exists, but we'll use
    ' error handling to deal with this instead)
    ' Find the first cell in the "E_T_TXT_SYMBOLS" worksheet
    ' with the text "Last Refreshed"
    ' (If the worksheet doesn't exist, an error will be thrown...)
    Set TextCell = Sheets("E_T_TXT_SYMBOLS").Cells.Find(What:="Last Refreshed", _
                LookIn:=xlValues)
    If TextCell Is Nothing Then
        ' Can't find the cell, so we know the user had canceled during previous refresh
        LastRefreshedVal = "NOT FOUND"
    Else
        ' Found the cell, now we're in business
        TextCellAddr$ = TextCell.Address ' $F$11
        TextCellRow% = CInt(Mid(TextCellAddr$, InStr(2, TextCellAddr$, "$") + 1))
        TextCellCol% = ColRef2ColNo(Mid(TextCellAddr$, 2, InStr(2, TextCellAddr$, "$") - 2))
        ' The cell with the "Last Refreshed" value is going to be 2 columns to the right
        LastRefreshedVal = Sheets("E_T_TXT_SYMBOLS").Cells(TextCellRow%, TextCellCol%).Offset(0, 2).Value
        ' Ensure the "Last Refreshed" value is a valid date/time
        If Not IsDate(LastRefreshedVal) Then LastRefreshedVal = "NOT FOUND"
    End If
GetLastRefreshed_Exit:
    ' Err.Number -2147220991 is my custom raised error:
    ' "sapbexDebugPrint failed to create the diagnostic workbook"
    If Err.Number <> -2147220991 Then
        ' Close the diagnostic workbook and return Last Refreshed value
        Workbooks(ActiveWorkbook.Name).Close SaveChanges:=False
        GetLastRefreshed = LastRefreshedVal
    End If
    Application.ScreenUpdating = True   ' Turn on screen updating
    Exit Function
GetLastRefreshed_Error:
    Select Case Err.Number
        Case 9  ' Subscript out of range (which means "E_T_TXT_SYMBOLS" worksheet doesn't exist)
            LastRefreshedVal = "NOT FOUND"
        Case Else
            MsgBox "Error encountered during getting Last Refreshed value." & vbCrLf & vbCrLf & _
           "Error: " & Err.Number & " - " & Err.Description, vbExclamation, gstrErrBoxTitle
    End Select
    Resume GetLastRefreshed_Exit
End Function
Like I said, the solution was a little circuitous, but it works!

Similar Messages

  • How to retrieve start and end date values from sharepoint 2013

    Hi,
    How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
    Thanks
    Gowri Balaguru

    Hi Srini
    Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
    Thanks
    Tripple k

  • How long should the battery last in between uses?

    I am just wondering how long the battery should last in between uses? I find mine really goes down FAST..I just purchased this on Sunday and charged it the right amount of time as such. The first time I used it after the initial charge I was downloading 2 music albums and just left it on and by morning the battery was drained..shouldn't it have lasted at least a few days? Its an iPod touch 16g V2.
    Then lastnight I had it charged and was browing youtube and in a couple hours the battery was about 1/2 way..is this normal?
    Thanks for your help!

    The Touch's Wireless Internet access really chews up the battery time. When you're not using the wireless, go to Settings and turn Wireless off. When you're ready to go browsing, you can always turn it back on. If you already have a wireless access set up in your abode, the Touch will quickly "re-find" it and you'll be browsing again. If you're in a public free wireless area, you'll have to log on, etc.
    If I leave wireless on all the time, my iPod Touch battery life is like halved-- sometimes more. The same holds true when viewing movies or video.
    Hope this helps!
    Abide.

  • How to retrieve public/ private from iKey token using Sun PKCS#11 provider

    Dear all,
    I'm trying to access one rainbow iKey 2032 token in Java 1.5 (Windows Environment) using Sun PKCS#11 provider. Token is stored with certificate. There is no problem to logging into the token using java.
         Provider p = new sun.security.pkcs11.SunPKCS11(configName);
         Security.addProvider(p);
         KeyStore ks = null;
         try{
              char[] pin = {'P','A','S','S','W','O','R','D'};
              ks = KeyStore.getInstance("pkcs11");
              ks.load(null,pin);
    catch(Exception e) {}
    Now I am wondering how to retrieve a public and private from token, so that I can encrypt and decrypt a plain text file. Could anyone give me a sample program for this?
    Your help is very much appreciated!!

    Hi Fred13
    1. I have the same pkcs.cfg and get the following trace. Can you help me understand? Does this imply a bad dkck201.dll? I would really like to get this working for my implementation. tia.
    lException in thread "main" java.security.ProviderException: Initialization failed
         at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:175)
         at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:76)
         at com.mkp.jce.chap1.ProviderDetail.main(ProviderDetail.java:38)
    Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_TOKEN_NOT_RECOGNIZED
         at sun.security.pkcs11.wrapper.PKCS11.C_GetTokenInfo(Native Method)
         at sun.security.pkcs11.Token.<init>(Token.java:105)
         at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:555)
         at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:169)
    2. (If I can be so indulgent of your time) Can you provide more information on cbp? I have done a search and there is little on it. It appears to be a new authentication framework tied in with sasl unique to 1.5. Any links for self education would be appreciated.

  • How to retrieve system Information on client machine Using Applets

    How to retrieve video card information on client machine using applets and JNI, please suggest me on this
    Thanks
    GReddy

    1. Research platform specific OS API to do whatever you want with video cards
    2. Write C/C++ code to wrap the functionality in 1 into something looks closer to what you want to see in java
    3. Write a class that models the functionality of 2 with native methods.
    4. Write the native methods of 3 such that they call the methods of 2.
    Note that steps 1 and 2 have NOTHING to do with jni nor java. So you start by looking somewhere else for the answers to that.

  • How can i measure SNR(S/N)value using FSP Spectrum analyser

    hi ,
     I want to measure S/N value using spectrum analyser.i already installed rsspecan instrument driver.I also configured span,center frequency ,RBW,VBW etc but i am not able to get measured S/N value.I have attached my vi here with.how could i measure SNR Ratio??can you please help me!
    thanks.
    Tadhika
    Attachments:
    Unbenannt 1.vi ‏77 KB

    Hi, first of all I'd recommend to contact the R&S customer support center to be shure the measure the correct value. Did you really measure the actual noise, or do you measure the noise which is "only" displayed?
    But anyway, did you have had a look at this example: http://www2.rohde-schwarz.com/file/rsspecan_lv8_noise_marker_example.zip
    There is the setup of one noise marker shown. With your already existing marker value this should do the trick, also in case of two noise markers; just use the rsspecan Configure Marker Noise Measurement.vi again with input parameter <YourMarker+1> of the "Marker" input of the VI.
    Hope that helps?
    juergen

  • How to extract the content of a section using VBA?

    For example, I have an article like this:
    Abstract
    AbstractParagraph1
    AbstractParagraph2
    Body
    BodyParagraph1
    BodyParagraph2
    Reference
    ReferenceParagraph1
    ReferenceParagraph2
    Knowing that Abstract, Body and Reference are all headings, which means if I click the triangle button on the left of the heading (For example, Abstract), AbstractParagraph1 AbstractParagraph2 will shrink or expand. So my question is: how to retrieve the paragraph
    in a specific section using VBA?

    Hi UW,
    >> how to retrieve the paragraph in a specific section using VBA?
    In my option, you could use the Section Object (Word) to get the section object, and then use the Section.Range Property (Word) to get the content of the special section. The links below might be useful to you.
    # Section Object (Word)
    https://msdn.microsoft.com/en-us/library/office/ff194295.aspx
    # Section.Range Property (Word)
    https://msdn.microsoft.com/en-us/library/office/ff836097.aspx
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Hashtable- how to retrieve key for a particular value?

    I fetched few values from the database and stored all them using hashtable. Then i check for the value entered by the user in a textbox using contains() method of hashtable. Now i want to fetch the key associated to this particular value so that i can pass it to my rest of the program?
    Pls help me....

    The obvious question is what are you using as your key when you store the value into your hashtable?? The idea behind the key/value system is that you use the key to get the value you want, not the other way around. In your current situation, the contains() method might return true, but that could you mean you have 1, or 1000 instances of that value in your hashtable. Which key do you want? You could, I suppose, parse through the output of Hashtable.toString()... but that still wouldn't resolve the possibility of duplicate values in the hash.
    Another possible solution to your problem, depending on how your application works, is to wait until you get that user input before running your database query. Simply append the added info onto your SQL SELECT statement to accurate retrieve only those entries from the database that you will need.

  • How to get the same period last year value using Fiscal Calendar?

    Hi there,
    I am using DAX in a Tabular Model project but I am getting stuck trying to get the following:
    We are using a Fiscal Calendar (from 01 April to 31 March). 
    Previous Period Value
           Value
    2012
    April
    15
    May
    10
    Jun
    20
    2013
    April
    15
    30
    May
    10
    20
    Jun
    20
    25
    I have tried to use sameperiodlastyear but there is an error saying that this function cannot be used for non contiguous dates. DATEADD is given the same error...
    Could anyone help me getting the right measure expressions for [Previous Period Value]?
    Thanks and best regards,
    Joss

    Hi Joss,
    In SQL Server Analysis Services, we can can compare revenue with the hierarchy periods (year, month, day) by using the PARALLELPERIOD function, and now you want to compare with custom periods. (NOTE: We cannot compare it with the PARALLELPERIOD function
    since
    PARALLELPERIOD function returns a member from a prior period in the same relative position as a specified member. So if the first time span not equal to the second one (such as the first period is 3 days, and the second period is 2 month)).  Here
    is a sample query about PARALLELPERIOD function for your reference.
    with
    set Hotels as
    [Hotels].[Hotel ID].&[1015],
    [Hotels].[Hotel ID].&[5640],
    [Hotels].[Hotel ID].&[8800]
    set Period as [Arrival Date].[Date].[Month].&[2012]&[1]:[Arrival Date].[Date].[Month].&[2012]&[12]
    member [Arrival Date].[Date].[0] as sum({ Period })
    member [Total Amount N-1] as (PARALLELPERIOD([Arrival Date].[Date].[Year], 1, [Arrival Date].[Date].[Year].&[2012]), [Measures].[Total Amount])
    select
    [Measures].[Total Amount],
    [Measures].[Total Amount N-1]
    } on 0,
    nonemptycrossjoin
    Hotels,
    Hotels.[Hotel].children,
    *{[Arrival Date].[Date].[0]}
    } on 1
    from [Booking_Cube]
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to retrieve IndividualStrings from a txt file using String Tokenizer.

    hello can any one help me to retrieve the individual strings from a txt file using string tokenizer or some thing like that.
    the data in my txt file looks like this way.
    Data1;
    abc; cder; efu; frg;
    abc1; cder2; efu3; frg4;
    Data2
    sdfabc; sdfcder; hvhefu; fgfrg;
    uhfhabc; gffjcder; yugefu; hhfufrg;
    Data3
    val1; val2; val3; val4; val5; val6;
    val1; val2; val3; val4; val5; val6;
    val1; val2; val3; val4; val5; val6;
    val1; val2; val3; val4; val5; val6;
    i need to read the data as an individual strings and i need to pass those values to diffarent labels,the dat in Data3 i have to read those values and add to an table datamodel as 6 columns and rows depends on the data.
    i try to retrieve data using buffered reader and inputstream reader,but only the way i am retrieving data as an big string of entire line ,i tried with stringtokenizer but some how i was failed to retrive the data in a way i want,any help would be appreciated.
    Regards,

    Hmmm... looks like the file format isn't even very consistent... why the semicolon after Data1 but not after Data2 or Data3??
    Your algorithm is reading character-by-character, and most of the time it's easier to let a StringTokenizer or StreamTokenizer do the work of lexical analysis and let you focus on the parsing.
    I am also going to assume your format is very rigid. E.g. section Data1 will ALWAYS come before section Data2, which will come before section Data3, etc... and you might even make the assumption there can never be a Data4, 5, 6, etc... (this is why its nice to have some exact specification, like a grammar, so you know exactly what is and is not allowed.) I will also assume that the section names will always be the same, namely "DataX" where X is a decimal digit.
    I tend to like to use StreamTokenizer for this sort of thing, but the additional power and flexibility it gives comes at the price of a steeper learning curve (and it's a little buggy too). So I will ignore this class and focus on StringTokenizer.
    I would suggest something like this general framework:
    //make a BufferedReader up here...
    do
      String line = myBufferedReader.readLine();
      if (line!=null && line.trim().length()>0)
        line = line.trim();
        //do some processing on the line
    while (line!=null);So what processing to do inside the if statement?
    Well, you can recognize the DataX lines easily enough - just do something like a line.startsWith("Data") and check that the last char is a digit... you can even ignore the digit if you know the sections come in a certain order (simplifying assumptions can simplify the code).
    Once you figure out which section you're in, you can parse the succeeding lines appropriately. You might instantiate a StringTokenizer, i.e. StringTokenizer strtok = new StringTokenizer(line, ";, "); and then read out the tokens into some Collection, based on the section #. E.g.
    strtok = new StringTokenizer(line, ";, ");
    if (sectionNo==0)
      //read the tokens into the Labels1 collection
    else if (sectionNo==1)
      //read the tokens into the Labels2 collection
    else //sectionNo must be 2
      //create a new line in your table model and populate it with the token values...
    }I don't think the delimiters are necessary if you are using end-of-line's as delimiters (which is implicit in the fact that you are reading the text out line-by-line). So the original file format you listed looks fine (except you might want to get rid of that rogue semicolon).
    Good luck.

  • How to retrieve data from a REF CURSOR using OCI 8.0?

    I found an example in Oracle docs (shown below) that discusses how to bind a REF CURSOR for later data retrieval, but it does not explain actually how to do the later data retrieval.
    I hope someone can explain it to me. Thanks
    The OCI provides the ability to bind and define PL/SQL REF CURSORs and nested tables. An application can use a statement handle to bind and define these types of variables. As an example, consider this PL/SQL block:
    static const text plsql_block = (text )
    "begin \
    OPEN :cursor1 FOR SELECT empno, ename, job, mgr, sal, deptno \
    FROM emp_rc WHERE job=:job ORDER BY empno; \
    OPEN :cursor2 FOR SELECT * FROM dept_rc ORDER BY deptno; \
    end;";
    An application would allocate a statement handle for binding, by calling OCIHandleAlloc(), and then bind the :cursor1 placeholder to the statement handle, as in the following code, where :cursor1 is bound to stm2p. Note that the handle allocation code is not included here.
    err = OCIStmtPrepare (stm1p, errhp, (text *) nst_tab, strlen(nst_tab),
    OCI_NTV_SYNTAX, OCI_DEFAULT);
    err = OCIBindByName (stm1p, (OCIBind **) bndp, errhp,
    (text *)":cursor1", (sb4)strlen((char *)":cursor1"),
    (dvoid *)&stm2p, (sb4) 0, SQLT_RSET, (dvoid *)0,
    (ub2 *)0, (ub2 *)0, (ub4)0, (ub4 *)0, (ub4)OCI_DEFAULT);
    In this code, stm1p is the statement handle for the PL/SQL block, while stm2p is the statement handle which is bound as a REF CURSOR for later data retrieval. A value of SQLT_RSET is passed for the dty parameter.

    ( sorry, i forgot the Link where i get this html fiLes, so i just copy-paste here )
    ( maybe it can heLp you a bit. -- it's heLp me, for sure )
    And the following is thanks to Brett Rosen :
    I noticed that you didn't have an OCI entry
    on http://osi.oracle.com/~tkyte/ResultSets/index.html .
    Here is OCI code to do this (Oracle 81) if you want to include it on
    that page.
    Some error checking and cleanup has been removed, but the below should
    work. (once dbname has been replaced appropriately)
    Brett
    int main(int argc, char* argv[])
    OCIError* pOciError;
    char* pConnectChar = "dbname";
    char* pUsernameChar = "scott";
    char* pPasswordChar = "tiger";
    int answer;
    OCIStmt* pOciStatement;
    char* sqlCharArray = "BEGIN :success := sp_ListEmp; END;";
    int id;
    char ename[40];
    OCIEnv* g_pOciEnvironment = NULL;
    OCIServer* g_pOciServer = NULL;
    OCISession* g_pOciSession = NULL;
    OCISvcCtx* g_pOciServiceContext = NULL;
    sb2* pIndicator=0;
    sb2* pIndicator2=0;
    sb2* pIndicator3=0;
    OCIDefine* pOciDefine;
    OCIDefine* pOciDefine2;
    OCIBind* pBind;
    OCIStmt* cursor;
    answer = OCIInitialize(OCI_THREADED, NULL, NULL, NULL, NULL);
    answer = OCIEnvInit(&g_pOciEnvironment, OCI_DEFAULT, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciSession, OCI_HTYPE_SESSION, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServer, OCI_HTYPE_SERVER, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
    answer = OCIServerAttach(g_pOciServer, pOciError, (unsigned char *)pConnectChar, strlen(pConnectChar),
    OCI_DEFAULT);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pUsernameChar, strlen(pUsernameChar),
    OCI_ATTR_USERNAME, pOciError);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pPasswordChar, strlen(pPasswordChar),
    OCI_ATTR_PASSWORD, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciServer, 0, OCI_ATTR_SERVER, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciSession, 0, OCI_ATTR_SESSION, pOciError);
    answer = OCISessionBegin(g_pOciServiceContext, pOciError, g_pOciSession, OCI_CRED_RDBMS, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&pOciStatement), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray, strlen(sqlCharArray),
    OCI_NTV_SYNTAX, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&cursor), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIBindByPos(pOciStatement,&pBind, pOciError, 1, &cursor, 0,SQLT_RSET,
    pIndicator2, 0,NULL, 0,0,OCI_DEFAULT);
    answer = OCIStmtExecute(g_pOciServiceContext, pOciStatement, pOciError, 1, 0, NULL, NULL,
    OCI_COMMIT_ON_SUCCESS);
    answer = OCIDefineByPos(cursor,&pOciDefine, pOciError,2,&id,sizeof(int),
    SQLT_INT,pIndicator, 0, 0,OCI_DEFAULT);
    answer = OCIDefineByPos(cursor,&pOciDefine2, pOciError,1,ename,40,
    SQLT_STR,pIndicator3, 0, 0,OCI_DEFAULT);
    if (answer == 0)
    while ((answer = OCIStmtFetch(cursor,pOciError, 1,OCI_FETCH_NEXT,OCI_DEFAULT)) == 0)
    printf("fetched id %d and name %s\n",id,ename);
    answer = OCIHandleFree(pOciError, OCI_HTYPE_ERROR);
    return 0;
    }

  • How to identify a change on parameters value using match code

    Hi everybody,
    I would like to know if it's possible to identify automatically a change on a parameters using match code.
    For example : In my wiew i set XXX in  my parameters, so i execute XXX treatment. Now if i change this value to YYY, i would like to treat the YYY treatment without press enter key.
    My requirement is the following : According to the values filled in this parameters, i need to display different views in my WD application. So when this value changes, it's neccesary to modify the displayed views.
    Does anybody can help me on this problem ?
    Thanks in advance.

    Hi,
    i think ,when you start a application with application parameters your first requirement is realized. However , the second requirement need more clarity.
    When you start a application with parameter XXX, the application is displaying a view-X. How and who will change the value of XXX. Without triggering a roundtrip to server you cannot check the value if it is changed and on top of it, you can not bring new view assembly  So keep this in mind and design your application..

  • How to select a row for update values, Using CTEs or suitable method

    HI All,
    I have a table as claim_data as below.
    claim_id   
    amount         change_monthkey
             created_monthkey
             ord
    54511      
    300            201304         
             201304          
              1
    54511      
    0              201305         
             201304          
              2
    120301     
    250            201502         
             201502          
              1
    120624     
    150            201502         
             201502          
              1
    120624     
    0              201503    
                  201502          
              2
    I want to isolate rows which appear in the table and do a update using below query ( This query is already in a procedure, so I just looking for a suitable way to modify it to support my task )
    In the above e.g.  ONLY row containing claim_id = 120301 needs to update (amount  as updated_amount)
    I use following query, but it update other rows as well, I want a suitable query only to capture rows of nature claim_id = 120301 and do this update? Is there any functions that I could use to facilitate my task??
    select
         a.claim_id
        , a.Created_MonthKey
        , a.Change_MonthKey
        , a.amount - ISNULL(b.amount,0.00) as amount_movement
        ,a.amount  as updated_amount   --- >> I need help here??
        FROM claim_data a
    LEFT JOIN claim_data b
        ON a.claim_id = b.claim_id
        AND b.Ord = a.Ord - 1
    Thanks
    Mira

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your datC1. You should follow ISO-11179 rules for naming data elements. You do not know this IT standard.
    You should follow ISO-8601 rules for displaying temporal datC1. We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. 
    And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I have a table AS claim_data AS below. << 
    Thanks to your lack of netiquette, we have no name, no DDL, no keys and have to re-type the raw data into SQL, guess at everything! Does your boss treat you with the same contempt? 
    Think about how silly “_data” is AS an attribute property! What tables do you have without an data in them? You had to give this meta-data in 1970's operating systems, FORTRAN compilers, etc. but we do not do this today. I see you use “A”, “B”, etc for table
    aliases This is the name of the disk or tape drive in a 1970 computer! In SQL we use helpful, meaningful table aliases so code is easier to maintain. I see you also use the old punch card trick of putting a comma at the front of each line of code. 
    The column named “ord” is a mathematical fiction for ordinal sets. I think you meant to use it as a non-relational sequential number to let you keep writing 1970's COBOL is T-SQL. We have not used the old Sybase ISNULL() since we got COALESCE() in SQL-92. They
    are actually different. 
    First, let's post what you should have posted if you followed forum rules: 
    CREATE TABLE Claims
    (claim_id CHAR(5) NOT NULL,
     claim_amount DECIMAL (8,2) NOT NULL
     CHECK (claim_amount >= 0.00),
     change_month_name CHAR(10) NOT NULL
     REFERENCES Month_Period(month_name),
     creation_month_name CHAR(10) NOT NULL
     REFERENCES Month_Period(month_name),
     ord INTEGER NOT NULL, -- NO!! Awful design! 
     PRIMARY KEY (claim_id, ord)); --required by definition
    Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
    The report period table gives a name to a range of dates that is common to the entire enterprise. 
    CREATE TABLE Month_Periods
    (month_name CHAR(10) NOT NULL PRIMARY KEY
     CHECK (month_name LIKE '[12][0-9][0-9][0-9]-[01][0-9]-00'),
     month_start_date DATE NOT NULL,
     month_end_date DATE NOT NULL,
     CONSTRAINT date_ordering
     CHECK (month_start_date <= month_end_date),
    etc);
    These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
    data format required by Standard SQL and it is language independent. It has been proposed for the Standard, but is not yet part of it. The regular expression pattern for validation is simple. 
    INSERT INTO Claims  -- a mess! 
    VALUES
    ('054511', 300.00, '2013-04-00', '2013-04-00', 1)
    ('054511', 0.00, '2013-05-00', '2013-04-00', 2),
    ('120301', 250.00, '2015-02-00', '2015-02-00', 1),
    ('120624', 150.00, '2015-02-00', '2015-02-00', 1),
    ('120624', 0.00, '2015-03-00', '2015-02-00', 2);
    Now, throw this mess out. It looks like your repeat the claim creation date over and over and over. It looks like you crammed a claim creation and a claim history together in one table. 
    >> I want to isolate rows which appear in the table and do a update using below query (This query is already in a procedure, so I just looking for a suitable way to modify it to support my task). 
    In the above e.g. ONLY row containing claim_id = '120301' needs to update (amount AS updated_amount)
    >> I use following query, but it update other rows as well, I want a suitable query only to capture rows of nature claim_id = '120301' and do this update? <<
    No. SQL is set oriented so an update applies to the whole table. You can filter out rows in a WHERE clause. 
    CREATE TABLE Claims
    (claim_id CHAR(5) NOT NULL PRIMARY KEY,
     claim_amount DECIMAL (8,2) NOT NULL
     CHECK (claim_amount >= 0.00),
    claim_creation_month_name CHAR(10) NOT NULL
     REFERENCES Month_Period(month_name));
    See how this works? 
    INSERT INTO Claims  -- a mess! 
    VALUES
    ('054511', 300.00, '2013-04-00'),
    ('120301', 250.00, '2015-02-00'),
    ('120624', 150.00, '2015-02-00');
    Normalize the table: 
    CREATE TABLE Claim_Changes
    (claim_id CHAR(5) NOT NULL 
      REFERENCES Claims(claim_id)
      ON DELETE CASCADE,
     change_month_name CHAR(10) NOT NULL
      REFERENCES Month_Period(month_name),
     PRIMARY KEY (claim_id, change_month_name),
     change_amount DECIMAL (8,2) NOT NULL
     CHECK (change_amount >= 0.00)
    INSERT INTO Claims_Changes
    VALUES
    ('054511', 0.00, '2013-05-00'),
    ('120624', 0.00, '2015-03-00');
    Now you just add another change row to the history. There is no update. If you want to the delta and so forth, use LAG() and other window functions. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to replace namespace tag with new value using -JAVA MAPPING

    Hi Guys,
    I need to replace namespace Tag in Target xml with a new value.
    For Eg: My namespace Tag is - <ns0:TestHeader xmlns:ns0="http://0020.TestHeader.SS.com">
    I want My target xml to have value- <ns0:TestHeader>
    How can i achieve it using JAVA mapping?
    Can you provide me the code to do so.

    Sarjana,
    Not well-formed XML is only possible by Java Mapping. Please use below replace logic in Java map.
    inputContent.replaceAll("<ns0:TestHeader xmlns:ns0=\"http://0020.TestHeader.SS.com\">", "<ns0:TestHeader>");
    Link1, Link2.

  • How to Retrieve a List of Business Objects using DI Server?

    In DI Server (and DI-API) I could not find how I can get a list of business objects, for instance ServiceCall objects.
    and more - say i need the list with a filter on customer code and call status?

    ...at least not to the extent that you are looking for.
    Please check the E-learning:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d78ab1f9-0901-0010-8495-8ca0facaea2e?prtmode=navigate
    at: https://www.sdn.sap.com/irj/sdn/businessone-elearning
    ...or go the sample code for the DataBrowser (sub-)object in the "SDK Help Center"...
    ...or go to the DI API sample (no. 2 I think I remember).
    ...to find out how you can navigate between the records of the result of your SQL query; from there you could e.g. export the objects to XML...
    HTH

Maybe you are looking for

  • IMovie '09 crashes endlessly

    Have a very short fim-almost finished-but program crashes everytime it is opened. I tried restating=no help. I clean the system-no help. The movie, just over one minute w/sound, consist of several hundred drawings that were photographed w/ Vixia and

  • Solaris 10 on 2nd hard drive?

    Im new to solaris and would like to install it on a second hard drive. Right now I have xp dual booted with win 7rc on 1 hard drive. And just bought a 2nd blank one. What I would like to do is put solaris 10 on my second drive. Is it possible to boot

  • What criteria are used by the site maintenence task: Clear Install Flag?

    I want to understand what exact criteria, i.e. what fields in the database, are used by the "Clear Install Flag" Maintenance task. Is it just LastDDR that needs to be either NULL or older than the configured "rediscovery period"? Or are other fields

  • Value category and description for maintenance costs

    Does anyone know how I can get the value category and description and tie it to our cost data coming from tables COSP & COSS?    I tried going to PMCO but there can be several entries say for labor, services and you have no way of knowing which entry

  • BO6: complex filter with data aggregates

    Hi, In BO 6.1 I have a report like this "name", "year", "value" Then I have made a variable : "A" = if count(<Year>) = 5 then 1 else 0 Now I want to display only the record that that have the variable "A" = 1 I tried to do a filter on "A" variable bu