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;
    }


Multiple Checkbox and Concatenating select flag values

Multiple Checkbox:
  • In the selected VO create a one transient variable like selected flag.
  • In the table region we create one multiple selection
  • Under the multiple selection assign the selected flag value using view instance and view attribute.

Concatenating using selected flag under selected values

            OAViewObject vo = (OAViewObject)am.findViewObject("Name of VO1");
           
            if(vo.isPreparedForExecution()){
                Row row[] = vo.getFilteredRows("SelectFlag","Y"); // Added for multiple select
               
                if(row.length < 1)  {
                       OAException exception = new OAException("Please Select atleast one serial number for reservation", OAException.WARNING);
                       pageContext.putDialogMessage(exception);  
                }
                else{
                        String totalserialnumber = "";
                        int j =0;
                        for (int i=0;i<row.length;i++){
                            String lvserialnumber = "";
                            Name of VORowImpl rowi = (Name of VORowImpl)row[i];
                           
                            if (rowi.getSelectFlag()!= null && rowi.getSelectFlag().equals("Y")){
                                j=j+1;
                                if(rowi.getSerialNumber()!=null && rowi.getSerialNumber().length()>0 ){
                                    lvserialnumber =rowi.getSerialNumber();
                                    }                          
                                if(lvserialnumber != null && lvserialnumber.length()>0 && j==1){
                                     totalserialnumber = lvserialnumber;
                                     }
                                else if(lvserialnumber != null && lvserialnumber.length()>0 && j>1){
                                     totalserialnumber = totalserialnumber+"|"+lvserialnumber;
                                } 
                                                 
                            }

                        }

Clear And Cancel Buttons

Handling on Clear Button:
Code for CO

Take the Item style to button and Action type fire action and event clear

if("clear".equals(pageContext.getParameter(EVENT_PARAM))){

OAMessageLovInputBean OAitem=(OAMessageLovInputBean)webBean.findChildRecursive("ItemName");

 OAitem.setValue(pageContext,null);
             
OAMessageTextInputBean omtb = (OAMessageTextInputBean)webBean.findChildRecursive("Quantaty");

omtb.setValue(pageContext,null);
             
 }
  
Cancel button:

Code for Co:

 using url and passing parameter to get main page

  if ("Cancel".equals(pageContext.getParameter(EVENT_PARAM))){
         HashMap map = new HashMap();
         String pProcessId = pageContext.getParameter("PrcId");
         map.put("rcId", ProcessId);
         pageContext.setForwardURL("OA.jsp? page=/xxxx/oracle/apps/fnd/test/webui/namePG",
                                                  null,
                                                  OAWebBeanConstants.KEEP_MENU_CONTEXT,
                                                  null,
                                                  map,
                                                  false,
                                                  OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
                                                  OAWebBeanConstants.IGNORE_MESSAGES); 
                     }


Creating form value and Search button code

Form value:
  • Form values assign only used in lovmappings
  • In the messagelayoutlovinputregion item under column take form value under the form value mapping return item and criteria item giving to another form value name.
  • Passing parameters using this code.

Under this code write only co;
             
OAFormValueBean itemfv = (OAFormValueBean)webBean.findChildRecursive("ItemIDFV");

String itemno = (String)itemfv.getValue(pageContext);

Search Button:
Code For CO:

if(pageContext.getParameter("searchId")!=null){
    try{
OAFormValueBean itemfv = (OAFormValueBean)webBean.findChildRecursive("ItemIDFV");
          String itemno = (String)itemfv.getValue(pageContext);
      
          String lotnumber =  pageContext.getParameter("LOtNumber");
          String serialstart = pageContext.getParameter("serialstart");
          String serialend = pageContext.getParameter("serialend");
              
          Serializable param[] = {itemno,lotnumber,serialstart,serialend};
          am.invokeMethod("initdetails",param);
         }
         catch (Exception e) {
             OAException.wrapperException(e);
          }
      }

AMIMPL code:

    public void initdetails(String itemid, String lotnumber ,String serialstart , String serialend){
        VOImpl vo = getVO1();
        try{
            vo.clearCache();
            vo.setWhereClause(null);
            vo.setWhereClauseParam(0,itemid);
            vo.setWhereClauseParam(2,lotnumber);
            vo.setWhereClauseParam(3,serialstart);
            vo.setWhereClauseParam(4,serialend);
            vo.executeQuery();
        }
        catch(Exception e){
            throw OAException.wrapperException(e);
         }
    }

OAF LOV Dependence

Lov Dependences

              MainRN --           Id : MainRN
                                       Region Style : pageLayout
                                       AM Definiton: Add that page location
                                       Windows title & title : same to display the page and load url

             MessageLayoutRN --        Id : MessageLayoutRN
                                                    Region Style : Message Component Layout

  • Right click on message layout region and select “Message layout lov input region”
  • We have to take two message layout lov input regions
  • If you want attribute from out side take one vo and the querry is created to asking the attribute like (select empno from emp where empno = :1).
  • Then you take one form value and assign the outside attribute to created form value using view instance and view attribute.
  • In the message layout lov input region under one item
  • In the item under one region and one lovmappings
  • Region using table region wizard and getting the columns in table using vo
  • Lovmapping based on columns take love maps 
  • Each map lov region item assign the column name
  • First map assign return item and criteria item giving to main item name.
  • Second and remaing maps only giving to criteria item only.
  • In the second message layout lov input region giving to same but the second lovmapping criteria item giving to first item colum based form valu name.
Code for co:

        if("ItemName".equals(pageContext.getLovInputSourceId())){ 
                      am.invokeMethod("xxipGetItems");
                  }

Code for AMIMPL:

    public void xxxGetItems(){
        LOVVOImpl vo = getLOVVO1();
        try{
            vo.clearCache();
            vo.setWhereClause(null);
            vo.setWhereClauseParams(null);
            vo.executeQuery();
        }
        catch(Exception e){
            throw OAException.wrapperException(e);
         }
    }


27-03-2019

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