I'm building a custom IKM, and I need to keep some values in memory during execution. So in the first task, I try to define all the variables that will be used in following tasks.
For example, I need to get Session Number as integer. I do it like this:
<%
int SESSIONID = Integer.parseInt(<?=odiRef.getSession("SESS_NO")?>);
%>
But I get the following error:
Parse error at line 2, column 17. Encountered: <
Pre-execution text:
int SESSIONID = 699;
out.print("");
This
<%
String sessionNo = odiRef.getSession("SESS_NO");
int SESSIONID = Integer.parseInt(sessionNo);
%>
is also not working:
Sourced file: inline evaluation of: `` String sessionNo =
odiRef.getSession("SESS_NO"); Integer SESSIONID = Integer.pa . . . '' : Typed variable declaration : Method Invocation Integer.parseInt
Target error:
For input string: "707"
Pre-execution text:
String sessionNo = odiRef.getSession("SESS_NO");
int SESSIONID = Integer.parseInt(sessionNo);
out.print("");
Error text:
Integer .parseInt ( sessionNo )
What am I doing wrong?
In the first attempt :
<%
tags are executed/substituted before the <?
tags so the odiRef.getSession() is not substitued. I would use <$
or <@
on the outer tag, so it happens after that substitution. More info at the end of this excellent blog : https://devepm.com/2014/09/16/odi-substitution-tags-demystified/Try
<@
int SESSIONID = Integer.parseInt("<?=odiRef.getSession("SESS_NO")?>");
@>
In the second attempt I'm not sure what's wrong. Could it be that the session is not available yet at the <%
pass? You could debug it by setting the KM step Technology on Jython and use this code :
raise '<%=odiRef.getSession("SESS_NO")%>'
That would show you the value of SESS_NO in the error message in the operator.