Tuesday, 11 April 2017

Lease Creation API in Oracle Property manager

BEGIN
            select vendor_id
            into   v_vendor_id
            from   ap_suppliers
            where vendor_name  = r_get_lease_rec.vendor_name
            ;
EXCEPTION
        WHEN NO_DATA_FOUND THEN
        v_error_msg:=v_error_msg||'Vendor'||r_get_lease_rec.vendor_name||'  is not found . Please verify!!';
            FND_FILE.PUT_LINE(FND_FILE.LOG,v_error_msg);
            v_error_flag := 'Y';
        WHEN OTHERS THEN
        v_error_msg:=v_error_msg||'Error in Validating Vendor '||r_get_lease_rec.vendor_name||', Error Message ->'||sqlerrm;
            FND_FILE.PUT_LINE(FND_FILE.LOG,v_error_msg);
            v_error_flag := 'Y';
END;

        --Validate Vendor Site
        BEGIN
            select vendor_site_id
            into   v_vendor_Site_id
            from   ap_supplier_sites_All
            where  1=1
            and    org_id           = v_circle_id
            and    vendor_id        = v_vendor_id
            and    vendor_site_code = r_get_lease_rec.vendor_site_Code;

        EXCEPTION
        WHEN NO_DATA_FOUND THEN
        v_error_msg:=v_error_msg||'Vendor Site'||r_get_lease_rec.vendor_site_Code||'  is not found . Please verify!!';
            FND_FILE.PUT_LINE(FND_FILE.LOG,v_error_msg);
            v_error_flag := 'Y';
        WHEN OTHERS THEN
        v_error_msg:=v_error_msg||'Error in Validating Vendor Site Code '||r_get_lease_rec.vendor_site_Code||', Error Message ->'||sqlerrm;
            FND_FILE.PUT_LINE(FND_FILE.LOG,v_error_msg);
            v_error_flag := 'Y';
        END;
            IF v_error_flag <> 'Y'
            THEN
            BEGIN
            FND_FILE.PUT_LINE(FND_FILE.LOG,'r_get_lease_rec.name'||r_get_lease_rec.name);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'r_get_lease_rec.lease_num'||r_get_lease_rec.lease_num);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'g_user_id'||g_user_id);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_circle_id'||v_circle_id);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_location_id'||v_location_id);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_frequency'||v_frequency);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_payment_purpose_code'||v_payment_purpose_code);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_payment_type'||v_payment_type);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_vendor_id'||v_vendor_id);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_vendor_site_id'||v_vendor_site_id);
            FND_FILE.PUT_LINE(FND_FILE.LOG,'v_sobid'||v_payment_type);

                pn_leases_pkg.insert_row
                                  (  x_rowid                          => v_chr_rowid1                   /*Output Parameter for Row Id*/
                                    ,x_lease_id                       => v_num_lease_id1                /*Output Parameter for lease Id*/
                                    ,x_lease_change_id                => v_num_lease_ch_id1             /*Output Parameter for lease change Id*/
                                    ,x_lease_detail_id                => v_num_detail_id1               /*Output parameter for Lease Detail id*/
                                    ,x_name                           => r_get_lease_rec.name           /*Input the Lease Name*/
                                    ,x_lease_num                      => r_get_lease_rec.lease_num      /*Input Lease number*/
                                    ,x_parent_lease_id                => NULL
                                    ,x_lease_type_code                => 'NNN'                          /*Input lease type and class code set in the above lookups*/
                                    ,x_lease_class_code               => 'DIRECT'
                                    ,x_payment_term_proration_rule    => 365                            /*Input the Proration rule Value*/
                                    ,x_abstracted_by_user             => g_user_id
                                    ,x_status                         => 'D'                            /*Input approval status as `DRAFT?. Initially lease will be created in `DRAFT? status and the Schedules and Items Program will finalize the Lease*/
                                    ,x_lease_status                   => 'ACT'                          --Active Status
                                    /*WHO Columns*/
                                    ,x_creation_date                  => sysdate
                                    ,x_created_by                     => g_user_id
                                    ,x_last_update_date               => sysdate
                                    ,x_last_updated_by                => g_user_id
                                    ,x_last_update_login              => g_user_id
                                    ,x_responsible_user               => g_user_id
                                    ,x_expense_account_id             => NULL
                                    ,x_accrual_account_id             => NULL
                                    ,x_receivable_account_id          => NULL
                                    ,x_term_template_id               => NULL
                                    /*Input Commencement, Termination and Execution Date for Lease*/
                                    ,x_lease_commencement_date        => r_get_lease_rec.lease_commencement_date
                                    ,x_lease_termination_date         => r_get_lease_rec.lease_termination_date
                                    ,x_lease_execution_date           => r_get_lease_rec.lease_execution_date
                                    /*Pass the values of any Attribute Columns*/
                                    ,x_attribute_category             => NULL
                                    ,x_attribute1                     => NULL
                                    ,x_attribute2                     => NULL
                                    ,x_attribute3                     => NULL
                                    ,x_attribute4                     => NULL
                                    ,x_attribute5                     => NULL
                                    ,x_attribute6                     => NULL
                                    ,x_attribute7                     => NULL
                                    ,x_attribute8                     => NULL
                                    ,x_attribute9                     => NULL
                                    ,x_attribute10                    => NULL
                                    ,x_attribute11                    => NULL
                                    ,x_attribute12                    => NULL
                                    ,x_attribute13                    => NULL
                                    ,x_attribute14                    => NULL
                                    ,x_attribute15                    => NULL
                                    ,x_org_id                         => v_circle_id
                                    /*Input Location Id from PN_LOCATIONS for the Profit Center (Store Number) and Customer Id for which the is to be created*/
                                    ,x_location_id                    => v_location_id
                                    ,x_customer_id                    => NULL
                                    ,x_grouping_rule_id               => NULL
                                    );
                dbms_output.put_line('v_chr_rowid'||v_chr_rowid1);
                dbms_output.put_line('v_num_lease_id'||v_num_lease_id1);
                dbms_output.put_line('v_num_lease_ch_id'||v_num_lease_ch_id1);
                dbms_output.put_line('v_num_detail_id'||v_num_detail_id1);
                FND_FILE.PUT_LINE(FND_FILE.LOG,'v_chr_rowid'||v_chr_rowid1);
                FND_FILE.PUT_LINE(FND_FILE.LOG,'v_num_lease_id'||v_num_lease_id1);
                FND_FILE.PUT_LINE(FND_FILE.LOG,'v_num_lease_ch_id'||v_num_lease_ch_id1);
                FND_FILE.PUT_LINE(FND_FILE.LOG,'v_num_detail_id'||v_num_detail_id1);
                COMMIT;
                pnt_payment_terms_pkg.insert_row (
                                                /*Output parameter for Row Id*/
                                                x_rowid                                      => v_chr_row_id6
                                                /*Output Parameter for Payment Term Id*/
                                                ,x_payment_term_id                           => v_num_payment_term_id
                                                /*Input Billing Purpose Code and the Billing term*/
                                                ,x_payment_purpose_code                      => v_payment_purpose_code--'RENT'
                                                ,x_payment_term_type_code                    => v_payment_type--'BASER'
                                                /*Input the frequency as Montly, One time, etc... */
                                                ,x_frequency_code                            => v_frequency--'MON'
                                                /*Input parameter Lease Id and lease Change Id*/
                                                ,x_lease_id                                  => v_num_lease_id1
                                                ,x_lease_change_id                           => v_num_lease_ch_id1
                                                /*Input Start and End date for the Payment Stream*/
                                                ,x_start_date                                => r_get_lease_rec.start_date--SYSDATE
                                                ,x_end_date                                  => r_get_lease_rec.end_date--SYSDATE+240
                                                ,x_vendor_id                                 => v_vendor_id
                                                ,x_vendor_site_id                            => v_vendor_site_id
                                                ,x_customer_id                               => NULL
                                                ,x_customer_site_use_id                      => NULL
                                                ,x_target_date                               => NULL
                                                /*Input the Amount for Payment Stream*/
                                                ,x_actual_amount                             => r_get_lease_rec.actual_amount
                                                ,x_estimated_amount                          => NULL
                                                /*Input Set of Books and Currency*/
                                                ,x_set_of_books_id                           => 1001--v_sob_id
                                                ,x_currency_code                             => r_get_lease_rec.currency_code
                                                ,x_rate                                      => 1
                                                /*Input Normalize flag value as `Y? if the payment stream needs to be Normalized*/
                                                ,x_normalize                                 =>'Y'
                                                ,x_location_id                               => NULL
                                                /*Input Special terms and Customer ship to Site*/
                                                ,x_schedule_day                              => r_get_lease_rec.schedule_day
                                                ,x_cust_ship_site_id                         => NULL
                                                /*Input the term Id from the table RA_TERMS and transaction Id from RA_CUST_TRX_TYPES*/
                                                ,x_ap_ar_term_id                             => NULL
                                                ,x_cust_trx_type_id                          => NULL
                                                ,x_project_id                                => NULL
                                                ,x_task_id                                   => NULL
                                                ,x_organization_id                           => NULL
                                                ,x_expenditure_type                          => NULL
                                                ,x_expenditure_item_date                     => NULL
                                                ,x_tax_group_id                              => NULL
                                                /*Input the tax Code Id from the table AR_VAT_TAX*/
                                                ,x_tax_code_id                               => NULL
                                                ,x_tax_included                              => NULL
                                                ,x_distribution_set_id                       => NULL
                                                ,x_inv_rule_id                               => NULL
                                                ,x_account_rule_id                           => NULL
                                                ,x_salesrep_id                               => NULL
                                                ,x_approved_by                               => NULL
                                                ,x_status                                    => NULL
                                                ,x_index_period_id                           => NULL
                                                ,x_index_term_indicator                      => NULL
                                                ,x_po_header_id                              => NULL
                                                ,x_cust_po_number                               => NULL
                                                ,x_receipt_method_id                            => NULL
                                                ,x_var_rent_inv_id                            => NULL
                                                ,x_var_rent_type                              => NULL
                                                ,x_period_billrec_id                            => NULL
                                                ,x_rec_agr_line_id                             => NULL
                                                ,x_amount_type                               => NULL
                                                ,x_changed_flag                              => NULL
                                                ,x_term_template_id                             => NULL
                                                ,x_attribute_category                           => NULL
                                                ,x_attribute1                                => NULL
                                                ,x_attribute2                                => NULL
                                                ,x_attribute3                                => NULL
                                                ,x_attribute4                                => NULL
                                                ,x_attribute5                                => NULL
                                                ,x_attribute6                                => NULL
                                                ,x_attribute7                                => NULL
                                                ,x_attribute8                                => NULL
                                                ,x_attribute9                                => NULL
                                                ,x_attribute10                               => NULL
                                                ,x_attribute11                                  => NULL
                                                ,x_attribute12                                  => NULL
                                                ,x_attribute13                                  => NULL
                                                ,x_attribute14                               => NULL
                                                ,x_attribute15                               => NULL
                                                ,x_project_attribute_category                 => NULL
                                                ,x_project_attribute1                         => NULL
                                                ,x_project_attribute2                         => NULL
                                                ,x_project_attribute3                         => NULL
                                                ,x_project_attribute4                         => NULL
                                                ,x_project_attribute5                         => NULL
                                                ,x_project_attribute6                         => NULL
                                                ,x_project_attribute7                         => NULL
                                                ,x_project_attribute8                         => NULL
                                                ,x_project_attribute9                         => NULL
                                                ,x_project_attribute10                       => NULL
                                                ,x_project_attribute11                       => NULL
                                                ,x_project_attribute12                       => NULL
                                                ,x_project_attribute13                       => NULL
                                                ,x_project_attribute14                       => NULL
                                                ,x_project_attribute15                       => NULL
                                                /*WHO Columns*/
                                                ,x_creation_date                             => SYSDATE
                                                ,x_created_by                                => g_user_id
                                                ,x_last_update_date                          => sysdate
                                                ,x_last_updated_by                           => g_user_id
                                                ,x_last_update_login                           => g_user_id
                                                /*Input Calling form value*/
                                                ,x_calling_form                              => 'PNTLEASE'
                                                ,x_org_id                                    => v_circle_id
                                                ,x_lease_status                              => 'ACT'  --Active Status
                                                ,x_recoverable_flag                          => NULL
                                                ,x_area_type_code                            => NULL
                                                ,x_area                                      => NULL
                                                ,x_grouping_rule_id                          => NULL
                                                );
            COMMIT;

