Reading return values in ArrayBinding situation

Hi All.
I'm currently using ArrayBinding to batch insert/update records into a table. I currently have an InOut parameter set that will either set or return the ID of the row depending if it's an INSERT or UPDATE.
What I'm struggling to do is to actually read the values that come back after ExecuteNonQuery. here is some excerpts of the code:
OracleParameter requirementId = new OracleParameter("p_id", OracleDbType.Int32, ParameterDirection.InputOutput);
               requirementId.ArrayBindStatus = new OracleParameterStatus[reqDS.MyRequirements.Count];
<set up the other params>
<set up the values in a loop>
requirementCmd.CommandText          = "PCM_PKG_REQUIREMENT_DAC.USP_SAVE_REQUIREMENT";
                    requirementCmd.ArrayBindCount     = reqDS.MyRequirements.Count;
requirementCmd.ExecuteNonQuery();
Now what? I've tried all sorts of ways to get to this but to no avail. My code to get it currently looks like this:
for (int j = 0; requirementId.ArrayBindStatus.Length - 1;j++)
                         //value = CType(outParameter.Value, Object)(i);
                         requirementToReqVersion.Add(reqDS.MyRequirements.RequirementId,requirementId[j].Value);               
This doesnt even compile but you can see what I'm getting at. I just need to retrieve a value given an index in the array bind? Thanks for the help in advance..
jk     

In VB.NET, we do something like this:
Option Explicit On
Option Strict On
Dim values() As Object
ReDim values(versions.Length - 1)     ' expected nbr of returned values
ReDim identities(versions.Length - 1)
Dim outParameter As OracleParameter
outParameter = command.Parameters("NameOfOutParameter")
CDbLateBinding.GetObjectArrayFromOutParameter(outParameter, values)
Dim i As Integer
For i = 0 To values.Length - 1
identities(i) = CType(CType(values(i), OracleDecimal).ToString, Decimal)
Next
' Separate file
Option Strict Off
Public Class CDbLateBinding
Public Shared Sub GetObjectArrayFromOutParameter(ByVal parameter As OracleParameter, _
ByVal values() As Object)
Dim i As Integer
For i = 0 To parameter.ArrayBindStatus.Length - 1
values(i) = CType(parameter.Value, Object)(i) ' Option Strict Off
Next
End Sub
End Class
Looks a bit awkward but works fine.
Armin

