I am trying to call the API QtocRtvTCPA in /QSYS.LIB/QTOCNETSTS.SRVPGM in v7r3 via jtOpen/jt400. parameter[3] is defined as ErrorCode in the API
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/apis/qtocrtvtcpa.htm
Every attempt I have made to call the service program has resulted in the error at the bottom. I have tried all the items that are commented out below. I could use some help in determining how to pass the error code parameter.
private byte[] receiverVariable = new byte[1000];
parameters[0].setOutputDataLength(receiverVariable.length);
parameters[1].setInputData(bin4.toBytes(receiverVariable.length));
parameters[2].setInputData(new AS400Text(8).toBytes("TCPA0200"));
//parameters[3] = new ErrorCodeParameter();
//parameters[3] = new ProgramParameter(BinaryConverter.intToByteArray(0));
//parameters[3] = new ProgramParameter(new AS400Text(8).toBytes("ERRC0100"), 0);
//parameters[3] = new ProgramParameter(new AS400Text(8).toBytes("ERRC0200"), 0);
//parameters[3] = new ProgramParameter(0);
ServiceProgramCall sPGMCall = new ServiceProgramCall(as400);
sPGMCall.setProgram("/QSYS.LIB/QTOCNETSTS.SRVPGM", parameters);
sPGMCall.setProcedureName("QtocRtvTCPA");
sPGMCall.setReturnValueFormat(ServiceProgramCall.NO_RETURN_VALUE);
Error code parameter not valid.
CPF3CF1
AS400Message (ID: CPF3CF1 text: Error code parameter not valid.):com.ibm.as400.access.AS400Message#1536d79
Cause . . . . . : The format of the error code parameter is not correct. Recovery . . . : Correct the error code parameter and try the request again. If you do not know the correct format for the error code parameter, see the APIs topic collection in the Programming category in the IBM i Information Center, http://www.ibm.com/systems/i/infocenter/.
The solution
parameters[3].setInputData(bin4.toBytes(0));
parameters[0].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
parameters[1].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
parameters[2].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
parameters[3].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
Related
I need to convert below working REST endpoint to java query
/rest-1.v1/Data/Timebox?Where=Schedule.ScheduledScopes.Name="Sample: Call Center Product"&sel=Workitems:Defect[AssetState='Closed'].Estimate.#Sum,Name,Workitems:Story[AssetState='Closed'].Estimate.#Sum
My Not working Code:
IAssetType storyType = services.getMeta().getAssetType("Timebox");
Query query = new Query(storyType, true);
IAttributeDefinition name = storyType.getAttributeDefinition("Name");
IAttributeDefinition defect_estimate = storyType.getAttributeDefinition("Workitems:Defect[AssetState='Closed'].Estimate.#Sum");
IAttributeDefinition story_estimate = storyType.getAttributeDefinition("Workitems:Story[AssetState='Closed'].Estimate.#Sum");
query.getSelection().add(name);
query.getSelection().add(defect_estimate);
query.getSelection().add(story_estimate);
//IFilterTerm activeSprint = new TokenTerm("State.Code='ACTV'");
IFilterTerm activeSprint = new TokenTerm("Schedule.ScheduledScopes.Name='Sample: Call Center Product'");
query.setFilter(activeSprint);
DefaultCategoryDataset dataset = new DefaultCategoryDataset( );
QueryResult result = services.retrieve(query);
Error i am getting:
Exception in thread "main" com.versionone.apiclient.exceptions.MetaException: Unknown AttributeDefinition: Timebox.Workitems:Defect[AssetState='Closed'].Estimate.#Sum
at com.versionone.apiclient.MetaModel.getAttributeDefinition(MetaModel.java:119)
at com.versionone.apiclient.AssetType.getAttributeDefinition(AssetType.java:96)
at v1_rest_intig.Example1.main(Example1.java:230)
what am i doing wrong??
any guidance is of great help
Thanks in advance
You are using the right attribute definition, but apparently, at some version of the API they stop translating symbols, like brakets '[' into the URL encoding ( '%5B' for open bracket) and therefore the resulting error message.
Please, try this instead:
Workitems:Defect%5BAssetState=%27128%27%5D
for your attributes definition for the Defect/Story AssetType.
Let me know if this works.
TIA,
I am trying to encode an HL7 message of the type ORU_R01 using the HAPI 2.0 library for an OpenMRS module. I have followed the tutorials given in the HAPI documentation and according to that, I have populated the required fields of the ORU_R01 message. Now, I want to post this message using the following link:
http://localhost:8080/openmrs/remotecommunication/postHl7.form
I am using the following message for testing:
MSH|^~\&|||||20140713154042||ORU^R01|20140713154042|P|2.5|1
PID|||1
OBR|1||1234^SensorReading|88304
OBX|0|NM|1||45
OBX|1|NM|2||34
OBX|2|NM|3||23
I have properly ensured that all the parameters are correct. Once I have posted the HL7 message, I start the HL7 task from the scheduler. Then I go to the admin page and click on "Manage HL7 errors" in order to see if the message arrives there. I get the following stack trace:
ca.uhn.hl7v2.HL7Exception: HL7 encoding not supported
...
Caused by: ca.uhn.hl7v2.parser.EncodingNotSupportedException: Can't parse message beginning MSH|^~\
at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:140)
The full stack trace is here: http://pastebin.com/ZnbFqfWC.
I have written the following code to encode the HL7 message (using the HAPI library):
public String createHL7Message(int p_id, int concept_id[], String val[])
throws HL7Exception {
ORU_R01 message = new ORU_R01();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss",
Locale.ENGLISH);
MSH msh = message.getMSH();
msh.getFieldSeparator().setValue("|");
msh.getEncodingCharacters().setValue("^~\\&");
msh.getProcessingID().getProcessingID().setValue("P");
msh.getSequenceNumber().setValue("1");
msh.getMessageType().getTriggerEvent().setValue("R01");
msh.getMessageType().getMessageCode().setValue("ORU");
msh.getVersionID().getVersionID().setValue("2.5");
msh.getMessageControlID().setValue(
sdf.format(Calendar.getInstance().getTime()));
msh.getDateTimeOfMessage().getTime()
.setValue(sdf.format(Calendar.getInstance().getTime()));
ORU_R01_ORDER_OBSERVATION orderObservation = message
.getPATIENT_RESULT().getORDER_OBSERVATION();
ca.uhn.hl7v2.model.v25.segment.PID pid = message.getPATIENT_RESULT()
.getPATIENT().getPID();
Patient patient = (Patient) Context.getPatientService()
.getPatient(p_id);
System.out.println(String.valueOf(p_id) + " " + patient.getGivenName()
+ " " + patient.getFamilyName());
pid.getPatientName(0).getFamilyName().getSurname()
.setValue(patient.getFamilyName());
pid.getPatientName(0).getGivenName().setValue(patient.getGivenName());
pid.getPatientIdentifierList(0).getIDNumber()
.setValue(String.valueOf(p_id));
System.out.println();
// Parser parser = new PipeParser();
// String encodedMessage = null;
// encodedMessage = parser.encode(message);
// System.out.println(encodedMessage);
// Populate the OBR
OBR obr = orderObservation.getOBR();
obr.getSetIDOBR().setValue("1");
obr.getFillerOrderNumber().getEntityIdentifier().setValue("1234");
obr.getFillerOrderNumber().getNamespaceID().setValue("SensorReading");
obr.getUniversalServiceIdentifier().getIdentifier().setValue("88304");
Varies value = null;
// Varies value[] = new Varies[4];
for (int i = 0; i < concept_id.length; i++) {
ORU_R01_OBSERVATION observation = orderObservation
.getOBSERVATION(i);
OBX obx2 = observation.getOBX();
obx2.getSetIDOBX().setValue(String.valueOf(i));
obx2.getObservationIdentifier().getIdentifier()
.setValue(String.valueOf(concept_id[i]));
obx2.getValueType().setValue("NM");
NM nm = new NM(message);
nm.setValue(val[i]);
value = obx2.getObservationValue(0);
value.setData(nm);
}
Parser parser = new PipeParser();
String encodedMessage = null;
encodedMessage = parser.encode(message);
return encodedMessage;
}
In all likelihood, something is wrong with the MSH segment of the message, but I cannot seem to figure out what it is. What can I do to correct this error?
Why do you declare the Encoding Characters using double backslashes?
msh.getEncodingCharacters().setValue("^~\\&");
Shouldn't it be:
msh.getEncodingCharacters().setValue("^~\&");
...and because your message is using the default encoding characters maybe you don't even need to declare them at all? Extract from HAPI MSH Class reference
getENCODINGCHARACTERS
public ST getENCODINGCHARACTERS()
Returns MSH-2: "ENCODING CHARACTERS" - creates it if necessary
Update
I have no previous experience with HAPI. A quick google found an ORU example. Could you try initializing your MSH with initQuickstart("ORU", "R01", "P");
According to the comments in the example-code the initQuickstart method populates all of the mandatory fields in the MSH segment of the message, including the message type, the timestamp, and the control ID. (...and hopefully the default encoding chars as well :-)
I'm trying to invoke RQLQueryForEach droplet from using DUST's DropletInvoker by using below code.
HeadPipelineServlet dynamoHandler = (HeadPipelineServlet) Nucleus.getGlobalNucleus().resolveName("/atg/dynamo/servlet/dafpipeline/DynamoHandler");
DynamoHttpServletRequest request = dynamoHandler.getRequest(null);
ByteBuffer buffer = ByteBuffer.allocate(1024);
TestingDynamoHttpServletRequest wrappedRequest = new TestingDynamoHttpServletRequest(request, buffer);
TestingDynamoHttpServletResponse wrappedResponce = new TestingDynamoHttpServletResponse(request.getResponse());
DynamoServlet droplet = (DynamoServlet) wrappedRequest.resolveName("/atg/dynamo/droplet/RQLQueryForEach");
wrappedRequest.setParameter("repository", "/atg/userprofiling/ProfileAdapterRepository");
wrappedRequest.setParameter("itemDescriptor", "user");
wrappedRequest.setParameter("transactionManager", "/atg/dynamo/transaction/TransactionManager");
wrappedRequest.setParameter("queryRQL", "ALL");
DropletInvoker mDropletInvoker = new DropletInvoker(Nucleus.getGlobalNucleus());
DropletResult result = mDropletInvoker.invokeDroplet(droplet, null, wrappedRequest, wrappedResponce);
assertNotNull("Check that output got rendered",result.getRenderedOutputParameter("output"));
invokeDroplet method is failing with exception "javax.servlet.ServletException: required parameter 'repository' not passed to droplet." Can any one point me in the right direction, what is that I'm doing incorrectly?
Here is the full stack trace...
javax.servlet.ServletException: required parameter 'repository' not passed to droplet
at atg.repository.servlet.RQLQueryForEach.getRangeResults(RQLQueryForEach.java:254)
at atg.repository.servlet.RQLQueryForEach.getResults(RQLQueryForEach.java:220)
at atg.repository.servlet.RQLQueryForEach.service(RQLQueryForEach.java:179)
at atg.servlet.DynamoServlet.service(DynamoServlet.java:152)
I could solve the problem using additional parameters. However the i still couldn't figure out why my original code isn't working.
Workaround I found
HeadPipelineServlet dynamoHandler = (HeadPipelineServlet) Nucleus.getGlobalNucleus().resolveName("/atg/dynamo/servlet/dafpipeline/DynamoHandler");
Map<String,Object> additionalParams = new HashMap<>();
additionalParams.put("repository", "/atg/userprofiling/ProfileAdapterRepository");
additionalParams.put("itemDescriptor", "user");
additionalParams.put("queryRQL", "ALL");
DropletInvoker mDropletInvoker = new DropletInvoker(Nucleus.getGlobalNucleus());
DropletResult result = mDropletInvoker.invokeDroplet("/atg/dynamo/droplet/RQLQueryForEach",additionalParams);
Are you building your dust code properly? The error only suggests that the input parameter repository is not sent in the request.
Was there a point when the below line was not in your code. If you have added it, probably your changes have not been built. Could you clean your project and try again. Other than this I don't see any thing wrong with your code. Also if you are using eclipse, probably your Build Automatically under Projects menu is not checked.
wrappedRequest.setParameter("repository", "/atg/userprofiling/ProfileAdapterRepository");
I have been assigned to clean up a project for a client that uses BIRT reporting. I have fixed most of the issues but I still have one report that is not working and is returning an error. The error is:
Row (id = 1467):
+ There are errors evaluating script "var fileName = row["Attached_File"];
params["HyperlinkParameter"].value = ImageDecoder.decodeDocs(row["Ecrash_Attach"],fileName);":
Wrapped java.lang.NullPointerException (/report/body/table[#id="61"]/detail/row[#id="70"]/cell[#id="71"]/grid[#id="1460"]/row[#id="1462"]/cell[#id="1463"]/table[#id="1464"]/detail/row[#id="1467"]/method[#name="onCreate"]#2)
I can post the full stack trace if someone wants it but for now I will omit it since it is very long.
Here is the source of the decodeDocs method:
public static String decodeDocs(byte[] source, String fileName) {
String randName = "";
byte[] docSource = null;
if ( Base64.isArrayByteBase64(source) ){
docSource = Base64.decodeBase64(source);
}
documentZipPath = writeByteStreamToFile(source);
randName = writeByteStreamToFile(docSource, fileName);
return randName;
}
I am pretty well lost on this one. The error looks to be telling me there is an error on line two of the script which is:
var fileName = row["Attached_File"];
params["HyperlinkParameter"].value = ImageDecoder.decodeDocs(row["Ecrash_Attach"],fileName);
This is written in the OnCreate method of the report. Any help, even clues would be greatly appreciated. If you would like to see the report just ask and I will post the xml for it.
A common mistake I make in BIRT is to access the value of a null report parameter.
In your case, could params["HyperlinkParameter"] be null?
I have a struts application, and I am trying to call the Action class with an URL. When I try to pass the request parameters, none of them get appended.
Here is the code I have :
document.myform.action = "mydetails_${firmID}_${empID}.action?id=56";
document.myform.submit();
But this is what I see in chrome console :
mydetails_123_04.action?
For some resaon, the stuff after the question mark is not appended. Am I missing something ?
Don't think you can set params like that in the action. You need to add them as parameters in the form, which involves creating a hidden input node:
var input = document.createElement( 'input' );
input.type = 'hidden';
input.name = 'id';
input.value = 56;
document.forms.myform.appendChild( input );