Thursday, 18 May 2017

Oracle Package using callable statement:

Oracle Package using callable statement:

Code for co:
                        try{
                              String rocid = "100023";  //pageContext.getParameter("LINE_ID");
                              String mponent = pageContext.getParameter("Name");
                              String lots = pageContext.getParameter("Number");
                             
                              OAFormValueBean item = (OAFormValueBean)webBean.findChildRecursive("Item");
                              String component_item_id = (String)item.getValue(pageContext);
                             
                              String qty = pageContext.getParameter("Quantaty");
                              Serializable pars[] = {cid,component,lot,totalserialnumber,item_id,qty};
                              String[] msgs=(String[])am.invokeMethod("methodname",pars);
                             
                              String succflag = null;
                              String msg = null;
                              
                              if(msgs.length>0){
                                  succflag = msgs[1];
                                  msg = msgs[2];
                                 
                                  if(msg!=null && msg.length()>0) {
                                        if(succflag.equals("Y")){
                                            OAException exception = new OAException(msg, OAException.INFORMATION);
                                            pageContext.putDialogMessage(exception);   
                                        }
                                        else{
                                            OAException exception = new OAException(msg, OAException.ERROR);
                                            pageContext.putDialogMessage(exception); 
                                        }
                                }
                            }
                        }
                        catch (Exception e) {
                             OAException.wrapperException(e);               
                        }


Code for AMIMPL:

    public String[] methodname(String p_procid, String p_componentid, String p_LotNum, String p_SerNum, String p_itemid, String p_qty){   
        int lv_procno = 0;
        int lv_itemid = 0;
        int lv_qty    = 0;
        String fg_alloc_id = null;
        String child_proc_id = null;
        int raw_alloc_id = -1;
           
        lv_procno = Integer.parseInt(p_procid);
        lv_itemid = Integer.parseInt(p_itemid);
        lv_qty   = Integer.parseInt(p_qty);
       
        StringBuffer str = new StringBuffer();
        str.append( " BEGIN ");
        str.append( " packagename.procedurename ( ");
        str.append( " proc_id => :1, ");
        str.append( " item => :2, ");
        str.append( "lot => :3, ");
        str.append( " numbers => :4, ");
        str.append( " item_id => :5, ");
        str.append( " qty => :6, ");
        str.append( " id => :7, ");
        str.append( " oc_id => :8, ");
        str.append( " xid => :9, ");
        str.append( " xflag    => :10, ");
        str.append( " xge => :11  ");
        str.append( " ); ");
        str.append( " END; ");
           
        OADBTransaction oa = (OADBTransaction)getTransaction();
        OracleCallableStatement cs = (OracleCallableStatement)oa.createCallableStatement(str.toString(), 1); 
       
        String msgs[]=new String[3];
        String SuccFlag;
        String ErrMsg;
        String rawalloc;
        try{
            cs.setInt(1,lv_procno );
            cs.setString(2,p_componentid);
            cs.setString(3,p_LotNum );
            cs.setString(4,p_SerNum);
            cs.setInt(5,lv_itemid );
            cs.setInt(6,lv_qty);
            cs.setString(7,fg_alloc_id );
            cs.setString(8,child_proc_id);
            cs.setInt(9,  raw_alloc_id );
           
            cs.registerOutParameter(9, Types.INTEGER);
            cs.registerOutParameter(10,Types.VARCHAR);
            cs.registerOutParameter(11,Types.VARCHAR);
           
            cs.execute();
            oa.commit();
           
            rawalloc = cs.getString(9).toString();
            SuccFlag = cs.getString(10);
            ErrMsg   = cs.getString(11);
           
            msgs[0]  = rawalloc;
            msgs[1]  = SuccFlag;
            msgs[2]  = ErrMsg;
        }  
        catch(Exception e){
            OAException.wrapperException(e);
        }
            return msgs;
    }


No comments:

Post a Comment

27-03-2019

                                                                  Apex Project Creation 1. Create new project and select desktop applicat...