Tuesday, June 20, 2017

Creating Materialized View Using AD_MV.CREATE_MV


begin
ad_mv.create_mv('XXABC_TEST_MV',
'create materialized view XXABC_TEST_MV'||
' build deferred refresh on demand as '||
' select /*AUTOREFRESH*/  * from per_jobs');
end;

Note:  While using this ad_mv.create_mv, you should not call plsql function, procedure calls in the MV sql statement.

Thursday, March 30, 2017

Custom OAF Pages (Non Standard Location ) Deployment in R12.2.4,2.5

Please follow below steps to deploy non standard location ( ex /oracle/apps/xxcust/.... or /oracle/apps/po/xxcust/.....)  custom oaf pages in EBS R12.2.X


1. zip -r customprod.zip oracle/apps/xxcust


2. adjava oracle.apps.ad.jri.adjmx -areas $JAVA_TOP/customprod.zip -outputFile 

$JAVA_TOP/customprod.jar -jar $CONTEXT_NAME 1 CUST jarsigner -storePass -keyPass 

3. rm $JAVA_TOP/customprod.zip 


4. below is  not necessary 
    cd /apps/R12VIS/fs2/EBSapps/appl/fnd/12.0.0/admin/template    ebsProductManifest_xml.tmp    <library>customprod.jar</library>     but tried

5. Run auto config adautocfg.sh


6. bounce

cd $ADMIN_SCRIPTS_HOME

./admanagedsrvctl.sh stop oacore_server1
./adapcctl.sh stop
./adapcctl.sh start
./admanagedsrvctl.sh start oacore_server1



Thursday, February 23, 2017

concurrent executables method codes


,      execution_method_code in fnd_executables

 

               'A', 'Spawned'
             , 'B', 'Request Set Stage Function'
             , 'E', 'Perl Concurrent Program'
             , 'H', 'Host'
             , 'I', 'PL/SQL Stored Procedure'
             , 'J', 'Java Stored Procedure'
             , 'K', 'Java Concurrent Program'
             , 'L', 'SQL*Loader'
             , 'M', 'Multi Language Function'
             , 'P', 'Oracle Reports'
             , 'Q', 'SQL*Plus'
             , 'S', 'Immediate'

Tuesday, February 21, 2017

Item Sub Inventories Conversion Script

Staging Table Script:


  CREATE TABLE XXXX_INV_ITEM_SUB_INV_STG
   ( "OLD_INV_ORGANIZATION_CODE" VARCHAR2(250 BYTE), 
"INVENTORY_ORGANIZATION_CODE" VARCHAR2(250 BYTE), 
"OLD_SUBINVENTORY" VARCHAR2(250 BYTE), 
"SUBINVENTORY_CODE" VARCHAR2(250 BYTE), 
"OLD_ITEM_CODE" VARCHAR2(250 BYTE), 
"ITEM_CODE" VARCHAR2(250 BYTE), 
"DESCRIPTION" VARCHAR2(250 BYTE), 
"MIN_MAX_PLANNING" VARCHAR2(250 BYTE), 
"MIN_QTY" NUMBER, 
"MAX_QTY" NUMBER, 
"OLD_UNIT_OF_MEASURE" VARCHAR2(250 BYTE), 
"UOM" VARCHAR2(250 BYTE), 
"ORDER_MOD_FIX_LOT_MULTIPLE" VARCHAR2(250 BYTE), 
"SOURCING_TYPE" VARCHAR2(250 BYTE), 
"SOURCING_ORGANIZATION" VARCHAR2(250 BYTE), 
"OLD_SOURCING_SUBINVENTORY" VARCHAR2(250 BYTE), 
"SOURCING_SUBINVENTORY" VARCHAR2(250 BYTE), 
"ERROR_MSG" VARCHAR2(4000 BYTE), 
"STATUS" VARCHAR2(100 BYTE), 
"REFERENCE1" VARCHAR2(150 BYTE), 
"PROGRAM_ID" NUMBER, 
"SOURCE" VARCHAR2(20 BYTE)
   );

Package Specification ;


CREATE OR REPLACE PACKAGE xxxx_item_sub_inv_conv_pkg
AS
   PROCEDURE xxxx_item_sub_inv_conv_proc (
      errbuff     OUT      VARCHAR2,
      retcode     OUT      NUMBER);