Cost Center Hierarchy Query

SELECT   ffvc.PARENT_FLEX_VALUE parent_value,
         ffvv.DESCRIPTION Parent,
         ffvc.FLEX_VALUE first_child_value,
         ffvc.DESCRIPTION First_Child,
--         ffvv2.attribute1 USER_GROUP_first_child,
         --ffvv.HIERARCHY_LEVEL,
         child_level.FLEX_VALUE second_child_value,
         child_level.second_child,
--         child_level.USER_GROUP_second_child,
         --child_level.HIERARCHY_LEVEL,
         child_level2.FLEX_VALUE third_child_value,
         child_level2.third_child,
--         child_level2.USER_GROUP_third_child,
         child_level3.FLEX_VALUE fourth_child_value,
         child_level3.fourth_child,
--         child_level3.USER_GROUP_Fourth_child
         child_level4.FLEX_VALUE fifth_child_value,
         child_level4.fifth_child
--         child_level3.USER_GROUP_fifth_child  
         --child_level2.HIERARCHY_LEVEL
  FROM   FND_FLEX_VALUES_VL ffvv,
         FND_FLEX_VALUE_CHILDREN_V ffvc,
         FND_FLEX_VALUES_VL ffvv2,
         (SELECT   ffvc.PARENT_FLEX_VALUE,
                   ffvc.FLEX_VALUE,
                   ffvc.DESCRIPTION second_child,
                   ffvv.HIERARCHY_LEVEL,
                   ffvv2.attribute1 USER_GROUP_second_child
            FROM   FND_FLEX_VALUES_VL ffvv, FND_FLEX_VALUE_CHILDREN_V ffvc,FND_FLEX_VALUES_VL ffvv2
           WHERE       ffvc.PARENT_FLEX_VALUE = ffvv.FLEX_VALUE
                   AND ffvc.FLEX_VALUE_SET_ID = ffvv.flex_value_set_id
                   and ffvv2.FLEX_VALUE = ffvc.FLEX_VALUE
                   and ffvc.flex_value_set_id = ffvv2.flex_value_set_id
                   AND ffvv.flex_value_set_id = 1016191--:P_VALUE_SET_ID
                   ) child_level,
         (SELECT   ffvc.PARENT_FLEX_VALUE,
                   ffvc.FLEX_VALUE,
                   ffvc.DESCRIPTION third_child,
                   ffvv.HIERARCHY_LEVEL,
                   ffvv2.attribute1 USER_GROUP_third_child
            FROM   FND_FLEX_VALUES_VL ffvv, FND_FLEX_VALUE_CHILDREN_V ffvc,FND_FLEX_VALUES_VL ffvv2
           WHERE       ffvc.PARENT_FLEX_VALUE = ffvv.FLEX_VALUE
                   AND ffvc.FLEX_VALUE_SET_ID = ffvv.flex_value_set_id
                   and ffvv2.FLEX_VALUE = ffvc.FLEX_VALUE
                   and ffvc.flex_value_set_id = ffvv2.flex_value_set_id
                   AND ffvv.flex_value_set_id = 1016191--:P_VALUE_SET_ID:P_VALUE_SET_ID
                   ) child_level2,
           (SELECT   ffvc.PARENT_FLEX_VALUE,
                   ffvc.FLEX_VALUE,
                   ffvc.DESCRIPTION fourth_child,
                   ffvv.HIERARCHY_LEVEL,
                   ffvv2.attribute1 USER_GROUP_Fourth_child
            FROM   FND_FLEX_VALUES_VL ffvv, FND_FLEX_VALUE_CHILDREN_V ffvc,FND_FLEX_VALUES_VL ffvv2
           WHERE       ffvc.PARENT_FLEX_VALUE = ffvv.FLEX_VALUE
                   AND ffvc.FLEX_VALUE_SET_ID = ffvv.flex_value_set_id
                   and ffvv2.FLEX_VALUE = ffvc.FLEX_VALUE
                   and ffvc.flex_value_set_id = ffvv2.flex_value_set_id
                   AND ffvv.flex_value_set_id = 1016191--:P_VALUE_SET_ID:P_VALUE_SET_ID
                   ) child_level3,
               (SELECT   ffvc.PARENT_FLEX_VALUE,
                   ffvc.FLEX_VALUE,
                   ffvc.DESCRIPTION fifth_child,
                   ffvv.HIERARCHY_LEVEL,
                   ffvv2.attribute1 USER_GROUP_fifth_child
            FROM   FND_FLEX_VALUES_VL ffvv, FND_FLEX_VALUE_CHILDREN_V ffvc,FND_FLEX_VALUES_VL ffvv2
           WHERE       ffvc.PARENT_FLEX_VALUE = ffvv.FLEX_VALUE
                   AND ffvc.FLEX_VALUE_SET_ID = ffvv.flex_value_set_id
                   and ffvv2.FLEX_VALUE = ffvc.FLEX_VALUE
                   and ffvc.flex_value_set_id = ffvv2.flex_value_set_id
                   AND ffvv.flex_value_set_id = 1016191--:P_VALUE_SET_ID:P_VALUE_SET_ID
                   ) child_level4                  
 WHERE       ffvc.PARENT_FLEX_VALUE = ffvv.FLEX_VALUE
         AND ffvc.FLEX_VALUE_SET_ID = ffvv.flex_value_set_id
         and ffvv2.FLEX_VALUE = ffvc.FLEX_VALUE
         and ffvc.flex_value_set_id = ffvv2.flex_value_set_id
         AND ffvv.flex_value_set_id = 1016191--:P_VALUE_SET_ID:P_VALUE_SET_ID
         AND child_level.PARENT_FLEX_VALUE(+) = ffvc.FLEX_VALUE
         AND child_level2.PARENT_FLEX_VALUE(+) = child_level.FLEX_VALUE
         AND child_level3.PARENT_FLEX_VALUE(+) = child_level2.FLEX_VALUE
         AND child_level4.PARENT_FLEX_VALUE(+) = child_level3.FLEX_VALUE
        AND  ffvv.END_DATE_ACTIVE is null
         AND ffvv.FLEX_VALUE in (select FLEX_VALUE from FND_FLEX_VALUES_VL
where FLEX_VALUE_SET_ID = 1016191
and HIERARCHY_LEVEL = 1
and ENABLED_FLAG = 'Y'
)      order by  ffvc.PARENT_FLEX_VALUE, ffvc.FLEX_VALUE,child_level.FLEX_VALUE,child_level2.FLEX_VALUE,
       child_level3.FLEX_VALUE,child_level4.FLEX_VALUE