Similar Messages

  • Subprocess 33 was not successful. Master cannot read return value from S 33

    Hi All,
    We are on BI 7.0 SP 19.
    We have submitted a planning sequence in the background with automatic packaging.
    The planning sequence has two steps:
    Step 1. Z_PLNG_FUNCTION1
    Step 2. Z_PLNG_FUNCTION2
    As per automatic packaging, the system chose 0ACCOUNT for packaging.
    When submitted, each step has been submitted to 30 packages as 30 subprocesses.
    For Step 1, the log shows that All subprocesses  executed.
    For Step 2, the log shows that the subprocess 33 and 58 failed, which means subprocess #3, and # 28 for the step 2 as the subprocess is numbered in the log in combination with step 1.
    The messages in the log for the failed subprocesses are as follows:
    @5C\QError@     Subprocess 33 was not successful
    @5C\QError@     Master cannot read return value from subprocess 33
    @5C\QError@     Subprocess 58 was not successful
    @5C\QError@     Master cannot read return value from subprocess 58
    Our question is on how to find the exact cause of the subprocess failure.
    I tried to look for the details on the error messages, they have been not helpful.
    What is meant by 'Master cannot read return value from subprocess' and how to get the exact cause of the failure?
    Thanks in advance,
    Best Regards,
    - Shashi

    Shashi,
    implement the following notes and check again:1368659, 1525723, 1532061.
    Regards,
    Marc
    SAP Techology RIG

  • RE: (forte-users) Reading return value from Javaprogram

    when using the RunCommand method you can specify the an error file:
    task.part.os.RunCommand(command = l_tdCommandLine,
    isSynchronous = TRUE,
    inputFile = Nil,
    outputFile = Nil,
    errorFile = l_ErrorFile.GetLocalName(TRUE));
    BEGIN
    l_ErrorFile.Open(SP_AM_READ);
    EXCEPTION
    WHEN Ex: FileResourceException DO
    l_ErrorFile = NIL;
    task.ErrorMgr.Clear();
    END;
    IF l_ErrorFile <> NIL THEN
    l_tdFileContents : TextData = New();
    l_ErrorFile.ReadText(l_tdFileContents);
    l_ErrorFile.Close();
    END IF;
    Have you java program output the return value to the standard IO. This way
    you will have an error file that you can read from Forte.
    ka
    -----Original Message-----
    From: Anthony D [mailto:saigonxyahoo.com]
    Sent: Tuesday, September 12, 2000 7:49 AM
    To: forte-userslists.xpedior.com
    Subject: (forte-users) Reading return value from Java program
    Hi,
    Does anyone know whether Forte application can
    read a return value from a Java program?
    I'm using the RunCmd method to invoke the Java
    program. I'd like to read the return value from the
    Java program. How do I go about doing it?
    Any suggestion will be appriciated.
    Thanks
    AD
    http://mail.yahoo.com/
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

    when using the RunCommand method you can specify the an error file:
    task.part.os.RunCommand(command = l_tdCommandLine,
    isSynchronous = TRUE,
    inputFile = Nil,
    outputFile = Nil,
    errorFile = l_ErrorFile.GetLocalName(TRUE));
    BEGIN
    l_ErrorFile.Open(SP_AM_READ);
    EXCEPTION
    WHEN Ex: FileResourceException DO
    l_ErrorFile = NIL;
    task.ErrorMgr.Clear();
    END;
    IF l_ErrorFile <> NIL THEN
    l_tdFileContents : TextData = New();
    l_ErrorFile.ReadText(l_tdFileContents);
    l_ErrorFile.Close();
    END IF;
    Have you java program output the return value to the standard IO. This way
    you will have an error file that you can read from Forte.
    ka
    -----Original Message-----
    From: Anthony D [mailto:saigonxyahoo.com]
    Sent: Tuesday, September 12, 2000 7:49 AM
    To: forte-userslists.xpedior.com
    Subject: (forte-users) Reading return value from Java program
    Hi,
    Does anyone know whether Forte application can
    read a return value from a Java program?
    I'm using the RunCmd method to invoke the Java
    program. I'd like to read the return value from the
    Java program. How do I go about doing it?
    Any suggestion will be appriciated.
    Thanks
    AD
    http://mail.yahoo.com/
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

  • Read return values in CC Extension Panel

    I am trying to read some information back to a javascript file in a CC extension panel. I am trying this which according to all the samples and documentation should work.
    >> js/host/main.js
    var getEnvironment = function(){
        var res = "1234";
        writeLn('returning '+res);
        return res;
    >> js/main.js
    function onLoaded() {
        var csi = new CSInterface();
        csi.evalScript("getEnvironment()", function(result) {
            console.log(result);
    When I load the extension, I can see the line "returning 1234" displayed  in the info panel. However the console.log(result) will not print out the value. What am I doing wrong? This is as simple as it gets and I just cant get it to work!
    Please help.

    This is a common stumbling block in trying to create extensions for AE CC. Contrary to the documentation and common sense, the method you're trying simply won't work. Instead, you have to use custom events and event handlers to pass data around. See my replies in the following thread, especially my last one: How to make an HTML5/CEP panel
    TL;DR of it is download this project from GitHub, run it, dissect it, and it will hopefully make more sense. It's intended for Photoshop but it will run just fine in After Effects (you might have to modify the manifest file). PS-Panels-Boilerplate/src/com.undavide.JSX2CEP at master · undavide/PS-Panels-Boilerplate · GitHub

  • Query Read returns # values

    Experts ,
    Please advise on below issue ...
    Comparing two systems (Dev and Quality)
    In execution for below read method (for BPC infocube) same parameters are passed (lt_range & ct_data_income), but in dev system <Lt_read_out> gets junk values (As ####)for all fields except ones selected in lt_range
    CALL METHOD me->read
    EXPORTING
    it_range       = lt_range
    it_data_income = ct_data_income
    IMPORTING
    ef_end_of_data = lf_end_of_data
    et_current     = <lt_read_out>
    CHANGING
    cf_first_call  = lf_first_call.
    Further drilling down, it calls the below DB_SQL function which is not possible to debug into it and again all parameters passed are the same in both systems but <outtab> gets junk (##) values
    CALL 'C_DB_FUNCTION' ID 'FUNCTION' FIELD 'DB_SQL'
                           ID 'FCODE'    FIELD c_fcode_next_package
                           ID 'CONNAME'  FIELD me->con_ref->con_name
                           ID 'CONDA'    FIELD me->con_ref->con_da
                           ID 'CURSOR'   FIELD me->cursor
                           ID 'BOUND'    FIELD me->outvals_bound
                           ID 'OUTVALS'  FIELD me->parameters->param_tab
                           ID 'OUTTAB'   FIELD <outtab>
                           ID 'LINE'     FIELD <line>
                           ID 'UPTO'     FIELD upto
                           ID 'ROWCNT'   FIELD rows_ret
                           ID 'SQLCODE'  FIELD sql_code
                           ID 'SQLMSG'   FIELD sql_msg.
    Checked on SQL traces in ST05, but no logs for execution of 'C_DB_FUNCTION'
    Thanks & Regards,
    Anup Singh

    Hi Gersh,
    When trying to insert values through Input schedule , It is creating a new value in BPC infocube instead of inserting only Delta values (so that it overwrites existing values).
    During debugging , I'm finding that - When it reads from info cube with "CALL METHOD me->read"
    It is reading ## values for all fields expect for BPC dimensions (Characteristics of Infocube)
    ie.. Dimension package of Infocube (0CHNGID , 0REQUID & RECORDDTP) has ## values
    All Navigational attrbutes has ### values
    Only BPC Dimension and Key figure has correct values
    As shown below : Data structure read from info Cube gets ## values and Data structure to be inserted has blank space , So it doesn't calculates delta value inserts as new value in info cube
    This ## values are getting populated from function "CALL 'C_DB_FUNCTION' ID 'FUNCTION' FIELD 'DB_SQL' for each of this fields , Is there a way to debug this execution step .... ?
    Thanks & Regards,
    Anup Singh

  • How to get return value from java and read by other application?

    i want to read return value from java and the other application read it.
    for example:
    public class test_return {
        test_return(){
        public int check(){
            return 1;
        public static void main(String args[]){
           new test_return().check();
    }from that class i make as jar file. How to read the return value (1) by other application?
    thx..

    If your installer is requiring some process it invokes to return a particular value on failure, then the installer is seriously broken. There are a bazillion commands your installer could invoke, and any of them could fail, which in turn could invalidate the entire install process, and any of them could return any value on failure. The only value that's consistent (in my experience) is that zero means success and non-zero means failure, with specific non-zero values being different in different programs.
    About the only control you have over the JVM's exit code is that if your main method completes without throwing an exception, the JVM will have an exit code of 0, and if main throws an exception (either explicitly or by not catching one thrown from below), it will be non-zero. I'm not even sure if that's guaranteed, but I would guess that's the case.
    EDIT: I'm kind of full of crap here. If you're writing the Java code, you can call System.exit(whatever). But nonetheless, if your installer requires certain exit codes from any app--java or otherwise--you have a problem.
    Edited by: jverd on Oct 29, 2009 1:27 AM

  • PL/SQL Function call error while reading or assigning returned value

    Hi,
    I am getting the following error while tryih to read the value of the PL/SQL Function. I am calling a function in one of my PL/SQL Packages passing mutliple IN parametes and the function returns some value back. Now on BPEL side when I try to read the return value I am getting an error:
    *<summary>*
    empty variable/expression result.
    xpath variable/expression expression "/ns3:OutputParameters/ns3:TEST_FUNCTION" is empty at line 124, when attempting reading/copying it.
    Please make sure the variable/expression result "/ns3:OutputParameters/ns3:TEST_FUNCTION" is not empty.
    *</summary>*
    Even though in the console when I check the Invoke Output Parameter it does shows me a valid value being retuned by a Function but when I am trying to Assgn this value to some variable using Assign Activity I get the above error.
    Even though all goes fine but looks like I am not able to read or assign the value returned from the Function.
    So just wondering if this even works as to me I have a very simple example and that seems not to work. Function is called successfully and is returning the value as I can see it in the BPEL console but when tryin to read or assign that value to some other variable I get the above error.
    Any ideas?
    Thanks

    This issue has come up a lot. The problem is with a mismatch between the version of JDeveloper and SOA. You'll encounter namespace issues if you use 10.1.3.1 in combination with 10.1.3.3 (or 10.1.3.4). You MUST synchronize both JDev and SOA to 10.1.3.3 or 10.1.3.4 (mixing 10.1.3.3 and 10.1.3.4 is OK). We changed when going to 10.1.3.3 by adding elementFormDefault="qualified" to the generated XSD. We used the default "unqualified" in 10.1.3.1. So you'll encounter namespace issues unless you're using 10.1.3.3 or higher JDev AND SOA. The fact that I see &lt;*db:*...&gt; tells me that you're using 10.1.3.1 JDeveloper. The correct solution is to upgrade your components.

  • Multiple return values (Bug-ID 4222792)

    I had exactly the same request for the same 3 reasons: strong type safety and code correctness verification at compile-time, code readability and ease of mantenance, performance.
    Here is what Sun replied to me:
    Autoboxing and varargs are provided as part of
    JSRs 14 and 201
    http://jcp.org/en/jsr/detail?id=14
    http://jcp.org/en/jsr/detail?id=201
    See also:
    http://forum.java.sun.com/forum.jsp?forum=316
    http://developer.java.sun.com/developer/earlyAccess/adding_generics/index.html
    Multiple return values is covered by Bug-ID 4222792
    Typically this is done by returning an array.
    http://developer.java.sun.com/developer/bugParade/bugs/4222792.html
    That's exactly the problem: we dynamically create instances of array objects that would better fit well within the operand stack without stressing the garbage collector with temporary Array object instances (and with their backing store: 2 separate allocations that need to be recycled when it is clearly a pollution that the operand stack would clean up more efficiently)
    If you would like to engage in a discussion with the Java Language developers, the Generics forum would be a better place:
    http://forum.java.sun.com/forum.jsp?forum=316
    I know that (my report was already refering to the JSR for language extension) Generics is not what I was refering to (even if a generic could handle multiple return values, it would still be an allocated Object
    instance to pack them, i.e. just less convenient than using a static class for type safety.
    The most common case of multiple return values involve values that have known static datatypes and that should be checked with strong typesafety.
    The simple case that involves returning two ints then will require at least two object instances and will not solve the garbage collection overhead.
    Using a array of variable objects is exactly similar, except that it requires two instances for the components and one instance for the generic array container. Using extra method parameters with Integer, Byte, ... boxing objects is more efficient, but for now the only practical solution (which causes the least pollution in the VM allocator and garbage collector) is to use a custom class to store the return values in a single instance.
    This is not natural, and needlessly complexifies many interfaces.
    So to avoid this pollution, some solutions are used such as packing two ints into a long and returning a long, depacking the long after return (not quite clean but still much faster at run-time for methods that need to be used with high frequencies within the application. In some case, the only way to cut down the overhead is to inline methods within the caller code, and this does not help code maintenance by splitting the implementation into small methods (something that C++ can do very easily, both because it supports native types parameters by reference, and because it also supports inline methods).
    Finally, suppose we don't want to use tricky code, difficult to maintain, then we'll have to use boxing Object types to allow passing arguments by reference. Shamely boxed native types cannot be allocated on the operand stack as local variables, so we need to instanciate these local variables before call, and we loose the capacity to track the cases where these local variables are not really initialized by an effective call to the method that will assign them. This does not help debugging, and is against the concept of a strongly typed language like Java should be:
    Java makes lots of efforts to track uninitialized variables, but has no way to determine if an already instanciated Object instance refered in a local variable has effectively received an effective assignment because only the instanciation is kept. A typical code will then need to be written like this:
    Integer a = null;
    Integer b = null;
    if (some condition) {
    //call.method(a, b, 0, 1, "dummy input arg");
    // the method is supposed to have assigned a value to a and b,
    // but can't if a and b have not been instanciated, so we perform:
    call.method(a = new Integer(), b = new Integer(), 0, 1, "dummy input
    arg");
    // we must suppose that the method has modified (not initialized!)
    the value
    // of a and b instances.
    now.use(a.value(), b.value())
    // are we sure here that a and b have received a value????
    // the code may be detected at run-time (a null exception)
    // or completely undetected (the method() above was called but it
    // forgot to assign a value to its referenced objects a and b, in which
    // case we are calling in fact: now.use(0, 0); with the default values
    // or a and b, assigned when they were instanciated)
    Very tricky... Hard to debug. It would be much simpler if we just used:
    int a;
    int b;
    if (some condition) {
    (a, b) = call.method(0, 1, "dummy input arg");
    now.use(a, b);
    The compiler would immediately detect the case where a and b are in fact not always initialized (possible use bere initialization), and the first invoked call.method() would not have to check if its arguments are not null, it would not compile if it forgets to return two values in some code path...
    There's no need to provide extra boxing objects in the source as well as at run-time, and there's no stress added to the VM allocator or garbage collector simply because return values are only allocated on the perand stack by the caller, directly instanciated within the callee which MUST (checked at compile-time) create such instances by using the return statement to instanciate them, and the caller now just needs to use directly the variables which were referenced before call (here a and b). Clean and mean. And it allows strong typechecking as well (so this is a real help for programmers.
    Note that the signature of the method() above is:
    class call {
    (int, int) method(int, int, String) { ... }
    id est:
    class "call", member name "method", member type "(IILjava.lang.string;)II"
    This last signature means that the method can only be called by returning the value into a pair of variables of type int, or using the return value as a pair of actual arguments for another method call such as:
    call.method(call.method("dummy input arg"), "other dummy input arg")
    This is strongly typed and convenient to write and debug and very efficient at run-time...

    Can anyone give me some real-world examples where
    multiple return values aren't better captured in a
    class that logically groups those values? I can of
    course give hundreds of examples for why it's better
    to capture method arguments as multiple values instead
    of as one "logical object", but whenever I've hankered
    for multiple return values, I end up rethinking my
    strategy and rewriting my code to be better Object
    Oriented.I'd personally say you're usually right. There's almost always a O-O way of avoiding the situation.
    Sometimes though, you really do just want to return "two ints" from a function. There's no logical object you can think of to put them in. So you end up polluting the namespace:
    public class MyUsefulClass {
    public TwoInts calculateSomething(int a, int b, int c) {
    public static class TwoInts {
        //now, do I use two public int fields here, making it
        //in essence a struct?
       //or do I make my two ints private & final, which
       //requires a constructor & two getters?
      //and while I'm at it, is it worth implementing
      //equals(), how about hashCode()? clone()?
      //readResolve() ?
    }The answer to most of the questions for something as simple as "TwoInts" is usually "no: its not worth implementing those methods", but I still have to think about them.
    More to the point, the TwoInts class looks so ugly polluting the top level namespace like that, MyUsefulClass.TwoInts is public, that I don't think I've ever actually created that class. I always find some way to avoid it, even if the workaround is just as ugly.
    For myself, I'd like to see some simple pass-by-value "Tuple" type. My fear is it'd be abused as a way for lazy programmers to avoid creating objects when they should have a logical type for readability & maintainability.
    Anyone who has maintained code where someone has passed in all their arguments as (mutable!) Maps, Collections and/or Arrays and "returned" values by mutating those structures knows what a nightmare it can be. Which I suppose is an argument that cuts both ways: on the one hand you can say: "why add Tuples which would be another easy thing to abuse", on the other: "why not add Tuples, given Arrays and the Collections framework already allow bad programmers to produce unmainable mush. One more feature isn't going to make a difference either way".
    Ho hum.

  • Authorization check on Function module return values

    Hi,
    I have a tricky situation. In our BW implementation, many of the FI infoobjects are authorization relevent. One of the objects is 0COSTCENTER.  A user has been assigned with authorization profile, in which the user is authorised for COST CENTER = A* and #.  All planning templates were working nice.
    We were on SP 12 earlier, now we upgraded to SP 20. Now came a issue, the user gets error that user is not authroised for the data. After our analysis, we found nothing wrong as such, so contacted SAP. They came back with a root cause
    In my planning function, an ABAP function module is used. The function module returns a COSTCENTER value. This return value is then assigned to a variable, this variable is of type 0COSTCENTER.
    SAP said there was a bug in their own design. The bug was, if the cost center value is directly used in planning function for other calculations, it will throw an authorization error.  But, if the COST CENTEr value is given to a variable and that variable is used for other calculations,  it works fine. Thats why it worked for us earlier.
    Now, they have removed that bug, so variables are also checked against authorizations and they said we need to either change the code or give * for the COST CENTER authorization.
    So we have a problem. It is not straight forward to give * for COSTCENTER in FI BW implementation. SAP theory is that they cannot say which value the functional module will return. So they will check against ALL the values for COSTCENTER but not the authorised values.
    Has anyone seen this issue before? is it only specific to planning function or its just ABAP concept? Any suggesations to come out this problem?

    Bindu, thanks,
    The error is coming at the program compile level itself i.e. before executing the planning group itself. As per the F1 help on forumla editor and from their support, the system reads all the reference data,  So when it sees the function module and its export parameter, it captures all the data for COST CENTER as reference data.
    Thus even I am sure that the return value will be always authorized, the reference data is checked for the full authorization. Thus its failing

  • Trying to write an if statement around the return value of a CANCEL_OPTION

    I am writing a program that takes an input String using JOptionPane. The String can be made of only letters of the A-Z alphabet and the space character. I have written an error-checking loop that will pop another input box up along with an error message if any invalid character is detected. The input box has an 'ok' button and a 'cancel' button. As it is, if you hit cancel, the program crashes and you get a NullPointerException. All I want to do is place an if statement inside of the error-checking loop, immediatly after the code to pop up the second input box, that simply does System.exit() and exits the program correctly(rather than crashing) if 'cancel' is clicked.
    My attempt at such an if statement is visible in the following code(letter is a boolean variable defined earlier, and message is the input String that has already been read in):
                   letter = isValidMessage(message);
              while(!letter)
                   message = JOptionPane.showInputDialog(null, "Message must contain only A-Z, a-z, or space character...");
                            if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)
                                JOptionPane.showMessageDialog(null, "No valid message entered - program will terminate...");
                                System.exit(JOptionPane.CANCEL_OPTION);
                   letter = isValidMessage(message);
                    }The if statement doesn't work correctly. If you click 'cancel' when the input box comes up, the program does terminate as it is supposed to. The problem is that if I type something in the box and click 'ok', it also causes the program to terminate rather than continuing. I've tried changing the > to ==. I've tried changing 0 to 1 to 2 to -1(I really am not sure which int return value of CANCEL_OPTION corresponds to which event). I think once I got to do the exact opposite...that is to say, it would continue on with the program whether I clicked 'cancel' or 'ok'. Which is equally bad. I don't know what I'm doing wrong.
    It's probably something simple that I'm just overlooking.

    Well, here's what CANCEL_OPTION is, according to the JOptionPane class:
    /** Return value from class method if CANCEL is chosen. */
        public static final int         CANCEL_OPTION = 2;However, I believe you're going about this in the wrong way.
    With JOptionPane, whenever you show a dialog, it usually returns whatever OPTION the user chose.
    For instance,
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");That will bring up a dialog centered on parentComponent, with a message of "hello".
    It will have the default options (YES_NO_OPTION).
    What it returns is the option the user chose.
    There are 4 possible things it can return:
    YES_OPTION, when user clicks "Yes"
    NO_OPTION, when user clicks "No"
    ERROR_OPTION, when an unforseen error occurs and the dialog closes
    CANCEL_OPTION, when the user clicks "Cancel" (if that OPTION type were being used), or if they close the dialog
    So this is how you would check for CANCEL_OPTION:
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");
        if (choice == JOptionPane.CANCEL_OPTION) {
            // User cancelled
        else if (choice == JOptionPane.YES_OPTION) {
            // User chose yes
        // EtcSo you see, going about it like this:
    if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)Is really the wrong way, because you're not checking what the user DID, but just what the constant variable "CANCEL_OPTION" is.
    However, it seems as if you're in a unique situation where you don't want the OPTION chosen by the user, but an input String.
    This is all well and good, but I think this limits how you can interact with the user, as the "showInputDialog" methods return the String the user input- not the OPTION they chose, and you need to use both.
    What I've done in the past is created a simple JPanel with its own JTextField.
    I pass the JPanel in as the "message" parameter of a showConfirmDialog call, and get both the user input and their chosen OPTION based off a getText call to the JTextField and the OPTION constant returned by showConfirmDialog.
    Basically,
    JPanel promptPanel = new JPanel(new BorderLayout());
    JTextField promptField = new JTextField();
    promptPanel.add(promptField, BorderLayout.CENTER);
    int choice = JOptionPane.showConfirmDialog(parentComponent, promptPanel, "Input", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (choice == JOptionPane.OK_OPTION) {
       // User chose OK, see if invalid characters were entered
       String input = promptField.getText();
    else if (choice == JOptionPane.CANCEL_OPTION) {
       // User cancelled
    }Hope that helps.
    (note that I'm unsure if showConfirmDialog can accept OK_CANCEL_OPTION as its OPTION parameter, as it says only YES_NO_OPTION and YES_NO_CANCEL_OPTION can be used, but I seem to remember using it in the past. if OK_CANCEL_OPTION doesn't want to work, then use one of the other two and adjust your if statements accordingly)
    Cheers!
    Edited by: LukeFoss on Oct 9, 2007 10:39 PM

  • Client/server RMI app using Command pattern: return values and exceptions

    I'm developing a client/server java app via RMI. Actually I'm using the cajo framework overtop RMI (any cajo devs/users here?). Anyways, there is a lot of functionality the server needs to expose, all of which is split and encapsulated in manager-type classes that the server has access to. I get the feeling though that bad things will happen to me in my sleep if I just expose instances of the managers, and I really don't like the idea of writing 24682763845 methods that the server needs to individually expose, so instead I'm using the Command pattern (writing 24682763845 individual MyCommand classes is only slightly better). I haven't used the command pattern since school, so maybe I'm missing something, but I'm finding it to be messy. Here's the setup: I've got a public abstract Command which holds information about which user is attempting to execute the command, and when, and lots of public MyCommands extending Command, each with a mandatory execute() method which does the actual dirty work of talking to the model-functionality managers. The server has a command invoker executeCommand(Command cmd) which checks the authenticity of the user prior to executing the command.
    What I'm interested in is return values and exceptions. I'm not sure if these things really fit in with a true command pattern in general, but it sure would be nice to have return values and exceptions, even if only for the sake of error detection.
    First, return values. I'd like each Command to return a result, even if it's just boolean true if nothing went wrong, so in my Command class I have a private Object result with a protected setter, public getter. The idea is, in the execute() method, after doing what needs to be done, setResult(someResult) is called. The invoker on the server, after running acommand.execute() eventually returns acommand.getResult(), which of course is casted by the client into whatever it should be. I don't see a way to do this using generics though, because I don't see a way to have the invoker's return value as anything other than Object. Suggestions? All this means is, if the client were sending a GetUserCommand cmd I'd have to cast like User user = (User)server.executeCommand(cmd), or sending an AssignWidgetToGroup cmd I'd have to cast like Boolean result = (Boolean)server.executeCommand(cmd). I guess that's not too bad, but can this be done better?
    Second, exceptions. I can have the Command's execute() method throw Exception, and the server's invoker method can in turn throw that Exception. Problem is, with a try/catch on the client side, using RMI (or is this just a product of cajo?) ensures that any exception thrown by a remote method will come back as a java.lang.reflect.InvocationTargetException. So for example, if in MyCommand.execute() I throw new MySpecialException, the server's command invoker method will in turn throw the same exception, however the try/catch on the client side will catch InvocationTargetException e. If I do e.getCause().printStackTrace(), THERE be my precious MySpecialException. But how do I catch it? Can it be caught? Nested try/catch won't work, because I can't re-throw the cause of the original exception. For now, instead of throwing exceptions the server is simply returning null if things don't go as planned, meaning on the client side I would do something like if ((result = server.executeCommand(cmd)) == null) { /* deal with it */ } else { /* process result, continue normally */ }.
    So using the command pattern, although doing neat things for me like centralizing access to the server via one command-invoking method which avoids exposing a billion others, and making it easy to log who's running what and when, causes me null-checks, casting, and no obvious way of error-catching. I'd be grateful if anyone can share their thoughts/experiences on what I'm trying to do. I'll post some of my code tomorrow to give things more tangible perspective.

    First of all, thanks for taking the time to read, I know it's long.
    Secondly, pardon me, but I don't see how you've understood that I wasn't going to or didn't want to use exceptions, considering half my post is regarding how I can use exceptions in my situation. My love for exception handling transcends time and space, I assure you, that's why I made this thread.
    Also, you've essentially told me "use exceptions", "use exceptions", and "you can't really use exceptions". Having a nested try/catch anytime I want to catch the real exception does indeed sound terribly weak. Just so I'm on the same page though, how can I catch an exception, and throw the cause?
    try {
    catch (Exception e) {
         Throwable t = e.getCause();
         // now what?
    }Actually, nested try/catches everywhere is not happening, which means I'm probably going to ditch cajo unless there's some way to really throw the proper exception. I must say however that cajo has done everything I've needed up until now.
    Anyways, what I'd like to know is...what's really The Right Way (tm) of putting together this kind of client/server app? I've been thinking that perhaps RMI is not the way to go, and I'm wondering if I should be looking into more of a cross-language RPC solution. I definitely do want to neatly decouple the client from server, and the command pattern did seem to do that, but maybe it's not the best solution.
    Thanks again for your response, ejp, and as always any comments and/or suggestions would be greatly appreciated.

  • UML notation: Class operation return value multiplicity

    Hallo,
    how would you write function from example below using UML notation on implementation level, please:
    class Coin {
      public String[] getSideNames() {
        return new String{ "Odd", "Even" };
    }Multiplicity in return value is troubling me. I've tried +getSideNames( ) : String [ 2 ] but my tool just created new class named "String[2]" :-( To be precise I know that return value of function is array of MyClass with one or more element (1..*) so created class name was "MyClass[1..*]" -- nasty name to pass to javac isn't it? :-)
    Is is possible to write multiplicity of return value this way? I couldn't find anything in omg's "UML: supertructure document" :-( I am not telling that it's not written there :-)))
    Thank You.

    jschell>
    Unfortunately [n] behaves in same fashion as [*] =>
    creating class named MyClass[1..n]" :-(
    duffymo> what's the point?
    this was only sample, real application is far more
    complex than that. Even "nature" of result was just
    made up. How am I or anyone else who responds supposed to know that?
    >
    duffymo> you can have cardinality in a class diagram
    that shows exactly two values are available.
    yup, i ended like that but there's still problem coz
    return value class is "Object[]" :-(Sounds like a bad design, but I haven't seen the code, so I can't tell.
    duffymo> personally, i don't think that exposing the
    side names as ...
    "side names" were just example :-) IMHO there are
    certain situations where one could say "screw the
    abstraction" :-D E.g. for final classes from one
    package that cooperate on single time critical task.
    :)"screw the abstraction" - good luck as an object-oriented designer with that attitude.
    Either you're doing real-time work where time really is critical, or you're just another yutz who is congratulating himself on recognizing a time critical task without doing profiling or getting any real data. (A common mistake.) The maintainence and development time might be more critical here.
    Gotta admit that I'm not much interested in commenting on your poor approximation of the real problem.
    %

  • When i add menu bar in my user interface gives me error that this handle is not a panel handle(return value -42)

    i have 3 panels in my application and parent panel is displayed first then i display other two panels which come to the front then on entering correct password i discard the child panel and then you can see parent panel , but there is an issue when i add menu to my parent panel i dont know whats wrong when i add menu bar in my user interface (parent panel)  gives me error that this handle is not a panel handle(return value -42) for a child panel. when i dont open and display child panel then its fine , and even without menu added to my parent panel all my panels and my application works perfactly

    Hello smartprogrammer,
    some more informations are needed in order to properlu help you in this situation:
    - Are you adding menus dynamically at runtime or in the UIR editor? If dynamically: how are you loading the menu bar?
    - Are you dynamically tailoring the menu bar at runtime (adding or deleting menu items, dimming / undimming some of them or checking / unchecking)?
    - Can you post the code where you are getting the error, documenting variables and scope (local to the function, global to the source file, global to the project)?
    You can look at uirview.prj example that ships with CVI for an example of LoadMenuBar (the exampl eis in <CVI samples>\userint folder): in that project, the menu bar is shown as a context menu when you right-click on a tree element (see DeferredMenuCB callback).

  • The returned value of BAPI call

    Hi, experts,
    I have a question about returned value of BAPI call.
    when the returned value is mapped as an attribute and this return value itsself is of the type: table of a certain structure. Is there any possibility that the value of this table still can be extracted from the mapped attribute? If it is possible, how?
    If not, how should this kind of situation be handled:
    when the returned value of the function at the backend has more one layer structure?
    Thanks and best regards,
    Fan

    In my experience you shouldn't use the service wizard to generate the context of such deeply nested structures. They don't generate or map correctly because it tries to put the table type as the type of the context attribute.
    Instead you should propery model the relationship in the context using nested nodes. Here is an example of address <-> address text where you can have multiple address texts per address.  From the service this was a returned nested table.
    ****BP Address and Address Text
      data lo_nd_bp_addr type ref to if_wd_context_node.
      data lo_nd_bp_addr_text type ref to if_wd_context_node.
      data lo_el_bp_addr type ref to if_wd_context_element.
    * navigate from <CONTEXT> to <BP_ADDR> via lead selection
      lo_nd_bp_addr = wd_context->get_child_node( name = wd_this->wdctx_bp_addr ).
      lo_nd_bp_addr->bind_table( wd_this->gt_bp_addr ).
    ****Add the Address Text Table as Child of each Address Context Record
      data element_set type wdr_context_element_set.
      field-symbols <wa_set> like line of element_set.
      field-symbols <wa_bp_addr> like line of wd_this->gt_bp_addr.
      element_set = lo_nd_bp_addr->get_elements( ).
      loop at element_set assigning <wa_set>.
        read table wd_this->gt_bp_addr index sy-tabix assigning <wa_bp_addr>.
        lo_nd_bp_addr_text = <wa_set>->get_child_node( name = if_componentcontroller=>wdctx_bp_addr_text ).
        lo_nd_bp_addr_text->bind_table( <wa_bp_addr>-t_text ).
      endloop.

  • Unable to capture return values in web services api

    At the time of login to web services if my server is down ,
    it returns following error :
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
            at java.lang.String.substring(String.java:1438)
            at java.lang.String.substring(String.java:1411)
    I want to capture this error so that i can try another server to login. how do i capture this error
    Another place where i want to capture the return Value is when i look for a report on the server
    rh = boBIPlatform.get("path://InfoObjects/Root Folder/"src_folder"/" + reportName +
                               "@SI_SCHEDULEINFO,SI_PROCESSINFO" ,oGetOptions);
    oInfoObjects = rh.getInfoObjects();
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    Here if the report is not there on the server , it returns a null handler exception.
    but if i try catching it by checking my responsehandler is null  like rh == null  it does not catch it.
    Any help will be appreciated
    thanks
    Rakesh Gupta

    Ted : i have two cases
    1)   server = server_st.nextToken();
        providerURL = "http://"server"/dswsbobje/services";
        sessConnURL = new URL(providerURL + "/session");
       Connection boConnection = new Connection(sessConnURL);
       Session boSession = new Session(boConnection);
      EnterpriseCredential boEnterpriseCredential = new    EnterpriseCredential();
                  boEnterpriseCredential.setLogin(userid);
      boEnterpriseCredential.setPassword(pwd);
      boEnterpriseCredential.setAuthType(auth);
    SessionInfo boSI = boSession.login(boEnterpriseCredential);
    I have got a list of servers running web servcies stored in my tokens. when i pass the first server name say " test:8080" and that server is down , i want to catch somewhere in the code above that it did not get the connection so that i can loop back and try with the second server say test1:8080
    This is for failover purposes.
    at present when i was trying to capture return value of boSI it  breaks giving the error
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1438)
    at java.lang.String.substring(String.java:1411)
    2nd case :
    I am geeting reports from the server and scheduling them:
    i run the following code which works fine if reports is there
    rh = boBIPlatform.get("path://InfoObjects/Root Folder/"src_folder"/" + reportName +
    "@SI_SCHEDULEINFO,SI_PROCESSINFO" ,oGetOptions);
    oInfoObjects = rh.getInfoObjects();
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    Here if  the  report  is not there on the server  then i should be able to catch from the response handle rh that it has got a null value.
    but rh does not return a null value 
    the code ultimately throws a null handle at the following line
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    i am not able to catch the null value there also.
    hope you got my issue.

Maybe you are looking for