Code Of OAF

Codes for Create , Apply ,Delete Via Image & Delete All


Code Of Application Module:-

package New_projects.oracle.apps.ak.AM1.server;

import krishna.oracle.apps.ak.SearchVendor.server.XxApSuppliersVOImpl;
import krishna.oracle.apps.ak.SearchVendor.server.XxApSuppliersVORowImpl;

import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OADBTransaction;

import oracle.jbo.RowSetIterator;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class AM1Impl extends OAApplicationModuleImpl {
    /**This is the default constructor (do not remove)
     */
    public AM1Impl() {
    }

    /**Sample main for debugging Business Components code using the tester.
     */
    public static void main(String[] args) {
        launchTester("New_projects.oracle.apps.ak.AM1.server", /* package name */
      "AM1Local" /* Configuration Name */);
    }

    /**Container's getter for VO1
     */
    public VO1Impl getVO1() {
        return (VO1Impl)findViewObject("VO1");
    }

    /**Container's getter for VO_LOV
     */
    public VO_LOVImpl getVO_LOV() {
        return (VO_LOVImpl)findViewObject("VO_LOV");
    }
    public void FilterRecords(String SearchVendorname)   
        {
            OAViewObject vo = getVO1();       
            vo.clearCache();
            vo.setWhereClauseParams(null);
            vo.setWhereClause(null);
            vo.setWhereClause("VENDOR_NAME= "+"'"+SearchVendorname+"'");       
            vo.executeQuery();
        }
  public void apply()
                   {
                       getTransaction().commit();
                   }
 public void CreateNewRecords()   
               {
                       OAViewObject vo = getVO1();
                       OADBTransaction tr = getOADBTransaction();
                      VO1RowImpl row = null;
                     vo.setMaxFetchSize(0);
                     OARow prow=(OARow)vo.createRow();
                                                        vo.last();
                                                      vo.next();
                                   vo.insertRow(prow);
    oracle.sql.NUMBER VendorId1 = tr.getSequenceValue("xx_vendor_id");
    vo.getCurrentRow().setAttribute("VendorId",VendorId1);
        vo.getCurrentRow().setAttribute("Segment1",VendorId1);
        vo.getCurrentRow().setAttribute("SummaryFlag",'N');
        vo.getCurrentRow().setAttribute("EnabledFlag",'Y');
       }

  public void deleteRecord()
      {
      OAViewObject vo = getVO1();
    
        VO1RowImpl row = null;

        int fetchedRowCount = vo.getFetchedRowCount();

       RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
        if (fetchedRowCount > 0)
        {  deleteIter.setRangeStart(0);
           deleteIter.setRangeSize(fetchedRowCount);
           for (int i = 0; i < fetchedRowCount; i++)
          {
            row = (VO1RowImpl)deleteIter.getRowAtRangeIndex(i);
            row.remove();
            getTransaction().commit();
            break;
          }
        }
       deleteIter.closeRowSetIterator();
    }
           
    public void DeleteChildrecord(String SearchVendorname1)   
            {
                    OAViewObject vo = getVO1();
                   
                      VO1RowImpl row = null;

                      int fetchedRowCount = vo.getFetchedRowCount();
    
                                                                                                                                              //   (Main VO)

                     RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
                      if (fetchedRowCount > 0)
                      {  deleteIter.setRangeStart(0);
                         deleteIter.setRangeSize(fetchedRowCount);
                         for (int i = 0; i < fetchedRowCount; i++)
                        {
                          row = (VO1RowImpl)deleteIter.getRowAtRangeIndex(i);
                            if (row.getVendorName().equals(SearchVendorname1))
                          //System.out.println("SearchVendorName1= "+row.getVendorName());
                            {
                          row.remove();
                          getTransaction().commit();
                          break;
                        }
                      }
                     deleteIter.closeRowSetIterator();
                }
            }

           
}



Code Of Controller:- /*===========================================================================+
 |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package New_projects.oracle.apps.ak.AM1.webui;

import java.io.Serializable;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

/**
 * Controller for ...
 */
public class CO1 extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
      OAApplicationModule am = pageContext.getApplicationModule(webBean) ;
      if (pageContext.getParameter("Go")!=null)
      {
            String SearchVendorname=pageContext.getParameter("Vendor_name");    
        //String SearchVendorID1=pageContext.getParameter("SearchVendorID");       
          //System.out.println("SearchVendorName1= "+SearchVendorName1);
          //System.out.println("SearchVendorID1= "+SearchVendorID1);     
      Serializable[] parameters1 = {SearchVendorname };
          am.invokeMethod("FilterRecords", parameters1);    
         }
      if (pageContext.getParameter("apply")!=null)
      {
          //System.out.println("Save Pressed= ");
          am.invokeMethod("apply");  
          String message = "Transaction Complete " +  "!"; 
          throw new OAException(message,OAException.CONFIRMATION );
      }
     
      if (pageContext.getParameter("create")!=null)
      {
          am.invokeMethod("CreateNewRecords");  
      }
     
      if (pageContext.getParameter("delete")!=null)
      {
          am.invokeMethod("deleteRecord");  
      }
     
         String Action=pageContext.getParameter(EVENT_PARAM);
         
          if(Action.equals("Delete_Row"))                                                                                           
          {
             
             
              String pvendorname=pageContext.getParameter("Pvendorid");

                                                 
              //System.out.println("Vendor id  is = "+Pvendorid);
             
              Serializable[] parameters1 = { pvendorname };
                  am.invokeMethod("DeleteChildrecord", parameters1); 
                 
              String message = "Record  Deleted " +  "!"; 
              throw new OAException(message,OAException.CONFIRMATION );
                 }    }