Splits Months into Weeks

SELECT START_date, END_DATE , START_date || ' To '|| END_DATE  P3riod
FROM
(
select  decode((trim(to_char(period,'DAY'))), 'MONDAY', period,period) START_date,
                decode((trim(to_char(period,'DAY'))), 'SUNDAY', period ,period + 6) END_date
from
(
select next_day(trunc(:P_DATE-7), 'Monday')+(7*(level-1)) PERIOD
from dual
connect by level <=1000
union all
select next_day(trunc(:P_DATE), 'Sunday')+(7*(level-1))  period
from dual
connect by level <=1000
order by 1
)
where PERIOD <= :T_DATE
)
WHERE  START_date <> END_date

Download and upload script in oracle


FND in Oracle: Download and upload script in oracle

FND is short for “Foundation” which was the name Oracle initially wanted to use for the Application Object Library- the application with common components shared between all the other applications in the Oracle E-Business Suite.

Profile Options:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afscprof.lct XXPRNAME.ldt PROFILE PROFILE_NAME="XXPRNAME" APPLICATION_SHORT_NAME="PN"
Upload
1. FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afscprof.lct XXPRNAME.ldt
2. FNDLOAD apps/apps 0 Y UPLOAD_PARTIAL $FND_TOP/patch/115/import/afscprof.lct XXPRNAME.ldt PROFILE PROFILE_NAME=" XXPRNAME" APPLICATION_SHORT_NAME="PN"