END xxxx_item_sub_inv_conv_pkg;
/

Package Body ;

CREATE OR REPLACE PACKAGE BODY APPS.xxxx_item_sub_inv_conv_pkg
AS
   PROCEDURE xxxx_item_sub_inv_conv_proc (
      errbuff     OUT      VARCHAR2,
      retcode     OUT      NUMBER)
   AS
      CURSOR c_sub_inv
      IS
         SELECT old_inv_organization_code,inventory_organization_code,old_subinventory,subinventory_code,
               OLD_ITEM_CODE,ITEM_CODE,DESCRIPTION,MIN_MAX_PLANNING,MIN_QTY,MAX_QTY,OLD_UNIT_OF_MEASURE,
               uom,order_mod_fix_lot_multiple,
               DECODE(sourcing_type,'Subinventory',3,'Supplier',2,'Inventory',1,sourcing_type) sourcing_type,
               SOURCING_ORGANIZATION,OLD_SOURCING_SUBINVENTORY,SOURCING_SUBINVENTORY
               FROM xxxx_inv_item_sub_inv_stg xis
          WHERE status = 'V'
          AND NOT EXISTS (SELECT 1
                         FROM mtl_item_sub_inventories   misi
                              ,mtl_secondary_inventories msi
                              ,mtl_system_items_b        msb
                              ,mtl_parameters            mp
                         WHERE 1=1
                         AND misi.inventory_item_id=msb.inventory_item_id
                         AND misi.organization_id= msb.organization_id
                         AND misi.secondary_inventory=msi.secondary_inventory_name
                         AND misi.organization_id=mp.organization_id
                         AND mp.organization_code=xis.inventory_organization_code
                         AND msb.segment1=xis.item_code
                         AND msi.secondary_inventory_name=xis.subinventory_code);

      ln_org_id        NUMBER;
      ln_item_id       NUMBER;
      ln_source_org    NUMBER;
      LN_CONC_REQ_ID   number;
      LN_PROCESSED     number:= 0;
      ln_not_processed number:= 0;
      lc_error_msg     VARCHAR2 (4000);
      lc_error_flag    VARCHAR2 (1);
      LN_COUNT1        number          := 0;
      lc_ins_err       VARCHAR2(1000);
      ln_inventory_planning_code  NUMBER;
     
   BEGIN
      LN_CONC_REQ_ID := FND_PROFILE.value ('CONC_REQUEST_ID');
      FND_FILE.PUT_LINE(FND_FILE.log,' CONC_REQUEST_ID : '||LN_CONC_REQ_ID);
      FOR a_cur IN c_sub_inv
      LOOP
        LC_ERROR_FLAG:='N';      
         begin
              SELECT organization_id INTO ln_org_id FROM org_organization_definitions
               WHERE organization_code = a_cur.inventory_organization_code;
 
              SELECT inventory_item_id INTO ln_item_id FROM mtl_system_items_b
               WHERE segment1 = a_cur.item_code AND organization_id = ln_org_id;

              begin
                    SELECT organization_id INTO ln_source_org FROM org_organization_definitions
                     where ORGANIZATION_CODE = A_CUR.SOURCING_ORGANIZATION;
              EXCEPTION
                  when NO_DATA_FOUND then
                        ln_source_org:='';
                  WHEN OTHERS THEN
                        fnd_file.put_line (fnd_file.LOG, SQLERRM||' Error occured while fetching source organization.');
              END;

           UPDATE xxxx_inv_item_sub_inv_stg SET program_id = ln_conc_req_id WHERE status = 'V'
               AND old_inv_organization_code = a_cur.old_inv_organization_code
               AND old_subinventory = a_cur.old_subinventory
               and OLD_ITEM_CODE = A_CUR.OLD_ITEM_CODE;
            COMMIT;
         EXCEPTION
            WHEN OTHERS
            then
               lc_error_flag='Y';
               lc_error_msg := SQLERRM;
               xxxx_conv_error_insert_proc ('ITEM SUBINVENTORY','I','PROGRAM_ID',ln_conc_req_id,lc_error_msg,ln_conc_req_id,NULL,NULL,NULL,NULL,lc_ins_err);
               fnd_file.put_line (fnd_file.LOG,'Error in Fetching Program Id');
         END;

         begin
            SELECT DECODE(a_cur.min_qty,NULL,6,2) INTO ln_inventory_planning_code FROM dual;
           
            fnd_file.put_line (fnd_file.LOG,'enters into sub inventory loop with -'
                               || a_cur.inventory_organization_code ||'-'||ln_item_id||'-'||a_cur.max_qty||'-'||a_cur.min_qty||'-'||ln_org_id||'-'||
                             a_cur.subinventory_code||'-'|| ln_source_org||'-'||a_cur.sourcing_subinventory||'-'||a_cur.sourcing_type
                              );

            INSERT INTO mtl_item_sub_inventories
                        (created_by, creation_date, inventory_item_id,
                         inventory_planning_code, last_update_date,
                         last_update_login,
                         last_updated_by, max_minmax_quantity,
                         min_minmax_quantity, organization_id,
                         secondary_inventory, source_organization_id,
                         source_subinventory, source_type
                        )
                 VALUES (fnd_profile.VALUE ('USER_ID'), SYSDATE, ln_item_id,
                         ln_inventory_planning_code,                         --INVENTORY_PLANNING_CODE,
                           SYSDATE,
                         fnd_profile.VALUE ('USER_ID'),
                         fnd_profile.VALUE ('USER_ID'), a_cur.max_qty,
                         a_cur.min_qty, ln_org_id,
                         a_cur.subinventory_code, ln_source_org,
                         a_cur.sourcing_subinventory, a_cur.sourcing_type
                        );

            fnd_file.put_line (fnd_file.LOG,'Inserted into Item Sub Inventories Table');
            commit;
         EXCEPTION
            WHEN OTHERS
            THEN
               lc_error_flag := 'Y';
               LC_ERROR_MSG :=SQLERRM;
               xxxx_conv_error_insert_proc ('ITEM SUBINVENTORY','I','Insertion','Organization_code : '||a_cur.old_inv_organization_code||'Subinventory : '||a_cur.old_subinventory||'Item Code : '||A_CUR.OLD_ITEM_CODE,lc_error_msg,ln_conc_req_id,NULL,NULL,NULL,NULL,lc_ins_err);
               fnd_file.put_line(fnd_file.LOG,'Exception Occured  while inserting into Item Sub Inventories '|| SQLERRM);
         END;

         BEGIN
            IF lc_error_flag = 'Y' THEN
               UPDATE xxxx_inv_item_sub_inv_stg
                  SET status = 'E',error_msg=lc_error_msg
                WHERE old_inv_organization_code =a_cur.old_inv_organization_code
                  AND old_subinventory = a_cur.old_subinventory
                  AND old_item_code = a_cur.old_item_code
                  and PROGRAM_ID = LN_CONC_REQ_ID;
              commit;
               LN_NOT_PROCESSED := LN_NOT_PROCESSED + 1;
               fnd_file.put_line (fnd_file.LOG,'Error Occurred status set to E');
            ELSE
               UPDATE xxxx_inv_item_sub_inv_stg
                  SET status = 'P'
                WHERE old_inv_organization_code =a_cur.old_inv_organization_code
                  AND old_subinventory = a_cur.old_subinventory
                  AND old_item_code = a_cur.old_item_code
                  and PROGRAM_ID = LN_CONC_REQ_ID;
                commit;
                  LN_PROCESSED:=LN_PROCESSED+1;
               fnd_file.put_line (fnd_file.LOG, 'Record is Processed status set to P');
            END IF;
         END;
      END LOOP;
      FND_FILE.PUT_LINE (FND_FILE.log,'Number of Records Processed : '||LN_PROCESSED);
      fnd_file.put_line (fnd_file.LOG,'Number of Records Not Processed : '||ln_not_processed);
   END xxxx_item_sub_inv_conv_proc;