API to Create Responsibilities

CREATE RESPONSIBILITY

/* Formatted on 2/9/2016 10:11:52 AM (QP5 v5.149.1003.31008) */
CREATE OR REPLACE PROCEDURE XX_CREATE_RESP_PRC
IS
   /*
   CREATE TABLE APPS.XX_CREATE_RESP_STG
   (
     USER_NAME            VARCHAR2(100 BYTE),
     RESPONSIBILITY_NAME  VARCHAR2(300 BYTE),
     START_DATE           DATE,
     END_DATE             DATE,
     STATUS               VARCHAR2(100 BYTE),
     ERROR                VARCHAR2(1000 BYTE)
   ) */

   CURSOR c1
   IS
      SELECT ROWID, t.*
        FROM XX_CREATE_RESP_STG t;

   l_user_name              VARCHAR2 (100);
   l_resp_appl_short_name   VARCHAR2 (100);
   l_responsibility_key     VARCHAR2 (100);
   l_responsibility_name    VARCHAR2 (111) := NULL;
   security_group_key       VARCHAR2 (100);
   v_status                 VARCHAR2 (111);
   l_ERROR                  VARCHAR2 (1000);
   v_error                  VARCHAR2 (111) := NULL;
BEGIN
   FOR i IN c1
   LOOP
      BEGIN
         SELECT user_name
           INTO l_user_name
           FROM fnd_user
          WHERE user_name = i.user_name;

         DBMS_OUTPUT.put_line ('User name  :=' || l_user_name);

         v_status := 'S';
      EXCEPTION
         WHEN OTHERS
         THEN
            v_status := NULL;
      END;

      BEGIN
         SELECT res.RESPONSIBILITY_NAME
           INTO l_responsibility_name
           FROM apps.FND_USER usr,
                apps.FND_RESPONSIBILITY_TL res,
                apps.FND_USER_RESP_GROUPS grp
          WHERE     grp.responsibility_id = res.responsibility_id
                AND grp.user_id = usr.user_id
                AND usr.USER_NAME = i.user_name
                AND res.RESPONSIBILITY_NAME = i.RESPONSIBILITY_NAME;

         DBMS_OUTPUT.
          put_line ('responsibility_name  :=   ' || l_responsibility_name);
      EXCEPTION
         WHEN OTHERS
         THEN
            l_responsibility_name := NULL;
      END;

      BEGIN
         SELECT res.responsibility_key, app.application_short_name
           INTO l_responsibility_key, l_resp_appl_short_name
           FROM fnd_responsibility_vl res, fnd_application_vl app
          WHERE res.responsibility_name = i.RESPONSIBILITY_NAME
                AND res.application_id = app.application_id;

         DBMS_OUTPUT.
          put_line (
               'responsibility_key :-  '
            || l_responsibility_key
            || '  '
            || 'short name :-  '
            || l_resp_appl_short_name);
      END;

      BEGIN
         IF v_status = 'S' AND l_responsibility_name is NULL
         THEN
            fnd_user_pkg.addresp (username         => l_user_name,
                                  resp_app         => l_resp_appl_short_name,
                                  resp_key         => l_responsibility_key,
                                  security_group   => 'STANDARD',
                                  description      => NULL,
                                  start_date       => i.start_date,
                                  end_date         => NULL);

            UPDATE APPS.XX_CREATE_RESP_STG T
               SET T.status = 'V', T.ERROR = 'Success'
             WHERE ROWID = i.ROWID;

            DBMS_OUTPUT.put_line ('IN API CREATED');

            COMMIT;
         ELSE
            UPDATE APPS.XX_CREATE_RESP_STG T
               SET T.status = 'E', T.ERROR = 'Already Available'
             WHERE ROWID = i.ROWID;

            DBMS_OUTPUT.
             put_line ('User Responsibility Already Available---------');
            COMMIT;
         END IF;
      END;

      v_status := NULL;
      v_error := NULL;
      l_user_name := NULL;
      l_resp_appl_short_name := NULL;
      l_responsibility_key := NULL;
      l_responsibility_name := NULL;
      security_group_key := NULL;
   END LOOP;
END;

exec XX_CREATE_RESP_PRC;

SELECT * FROM XX_CREATE_RESP_STG