Concurrent Programs:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct XXCPNAME.ldt PROGRAM APPLICATION_SHORT_NAME="PN" CONCURRENT_PROGRAM_NAME="XXCPNAME"
Upload
FNDLOAD apps/apps 0 Y UPLOAD_PARTIAL $FND_TOP/patch/115/import/afcpprog.lct XXCPNAME.ldt PROGRAM CONCURRENT_PROGRAM_NAME="XXCPNAME" APPLICATION_SHORT_NAME="PN"

Forms:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct XXFRMNAME.ldt FORM APPLICATION_SHORT_NAME="PN" FORM_NAME="XXFRMNAME"
Upload
FNDLOAD apps/apps 0 Y UPLOAD @FND:patch/115/import/afsload.lct XXFRMNAME.ldt

Functions:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct XXFUNNAME.ldt FUNCTION FUNC_APP_SHORT_NAME="PN" FUNCTION_NAME="XXFUNNAME"
Upload
FNDLOAD apps/apps O Y UPLOAD @FND:patch/115/import/afsload.lct XXFUNNAME.ldt

Menus:

Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct XXMNNAME.ldt MENU MENU_NAME="XXMNNAME"
Upload
FNDLOAD apps/apps 0 Y UPLOAD @FND:patch/115/import/afsload.lct XXMNNAME.ldt