END xxxx_item_sub_inv_conv_pkg;
/

Thursday, February 16, 2017

comparision of dates in CO class file


Comparision of Dates in Controller

1)  

    Date StartDate= (Date)CurrentRow.getAttribute("StartDate");
    Date CurrentDate = (Date)am.getOADBTransaction().getCurrentDBDate();
    java.sql.Date sdate = (java.sql.Date) StartDate.dateValue();
    java.sql.Date cdate = (java.sql.Date) CurrentDate.dateValue();
    int days = daysBetween(sdate,cdate );
 
  public int daysBetween(java.sql.Date d1, java.sql.Date d2){
     return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
         }


2)

OAViewObject oaviewobject1 = (OAViewObject)am.findViewObject("NewEmployeeVO1");

System.out.println("1");
if (oaviewobject1 != null)
{
System.out.println("Inside");
oaviewobject1.reset(); //New line added
oaviewobject1.next(); //new line added
OARow row = (OARow)oaviewobject1.getCurrentRow();


Date sDate =(Date)row.getAttribute("EffectiveStartDate");

Date eDate =(Date)row.getAttribute("EffectiveEndDate");
java.util.Date VChangeDateTime =
new java.util.Date(sDate.timestampValue().getTime());

if (sDate !=null && eDate !=null)
{
long m1 = sDate.timestampValue().getTime() ;
long m2 = eDate.timestampValue().getTime();

long diff = m2 - m1;

int diffDays = Math.round(diff / (24 * 60 * 60 * 1000));

if (diffDays >365)
{
System.out.println("Date is greater than 365");
}
else

{
System.out.println("Date is less than 365");
}

JDR_UTILS packages in oaf

Jdr_utils package is most important APIs commonly used in OA Framework customisation. The most import scripts used are as follows :
·                     JDR_UTILS.LISTDOCUMENTS
·                     JDR_UTILS.PRINTDOCUMENT

·                     JDR_UTILS.DELETEDOCUMENT
                       JDR_UTILS.LISTCUSTOMIZATIONS

execute jdr_utils.listcustomizations('/oracle/apps/irc/candidateSelfService/server/JobResultsSSVO');


execute jdr_utils.printdocument('/oracle/apps/irc/candidateSelfService/server/customizations/site/0/JobResultsSSVO');



execute jdr_utils.deletedocument('/oracle/apps/irc/candidateSelfService/server/customizations/site/0/JobResultsSSVO');



DECLARE 
BEGIN 
    jdr_utils.listdocuments ( '/oracle/apps/per/selfservice.webui' , TRUE ) ;
END ;


DECLARE 
BEGIN
    jdr_utils.printdocument ( ' p_document => /oracle/apps/per/selfservice.webui/ somepagePG ') ;
END ;


DECLARE 
BEGIN 
    jdr_utils.deletedocument ( ' p_document => /oracle/apps/per/selfservice.webui/ somepagePG ') ;
END ;


BOM ( Bill Of Materials) Extraction Script in R12

SELECT msi1.segment1 Parent_item,
  msi1.description Parent_item_description,
  msi1.item_type Parent_item_type,
  msi2.segment1 Child_item,
  msi2.description Child_item_description,
  msi2.item_type Child_item_type,
  --assembly_item_id, bom.organization_id, bic.component_item_id,
  bic.component_quantity,
  bic.effectivity_date,
  bic.implementation_date,
  bic.disable_date,
  ood.organization_code,
  OOD.ORGANIZATION_NAME,
  bom.assembly_type,
  bic.planning_factor,
  bic.quantity_related,
  bic.include_in_cost_rollup,
  Bic.Check_Atp,
  Bic.Component_Yield_Factor
FROM apps.bom_bill_of_materials bom,
  Apps.Bom_Inventory_Components Bic,
  apps.mtl_system_items_b msi1,
  apps.mtl_system_items_b msi2,
  apps.org_organization_definitions ood
WHERE BOM.bill_sequence_id = bIC.bill_sequence_id
      AND msi1.inventory_item_id         = bom.assembly_item_id
      AND msi1.organization_id              = bom.organization_id
      AND msi2.inventory_item_id            = bic.component_item_id
      AND  msi2.organization_id             = bom.organization_id
      AND ood.organization_id            = bom.organization_id
      And Nvl(Bic.Disable_Date, Sysdate + 1) > Sysdate
      and bom.organization_id not in (select organization_id from apps.org_organization_definitions where organization_code not in ('CSM', 'DS3', 'FS1'))
      and UPPER(msi1.item_type) not in ('FG', 'NRE', 'PC')
      AND Upper(Msi2.Item_Type) NOT IN ('RW','FG', 'NRE', 'RETICLE')
      AND Msi1.Inventory_Item_Status_Code='Active' ;