Please help how to get return array from rpg program on java code?

Hi
I have created a rpg program that returns 2 parameter 1 is the id and another one is list of array, when I called this program I passed two programparameter from my java code (see the code below) but when i checked what value would be return it is returned only first value of array. how will i get all array values ?
please suggest me regarding this issues I amn't so much aware on java & AS400.
try
ProgramParameter[] parmList = new ProgramParameter[2];
AS400Text p1 = new AS400Text(10);
AS400Text p2 = new AS400Text(30);
try
parmList[0] = new ProgramParameter(10);
parmList[1] = new ProgramParameter(30);
parmList[0].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
parmList[1].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
parmList[0].setInputData(p1.toBytes("Pune"));
parmList[1].setInputData(p2.toBytes(" "));
catch(Exception ex)
ProgramCall pgm = new ProgramCall(o);
pgm.setProgram("/QSYS.LIB/XXX/XXX.PGM",parmList);
if (pgm.run())
byte s[] = parmList[1].getOutputData(); // HERE I got only first value of returning array.
parmList[1].getOutputDataLength();
//String sts = ((String) (new AS400Text(10,o).toBytes(s[0])));
else
AS400Message[] messageList = pgm.getMessageList();
for (int msg = 0; msg < messageList.length; msg++) {
catch(Exception ex)
AS400Message[] messageList = null;
finally
o.disconnectAllServices();
Reply With Quote

Try this :
try
ProgramParameter[] parmList = new ProgramParameter[2];
AS400Text p1 = new AS400Text(10);
AS400Text p2 = new AS400Text(30);
AS400Array arrP2 = new AS400Array(p2, 4);
try
parmList[0] = new ProgramParameter(10);
parmList[1] = new ProgramParameter(30);
parmList[0].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
parmList[1].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
parmList[0].setInputData(p1.toBytes("Pune"));
parmList[1].setInputData(arrP2.toBytes({"","","",""}));
catch(Exception ex)
ProgramCall pgm = new ProgramCall(o);
pgm.setProgram("/QSYS.LIB/XXX/XXX.PGM",parmList);
if (pgm.run())
     Object[] objArr =  (Object [])arrP2.toObject( parmList[1].getOutputData() );
     for(int i =0; i<objArr.length;i++){
            System.out.println( " SKU " + i +" : " + objArr.toString());
else
AS400Message[] messageList = pgm.getMessageList();
for (int msg = 0; msg < messageList.length; msg++) {
catch(Exception ex)
AS400Message[] messageList = null;
finally
o.disconnectAllServices();

Similar Messages

  • How can i return object from oracle in my java code using pl/sql procedure?

    How can i return object from oracle in my java code using pl/sql procedure?
    And How can i returned varios rows fron a pl/sql store procedure
    please send me a example....
    Thank you
    null

    yes, i do
    But i can't run this examples...
    my problem is that i want recive a object from a PL/SQL
    //procedure callObject(miObj out MyObject)
    in my java code
    public static EmployeeObj callObject(Connection lv_con,
    String pv_idEmp)
    EmployeeObj ret = new EmployeeObj();
    try
    CallableStatement cstmt =
    lv_con.prepareCall("{call admin.callObject(?)}");
    cstmt.registerOutParameter(1, OracleTypes.STRUCT); // line ocurr wrong
    //registerOutParameter(int parameterIndex, int sqlType,String sql_name)
    cstmt.execute();
    ret = (EmployeeObj) cstmt.getObject(1);
    }//try
    catch (SQLException ex)
    System.out.println("error SQL");
    System.out.println ("\n*** SQLException caught ***\n");
    while (ex != null)
    System.out.println ("SQLState: " + ex.getSQLState ());
    System.out.println ("Message: " + ex.getMessage ());
    System.out.println ("Vendor: " + ex.getErrorCode ());
    ex = ex.getNextException ();
    System.out.println ("");
    catch (java.lang.Exception ex)
    System.out.println("error Lenguaje");
    return ret;
    Do you have any idea?

  • Please help me to get a clue from this program

    I'm sorry to bother you with such stupid questions. I have to admit I'm just making my first steps in programming.
    So I have a program like this and don't understand how it works:
    // Masking sign extension.
    class HexByte {
    static public void main(String args[]) {
    char hex[] = {
    '0', '1', '2', '3', '4', '5', '6', '7',
    '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
    byte b = (byte) 0xf1;
    System.out.println("b = 0x" + hex[(b >> 4) & 0x0f] + hex[b & 0x0f]);
    Specifically, how could 0xf1 be represented in binary? As far as I know 11110001 contains negative value. Moreover 0xf1 in 10's base is 241, so how can I convert it to byte? Doin so, I'm gonna lose its value (since the byte range is from -128 to 127). And why do I need it? I even have no idea how the variable would look like in binary after converting to byte, not mentioning last part of this program.
    I would really appreaciate your help.
    Thank you for your time.

    AntShay wrote:
    Thank you so much for your help guys. Now I got just 2 more questions. First of all. I guess sign-extension works only with negative values. Is that correct? When sign-extension takes place and I shift any value to the right by any number of positions, does it fill in all the previous bits with *1s*? If you can, please, tell me how exactly this works.Java primitives are all signed, so sign extension is always at work for right bit shifts. However, if you were to look into the code, it has masked away the 4 most significant bits using bit-wise and operation. Alternatively, you may use the unsigned shift (+>>>+) operator.
    And by the way, is there any method to convert the value of byte to a binary string? I only figured that it might work this way: Integer.toBinaryString(b&0xff), but is there Byte.toBinaryString method or something?It is always okay to up cast, as sign extension will convert correctly. If you don't like the long integer output, you may do a substring() on the output. It is also not hard to roll your own.

  • Please help : How to print a matrix from the console...

    Hi..
    Please help:
    How to print a matrix on the console , but i want to take all the input from the console.. like...
    if the matrix is of size...
    mxn
    where
    m : row
    n : column
    and the all the elements of the matrix from the console it self... .
    Please help...

    Thanks...
    I am able to print the elements of the array but i am not able to assign those values to the array ....
    How to do that...
    I just did a little change in my code...
    import java.util.Scanner;
    public class CreatingAMatrix {
        public static void main(String[] args) {
         // TODO Auto-generated method stub
         System.out.print("Enter the number of rows: ");
         Scanner scanner1 = new Scanner(System.in);
         int m = scanner1.nextInt();
         System.out.print("Enter the number of coulmns:");
         Scanner scanner2 = new Scanner(System.in);
         int n = scanner2.nextInt();
         System.out.println("The size of the matrix is : " +m+" x "+n );
         int[][] a = new int[100][100];
         for(int i=0;i<=m;i++)
             for(int j =0; j <= n; j++)
              Scanner scanner3 = new Scanner(System.in);
              int o = scanner3.nextInt();
             System.out.println();
         for(int i=0;i<=m;i++)
             for(int j =0; j <= n; j++)
              System.out.print(a[i][j] + "\t");
             System.out.println();
    }I am getting an output as this
    output:
    Enter the number of rows: 2
    Enter the number of coulmns:1
    The size of the matrix is : 2 x 1
    1
    2
    1
    2
    3
    5
    0     0     
    0     0     
    0     0     
    how should i assig those input values to my array..
    Please help

  • Please help - how do I import music from my ipod into a new itunes library?

    Hello
    I would very much appreciate it if someone could tell me how to get the music from my old ipod mini into the new itunes library on my new laptop.
    The mini was previously sync'd with my old PC which died so my files are only present on the ipod. Upon loading itunes, the software is only letting my sync the ipod providing I wipe it (obviously not desirable...)
    Thanks for any support, Andy

    Connect your iPod to your computer. When you get the message that it is linked to a different library and asking if you want to link to this one and replace all your songs etc, press "Cancel". Pressing "Erase and Sync" as you already know will irretrievably remove all the songs from your iPod. Your iPod should appear in the iTunes source list from where you can change the update setting to manual and use your iPod without the risk of accidentally erasing it. Also when using most of the utilities listed below your iPod needs to be enabled for disc use, changing to manual update will do this by default. Check the "manually manage music and videos" box in Summary then press the Apply button: Managing content manually on iPod
    Once you are safely connected there are a few things you can do to restore your iTunes from the iPod. If you have any iTunes Music Store purchases the transfer of purchased content from the iPod to authorised computers was introduced with iTunes 7. You'll find details in this article: Copying iTunes Store purchases from your iPod to a computer
    The transfer of content from other sources such as songs imported from CD is designed by default to be one way from iTunes to iPod. However there are a number of third party utilities that you can use to retrieve the music files and playlists from your iPod. You'll find that they have varying degrees of functionality and some will transfer movies, videos, photos, podcasts and games as well. Have a look at the web pages and documentation, this is just a small selection of what's available, they are generally quite straightforward. You can read reviews of some of them here: Wired News - Rescue Your Stranded Tunes
    TuneJack Windows Only
    iPod2PC Windows Only
    iGadget Windows Only
    iDump Windows Only
    SharePod Windows Only
    iRepo Mac and Windows
    iPodRip Mac & Windows
    YamiPod Mac and Windows
    Music Rescue Mac & Windows
    iPodCopy Mac and Windows
    There is also a manual method of accessing the iPod's hard drive and copying songs back to iTunes on Windows or a Mac. The procedure is a bit involved and won't recover playlists but if you're interested it's available at this link: Two-way Street: Moving Music Off the iPod
    Whichever of these retrieval methods you choose, keep your iPod in manual mode until you have reloaded your iTunes and you are happy with your playlists etc then it will be safe to return it auto-sync. I would also advise that you get yourself an external hard drive and back your stuff up, relying on an iPod as your sole backup is not a good idea and external drives are comparatively inexpensive these days, you can get loads of storage for a reasonable outlay.

  • How to get return value from Java runtime.getRuntime.exec?

    I'm running shell commands from an Oracle db (11gr2) on aix.
    But, I would like to get a return value from a shell comand... like you get with "echo $?"
    I use a code like
    CREATE OR REPLACE JAVA SOURCE NAMED common."Host" AS
    import java.io.*;
    public class Host {
      public static int executeCommand(String command) {
        int retval=0;
        try {
            String[] finalCommand;
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
          final Process pr = Runtime.getRuntime().exec(finalCommand);
          pr.waitFor();
       catch (Exception ex) {
          System.out.println(ex.getLocalizedMessage());
          retval=-1;
        return retval;
    /but I do not get a return value... because I don't know how to get return value..
    Edited by: user9158455 on 22-Sep-2010 07:33

    Hi,
    Have your tried pr.exitValue() ?
    I think you also need a finally block that destroys the subprocess
    Regards
    Peter

  • How to get byte array from jpg in resource for Image XObject?

    Hi,
    Does anyone know how to get an array of bytes from a jpg from resource without an external library except MFC?
    The array of bytes is needed to create an Image XObject so it can be included in an appearance for an annotation.

    Sounds like a standard Windows programming question, not specific to the SDK.

  • How to get return values from stored procedure to ssis packge?

    Hi,
    I need returnn values from my stored procedure to ssis package -
    My procedure look like  and ssis package .Kindly help me to oget returnn value to my ssis package
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author: <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description: <Description,,>
    -- =============================================
    ALTER PROCEDURE [TSC]
    -- Add the parameters for the stored procedure here
    @P_STAGE VARCHAR(2000)
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    --SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
    truncate table [INPUTS];
    INSERT
    INTO
    [INPUTS_BASE]
    SELECT
    [COLUMN]
    FROM [INPUTS];
    RETURN
    END
    and i am trying to get the return value from execute sql task and shown below
    and i am taking my returnn value to result set variable

    You need to have either OUTPUT parameters or use RETURN statement to return a value in stored procedures. RETURN can only return integer values whereas OUTPUT parameters can be of any type
    First modify your procedure to define return value or OUTPUT parameter based on requirement
    for details see
    http://www.sqlteam.com/article/stored-procedures-returning-data
    Once that is done in SSIS call sp from Execute SQL Task and in parameter mapping tabe shown above add required parameters and map them to variables created in SSIS and select Direction as Output or Return Value based on what option you used in your
    procedure.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Please Help(How to get RadioButtons in tree View)

    Hi.
    Sub/Requirement: How to implement RadioButtons in tree view with/without using xml file.
    I have a requirement like this i want to display RadioButton in tree view.
    I implemented tree same as which is given in sampleApplications.
    In this sampleApplications they implemted tree by using xml file.
    I also implemented tree by Generating xml file. In this xml file i get the values from the database. I am using <netui:tree > tag.
    Is it possible to implement tree without using xml file. I need to generate tree Dynamically.
    Please any one help me to come out with this solution.

    The issue here is while you are retrieving all the details, you are consistently overwriting them in the request.setAttribute() call before you get to the JSP to display them.
    Do you actually have a class/object called Student?
    That object should have attributes for classes, subjects, teachers (all of which are lists apparently)
    public class Student{
      String name;
      List classes;
      List subjects;
      List teachers;
      // appropriate getter/setter methods
    }Then you load each student, and populate its individual lists.
    That lets you pass the list of students, each student having its own lists for display.
    Hope this helps,
    evnafets

  • How to get An Array from PostgreSQL.

    When I design a programm to get an array object from a postgreSQL database, the programm give the following exception:
    "This method is not yet implemented"
    Who can help me?
    Thanks!!!!
    Here are my codes:
    import java.sql.*;
    class test {
    public static void main(String args[]) {
    String url = "jdbc:postgresql://localhost:5432/testdb";
    String query = "select * from table1";
    try {
    Class.forName("org.postgresql.Driver");
    Connection con = DriverManager.getConnection(url,"aa", "bb");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(queryStr);
    while(rs.next()) {
         Array array = rs.getArray("idnum");
    } catch(Exception ex) {
    System.out.println("Get Data Fail: " + ex);
    the table struct of "table1"
    =============================
    varchar(10) int4[]
    name | idnum
    -----------------+--------------------------------
    Bill | {100430,134630000,10000,10000}

    You pass a string to the getArray method. The parameter should be an integer, representing the desired column.

  • How to get return values from task flow in af:region ?

    Hi!
    I'm working with a taskFlow that is rendered inside a popup using the "popup inside a region pattern" (http://www.oracle.com/technology/products/adf/patterns/popupregionpattern.pdf), but now this taskFlow has an input parameter and a return value definition. So the question is how to get a value returned by this taskFlow thas is called inside a region?
    Any suggestion?
    Thanks in advance!

    Hi,
    write the value to a shared memory scope like session and read it in the regionNavigation listener. If you follow the paper you refer to then the listener determines of the viewId is null, this a return happens. It wuld then look in the memory scope for the return value.
    Another option would be to use an object that you pass as an argument to the task flow you open in the popup. Then you change the object you passed in, which then makes the return information available in teh calling flow. The object you pass in would have to be in a shared scope too
    Frank

  • 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

  • How to get return values from region?

    I add a page flow as region into a page. The page flow has a return parameter. How to get the return value in parent page?

    I have been also intrigued by this question.
    There is however a workaround that you can set the values in requestScope.
    We can have a regionNavigationListener on the region and catch the end of taskflow if viewid is null.
    regionNavigationEvent.getNewViewId() == null
    Here we can read the request values and set wherever to be used.
    maniesh (sid)

  • How to detlete  .jpg file  from perticular folder  in java code

    As part of my programming java & jsp code logic i want to delete some *.jpg photos from perticular path in flder.can any body help how to delte the photo using java code logic.

    File inFile = new File("C:\\folder\\file.tif"); //this should not be hardcoded
    inFile.delete();

  • HELP: How to get window (JFrame) from JPanel ???

    Hi there,
    anyone knows how I can get a ref. to the window (in the form of JFrame) from my JPanel that is in the actual window??
    I need that window when I display a modal dialog from the panel, as the dialog constructor takes the window as a param.
    I could always pass a window-ref. to the JPanel when I create it, but as I have a lot of panels, I'd rather be able to get it just when I need it from the JPanel!
    Thanks a lot for any help on this issue!
    Best regards,
    AC

    Thanks a lot!
    I'll use windowForComponent in swingUtils, I think getRootPane() would only return the panel that the component is in!
    Regards,
    AC

Maybe you are looking for

  • DPS APP Builder Error Code 1

    Hello, I'm getting an Error Code 1 message when trying to download the test APP from the DPS APP Builder. I've tried re-building the document (a process that takes almost 8 hours in my case as our APP features 110 articles including almost 1000 image

  • I can't download garageband, iMovie and iPhoto because it says that the apps were already assigned to another apple id

    I reinstalled the mac os and when I open the app utility, it shows that I have these three apps ready for download.  I sign in with my apple id, but the dowload is blocked because it says that they have been assigned to another apple id.  This probab

  • Boot Camp no longer on my computer?

    I use parallels with boot camp. I went to use it, and a window pops up with the following... "Virtual machine cannot be started because of the following problem: The Hard Disk 1 is set to use the Boot Camp while Boot Camp is not installed on this com

  • Error when installing 10.2.0.3 agent on solaris 8

    I've installed the agent successfully on other solaris 8 servers but on this one machine, i get the "Heap at VM Abort" error. I've seen this in the past when doing oracle installations and the trick was to use a different size for jre_memory_options.

  • Quickest way to move albums between libraries..

    I am splitting my itunes libary because it is too big...is there any way to do this easily...I figured I'd create a new libary and copy about 100 albums in..and then go back and delete them from the first library.. does that sound right..