Responsibilities:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afscursp.lct XXRESNAME.ldt FND_RESPONSIBILITY RESP_KEY="XXRESNAME"
Upload
1. FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afscursp.lct XXRESNAME.ldt
2. FNDLOAD apps/apps 0 Y UPLOAD_PARTIAL $FND_TOP/patch/115/import/afscursp.lct XXRESNAME.ldt FND_RESPONSIBILITY RESP_KEY="XXRESNAME" APPLICATION_SHORT_NAME="PN"

Request Groups:

Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afcpreqg.lct XXRQGNAME.ldt REQUEST_GROUP REQUEST_GROUP_NAME="XXRQGNAME" APPLICATION_SHORT_NAME="PN"
Upload
1. FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afcpreqg.lct XXRQGNAME.ldt
2. FNDLOAD apps/apps 0 Y UPLOAD_PARTIAL $FND_TOP/patch/115/import/afcpreqg.lct XXRQGNAME.ldt REQUEST_GROUP REQUEST_GROUP_NAME="XXRQGNAME" APPLICATION_SHORT_NAME="PN"

Request Sets:

Download
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct XXRQSNAME.ldt REQ_SET REQUEST_SET_NAME="XXRQSNAME"
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct XXRQSLNAME.ldt REQ_SET_LINKS REQUEST_SET_NAME="XXRQSNAME"

