public Boolean setDependentFieldsOnEnteringPluCode(String pluCode,String compCode,Row invDtlCurRow){
System.out.println("Checking ****");
CallableStatement cstmt=null;
ResultSet rs=null;
String funName = "{?= call pos_invoice_pkg.Get_Plu_Dtls(?,?)}";
cstmt = CommonCode.getAM().getDBTransaction().createCallableStatement(funName, 0);
try {
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.setString(2, compCode);
cstmt.setString(3, pluCode);
cstmt.execute();
rs =((OracleCallableStatement) cstmt).getCursor(1);
if(rs.next()){
System.out.println("****Entered into if******");
if(invDtlCurRow.getAttribute("ProdCode") == null)
invDtlCurRow.setAttribute("ProdCode",rs.getString("Prod_code"));
if(invDtlCurRow.getAttribute("ProdId") == null)
invDtlCurRow.setAttribute("ProdId", rs.getBigDecimal("Prod_id"));
if(invDtlCurRow.getAttribute("Atr1Code") == null)
invDtlCurRow.setAttribute("Atr1Code", rs.getString("ATR1_CODE"));
if(invDtlCurRow.getAttribute("Atr1Id") == null)
invDtlCurRow.setAttribute("Atr1Id", rs.getBigDecimal("ATR1_id"));
if(invDtlCurRow.getAttribute("Atr2Code") == null)
invDtlCurRow.setAttribute("Atr2Code", rs.getString("ATR2_CODE"));
if(invDtlCurRow.getAttribute("Atr2Id") == null)
invDtlCurRow.setAttribute("Atr2Id", rs.getBigDecimal("ATR2_id"));
invDtlCurRow.setAttribute("ProdType", rs.getString("PROD_TYPE"));
invDtlCurRow.setAttribute("TProdCatCode", rs.getString("CAT_CODE"));
invDtlCurRow.setAttribute("TSaleAllowedYN", rs.getString("SALE_ALLOWED_YN"));
invDtlCurRow.setAttribute("Iskit", rs.getString("KITPROD_YN"));
invDtlCurRow.setAttribute("TWarrantyRefCode", rs.getString("WARRANTY_REF"));
invDtlCurRow.setAttribute("TIsWarrantyReqYn", rs.getString("WARRANTY_YN"));
invDtlCurRow.setAttribute("WarrantyRef", rs.getString("WARRANTY_REF"));
System.out.println("***After setting valuse******");
}else{
return false;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
cstmt.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
return true;
}
function with sysrefcursor return
Function Get_Plu_Dtls (p_comp varchar2, p_plucode varchar2 )
return sys_refcursor
is
v_plulen number ;
o_cursor sys_refcursor ;
Begin
select length(p_plucode) into v_plulen from dual ;
If v_plulen >= 13 then
open o_cursor
for
select
a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
b.atr_id atr1_id, c.atr_id atr2_id , d.prod_type ,
nvl(d.kitprod_yn,decode(d.prod_type,'K','Y','N')) kitprod_yn, a.sup_barcode,
d.cat_code, nvl(e.sale_allowed_yn,'N') sale_allowed_yn,d.warranty_yn,d.warranty_ref
from (select a.comp_code, a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
a.plu_code, a.plu_id, a.crtd_by, a.crtd_dt, a.updt_by, a.updt_dt,
a.crtd_ip, a.updt_ip,'N' is_Sup_barcode,a.sup_barcode
From pi_prod_plu a
) a,
pi_prod_atr1_vu b ,
pi_prod_atr2_vu c ,
pi_product_mst d,
pi_prod_stat_mst e
where a.atr1_code = b.atr_code(+)
and a.comp_code = b.comp_code(+)
and a.prod_id = b.prod_id(+)
and a.atr2_code = c.atr_code(+)
and a.comp_code = c.comp_code(+)
and a.prod_id = c.prod_id(+)
and a.prod_id = d.prod_id and a.comp_code = d.comp_code
and d.comp_code = e.comp_code
and e.prod_stat_code = d.status_code
and Nvl(d.invoice_yn,'N') = 'Y'
and Nvl(d.active_yn,'Y') = 'Y'
and a.comp_code = p_comp
and a.sup_barcode = p_plucode ;
Else
open o_cursor
for
select
a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
b.atr_id atr1_id, c.atr_id atr2_id , d.prod_type ,
nvl(d.kitprod_yn,decode(d.prod_type,'K','Y','N')) kitprod_yn, a.sup_barcode,
d.cat_code, nvl(e.sale_allowed_yn,'N') sale_allowed_yn,d.warranty_yn,d.warranty_ref
from (select a.comp_code, a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
a.plu_code, a.plu_id, a.crtd_by, a.crtd_dt, a.updt_by, a.updt_dt,
a.crtd_ip, a.updt_ip,'N' is_Sup_barcode,a.sup_barcode
From pi_prod_plu a
) a,
pi_prod_atr1_vu b ,
pi_prod_atr2_vu c ,
pi_product_mst d,
pi_prod_stat_mst e
where a.atr1_code = b.atr_code(+)
and a.comp_code = b.comp_code(+)
and a.prod_id = b.prod_id(+)
and a.atr2_code = c.atr_code(+)
and a.comp_code = c.comp_code(+)
and a.prod_id = c.prod_id(+)
and a.prod_id = d.prod_id and a.comp_code = d.comp_code
and d.comp_code = e.comp_code
and e.prod_stat_code = d.status_code
and Nvl(d.invoice_yn,'N') = 'Y'
and Nvl(d.active_yn,'Y') = 'Y'
and a.comp_code = p_comp
and a.plu_code = p_plucode ;
End If;
return o_cursor;
End Get_Plu_Dtls;
System.out.println("Checking ****");
CallableStatement cstmt=null;
ResultSet rs=null;
String funName = "{?= call pos_invoice_pkg.Get_Plu_Dtls(?,?)}";
cstmt = CommonCode.getAM().getDBTransaction().createCallableStatement(funName, 0);
try {
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.setString(2, compCode);
cstmt.setString(3, pluCode);
cstmt.execute();
rs =((OracleCallableStatement) cstmt).getCursor(1);
if(rs.next()){
System.out.println("****Entered into if******");
if(invDtlCurRow.getAttribute("ProdCode") == null)
invDtlCurRow.setAttribute("ProdCode",rs.getString("Prod_code"));
if(invDtlCurRow.getAttribute("ProdId") == null)
invDtlCurRow.setAttribute("ProdId", rs.getBigDecimal("Prod_id"));
if(invDtlCurRow.getAttribute("Atr1Code") == null)
invDtlCurRow.setAttribute("Atr1Code", rs.getString("ATR1_CODE"));
if(invDtlCurRow.getAttribute("Atr1Id") == null)
invDtlCurRow.setAttribute("Atr1Id", rs.getBigDecimal("ATR1_id"));
if(invDtlCurRow.getAttribute("Atr2Code") == null)
invDtlCurRow.setAttribute("Atr2Code", rs.getString("ATR2_CODE"));
if(invDtlCurRow.getAttribute("Atr2Id") == null)
invDtlCurRow.setAttribute("Atr2Id", rs.getBigDecimal("ATR2_id"));
invDtlCurRow.setAttribute("ProdType", rs.getString("PROD_TYPE"));
invDtlCurRow.setAttribute("TProdCatCode", rs.getString("CAT_CODE"));
invDtlCurRow.setAttribute("TSaleAllowedYN", rs.getString("SALE_ALLOWED_YN"));
invDtlCurRow.setAttribute("Iskit", rs.getString("KITPROD_YN"));
invDtlCurRow.setAttribute("TWarrantyRefCode", rs.getString("WARRANTY_REF"));
invDtlCurRow.setAttribute("TIsWarrantyReqYn", rs.getString("WARRANTY_YN"));
invDtlCurRow.setAttribute("WarrantyRef", rs.getString("WARRANTY_REF"));
System.out.println("***After setting valuse******");
}else{
return false;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
cstmt.close();
} catch (SQLException sqle) {
sqle.printStackTrace();
}
}
return true;
}
function with sysrefcursor return
Function Get_Plu_Dtls (p_comp varchar2, p_plucode varchar2 )
return sys_refcursor
is
v_plulen number ;
o_cursor sys_refcursor ;
Begin
select length(p_plucode) into v_plulen from dual ;
If v_plulen >= 13 then
open o_cursor
for
select
a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
b.atr_id atr1_id, c.atr_id atr2_id , d.prod_type ,
nvl(d.kitprod_yn,decode(d.prod_type,'K','Y','N')) kitprod_yn, a.sup_barcode,
d.cat_code, nvl(e.sale_allowed_yn,'N') sale_allowed_yn,d.warranty_yn,d.warranty_ref
from (select a.comp_code, a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
a.plu_code, a.plu_id, a.crtd_by, a.crtd_dt, a.updt_by, a.updt_dt,
a.crtd_ip, a.updt_ip,'N' is_Sup_barcode,a.sup_barcode
From pi_prod_plu a
) a,
pi_prod_atr1_vu b ,
pi_prod_atr2_vu c ,
pi_product_mst d,
pi_prod_stat_mst e
where a.atr1_code = b.atr_code(+)
and a.comp_code = b.comp_code(+)
and a.prod_id = b.prod_id(+)
and a.atr2_code = c.atr_code(+)
and a.comp_code = c.comp_code(+)
and a.prod_id = c.prod_id(+)
and a.prod_id = d.prod_id and a.comp_code = d.comp_code
and d.comp_code = e.comp_code
and e.prod_stat_code = d.status_code
and Nvl(d.invoice_yn,'N') = 'Y'
and Nvl(d.active_yn,'Y') = 'Y'
and a.comp_code = p_comp
and a.sup_barcode = p_plucode ;
Else
open o_cursor
for
select
a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
b.atr_id atr1_id, c.atr_id atr2_id , d.prod_type ,
nvl(d.kitprod_yn,decode(d.prod_type,'K','Y','N')) kitprod_yn, a.sup_barcode,
d.cat_code, nvl(e.sale_allowed_yn,'N') sale_allowed_yn,d.warranty_yn,d.warranty_ref
from (select a.comp_code, a.prod_code, a.prod_id, a.atr1_code, a.atr2_code,
a.plu_code, a.plu_id, a.crtd_by, a.crtd_dt, a.updt_by, a.updt_dt,
a.crtd_ip, a.updt_ip,'N' is_Sup_barcode,a.sup_barcode
From pi_prod_plu a
) a,
pi_prod_atr1_vu b ,
pi_prod_atr2_vu c ,
pi_product_mst d,
pi_prod_stat_mst e
where a.atr1_code = b.atr_code(+)
and a.comp_code = b.comp_code(+)
and a.prod_id = b.prod_id(+)
and a.atr2_code = c.atr_code(+)
and a.comp_code = c.comp_code(+)
and a.prod_id = c.prod_id(+)
and a.prod_id = d.prod_id and a.comp_code = d.comp_code
and d.comp_code = e.comp_code
and e.prod_stat_code = d.status_code
and Nvl(d.invoice_yn,'N') = 'Y'
and Nvl(d.active_yn,'Y') = 'Y'
and a.comp_code = p_comp
and a.plu_code = p_plucode ;
End If;
return o_cursor;
End Get_Plu_Dtls;
Comments
Post a Comment