For loop in a scriptlet tag style
For loops in a a XML style JSP tags won't work.
Please have a look at the following code snippets:
Works:
<%
for (int i = 0; i < 5; i++) {
out.print(i);
%>
Works:
<jsp:scriptlet>
int i = true;
while (i) {
out.print(i);
i = false;
</jsp:scriptlet>
Won't work
<jsp:scriptlet>
for (int i = 0; i < 5; i++) {
out.print(i);
</jsp:scriptlet>I am using tomcat-5.5.17
error:
org.apache.jasper.JasperException: /test/index.jsp(7,15) Unterminated <jsp:scriptlet> tag
Thank you,
Although not entirely right, but you sure put me in the right direction, if anybody wants to know the (best) solution:
<jsp:scriptlet>
<![CDATA[
for (int i = 0; i < 5; i++) {
out.print(i);
]]>
</jsp:scriptlet>
Similar Messages
-
Hi all,
I am trying to implement a custom "for loop tag". But it seems to me that there is a type conversion problem. I've tried many ways to fixed it but I still cannot get it to work. I've dug through my books, searched the internet and this forum but I can't found anythig useful. I am really lost now! Can anyone help me with this? Many many many thanks!!
loopTag.jsp
<%@ taglib prefix="myTag" uri="/WEB-INF/myTag.tld" %>
<% int num=5; %>
<myTag:loop index="i" count="<%=num%>">
body1here: i expr: <%=i%> i property: <jsp:getProperty name="i" property="value"/> <br>
</myTag:loop>
myTag.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>simple</shortname>
<tag>
<name>loop</name>
<tagclass>myTag.LoopTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>for loop</info>
<attribute>
<name>index</name>
<required>true</required>
</attribute>
<attribute>
<name>count</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
LoopTag.java
package myTag;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.util.Hashtable;
import java.io.Writer;
import java.io.IOException;
public class LoopTag extends BodyTagSupport {
String index;
int count;
int i=0;
public void setIndex(String index){
this.index=index;
public void setCount(String count){
this.count=Integer.parseInt(count);
public int doStartTag() throws JspException {
return EVAL_BODY_TAG;
public void doInitBody() throws JspException {
pageContext.setAttribute(index, i);
i++;
public int doAfterBody() throws JspException {
try {
if (i >= count) {
bodyContent.writeOut(bodyContent.getEnclosingWriter());
return SKIP_BODY;
else{
pageContext.setAttribute(index, i);
i++;
return EVAL_BODY_TAG;
catch (IOException ex) {
throw new JspTagException(ex.toString());
Error message:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /loopTag.jsp
Generated servlet error:
The method setCount(String) in the type LoopTag is not applicable for the arguments (int)
An error occurred at line: 5 in the jsp file: /loopTag.jsp
Generated servlet error:
i cannot be resolved
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.11 logs.I took the custom for-loop one step further and now it can be nested with in other for-loop.
Hope this is the last time I have to reinvent the wheel. Now I REALLY apprecate JSTL!!
loopTag.jsp
<%@ taglib prefix="myTag" uri="/WEB-INF/myTag.tld" %>
<% int row = 5; %>
<% int col = 5; %>
<table border=0>
<myTag:loop index="i" count="<%= row %>">
<tr>
<myTag:loop index="j" count="<%= col %>">
<td>index: i=<myTag:printIndex parentLevel="2" /> j=<myTag:printIndex parentLevel="1" />, <br></td>
</myTag:loop>
</tr>
</myTag:loop>
</table>
myTag.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>simple</shortname>
<tag>
<name>loop</name>
<tagclass>myTag.LoopTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>for loop</info>
<attribute>
<name>index</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>count</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>printIndex</name>
<tagclass>myTag.LoopPrintTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>for loop print</info>
<attribute>
<name>parentLevel</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
LoopTag.java
package myTag;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.util.Hashtable;
import java.io.Writer;
import java.io.IOException;
public class LoopTag extends BodyTagSupport {
String index;
int count;
int i=0;
public void setIndex(String index){
this.index=index;
public String getIndex(){
return String.valueOf(pageContext.getAttribute(index));
public void setCount(int count){
this.count=count;
public int doStartTag() throws JspException {
i = 0;
return EVAL_BODY_TAG;
public void doInitBody() throws JspException {
pageContext.setAttribute(index, i);
i++;
public int doAfterBody() throws JspException {
try {
if (i >= count) {
bodyContent.writeOut(bodyContent.getEnclosingWriter());
return SKIP_BODY;
else{
pageContext.setAttribute(index, i);
i++;
return EVAL_BODY_TAG;
catch (IOException ex) {
throw new JspTagException(ex.toString());
LoopPrintTag.java
package myTag;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import javax.servlet.*;
public class LoopPrintTag extends BodyTagSupport {
private int parentLevel = 1;
public int doStartTag() throws JspTagException {
LoopTag parent = (LoopTag)findAncestorWithClass(this, LoopTag.class);
for(int i=1; i<parentLevel; i++){
parent = (LoopTag)findAncestorWithClass(parent, LoopTag.class);
if (parent == null) {
throw new JspTagException("print not inside loop");
else{
try {
JspWriter out = pageContext.getOut();
out.print(parent.getIndex());
} catch(IOException ioe) {
System.out.println("Error in printTag: " + ioe);
return(SKIP_BODY);
public void setParentLevel(int _parentLevel){
if(_parentLevel > 0){
parentLevel = _parentLevel;
Output:
index: i=0 j=0, index: i=0 j=1, index: i=0 j=2, index: i=0 j=3, index: i=0 j=4,
index: i=1 j=0, index: i=1 j=1, index: i=1 j=2, index: i=1 j=3, index: i=1 j=4,
index: i=2 j=0, index: i=2 j=1, index: i=2 j=2, index: i=2 j=3, index: i=2 j=4,
index: i=3 j=0, index: i=3 j=1, index: i=3 j=2, index: i=3 j=3, index: i=3 j=4,
index: i=4 j=0, index: i=4 j=1, index: i=4 j=2, index: i=4 j=3, index: i=4 j=4, -
How to return multiple tags (based on different checks) in a for loop?
Hi,
I'm trying to return multiple elements, based on different checks that are done in the XQuery, within a for loop. But I'm getting syntax errors at any attempt to do this.
This is the structure of what I'm trying to do:
<ActionList>
<ACtion>
let $total := count(...)
for $x in (1 to $total)
let $lineItems := $someVariable/*:Items/*:Item[$x]
return
if(...)
<Qty1>{...}</Qty1>
else ""
if(...)
<Qty2>{...}</Qty2>
else ""
{ if(...)
<Qty3>{...}</Qty3>
else ""
<LinesList>
let $totalcount(...)
for $y in (1 to $totalcount(...)
let $DTL := $someVariable*:DTL[$y]
return
<Line>
<Carrier>{...}</Carrier>
<Path>{...}</Path>
<CA>{
if(...)
data($$someVariable/*:CA)
else
}</CA>
<RE>{
if(...)
data($someVariable*:CA[@XX="RG"])
else
}</RE>
<Time>{
if(...)
data($someVariable*:CA[@XX="BN"])
else
</Time>
</Line>
</LinesList>
</ACtion>
</ActionList>
I'm not able to return elements without having their father being returned as well, I just want to iterate over those fields and, based on that verification, decide whether they should be returned or not.
Can someone please advise?An example anyway...
Input document ($d) :
<ns0:Items xmlns:ns0="http://my.company.org/my-namespace">
<ns0:Item type="A">
<ns0:Qty>2</ns0:Qty>
<ns0:UnitPrice>10.00</ns0:UnitPrice>
<ns0:DTL>
<ns0:Article>ART001</ns0:Article>
<ns0:DispatchDate>2012-01-20</ns0:DispatchDate>
<ns0:Destination direct="1">Location1</ns0:Destination>
</ns0:DTL>
<ns0:DTL>
<ns0:Article>ART002</ns0:Article>
<ns0:DispatchDate>2012-01-21</ns0:DispatchDate>
<ns0:Destination direct="1">Location2</ns0:Destination>
</ns0:DTL>
</ns0:Item>
<ns0:Item type="B">
<ns0:Mass>5</ns0:Mass>
<ns0:Unit>kg</ns0:Unit>
<ns0:DTL>
<ns0:Article>ART003</ns0:Article>
<ns0:DispatchDate>2012-01-20</ns0:DispatchDate>
<ns0:Destination direct="1">Location3</ns0:Destination>
</ns0:DTL>
<ns0:DTL>
<ns0:Article>ART004</ns0:Article>
<ns0:DispatchDate>2012-01-21</ns0:DispatchDate>
<ns0:Destination direct="1">Location4</ns0:Destination>
</ns0:DTL>
<ns0:DTL>
<ns0:Article>ART005</ns0:Article>
<ns0:DispatchDate>2012-01-22</ns0:DispatchDate>
<ns0:Destination direct="2">Location5</ns0:Destination>
</ns0:DTL>
</ns0:Item>
</ns0:Items>XQuery :
declare namespace ns0 = "http://my.company.org/my-namespace";
<DispatchInfo>
for $i in $d/ns0:Items/ns0:Item
return
<Parcel>
if ($i/@type = "A")
then <Amount>{xs:decimal($i/ns0:Qty * $i/ns0:UnitPrice)}</Amount>
else <Weight>{concat($i/ns0:Mass, " ", $i/ns0:Unit)}</Weight>
, for $j in $i/ns0:DTL
return
<Article>
<Num>{data($j/ns0:Article)}</Num>
, <Dt>{data($j/ns0:DispatchDate)}</Dt>
, if ($j/ns0:Destination/@direct = "1")
then <Dest>{data($j/ns0:Destination)}</Dest>
else ()
</Article>
</Parcel>
</DispatchInfo>Output :
<DispatchInfo>
<Parcel>
<Amount>20</Amount>
<Article>
<Num>ART001</Num>
<Dt>2012-01-20</Dt>
<Dest>Location1</Dest>
</Article>
<Article>
<Num>ART002</Num>
<Dt>2012-01-21</Dt>
<Dest>Location2</Dest>
</Article>
</Parcel>
<Parcel>
<Weight>5 kg</Weight>
<Article>
<Num>ART003</Num>
<Dt>2012-01-20</Dt>
<Dest>Location3</Dest>
</Article>
<Article>
<Num>ART004</Num>
<Dt>2012-01-21</Dt>
<Dest>Location4</Dest>
</Article>
<Article>
<Num>ART005</Num>
<Dt>2012-01-22</Dt>
</Article>
</Parcel>
</DispatchInfo> -
Replace the following open/fetch/close statements with a cursor FOR loop
Hi anyone could you please help me,
I would like to replace the following open/fetch/close statements with a cursor FOR loop.
Codes are:
CREATE OR REPLACE PROCEDURE COMOES.orchid_shipment_interface IS
-- get the com shipment header records
CURSOR c_com_shphdr ( p_dwn_end_dt DATE ) IS
SELECT custno client_id
, plheadno plheadno
, DECODE(carr_no,'FEDX',lading_no,'UPS',lading_no,carrier_pro_no) tracking_no
, carr_no||'/'||carr_method carrier_id
, plantid plant_id
, carr_no
, lading_no
, del_custaddr ship_to_id
, ol_type cfm_order_type
, del_custno
, shipterm freight_terms
, del_custattn attn_line
, custaddr
FROM com_plhead@com_pricing.world
WHERE status = '9'
AND (mod_dat) > p_dwn_end_dt;
-- get the com shipment address records
CURSOR c_com_shpadr (p_custaddr VARCHAR2) IS
SELECT name1 addr_name
, street1 addr_line1
, street2 addr_line2
, city city
, state state_cd
, zip zip
, country country_cd
, phone work_phone
, email email1
FROM com_address@com_pricing.world
WHERE addr_id = p_custaddr;
-- get the com shipment detail records
CURSOR c_com_shpdtl ( p_plheadno NUMBER) IS
SELECT pll.plheadno pllheadno
, pll.pllineno ord_line_no
, pll.ol_no erp_line_no
, pll.ol_segno
, pll.fg_id sku
, pll.qty_shipped ship_qty
, pll.ordno erp_ord_no
FROM com_plline@com_pricing.world pll
WHERE pll.plheadno = p_plheadno
AND NOT EXISTS (SELECT '1'
FROM com_pkg_int_interface@com_pricing.world cpi
WHERE pll.ordno = cpi.ordno
AND pll.ol_no = cpi.ol_no);
-- type declaration
-- type declaration of com table.
TYPE t_com_shphdr IS TABLE OF c_com_shphdr%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shphdr IS TABLE OF orchid_shipment_hdr_intf%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_com_shpadr IS TABLE OF c_com_shpadr%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shpadr IS TABLE OF orchid_shipment_address_intf%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_com_shpdtl IS TABLE OF c_com_shpdtl%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE t_orchid_shpdtl IS TABLE OF orchid_shipment_dtl_intf%ROWTYPE INDEX BY BINARY_INTEGER;
lv_company_code com_customer.business_unit%TYPE;
lv_erp_ord_no com_plline.ordno%TYPE;
lv_actual_ship_date com_plline.confirm_date%TYPE;
lv_po_no com_oline.po_no%TYPE;
lv_ord_date com_oline.entrydate%TYPE;
lv_hdr_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_adr_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_dtl_batch_ctrl_no download_batch_info.batch_ctrl_no%TYPE;
lv_sku_desc com_salesitem.title%TYPE;
lv_ord_qty com_oldelseg.qty%TYPE;
lr_com_shphdr t_com_shphdr;
lr_orchid_shphdr t_orchid_shphdr;
lr_com_shpadr t_com_shpadr;
lr_orchid_shpadr t_orchid_shpadr;
lr_com_shpdtl t_com_shpdtl;
lr_orchid_shpdtl t_orchid_shpdtl;
-- variable declaration
ln_shphdr_seq NUMBER(10):= 0;
ln_shpadr_seg NUMBER(10):= 0;
ln_shpdtl_seq NUMBER(10):= 0;
cnt NUMBER(10):= 0;
cnt1 NUMBER(10):= 0;
ld_hdr_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_hdr_dwn_status download_batch_info.dwn_status%TYPE;
ld_hdr_download_end_tstamp DATE;
ln_hdr_running_seq NUMBER(10) := 0;
ld_adr_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_adr_dwn_status download_batch_info.dwn_status%TYPE;
ld_adr_download_end_tstamp DATE;
ln_adr_running_seg NUMBER(10) := 0;
ld_dtl_dwn_end_dt download_batch_info.download_end_tstamp%TYPE;
lc_dtl_dwn_status download_batch_info.dwn_status%TYPE;
ld_dtl_download_end_tstamp DATE;
ln_dtl_running_seq NUMBER(10) := 0;
BEGIN
-- get the batch control number details from batch information table for shipment header
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_hdr_batch_ctrl_no
, ld_hdr_dwn_end_dt
, lc_hdr_dwn_status
FROM comoes.download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- get the batch control number details from batch information table for shipment address
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_adr_batch_ctrl_no
, ld_adr_dwn_end_dt
, lc_adr_dwn_status
FROM comoes.download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_ADDRESS_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- get the batch control number details from batch information table for shipment details
BEGIN
SELECT batch_ctrl_no
, NVL(download_end_tstamp,TO_DATE('01/01/1980','MM/DD/YYYY'))
, dwn_status
INTO lv_dtl_batch_ctrl_no
, ld_dtl_dwn_end_dt
, lc_dtl_dwn_status
FROM download_batch_info
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF';
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE (' No Data Found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
RAISE;
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE (' Too Many Rows found for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!');
RAISE;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_DTL_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;
END;
-- if previous run is not sucess then do nothing and return.
OPEN c_com_shphdr ( ld_hdr_dwn_end_dt ) ;
LOOP
-- delete the collection for every cycle
lr_com_shphdr.DELETE;
lr_orchid_shphdr.DELETE;
lr_com_shpadr.DELETE;
lr_orchid_shpadr.DELETE;
lr_com_shpdtl.DELETE;
lr_orchid_shpdtl.DELETE;
-- fetch the order header records to collection
FETCH c_com_shphdr BULK COLLECT INTO lr_com_shphdr LIMIT 500;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shphdr.COUNT = 0;
-- build your logic there to populate the data into order header collection.
FOR i IN 1..lr_com_shphdr.COUNT
LOOP
-- accumulate header running sequence number
ln_hdr_running_seq := ln_hdr_running_seq + 1;
ln_shphdr_seq := ln_hdr_running_seq;
-- Get the business unit for the customer from com_customer
BEGIN
SELECT business_unit
INTO lv_company_code
FROM com_customer@com_pricing.world
WHERE custno = lr_com_shphdr(i).del_custno;
EXCEPTION
WHEN OTHERS THEN
lv_company_code := NULL;
END;
-- Get the ordno, confirm_date from COM_PLLINE
BEGIN
SELECT ordno
, confirm_date
INTO lv_erp_ord_no
, lv_actual_ship_date
FROM com_plline@com_pricing.world cpl
WHERE cpl.plheadno = lr_com_shphdr(i).plheadno
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
lv_erp_ord_no := NULL;
lv_actual_ship_date := NULL;
END;
-- Get the po_no, Entry_date from COM_OLINE
BEGIN
SELECT po_no
, entrydate
INTO lv_po_no
, lv_ord_date
FROM com_oline@com_pricing.world col
WHERE col.ordno = lv_erp_ord_no
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
lv_po_no := NULL;
lv_ord_date := NULL;
END;
-- To assign the Bol Number from Lading Number
IF lr_com_shphdr(i).carr_no NOT IN ('FEDX','UPS') THEN
lr_orchid_shphdr(i).bol_no := lr_com_shphdr(i).lading_no;
ELSE
lr_orchid_shphdr(i).bol_no := NULL;
END IF;
-- For each order header get the Shipment Delivery Adderss
OPEN c_com_shpadr ( lr_com_shphdr(i).custaddr);
FETCH c_com_shpadr BULK COLLECT INTO lr_com_shpadr;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shpadr.COUNT = 0;
-- biuld your logic here to populate the del address collection.
FOR j IN 1..lr_com_shpadr.COUNT
LOOP
-- accumulate the loop count into temp variable, so that will through tell each set of order header.
cnt := cnt + 1;
-- accumolate the header running sequence number.
ln_adr_running_seg := ln_adr_running_seg + 1;
ln_shpadr_seg := ln_adr_running_seg;
-- move the order address data into collection.
lr_orchid_shpadr(cnt).client_id := lr_com_shphdr(i).del_custno;
lr_orchid_shpadr(cnt).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shpadr(cnt).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shpadr(cnt).addr_name := lr_com_shpadr(j).addr_name;
lr_orchid_shpadr(cnt).attn_line := lr_com_shphdr(i).attn_line;
lr_orchid_shpadr(cnt).addr_line1 := lr_com_shpadr(j).addr_line1;
lr_orchid_shpadr(cnt).addr_line2 := lr_com_shpadr(j).addr_line2;
lr_orchid_shpadr(cnt).addr_line3 := NULL;
lr_orchid_shpadr(cnt).addr_line4 := NULL;
lr_orchid_shpadr(cnt).addr_line5 := NULL;
lr_orchid_shpadr(cnt).city := lr_com_shpadr(j).city;
lr_orchid_shpadr(cnt).state_cd := lr_com_shpadr(j).state_cd;
lr_orchid_shpadr(cnt).zip := lr_com_shpadr(j).zip;
lr_orchid_shpadr(cnt).zip_ext := NULL;
lr_orchid_shpadr(cnt).country_cd := lr_com_shpadr(j).country_cd;
lr_orchid_shpadr(cnt).tax_geo_cd := NULL;
lr_orchid_shpadr(cnt).work_phone := lr_com_shpadr(j).work_phone;
lr_orchid_shpadr(cnt).email1 := lr_com_shpadr(j).email1;
lr_orchid_shpadr(cnt).cre_dat := SYSDATE;
lr_orchid_shpadr(cnt).cre_usr := USER;
lr_orchid_shpadr(cnt).batch_ctrl_no := lv_adr_batch_ctrl_no;
END LOOP;
CLOSE c_com_shpadr;
-- For each order header get the order detail/delivery segment data
OPEN c_com_shpdtl ( lr_com_shphdr(i).plheadno );
FETCH c_com_shpdtl BULK COLLECT INTO lr_com_shpdtl;
-- where there is no record in the collection the exit from the loop
EXIT WHEN lr_com_shpdtl.COUNT = 0;
-- build your logic here to populate the order detail collection
FOR k IN 1..lr_com_shpdtl.COUNT
LOOP
-- accumulate the loop count into a temp variable, so that will through till each set of Order Header.
cnt1 := cnt1 + 1;
-- accumulate header running sequence number
ln_dtl_running_seq := ln_dtl_running_seq + 1;
ln_shpdtl_seq := ln_dtl_running_seq;
-- Get Quantity for the delvery from delevery segment table.
BEGIN
SELECT NVL(Qty,0)
INTO lv_ord_qty
FROM com_oldelseg@com_pricing.world cds
WHERE cds.ordno = lr_com_shpdtl(k).erp_ord_no
AND cds.ol_no = lr_com_shpdtl(k).erp_line_no
AND cds.ol_segno = lr_com_shpdtl(k).ol_segno;
EXCEPTION
WHEN OTHERS THEN
lv_ord_qty := NULL;
END;
-- Get Title for the salesitem from the salesitem table.
BEGIN
SELECT Title
INTO lv_sku_desc
FROM com_salesitem@com_pricing.world cs
WHERE cs.fg_id = lr_com_shpdtl(k).sku;
EXCEPTION
WHEN OTHERS THEN
lv_sku_desc := NULL;
END;
-- move the Order detail data into collection
lr_orchid_shpdtl(cnt1).client_id := lr_com_shphdr(i).client_id;
lr_orchid_shpdtl(cnt1).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shpdtl(cnt1).ord_line_no := lr_com_shpdtl(k).ord_line_no;
lr_orchid_shpdtl(cnt1).erp_line_no := lr_com_shpdtl(k).erp_line_no;
lr_orchid_shpdtl(cnt1).sku := lr_com_shpdtl(k).sku;
lr_orchid_shpdtl(cnt1).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shpdtl(cnt1).container_no := NULL;
lr_orchid_shpdtl(cnt1).ord_qty := lv_ord_qty;
lr_orchid_shpdtl(cnt1).ship_qty := lr_com_shpdtl(k).ship_qty;
lr_orchid_shpdtl(cnt1).price_point := NULL;
lr_orchid_shpdtl(cnt1).pick_invoice_no := NULL;
lr_orchid_shpdtl(cnt1).cancel_qty := NULL;
lr_orchid_shpdtl(cnt1).bldg_id := NULL; --lr_com_shpdtl(k).bldg_id;
lr_orchid_shpdtl(cnt1).sku_company := NULL; --lr_com_shpdtl(k).sku_company;
lr_orchid_shpdtl(cnt1).sku_desc := lv_sku_desc;
lr_orchid_shpdtl(cnt1).icc_cd1 := NULL; --lr_com_shpdtl(k).icc_cd1;
lr_orchid_shpdtl(cnt1).erp_ord_no := lr_com_shpdtl(k).erp_ord_no;
lr_orchid_shpdtl(cnt1).cre_dat := SYSDATE;
lr_orchid_shpdtl(cnt1).cre_usr := USER;
lr_orchid_shpdtl(cnt1).batch_ctrl_no := lv_dtl_batch_ctrl_no;
END LOOP;
CLOSE c_com_shpdtl;
-- build the logic to populate Order Header
lr_orchid_shphdr(i).client_id := lr_com_shphdr(i).client_id;
lr_orchid_shphdr(i).ord_no := lr_com_shphdr(i).plheadno;
lr_orchid_shphdr(i).tracking_no := lr_com_shphdr(i).tracking_no;
lr_orchid_shphdr(i).container_no := NULL; -- container number is not maintained in COM
lr_orchid_shphdr(i).carrier_id := lr_com_shphdr(i).carrier_id;
lr_orchid_shphdr(i).plant_id := lr_com_shphdr(i).plant_id;
lr_orchid_shphdr(i).erp_ord_no := lv_erp_ord_no;
lr_orchid_shphdr(i).erp_ord_no2 := NULL;
lr_orchid_shphdr(i).po_no := lv_po_no;
lr_orchid_shphdr(i).ship_to_id := lr_com_shphdr(i).ship_to_id;
lr_orchid_shphdr(i).ship_to_addr_id := lr_com_shphdr(i).custaddr;
lr_orchid_shphdr(i).scac := NULL; --lr_com_shphdr(i).scac;
lr_orchid_shphdr(i).actual_ship_date := lv_actual_ship_date;
lr_orchid_shphdr(i).cfm_order_type := lr_com_shphdr(i).cfm_order_type;
lr_orchid_shphdr(i).company_code := lv_company_code;
lr_orchid_shphdr(i).no_of_order_lines := NULL; --lr_com_shphdr(i).no_of_order_lines;
lr_orchid_shphdr(i).pick_invoice_no := NULL;
lr_orchid_shphdr(i).ord_date := lv_ord_date;
lr_orchid_shphdr(i).orig_tender_date := NULL;
lr_orchid_shphdr(i).orig_delv_date := NULL;
lr_orchid_shphdr(i).delivery_flag := NULL;
lr_orchid_shphdr(i).delv_date_from := NULL;
lr_orchid_shphdr(i).delv_date_to := NULL;
lr_orchid_shphdr(i).orig_carr_cd := NULL;
lr_orchid_shphdr(i).routing_comment := NULL;
lr_orchid_shphdr(i).segment_type := NULL;
lr_orchid_shphdr(i).back_order_flag := NULL;
lr_orchid_shphdr(i).addr_override_flag := NULL;
lr_orchid_shphdr(i).fmx_assigned_carr := NULL;
lr_orchid_shphdr(i).fmx_assigned_ship_date := NULL;
lr_orchid_shphdr(i).fmx_assigned_delv_date := NULL;
lr_orchid_shphdr(i).freight_terms := lr_com_shphdr(i).freight_terms;
lr_orchid_shphdr(i).fmx_load_id := NULL;
lr_orchid_shphdr(i).asn_type := NULL;
lr_orchid_shphdr(i).icc_cd1 := NULL; --lr_com_shphdr(i).icc_cd1;
lr_orchid_shphdr(i).trans_type := NULL;
lr_orchid_shphdr(i).ref_no1 := NULL;
lr_orchid_shphdr(i).ref_no2 := NULL;
lr_orchid_shphdr(i).ref_no3 := NULL;
lr_orchid_shphdr(i).ref_no4 := NULL;
lr_orchid_shphdr(i).cre_dat := SYSDATE;
lr_orchid_shphdr(i).cre_usr := USER;
lr_orchid_shphdr(i).batch_ctrl_no := lv_hdr_batch_ctrl_no;
-- logic to get total boxes and weight.
BEGIN
SELECT SUM(no_cartons), SUM(weight)
INTO lr_orchid_shphdr(i).total_boxes
, lr_orchid_shphdr(i).weight
FROM com_plline@com_pricing.world pll
WHERE pll.plheadno = lr_com_shphdr(i).plheadno;
EXCEPTION
WHEN OTHERS THEN
lr_orchid_shphdr(i).total_boxes := NULL;
lr_orchid_shphdr(i).weight := NULL;
END;
END LOOP;
-- initialize the variables for next loop cycle.
cnt := 0;
cnt1 := 0;
-- populate the shipment header interface table.
FOR x IN 1..lr_orchid_shphdr.COUNT
LOOP
ld_hdr_download_end_tstamp := lr_orchid_shphdr(x).cre_dat;
INSERT INTO orchid_shipment_hdr_intf
(record_qualifier
,client_id
,ord_no
,tracking_no
,container_no
,bol_no
,carrier_id
,plant_id
,erp_ord_no
,erp_ord_no2
,po_no
,ship_to_id
,ship_to_addr_id
,scac
,actual_ship_date
,cfm_order_type
,company_code
,no_of_order_lines
,pick_invoice_no
,total_boxes
,weight
,ord_date
,orig_tender_date
,orig_delv_date
,delivery_flag
,delv_date_from
,delv_date_to
,orig_carr_cd
,routing_comment
,segment_type
,back_order_flag
,addr_override_flag
,fmx_assigned_carr
,fmx_assigned_ship_date
,fmx_assigned_delv_date
,freight_terms
,fmx_load_id
,asn_type
,upl_status
,icc_cd1
,trans_type
,ref_no1
,ref_no2
,ref_no3
,ref_no4
,cre_dat
,cre_usr
,batch_ctrl_no)
VALUES
( 10
,lr_orchid_shphdr(x).client_id
,lr_orchid_shphdr(x).ord_no
,lr_orchid_shphdr(x).tracking_no
,lr_orchid_shphdr(x).container_no
,lr_orchid_shphdr(x).bol_no
,lr_orchid_shphdr(x).carrier_id
,lr_orchid_shphdr(x).plant_id
,lr_orchid_shphdr(x).erp_ord_no
,lr_orchid_shphdr(x).erp_ord_no2
,lr_orchid_shphdr(x).po_no
,lr_orchid_shphdr(x).ship_to_id
,lr_orchid_shphdr(x).ship_to_addr_id
,lr_orchid_shphdr(x).scac
,lr_orchid_shphdr(x).actual_ship_date
,lr_orchid_shphdr(x).cfm_order_type
,lr_orchid_shphdr(x).company_code
,lr_orchid_shphdr(x).no_of_order_lines
,lr_orchid_shphdr(x).pick_invoice_no
,lr_orchid_shphdr(x).total_boxes
,lr_orchid_shphdr(x).weight
,lr_orchid_shphdr(x).ord_date
,lr_orchid_shphdr(x).orig_tender_date
,lr_orchid_shphdr(x).orig_delv_date
,lr_orchid_shphdr(x).delivery_flag
,lr_orchid_shphdr(x).delv_date_from
,lr_orchid_shphdr(x).delv_date_to
,lr_orchid_shphdr(x).orig_carr_cd
,lr_orchid_shphdr(x).routing_comment
,lr_orchid_shphdr(x).segment_type
,lr_orchid_shphdr(x).back_order_flag
,lr_orchid_shphdr(x).addr_override_flag
,lr_orchid_shphdr(x).fmx_assigned_carr
,lr_orchid_shphdr(x).fmx_assigned_ship_date
,lr_orchid_shphdr(x).fmx_assigned_delv_date
,lr_orchid_shphdr(x).freight_terms
,lr_orchid_shphdr(x).fmx_load_id
,lr_orchid_shphdr(x).asn_type
,00
,lr_orchid_shphdr(x).icc_cd1
,lr_orchid_shphdr(x).trans_type
,lr_orchid_shphdr(x).ref_no1
,lr_orchid_shphdr(x).ref_no2
,lr_orchid_shphdr(x).ref_no3
,lr_orchid_shphdr(x).ref_no4
,lr_orchid_shphdr(x).cre_dat
,lr_orchid_shphdr(x).cre_usr
,lr_orchid_shphdr(x).batch_ctrl_no);
END LOOP;
-- populate the shipment address interface table.
FOR y IN 1..lr_orchid_shpadr.COUNT
LOOP
ld_adr_download_end_tstamp := lr_orchid_shpadr(y).cre_dat;
INSERT INTO orchid_shipment_address_intf
( record_qualifier
, client_id
, ord_no
, tracking_no
, addr_name
, attn_line
, addr_line1
, addr_line2
, addr_line3
, addr_line4
, addr_line5
, city
, state_cd
, zip
, zip_ext
, country_cd
, tax_geo_cd
, work_phone
, email1
, cre_dat
, cre_usr
, batch_ctrl_no)
VALUES ( 14
, lr_orchid_shpadr(y).client_id
, lr_orchid_shpadr(y).ord_no
, lr_orchid_shpadr(y).tracking_no
, lr_orchid_shpadr(y).addr_name
, lr_orchid_shpadr(y).attn_line
, lr_orchid_shpadr(y).addr_line1
, lr_orchid_shpadr(y).addr_line2
, lr_orchid_shpadr(y).addr_line3
, lr_orchid_shpadr(y).addr_line4
, lr_orchid_shpadr(y).addr_line5
, lr_orchid_shpadr(y).city
, lr_orchid_shpadr(y).state_cd
, lr_orchid_shpadr(y).zip
, lr_orchid_shpadr(y).zip_ext
, lr_orchid_shpadr(y).country_cd
, lr_orchid_shpadr(y).tax_geo_cd
, lr_orchid_shpadr(y).work_phone
, lr_orchid_shpadr(y).email1
, lr_orchid_shpadr(y).cre_dat
, lr_orchid_shpadr(y).cre_usr
, lr_orchid_shpadr(y).batch_ctrl_no);
END LOOP;
-- populate the shipment detail interface table.
FOR z IN 1..lr_orchid_shpdtl.COUNT
LOOP
ld_dtl_download_end_tstamp := lr_orchid_shpdtl(z).cre_dat;
INSERT INTO orchid_shipment_dtl_intf
( record_qualifier
, client_id
, ord_no
, ord_line_no
, erp_line_no
, sku
, tracking_no
, container_no
, ord_qty
, ship_qty
, price_point
, pick_invoice_no
, cancel_qty
, bldg_id
, sku_company
, sku_desc
, icc_cd1
, erp_ord_no
, cre_dat
, cre_usr
, batch_ctrl_no)
VALUES ( 20
, lr_orchid_shpdtl(z).client_id
, lr_orchid_shpdtl(z).ord_no
, lr_orchid_shpdtl(z).ord_line_no
, lr_orchid_shpdtl(z).erp_line_no
, lr_orchid_shpdtl(z).sku
, lr_orchid_shpdtl(z).tracking_no
, lr_orchid_shpdtl(z).container_no
, lr_orchid_shpdtl(z).ord_qty
, lr_orchid_shpdtl(z).ship_qty
, lr_orchid_shpdtl(z).price_point
, lr_orchid_shpdtl(z).pick_invoice_no
, lr_orchid_shpdtl(z).cancel_qty
, lr_orchid_shpdtl(z).bldg_id
, lr_orchid_shpdtl(z).sku_company
, lr_orchid_shpdtl(z).sku_desc
, lr_orchid_shpdtl(z).icc_cd1
, lr_orchid_shpdtl(z).erp_ord_no
, lr_orchid_shpdtl(z).cre_dat
, lr_orchid_shpdtl(z).cre_usr
, lr_orchid_shpdtl(z).batch_ctrl_no);
END LOOP;
COMMIT;
END LOOP;
CLOSE c_com_shphdr;
-- set the status to success
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_plhead_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_address_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_hdr_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
AND batch_ctrl_no = lv_adr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET batch_ctrl_no = orchid_plline_btch_ctrl_seq.NEXTVAL
, dwn_status = '90'
, download_end_tstamp = NVL(ld_dtl_download_end_tstamp,SYSDATE)
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
-- Update the download status to success in the interface table.
-- Shipment Header
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- load is not sucess then set the status to fail
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_HDR_INTF'
AND batch_ctrl_no = lv_hdr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_ADDRESS_INTF'
AND batch_ctrl_no = lv_adr_batch_ctrl_no;
UPDATE comoes.download_batch_info
SET dwn_status = '99'
WHERE download_id = 'ORCHID_SHIPMENT_DTL_INTF'
AND batch_ctrl_no = lv_dtl_batch_ctrl_no;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Following error occured while executing ORCHID_SHIPMENT_INTF procedure...!!!'||SQLERRM);
RAISE;
END orchid_shipment_interface;Edited by: BluShadow on 03-Aug-2011 13:28
added {noformat}{noformat} tags. Please read {message:id=9360002} to learn to do this yourself. &nbPlease read the Forum FAQ on how to ask a question, particularly how to format code
SQL and PL/SQL FAQ
SQL and PL/SQL FAQ
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE (' Following error occured while getting batch control number for ORCHID_SHIPMENT_HDR_INTF in Download Batch Info table...!!!'||SQLERRM);
RAISE;http://tkyte.blogspot.com/2008/01/why-do-people-do-this.html -
I'm calling 5 identical web service calls using a parallel for loop in BPM. Obviously the data in each slightly differs. Why would this call suspend the process and give the following errors:
handleCommunicationError( ErrorContextData, Throwable, TransitionTicket ): A technical error occurred.
Interface namespace = myNamespace
Interface name = myService
Operation name = myOperation
Connectivity type = WS
Application name = myAppName
Reference name = 8bd95deb-8cf1-453d-94e5-0576bb385149
Message Id = null
WS style = DOC
Start time of WS call = 2014-02-26 17:51:23.297
Return time of WS call = 2014-02-26 17:51:23.412
Principal name = SAP_BPM_Service
Root error message = local part cannot be "null" when creating a QName
Error message = Could not invoke service reference name 8bd95deb-8cf1-453d-94e5-0576bb385149, component name myComp application name myappname
com.sap.engine.interfaces.sca.exception.SCADASException: Could not invoke service reference name 8bd95deb-8cf1-453d-94e5-0576bb385149, component name
myCompname
at com.sap.engine.services.sca.das.SCADASImpl.invokeReference(SCADASImpl.java:341)
at com.sap.glx.adapter.app.ucon.SCADASWrapperImpl.invoke(SCADASWrapperImpl.java:101)
at com.sap.glx.adapter.app.ucon.UnifiedWebServiceCallObject.invokeWebServiceOperation(UnifiedWebServiceCallObject.java:101)
at com.sap.glx.adapter.app.ucon.UnifiedWebServiceCallClass.invoke(UnifiedWebServiceCallClass.java:178)
at com.sap.glx.core.dock.impl.DockObjectImpl.invokeMethod(DockObjectImpl.java:657)
at com.sap.glx.core.kernel.trigger.config.Script$MethodInvocation.execute(Script.java:248)
at com.sap.glx.core.kernel.trigger.config.Script.execute(Script.java:798)
at com.sap.glx.core.kernel.execution.transition.ScriptTransition.execute(ScriptTransition.java:78)
at com.sap.glx.core.kernel.execution.transition.Transition.commence(Transition.java:196)
at com.sap.glx.core.kernel.execution.LeaderWorkerPool$Follower.run(LeaderWorkerPool.java:163)
at com.sap.glx.core.resource.impl.common.WorkWrapper.run(WorkWrapper.java:58)
at com.sap.glx.core.resource.impl.j2ee.J2EEResourceImpl$Sessionizer.run(J2EEResourceImpl.java:261)
at com.sap.glx.core.resource.impl.j2ee.ServiceUserManager$ServiceUserImpersonator$1.run(ServiceUserManager.java:152)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:337)
at com.sap.glx.core.resource.impl.j2ee.ServiceUserManager$ServiceUserImpersonator.run(ServiceUserManager.java:149)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:185)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:302)
Caused by: java.lang.IllegalArgumentException: Could not process message for operation myOperation in web service plugin module.
at com.sap.engine.services.sca.plugins.ws.WebServiceImplementationInstance.accept(WebServiceImplementationInstance.java:228)
at com.sap.engine.services.sca.das.SCADASImpl.invokeReference(SCADASImpl.java:314)
... 19 more
Caused by: java.lang.IllegalArgumentException: local part cannot be "null" when creating a QName
at javax.xml.namespace.QName.<init>(QName.java:246)
at javax.xml.namespace.QName.<init>(QName.java:190)
at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DInterfaceImpl.getInterfaceInvoker(DInterfaceImpl.java:126)
at com.sap.engine.services.webservices.espbase.wsdas.impl.WSDASImpl.<init>(WSDASImpl.java:43)
at com.sap.engine.services.webservices.espbase.wsdas.impl.WSDASFactoryImpl.createWSDAS(WSDASFactoryImpl.java:39)
at com.sap.engine.services.sca.plugins.ws.tools.wsdas.WsdasFactoryWrapper.createWsdas(WsdasFactoryWrapper.java:30)
at com.sap.engine.services.sca.plugins.ws.WebServiceImplementationInstance.initWsdas(WebServiceImplementationInstance.java:256)
at com.sap.
Surely if it was the service group unassign then reassign issue then none of the calls would have worked?Hi David,
While a random error is still an error it will be difficult for support to find a problem for an error which is not reproducible. It is always a faster resolution if you can determine how to provoke the error and provide those details. If we can reproduce an error on internal systems then we can fix the problem quickly and without having to access your system.
regards, Nick -
Hi i'm wondering what is the format of a for loop in jstl.
for example:
my for loop:
for(int i = 0; i< stringArray.Length(); i++){
i++;
thanks<c:forEach var="i" items="stringArray">
${i}
</c:forEach>Note: stringArray should be a variable in scope, and not a scriptlet variables.
ram. -
For Loop in Struts ?(without Collections)
Hi all,
Pls tell me how can v use FOR LOOP IN JSP STRUTS without using scriplets and collections .
suppose i want to display 20 times "hello world "in jsp .How can i display it using STRUTS as conventionally scriplets are not allowed in it.
and Iterator is only for Collections .
thanxTestBean.java
* $Id: TestBean.java 54929 2004-10-16 16:38:42Z germuska $
* Copyright 1999-2004 The Apache Software Foundation.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
package org.apache.struts.webapp.exercise;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
* General purpose test bean for Struts custom tag tests.
* @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
public class TestBean extends ActionForm {
// ------------------------------------------------------------- Properties
* A collection property where the elements of the collection are
* of type <code>LabelValueBean</code>.
private Collection beanCollection = null;
public Collection getBeanCollection() {
if (beanCollection == null) {
Vector entries = new Vector(10);
entries.add(new LabelValueBean("Label 0", "Value 0"));
entries.add(new LabelValueBean("Label 1", "Value 1"));
entries.add(new LabelValueBean("Label 2", "Value 2"));
entries.add(new LabelValueBean("Label 3", "Value 3"));
entries.add(new LabelValueBean("Label 4", "Value 4"));
entries.add(new LabelValueBean("Label 5", "Value 5"));
entries.add(new LabelValueBean("Label 6", "Value 6"));
entries.add(new LabelValueBean("Label 7", "Value 7"));
entries.add(new LabelValueBean("Label 8", "Value 8"));
entries.add(new LabelValueBean("Label 9", "Value 9"));
beanCollection = entries;
return (beanCollection);
public void setBeanCollection(Collection beanCollection) {
this.beanCollection = beanCollection;
* A multiple-String SELECT element using a bean collection.
private String[] beanCollectionSelect = { "Value 1", "Value 3",
"Value 5" };
public String[] getBeanCollectionSelect() {
return (this.beanCollectionSelect);
public void setBeanCollectionSelect(String beanCollectionSelect[]) {
this.beanCollectionSelect = beanCollectionSelect;
* A boolean property whose initial value is true.
private boolean booleanProperty = true;
public boolean getBooleanProperty() {
return (booleanProperty);
public void setBooleanProperty(boolean booleanProperty) {
this.booleanProperty = booleanProperty;
* A multiple-String SELECT element using a collection.
private String[] collectionSelect = { "Value 2", "Value 4",
"Value 6" };
public String[] getCollectionSelect() {
return (this.collectionSelect);
public void setCollectionSelect(String collectionSelect[]) {
this.collectionSelect = collectionSelect;
* A double property.
private double doubleProperty = 321.0;
public double getDoubleProperty() {
return (this.doubleProperty);
public void setDoubleProperty(double doubleProperty) {
this.doubleProperty = doubleProperty;
* A boolean property whose initial value is false
private boolean falseProperty = false;
public boolean getFalseProperty() {
return (falseProperty);
public void setFalseProperty(boolean falseProperty) {
this.falseProperty = falseProperty;
* A float property.
private float floatProperty = (float) 123.0;
public float getFloatProperty() {
return (this.floatProperty);
public void setFloatProperty(float floatProperty) {
this.floatProperty = floatProperty;
* Integer arrays that are accessed as an array as well as indexed.
private int intArray[] = { 0, 10, 20, 30, 40 };
public int[] getIntArray() {
return (this.intArray);
public void setIntArray(int intArray[]) {
this.intArray = intArray;
private int intIndexed[] = { 0, 10, 20, 30, 40 };
public int getIntIndexed(int index) {
return (intIndexed[index]);
public void setIntIndexed(int index, int value) {
intIndexed[index] = value;
private int intMultibox[] = new int[0];
public int[] getIntMultibox() {
return (this.intMultibox);
public void setIntMultibox(int intMultibox[]) {
this.intMultibox = intMultibox;
* An integer property.
private int intProperty = 123;
public int getIntProperty() {
return (this.intProperty);
public void setIntProperty(int intProperty) {
this.intProperty = intProperty;
* A long property.
private long longProperty = 321;
public long getLongProperty() {
return (this.longProperty);
public void setLongProperty(long longProperty) {
this.longProperty = longProperty;
* A multiple-String SELECT element.
private String[] multipleSelect = { "Multiple 3", "Multiple 5",
"Multiple 7" };
public String[] getMultipleSelect() {
return (this.multipleSelect);
public void setMultipleSelect(String multipleSelect[]) {
this.multipleSelect = multipleSelect;
* A nested reference to another test bean (populated as needed).
private TestBean nested = null;
public TestBean getNested() {
if (nested == null)
nested = new TestBean();
return (nested);
* A String property with an initial value of null.
private String nullProperty = null;
public String getNullProperty() {
return (this.nullProperty);
public void setNullProperty(String nullProperty) {
this.nullProperty = nullProperty;
* A short property.
private short shortProperty = (short) 987;
public short getShortProperty() {
return (this.shortProperty);
public void setShortProperty(short shortProperty) {
this.shortProperty = shortProperty;
* A single-String value for a SELECT element.
private String singleSelect = "Single 5";
public String getSingleSelect() {
return (this.singleSelect);
public void setSingleSelect(String singleSelect) {
this.singleSelect = singleSelect;
* String arrays that are accessed as an array as well as indexed.
private String stringArray[] =
{ "String 0", "String 1", "String 2", "String 3", "String 4" };
public String[] getStringArray() {
return (this.stringArray);
public void setStringArray(String stringArray[]) {
this.stringArray = stringArray;
private String stringIndexed[] =
{ "String 0", "String 1", "String 2", "String 3", "String 4" };
public String getStringIndexed(int index) {
return (stringIndexed[index]);
public void setStringIndexed(int index, String value) {
stringIndexed[index] = value;
private String stringMultibox[] = new String[0];
public String[] getStringMultibox() {
return (this.stringMultibox);
public void setStringMultibox(String stringMultibox[]) {
this.stringMultibox = stringMultibox;
* A String property.
private String stringProperty = "This is a string";
public String getStringProperty() {
return (this.stringProperty);
public void setStringProperty(String stringProperty) {
this.stringProperty = stringProperty;
* An empty String property.
private String emptyStringProperty = "";
public String getEmptyStringProperty() {
return (this.emptyStringProperty);
public void setEmptyStringProperty(String emptyStringProperty) {
this.emptyStringProperty = emptyStringProperty;
* A single-String value for a SELECT element based on resource strings.
private String resourcesSelect = "Resources 2";
public String getResourcesSelect() {
return (this.resourcesSelect);
public void setResourcesSelect(String resourcesSelect) {
this.resourcesSelect = resourcesSelect;
* A property that allows a null value but is still used in a SELECT.
private String withNulls = null;
public String getWithNulls() {
return (this.withNulls);
public void setWithNulls(String withNulls) {
this.withNulls = withNulls;
* A List property.
private List listProperty = null;
public List getListProperty() {
if (listProperty == null) {
listProperty = new ArrayList();
listProperty.add("dummy");
return listProperty;
public void setListProperty(List listProperty) {
this.listProperty = listProperty;
* An empty List property.
private List emptyListProperty = null;
public List getEmptyListProperty() {
if (emptyListProperty == null) {
emptyListProperty = new ArrayList();
return emptyListProperty;
public void setEmptyListProperty(List emptyListProperty) {
this.emptyListProperty = emptyListProperty;
* A Map property.
private Map mapProperty = null;
public Map getMapProperty() {
if (mapProperty == null) {
mapProperty = new HashMap();
mapProperty.put("dummy", "dummy");
return mapProperty;
public void setMapProperty(Map mapProperty) {
this.mapProperty = mapProperty;
* An empty Map property.
private Map emptyMapProperty = null;
public Map getEmptyMapProperty() {
if (emptyMapProperty == null) {
emptyMapProperty = new HashMap();
return emptyMapProperty;
public void setEmptyMapProperty(Map emptyMapProperty) {
this.emptyMapProperty = emptyMapProperty;
// --------------------------------------------------------- Public Methods
* Reset the properties that will be received as input.
public void reset(ActionMapping mapping, HttpServletRequest request) {
booleanProperty = false;
collectionSelect = new String[0];
intMultibox = new int[0];
multipleSelect = new String[0];
stringMultibox = new String[0];
if (nested != null)
nested.reset(mapping, request);
} -
Hi,
I want to write a C-Style for loop so that i can increment a variable using the loop.
for ex : for (( i=0 ; i < 10 ; i++ )) ; do echo $i ; done
The above mentioned code is not working for korn shell.
How to write a c-style for loop in korn shell?
Thanks
SandeepI guess thats possible only Bourne Shell.
check this out.
http://books.google.com/books?id=5Xw8ozq8CbIC&pg=PA193&lpg=PA193&dq=c-style+for+loop+in+ksh&source=web&ots=IeJgCNUzaZ&sig=e8zrdSultWKxnkR75ygHszdcHCA&hl=en&ei=e2CUSYLaFePetgejy5ibCw&sa=X&oi=book_result&resnum=8&ct=result#PPA154,M1
http://www.unix.com/answers-frequently-asked-questions/12274-difference-between-ksh-bash-different-shells.html
HTH
Anantha. -
Hi ALL,
How can I work with iteration operation in JSF View Class as JSP scriptlets won't work in it
thanks
SudhakarHi Sudhakar,
Thank you for explaining your requirement so clearly.
The task you are trying to achieve is not possible in the jsp source. The reason being that Creator has a page backing bean where the component declarations are done. Hence adding components via the jsp source would not work as the page backing bean is essential for the working of the application.
The solution for your problem would be something like this:
Create an integer property named counter in your session bean and initialise it to 0.
Add a gridpanel to your page.
In your page backing bean (Page1.java) constructor add the following code
for(int i=0; i<array.length;i++){
SessionBean1 sb = getSessionBean1();
int ctr = sb.getCounter();
UIComponent parent = gridPanel1;
HtmlSelectBooleanCheckbox chkBx = new HtmlSelectBooleanCheckbox();
chkBx.setId("checkBox" + ctr);
parent.getChildren().add(chkBx);
sb.setCounter(ctr+1);
The above code just uses one for loop. You could extend it to mak use of nested loops.
I hope this helps
Cheers
Giri :-)
Creator Team -
Geting ORA 936 -while building dynamic query in for loop.
HI,
I hav written a SP and its compiled and giving me the results for the data I am quering but giving ORA936 - missing expressin and giving ORA 6512 at 2 lines. Please help me me out where I am going wrong.
CREATE OR REPLACE TYPE LIST as VARRAY(5000) of NUMBER;
CREATE OR REPLACE PROCEDURE test( V_id IN LIST,
v-fdate IN DATE,
v-tdate IN DATE,
v_flg IN CHAR)
AS
TYPE opfld IS RECORD (
FID TAB.ID%TYPE,
FCURR TAB.CURR %TYPE,
FCNT TAB.CNT%TYPE,
FTOT TAB.TOT%TYPE );
TYPE OPLIST IS REF CURSOR;
Rc oplist;
Edtab opfld;
Selstr VACHAR2(200);
Whstr1 VACHAR2(200);
Whstr2 VACHAR2(200);
Whstr3 VACHAR2(200);
Whstr VACHAR2(200);
Grpstr VACHAR2(200);
Andstr VACHAR2(200);
Fullstr VACHAR2(200);
BEGIN
Selstr := ‘SELECT col1,col2,sum(col3),sum(col4) from tab1 ’;
Whstr1 := ‘ WHERE tdate BETWEEN TO_DATE(‘||’’’’||vfdate||’’’’||’)’;
Whstr2: = ‘ AND TO_DATE(‘||’’’’||vtdate||’’’’||’)’;
Whstr := whstr1||whstr2;
Grpstr := ‘GROUP BY col1,col2’;
IF v_flg IS NOT NULL THEN
Whstr3 := whstr||’AND FLAG = ‘||v_flg;
else
Whstr3 := whstr ;
END IF;
FOR I IN 1..id.COUNT LOOP
BEGIN
Andstr := ‘ AND id =’|| v_id(i);
Whstr := whstr3 || andstr ;
Fullstr := selstr||whstr||grpstr;
OPEN rc for fullstr;
LOOP
FETCH rc into edtab
EXIT when rc%NOTFOUND;
END LOOP;
Andstr := ‘’;
Whstr :=’’;
END; ---BEGIN of FOR loop
END LOOP; -- for end
CLOSE rc;
END; -- proc end
Created above SP and its compiled. When I try to execute the SP with below code I am getting--
DECLARE
V_t LIST;
BEGIN
V_t:= LIST();
V_t.EXTEND(10);
V_t(1) := 10;
V_t(2) := 20;
Test(v_t,’25-APR-2012’,’30-APR-2012’,’Y’);
END;
The SP is building correct dynamic querry and its getting executed for id = 10 and 20, giving the correct results but though I defined only 2 ids while executing and written FOR lOOP upto ID.COUNT its building query for third time and that time its not getting id, so for the third time the last part of where clause is built like
SELECT.....
WHERE....
AND id = (its taking blank here)
GROUP BY ...;
and thus its giving me ORA 936 missing expression and ORA 06152 at line of RECORD TYPE declaration and line of OPEN rc for fullstr;
ERROR at line 1
ORA 00936 misssing expresiion
ORA 006152 at line 9
ORA 006512 at line 87
I hav put DBMS_OUTPUT statements @ every build of dynamic wuery and its correct. here I have not copid the code I hav typed hereso not wriiten DBMS_OUTPUT.
I tried lot of ways redefining Andstr := ‘’;
Whstr :=’’; after for endloop but its giving the same error. is this because I am using varray? If am providing 2 ids in anonymous block then how its building query for third blank ID value.
Please help me out here..
Thanks a lot..>
I hav written a SP and its compiled and giving me the results for the data I am quering
>
Then you should have posted the one that compiles and gives you results.
The code you posted will not compile without errors. Edit your original post and provide the corrected code.
When you do please add \ tags on the line before and after the code to preserve formatting. See the FAQ for details. -
Having errors in basic for loop
Folks
I am tring to write SQL script that implements a block that contains a for-loop which increments a counter from 1 to 10 and inserts the counter value into the results field of the LOOPING table that i have created. i want to insert a null val in place of the counter if the counter value is equal to either 6 or 8.
Below are my work
Table creation
CREATE TABLE LOOPING (Result VARCHAR2(60));
I am expecting a output like this
Result
1
2
3
4
5
NULL
7
Null
9
10
My SCRIPT
BEGIN
FOR COUNTER IN 1..10
IF ((COUNTER = 6 ) AND (COUNTER = 8 ))
THEN
INSERT INTO MESSAGES
VALUES(NULL);
ELSE
INSERT INTO MESSAGES
VALUES(COUNTER);
END LOOP;
END;
I am getting errors. I am a beginner . Please help me out .
can you point out my errors and explain
And finaly please tell me how to correct it .
Thanks
Guna1) When you get an error, it's always helpful to post the details of that error (the error number and the line number). That makes it far easier for us to help you.
2) Thank you for posting your code and table definition. That definitely helps! In the future, you'll want to use the \ tag (6 characters, all lower case) before and after any code fragments to preserve the white space & indentation. That makes your code far easier to read.
3) Your code fails to compile because
- you are missing the LOOP keyword between lines 2 and 3
- you are missing the END IF at the end of your IF statement
- you are referring to a table named MESSAGES while your CREATE TABLE statement refers to a table named LOOPING
If you correct those three errors, your code will compile
[code]
SQL> ed
Wrote file afiedt.buf
1 BEGIN
2 FOR COUNTER IN 1..10
3 LOOP -- Added
4 IF ((COUNTER = 6 ) AND (COUNTER = 8 ))
5 THEN
6 INSERT INTO looping -- Changed table name
7 VALUES(NULL);
8 ELSE
9 INSERT INTO looping -- Changed table name
10 VALUES(COUNTER);
11 END IF; -- Added
12 END LOOP;
13* END;
SQL> /
PL/SQL procedure successfully completed.
[/code]
4) However, now that the code compiles, you'll have a problem that it does not meet the requirements. It will never insert a NULL value because your IF condition is incorrect. Since this looks like a homework problem, however, I don't want to completely give it away-- I've probably done more than I should have already.
Justin -
How convert java FOR loop into taglib directive
hi all,
I have following code in my Jsp. It is working but, we dont want to use java FOR loop anymore. Instead use corresponding taglib directive.
How can i convert this Java FOR loop into taglib implementation of FOR loop ?
<%
for(int i=0;i< arrMemberBenefit.length;i++) {
pageContext.setAttribute("arrMemberBenefiti", arrMemberBenefit);
System.out.println("PCPNAME: " + arrMemberBenefit[0].getPcpName());
%>
<tr class="rowOdd">
<td headers="t1h1" class="first"><c:out value="${arrMemberBenefiti.member.firstName}${space}${arrMemberBenefiti.member.lastName}" /></td>
<td headers="t1h2" class="last"><c:out value="${arrMemberBenefiti.pcpName}" /></td>
</tr>
<%}
%>
pl any help highly apprecialted
ppUsing the JSTL forEach tag:
I have used your variable name for arrMemberBenefiti
myself I would probably call it something like memberBenefit
You may need to put the array into an attribute to begin with
// just in case
<% pageContext.setAttribute("arrMemberBenefit", arrMemberBenefit); %>
// and the actual JSTL loop
<c:forEach var="arrMemberBenefiti" items="${arrMemberBenefit}">
<tr class="rowOdd">
<td headers="t1h1" class="first"><c:out value="${arrMemberBenefiti.member.firstName}${space}${arrMemberBenefiti.member. lastName}" /></td>
<td headers="t1h2" class="last"><c:out value="${arrMemberBenefiti.pcpName}" /></td>
</tr>
</c:forEach>Cheers,
evnafets -
I know this question has probably been asked and answered before, but after searching/reading in the forums, I'm still confused.
So I would like my VI to effectively move a stage a given distance with incremental sizes with pauses of between each step.
Effectively: "Go To" _____ With X step size: causes the VI to: move, pause, move pause...etc until the stage has reached the end.
To accomplish this I set up a for loop inside a case structure, and took the "Go To" / by Step Size to get the number of iterations the loop aught to run (labview apparently rounds the double result to the integer form), and then I send the "Step Size" to the MoveAbs VI.
I am not sure if my logic is terribly off, but when I perform the command, the stage at least moves, but not to the correct location.When I inserted probes, they list the correct values being sent to the subvi's etc...
Does anyone have an idea why this would not work? Any better ideas to institute this type of motion?
Thanks
Attachments:
delayedmotiontrial2.vi 85 KBHey Tim,
I've got another question for you--I've been working on the program and I think I finally understand the basic outline. I've been trying to add other subvi's to increase functionality and I came across a problem:
The error list says that the selector values of the case structure are not unique--which is true of the program I am sending you. So naturally I deleted the extra "VI INI" which was tagged onto the default case. However doing so caused my program to crash--or more accurately cycle in an infinite loop. The program initializes over and over again. The "INI VI" sends another "INI VI" to the array and gets stuck.
I am not quite sure what is wrong, because when I looked at the original program you had sent to me, and earlier versions I had edited, I noticed that they have the same code within the "INI VI" case...in addition, now when I open previous programs--that were functioning perfectly well before--I get the same error message complaining about "not unique selector values". I honestly don't recall ever adding "INI VI" to the default case...
I am attaching the program and was wondering your thoughts, especially given the retrospective error...
Let me know if I was unclear in explaining the problem etc...and thanks again for your help. Others' input welcomed too!
Nathan
Attachments:
DelayedMotionTrial7c.vi 85 KB
State Machine States.ctl 5 KB -
I am trying to go through an array but instead of autoindexing I want to skip every other element or maybe a number of elements that will be specified for the user.
Basic functionality that I want to acheive is the following in C code.
int temp_var = 10;
int i=0;
for(i=0; i<=1000; i=i+temp_var)
I am very new to LabVIEW and I did not know how to use internal variables.
Can this be acheived using shift registers?
I am attaching the code I currently have for this. Let me know what you think.
Thanks guys.
Solved!
Go to Solution.
Attachments:
24_Sep_NchanNSamp.vi 44 KBtbob wrote:
I have been asking for a new For Loop style that would allow us to specify start, stop, and step conditions, but it seems that many people are just not for this idea. Don't know why?
See here.
I wouldn't say there aren't many people for it. The idea you linked to was one of a half dozen of basically duplicate ideas, including another one of your own.
These two ideas have a fairly large number of kudoes showing people want the idea.
Smart Iterators with Loops
For Loop Increment -
For loop stops iterating at first page
I have a loop that applies a paragraph style but it stops iterating at the first page of the document.
I need it to apply the style to the entire document...can't figure out why this isn't working.
Here is my script:
var myDocument = app.activeDocument;
var myParagraphStyle = myDocument.paragraphStyles.item("Paragraph Style");
myDocument.pages.item(0).textFrames.item(0).paragraphs.item(0).appliedParagraphStyle = myParagraphStyle;
var paragraphs = myDocument.pages.item(0).textFrames.item(0).paragraphs
for( i = 0; i < paragraphs.length; i++)
var paragraph = paragraphs.item(i)
paragraph.applyParagraphStyle(myParagraphStyle, true);
Thank youmyDocument.pages.item(0).textFrames.item(0).paragraphs.item(0).applied ParagraphStyle = myParagraphStyle;
Why do you have this line, when you iterate through the paragraphs later? (BTW: between "applied" and "ParagraphStyle" is a space)
But I think the problem is that you forgot two semicolon here:
var paragraphs = myDocument.pages.item(0).textFrames.item(0).paragraphs
(BTW: you should also call it "var myParagraphs ..." or something like that.)
and here:
var paragraph = paragraphs.item(i)
Maybe you are looking for
-
Upgraded my itunes yesterday and it failed. Tried reinstalling and failed again. Now tried to install several earlier versions and coming up with windows error 126. Do you have any ideas on how I can fix this? Please help.
-
How do I use my second hard drive for storage, not back up?
Hi, I bought a second hard drive to store files (not back-up for my system), but when I moved some files over to drive two and then deleted the same files from drive one, they also deleted from the 2nd drive! Fortunately I could reverse the process a
-
Adding video in different quality into iTunes library
I have the problem with importing my video in different quality (for iPhone 3GS, Full HD and so on) into my iTunes Library. Before upgrade of my mac pro 1.1 to Lion 10.7.5. from Snow Leo I was able to drag the whole folder with video files in differe
-
How to find the largest odd number and smallest even number from an array
Hello All I want to find out largest odd number and the smallest even number from an arry numbers? What is the best method to achieve this. Thanks Sravz
-
Hi Experts, I am finding Swaps on daily basis .we are planning to go live very soon with additional 500 users which will make total of 1000. I want to know whether I may get any issue with performance?will my system may come down with current sttting