Upload
FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afcprset.lct XXRQSNAME.ldt
FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afcprset.lct XXRQSLNAME.ldt

Lookups:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct XXLKPNAME.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME="PN" LOOKUP_TYPE="XXLKPNAME"

Upload
1. FNDLOAD apps/apps 0 Y UPLOAD aflvmlu.lct XXLKPNAME.ldt
2. FNDLOAD apps/apps 0 Y UPLOAD_PARTIAL $FND_TOP/patch/115/import/aflvmlu.lct XXLKPNAME.ldt FND_LOOKUP_TYPE LOOKUP_TYPE="XXLKPNAME" APPLICATION_SHORT_NAME="PN"

Value Sets:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct XXVALSNAME.ldt VALUE_SET FLEX_VALUE_SET_NAME="XXVALSNAME"
Upload
1. FNDLOAD apps/apps 0 Y UPLOAD afffload.lct XXVALSNAME.ldt
2. FNDLOAD apps/apps 0 Y UPLOAD_PARTIAL $FND_TOP/patch/115/import/afffload.lct XXVALSNAME.ldt VALUE_SET FLEX_VALUE_SET_NAME="XXVALSNAME" APPLICATION_SHORT_NAME="PN"

Descriptive Flex-fields:

Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct XXDFFNAME.ldt DESC_FLEX P_LEVEL='COL_ALL:REF_ALL:CTX_ONE:SEG_ALL' APPLICATION_SHORT_NAME="PN" DESCRIPTIVE_FLEXFIELD_NAME="PN_LEASE_DETAILS" P_CONTEXT_CODE="Global Data Elements"
Upload
FNDLOAD apps/apps 0 Y UPLOAD @FND:patch/115/import/afffload.lct XXDFFNAME.ldt

Key Flex-fields:
Donwload
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct XXKFFNAME.ldt KEY_FLEX P_LEVEL=’COL_ALL:FQL_ALL:SQL_ALL:STR_ONE:WFP_ALL:SHA_ALL:CVR_ALL:SEG_ALL’ APPLICATION_SHORT_NAME="FND" ID_FLEX_CODE="key flex code" P_STRUCTURE_CODE="structure name”
Upload
FNDLOAD apps/apps 0 Y UPLOAD @FND:patch/115/import/afffload.lct XXKFFNAME.ldt


Form Personalization:
Download
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct XXFPNAME.ldt FND_FORM_CUSTOM_RULES function_name="XXFPNAME"
Upload
FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/affrmcus.lct XXFPNAME.ldt

FND Users:

Download
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afscursp.lct ./XXUSERNAME.ldt FND_USER USER_NAME='XXUSERNAME'
Upload
FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afscursp.lct ./ XXUSERNAME.ldt

Printer Styles:
Download
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afcppstl.lct XXPRSTYLE.ldt STYLE PRINTER_STYLE_NAME="XXPRSTYLE"
Upload
FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afcppstl.lct XXPRSTYLE.ldt


Query for move order transfer

SELECT DISTINCT (SELECT segment1
                         FROM mtl_system_items_b
                        WHERE inventory_item_id = mmt.inventory_item_id
                          AND ROWNUM < 2) item,
                      mmt.organization_id inv_org_id, mmt.transaction_id,
                      SUM (mmt.transaction_quantity) quantity,
                      mmt.transaction_date,
                      mmt.subinventory_code AS subinventory_from,
                      mmt.transfer_subinventory AS subinventory_to,
                      mmt.attribute8 AS dc_no, mmt.attribute9 AS dc_date,
                      mmt.move_order_line_id,
                      (SELECT header_id
                         FROM mtl_txn_request_lines
                        WHERE line_id = mmt.move_order_line_id
                          AND ROWNUM < 2) mo_number,
                      mmt.locator_id from_locator_id,
                      mmt.transfer_locator_id to_locator_id,
                      (SELECT lot_number
                         FROM mtl_transaction_lot_numbers
                        WHERE transaction_id = mmt.transaction_id
                          AND ROWNUM < 2) lot_number,
                      (SELECT NVL (origination_date, creation_date)
                         FROM mtl_transaction_lot_numbers
                        WHERE transaction_id = mmt.transaction_id
                          AND ROWNUM < 2) lot_date,
                      mmt.new_cost COST
                 FROM mtl_material_transactions mmt
                WHERE 1 = 1
                  AND mmt.transaction_quantity < 0
                  AND mmt.transaction_action_id IN (1, 2)
                  AND TRUNC (mmt.transaction_date) BETWEEN TRUNC (SYSDATE
                                                                  - 180
                                                                 )
                                                       AND TRUNC (SYSDATE)
                  AND mmt.transaction_type_id = 64              -- MO Transfer                
             GROUP BY mmt.organization_id,
                      mmt.inventory_item_id,
                      mmt.transaction_type_id,
                      mmt.transaction_date,
                      mmt.subinventory_code,
                      mmt.transfer_subinventory,
                      mmt.attribute8,
                      mmt.attribute9,
                      mmt.move_order_line_id,
                      mmt.new_cost,
                      mmt.transaction_id,
                      mmt.locator_id,
                      transfer_locator_id;

