× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I am having some difficulty getting a data structure returned to my Java
program using ServiceProgamCall to call an RPG procedure. I can watch it
in debug and the data structure gets populated okay. 

Can anyone shed some light on this ? I would really appreciate some
expertise on this problem. 

d RtvJDARtlWrapper...                                 

d                 pr                                  

d pSKU                           9p 0 const           

d pStore                         5p 0 const           

d pReturnDS                           likeDS(returnDS)

                    

d returnDS        ds                  qualified       

d regularPrice                        like(o4regu)    

d POSPrice                            like(o4posu)    

d eventStartDate...                                   

d                                     like(o3sdt)     

d eventEndDate                        like(o3edt)     

d precedenceLevel...                                  

d                                     like(o3ppre)    

 

import java.math.BigDecimal;

import com.ibm.as400.access.AS400;

import com.ibm.as400.access.AS400Message;

import com.ibm.as400.access.AS400PackedDecimal;

import com.ibm.as400.access.AS400DataType;

import com.ibm.as400.access.AS400Structure;

import com.ibm.as400.access.ProgramParameter;

import com.ibm.as400.access.ServiceProgramCall;

 

public class ServiceProgramCallExample {

 

    public static void main(String[] args) {

 

            try {

                AS400 as400 = new AS400();

                

                //create ServiceProgram call object passing two 5-byte

                //parms and output a data structure

                ServiceProgramCall srvpgm = new
ServiceProgramCall(as400);

 

                ProgramParameter[] parmlist = new ProgramParameter[] {

                                    new ProgramParameter(5),

                                    new ProgramParameter(5),

 
new ProgramParameter(24)

                };

                

 
srvpgm.setProgram("/QSYS.LIB/QGPL.LIB/RTVJDASRV.SRVPGM");

                srvpgm.setProcedureName("RTVJDARTLWRAPPER");

                srvpgm.setParameterList(parmlist);      

 

                // Create a structure of data types to handle the
returned data

                AS400DataType[] myStruct = {

                        new AS400PackedDecimal(13, 3),

                                                            new
AS400PackedDecimal(13, 3),

                        new AS400PackedDecimal(6, 0),

                                                            new
AS400PackedDecimal(6, 0),

                        new AS400PackedDecimal(2, 0)

                        };

                

                // Create a conversion object using the structure 

                AS400Structure dataConverter = new
AS400Structure(myStruct); 

 

                Object[] returnData = {

                                    new BigDecimal(0),

                                    new BigDecimal(0),

                                    new BigDecimal(0),

                                    new BigDecimal(0),

                                    new BigDecimal(0)

                };

                

                // convert from Java object to byte array

                byte[] as400Data = dataConverter.toBytes(returnData);

                

                //convert each parm

                AS400PackedDecimal sku = new AS400PackedDecimal(9, 0); 

                parmlist[0].setInputData(sku.toBytes(171403));

                AS400PackedDecimal store = new AS400PackedDecimal(5, 0);

                parmlist[1].setInputData(store.toBytes(1));

                parmlist[2].setInputData(as400Data);

                

 
parmlist[0].setParameterType(ProgramParameter.PASS_BY_REFERENCE);

 
parmlist[1].setParameterType(ProgramParameter.PASS_BY_REFERENCE);


 
parmlist[2].setParameterType(ProgramParameter.PASS_BY_REFERENCE);


                

                if (srvpgm.run() != true) {

                        AS400Message[] msgList =
srvpgm.getMessageList();

                        System.out.println("AS/400 messages : ");

                        for (int i = 0; i < msgList.length; i++) {

 
System.out.println(msgList[i].getText());

 
System.out.println(msgList[i].getID());

 
System.out.println(msgList[i].getSeverity());

 
System.out.println(msgList[i].getType());

                        }

                }

                else {

                        //get the returned data

                        byte[] data = parmlist[2].getOutputData();


                }

            } catch (Exception e) {

                System.out.println(e.getMessage());

                e.printStackTrace();

            }

        }

    }


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.