Monday, 10 April 2017

Pl/Sql interview question

1.            Difference b/w procedure and function?  A procedure may return (one or more values using OUT & INOUT Parameters) or may not return a value. But a function has to return a single value and has the return clause in its definition. Function can be called in select statements but procedure can only be called in a pl/sql block.  Procedure's parameters can have IN or OUT or INOUT parameters. But function's parameters can only have IN parameters.
2.            Difference b/w ROWID and ROWNUM? ROWID : It gives the hexadecimal string representing the address of a row.It gives the location in database where row is physically stored. ROWNUM: It gives a sequence number in which rows are retrieved from the database.
3.            Give some examples of pseudo columns? NEXTVAL, CURRVAL, LEVEL, SYSDATE
4.            Difference b/w implicit cursor and explicit cursor? Implicit cursors are automatically created by oracle for all its DML stmts. Examples of implicit cursors: SQL%FOUND, SQL%NOTFOUND, SQL%ROWCOUNT, SQL%ISOPEN; Explicit cursors are created by the users for multi row select stmts.
5.            How to create a table in a procedure or function? See the below piece of code:  Since create stmt can be used only at the sql prompt, we have used dynamic sql to create a table.           
DECLARE
                    L_STMT VARCHAR2(100);
BEGIN
                    DBMS_OUTPUT.PUT_LINE('STARTING ');
                    L_STMT := 'create table dummy1 (X VARCHAR2(10) , Y NUMBER)';
                    EXECUTE IMMEDIATE L_STMT;
                    DBMS_OUTPUT.PUT_LINE('end ');
END;
The above piece of code can be written In procedure and function DDL's can be used in function provided that function should be invoked in Begin-End block not from Select statement.

6.            Explain the usage of WHERE CURRENT OF clause in cursors ? Look at the following pl/sql code:
DECLARE
                   CURSOR wip_cur IS
                   SELECT acct_no, enter_date
                   FROM wip
WHERE enter_date < SYSDATE -7
FOR UPDATE;
BEGIN
FOR wip_rec IN wip_cur
LOOP
                   INSERT INTO acct_log (acct_no, order_date)
                   VALUES (wip_rec.acct_no, wip_rec.enter_date);

                   DELETE FROM wip
WHERE CURRENT OF wip_cur;
          END LOOP;
END;
"WHERE CURRENT OF" has to be used in concurrence with "FOR UPDATE"  in the cursor select stmt.
"WHERE CURRENT OF" used in delete or update stmts means, delete/update the current record specified by the cursor.
By using WHERE CURRENT OF, you do not have to repeat the WHERE clause in the SELECT statement.

7.            What is the purpose of FORUPDATE? Selecting in FOR UPDATE mode locks the result set of rows in update mode, which means that row cannot be updated or deleted until a commit or rollback is issued which will release the row(s). If you plan on updating or deleting records that have been referenced by a Select For Update statement, you can use the Where Current Of statement.                                                                                               
8.            What is RAISE_APPLICATION_ERROR? The RAISE_APPLICATION_ERROR is a procedure defined by Oracle that allows the developer to raise an exception and associate an error number and message with the procedure other than just Oracle errors. Raising an Application Error With raise_application_error
9.            
DECLARE
   num_tables NUMBER;
BEGIN
   SELECT COUNT(*) INTO num_tables FROM USER_TABLES;
   IF num_tables < 1000 THEN
      /* Issue your own error code (ORA-20101) with your own error message.
         Note that you do not need to qualify raise_application_error with
         DBMS_STANDARD */
      raise_application_error(-20101, 'Expecting at least 1000 tables');
   ELSE
      NULL; -- Do the rest of the processing (for the non-error case).
   END IF;
END;
/

The procedure RAISE_APPLICATION_ERROR lets you issue user-defined ORA- error messages from stored subprograms. That way, you can report errors to your application and
avoid returning unhandled exceptions.

9.            What is mutating error? Mutating error occurs in the following scenario:
WHEN WE ARE UPDATING A TABLE (TRIGGER WRITTEN ON A TABLE FOR UPDATE) AND AT THE SAME TIME TRYING TO RETRIEVE DATA FROM THAT TABLE. IT WILL RESULT INTO MUTATING TABLE AND IT WILL RESULT INTO MUTATING ERROR.

10.         Can we have commit/rollback in DB triggers? Having Commit / Rollback inside a trigger defeats the standard of whole transaction's commit / rollback all together. Once trigger execution is complete then only a transaction can be said as complete and then only commit should take place. If we still want to carry out some action which should be initiated from trigger but should be committed irrespective of trigger completion / failure we can have AUTONOMUS TRANSACTION. Inside Autonomous transaction block we can have Commit and it will act as actual commit.                                                                                                
11.         Can we make the trigger an autonomous transaction? This makes all the difference because within the autonomous transaction (the trigger), Oracle will view the triggering table as it was before any changes occurred—that is to say that any changes are uncommitted and the autonomous transaction doesn’t see them. So the potential confusion Oracle normally experiences in a mutating table conflict doesn’t exist.
12.         What is autonomous transaction? Autonomous transaction means a transaction that is embedded in some other transaction, but functions independently.
13.         What is a REF Cursor? The REF CURSOR is a data type in the Oracle PL/SQL language. It represents a cursor or a result set in Oracle Database.
14.         What is the difference between ref cursors and normal pl/sql cursors?
   Declare
          type rc is ref cursor;
          cursor c is
          select * from dual;
          l_cursor rc;
       begin
          if ( to_char(sysdate,'dd') = 30 ) then
                   open l_cursor
                             for select * from emp;
          elsif ( to_char(sysdate,'dd') = 29 ) then
                   open l_cursor
                             for select * from dept;
          else
                   open l_cursor
                             for select * from dual;
          end if;
          open c;
      end;                                                                                                                    
Given that block of code you see perhaps the most "salient" difference, no matter how many times you run that block The cursor C will always be select * from dual.  The ref cursor can be anything.

15.         Is Truncate a DDL or DML statement? And why? Truncate is a DDL statement. Check the LAST_DDL_TIME on USER_OBJECTS after truncating your table. TRUNCATE will automatically commit, and it's not rollback able. This changes the storage definition of the object. That's why it is a DDL.
16.         What are the actions you have to perform when you drop a package? If you rename a package, the other packages that use it will have to be MODIFIED. A simple compilation of the new renamed package won't do. If you have toad, go to the "used by" tab that will show you the packages that call the package being renamed.
17.         What is cascading triggers? When a trigger fires, a SQL statement within its trigger action potentially can fire other triggers, resulting in cascading triggers.
18.         What are materialized views? A materialized view is a database object that stores the results of a query (possibly from a remote database). Materialized views are sometimes referred to as snapshots.


Thursday, 2 May 2013

Query for Getting Profile option value by user level, Site level, resposibilty level

SELECT user_profile_option_name,SUBSTR(e.profile_option_name,1,25) PROFILE
,DECODE(a.level_id,10001,'Site',10002,'Application',10003,'Resp',10004,'User') "Level"
,DECODE(a.level_id,10001,'Site',10002,c.application_short_name,10003,b.responsibility_name,10004,d.user_name) LValue
,NVL(a.profile_option_value,'Is Null') Value
,SUBSTR(a.last_update_date,1,25) UPDATED_DATE
FROM fnd_profile_option_values a
, fnd_responsibility_tl b
, fnd_application c
,fnd_user d
, fnd_profile_options e
, fnd_profile_options_tl f
WHERE 1=1
--and e.profile_option_name IN ('FND_BRANDING_SIZE','ASO_COMP_LOGO')
and f.user_profile_option_name in ('AP: Use Invoice Batch Controls')
AND e.profile_option_id = a.profile_option_id AND a.level_value = b.responsibility_id (+)
AND a.level_value = c.application_id (+) AND a.level_value = d.user_id (+)
and f.PROFILE_OPTION_NAME(+)=e.profile_option_name
ORDER BY e.profile_option_name;

Interview Question in Oracle OTBI Report

What is Subject Area In OTBI, a Subject Area is a logical view of business data. Under a Subject Area, we have multiple folders , which are...