Thursday 31 December 2015

Open various accounting periods in Oracle Apps



1. Please check "GL Set of Books Name" profile for the responsibility in which you are receiving,   from System Administrator responsibility. It should be set to the correct Set of Books name

2. Ensure the GL period is open for the accounting period in question using:
    Purchasing -> Setup -> Financials -> Accounting -> Open and Close Periods

3. Ensure the Purchasing period is open for the accounting period in question using:
    Purchasing ->  Setup-> Financials -> Accounting -> Control PO Periods

4. Ensure the Inventory period is open for the accounting period in question using:
    Inventory ->  Accounting Close Cycle -> Inventory Accounting Periods

5. Ensure the Accounts Payable period is open for the accounting period in question using:
    Payables -> Accounting -> Control Payables Period



Tuesday 22 December 2015

Creating JAR files on desktop for custom OAF project files



Creating JAR files on desktop for OAF project files

Steps:

1) Go to the <code path>/myprojects/oracle/apps
2) Copy xxcst folder and paste to <jdev install dir>/jdevbin\jdk\bin
3) Remove any unnecessary files from xxcst folder.
4) Go to Cmd and cd to <jdev install dir>/jdevbin\jdk\bin
5) Execute the below cmd

jar -cf <jar file name>.jar xxcst

6) Deploy the JAR appropriately

Thursday 17 December 2015

Useful metalinks for EBS Developers


Useful metalinks for EBS Developers

Oracle Applications Framework(OAF) related notes:

Dev Guides:

Oracle Application Framework Developer's Guide Release 12.1.3 [ID 1107973.1]

Oracle Application Framework Developer's Guide Release 12.1.2 [ID 972774.1]

Oracle Application Framework Developer's Guide Release 12.1.1 [ID 744832.1]

Configuring JDeveloper For Use With Oracle Applications 11i and R12 [ID 330236.1])

Oracle Application Framework: Allowing an Extended VO to See Subsequent Parent VO Changes (Doc ID 353443.1)

How To Make DFF Segments Read Only Using OAF Personalise (Doc ID 438215.1)

Oracle Application Framework: Allowing an Extended VO to See Subsequent Parent VO Changes (Doc ID 353443.1)


MOAC related notes:

Oracle Applications Multiple Organizations Access Control for Custom Code [ID 420787.1] --> Very Good document for developers.

SQL Queries and Multi-Org Architecture in Release 12 [ID 462383.1]

Multi Org Access Control (MOAC) in Oracle Purchasing [ID 397362.1]

FAQ - Multiple Organizations Architechure (Multi-Org) [ID 165042.1]


Localizations related notes:

Globalization Guide for Oracle Applications Release 12 (Doc ID 393861.1)

Country-Specific Features (Globalizations/Localizations) Guide (Doc ID 403211.1)

Oracle Applications 11i Internationalization Guide (Doc ID 333785.1) --> char set

Oracle E-Business Suite Release 12.1+ Information Center - Localizations [ID 885960.1]

Introduction to Add-On Localizations for R12 [ID 429042.1]


XML Publisher related notes:


XML Publisher Report Issues, Recommendations and Errors (Doc ID 862644.1)

R12: Troubleshooting Known XML Publisher and E-Business Suite (EBS) Integration Issues (Doc ID 1410160.1)

Troubleshooting Oracle XML Publisher For The Oracle E-Business Suite [ID 364547.1]

Concurrent Processing and Post Processor related notes:

Unable to Find the Concurrent Request Output Post Processor (OPP) Service [ID 465036.1]

The Output Post Processor does not process all requests. [ID 1399463.1]
BI Publisher Requests in Pending Status End in Warning When Starting Concurrent Managers [ID 375208.1]

APIs and Integration repository:

Note: 462586.1 - Where are the Oracle® Release 12 (R12) API Reference Guide?


Note: 458225.1 - Release 12 Integration Repository


Note: 396116.1 - Oracle Integration Repository Documentation Resources Release 12


Audit Trail:

FAQ (Audit Trail) (Doc ID 107330.1)




AP (Oracle Payables):

Information Center: Using Oracle Payables (Doc ID 1417577.2)

AP: How To Determine Ap Invoice Approval Status Via The Backend? (Doc ID 220653.1)


11i & R12: AP: Where Is The Invoice Validation Status Stored? How Is The Invoice Validation Status Determined? (Doc ID 301806.1)


PO(Oracle Purchasing):

Attachments:

Note 338651.1: trouble shouting attachmetns and export

How to Query Attachments with SQL - Querying an Item Attachment? (Doc ID 370176.1)

Enable Attachments in a Form (Doc ID 369215.1)

How to enter images in the HRMS Application (Doc ID 103263.1)

How To Use Attachments In Oracle Applications? (Doc ID 197549.1)

Is There A File Size Limit For EBS Attachments (Doc ID 739643.1)

Misc Notes:

ICX related notes:

How To Handle Numeric Fields When Profile Icx: Numeric Character = 10.000,00 [ID 452839.1]

What is the setting and functionality of Profile Option ICX: Numeric characters? [ID 167513.1]

Report is missing data ICX Numeric Characters Profile option set to 10.000,00 [ID 858245.1]


Other Notes:

How to Determine Data Populated in the Reference Columns in GL,AR,AP Interface tables for AGIS Invoices [ID 853296.1]
Reports Exchange (RXi) Basics (Doc ID 119736.1)


AME:
How To Copy / Migrate AME Setup Like Rules/Attributes/Transactions etc From One Instance To Another Instance ? (Doc ID 371605.1)
How To Migrate AME Setups From One Instance To Another (Doc ID 1168883.1)

R12.1 Where can I find the latest eTRM information for 12.1.3 or 12.1.2? (Doc ID 1190603.1)

Oracle E-Business Suite Electronic Technical Reference Manual (eTRM), Release 12.1 and 12.2 (Doc ID 2736939.1)


Format number in BI report according to the ICX: Numeric Char profile option

Format number in BI report according to the ICX: Numeric Char profile option:

Its common in Oracle Apps UIs that the number and date formats are displayed according to the user preferences.


Often we need the number format preference be honoured in BI Publisher (XML Publisher) reports.


With the following we can achieve the same:

1) Set the profile 'ICX: Numeric characters' according to your need.
2) Set the profile XDO: Numeric characters to 'Read from ICX: Numeric characters'

When the above is set, the system passes the separators to xslt._XDONFSEPARATORS XDO parameter during runtime.


In your RTF for the number field - write the following code:

<?format-number:NUM_COLUMN;'999G999D99'?>

Where 'G' denotes thousands separtor and D denotes decimal separator.


During runtime, the BIP engine uses XSL-FO style sheet instead of RTF that was uploaded. 

As soon as you upload the RTF document and save you can see one more extra record in XDO_LOBS for the XSL:

We can see the XSL from the BIP add-in as well.


Open your RTF --> From Add-ins --> Tools --> export --> XSL-FO Style sheet.


You will something like this:


<xsl:value-of select="xdoxslt:xdo_format_number($_XDOXSLTCTX, .//NUM_COLUMN, '999G999D99')"/>



$_XDOXSLTCTX is made up of locale, timezone, calendar, numeric separtors etc..


You can refer metalink notes 760434.1,1355022.1

Wednesday 16 December 2015

ORA-00947: not enough values even when number of VALUES matches the insert

ORA-00947: not enough values even when number of VALUES matches the insert

I faced the issue "ORA-00947: not enough values even when number of VALUES matches the insert" - I checked the couple of sites but did not get any clue finally found that the issue is because of 'VALUES' clause with 'SELECT' statement..


Wrong:
insert into tabA(a,b,c) Values (Select 'a', 'b', 'c' from dual); 

Correct: - No Values clause
insert into tabA(a,b,c) 
(Select 'a', 'b', 'c' from dual);  

Tuesday 8 December 2015

Format Numbers as text so that the report output displays leading zeros.


Introduction:
Many times when working with reports customers use sequence numbers that often appended with zeros to the start of the number. When we use that in the report, the report output Excel or PDF, usually the Zero's disappears.

Example: 
Data in the table: 000000220513
Report output    : 220513


Steps:
To display the report output as 220513, the following options can be used.

1. Changes in RTF layout template.

Open the the BI Publisher properties for the field and check Force LTR option.

When you check this option you can see the following code in the Advanced tab or Form field help text field you can see following:

<fo:bidi-override direction="ltr" unicode-bidi="bidi-override"><?DOC_SEQ_NUM?></fo:bidi-override>

Alternatley you can write the above code for the field.


2. Change the SQL to output the column with quotes so that the character format preserves.

select '="' ||DOC_SEQ_NUM || '"'  from dual;

Script to copy parameters from one concurrent program to other


Input:
l_from_prog_short_name  => From Program short name
l_to_prog_short_name => To Program short name
l_to_prog_appl_short_name => To program application short name


Script:
declare
l_from_prog_short_name varchar2(240) := '<From Prog Name>';
l_to_prog_short_name varchar2(240) := '<to prog name>';
l_to_prog_appl_short_name varchar2(240) := '<to prog appl short name>';

cursor cp_from_program_parms
is
select
 params.column_seq_num sequence
,params.end_user_column_name parameter
,params.description
,params.enabled_flag enabled
,vs.flex_value_set_name value_set
,params.default_type
,params.default_value
,params.required_flag required
,params.security_enabled_flag enable_security
,params.range_code range
,params.display_flag display
,params.display_size
,params.maximum_description_len description_size
,params.concatenation_description_len concatenated_description_size
,params.form_left_prompt prompt
,params.srw_param token
,'N'    cd_parameter  --cp.cd_parameter
from FND_DESCR_FLEX_COL_USAGE_VL params, fnd_flex_value_sets vs
where 1=1
and descriptive_flexfield_name = '$SRS$.'||l_from_prog_short_name
and vs.flex_value_set_id=params.flex_value_set_id(+);
begin
for param_rec in cp_from_program_parms
 loop

  begin
  fnd_program.parameter(
program_short_name    =>  l_to_prog_short_name, -- program short name
application           =>  l_to_prog_appl_short_name, -- application short name
sequence              =>  param_rec.sequence,
  parameter             =>  param_rec.parameter,
--parameter             =>  param_rec.token,
description           =>  param_rec.description,
enabled              =>  param_rec.enabled,
value_set            =>  param_rec.value_set,
default_type           =>  param_rec.default_type,
default_value          =>  param_rec.default_value,
required                 =>  param_rec.required,
enable_security           =>  param_rec.enable_security,
range                      =>  param_rec.range,
display                   =>  param_rec.display,
display_size               =>  param_rec.display_size,
description_size          =>  param_rec.description_size,
concatenated_description_size =>  param_rec.concatenated_description_size,
prompt                       =>  param_rec.prompt,
  token                        =>  param_rec.token,
  --token                        =>  null,
cd_parameter                 =>  param_rec.cd_parameter);
  exception
   when others
    then
    dbms_output.put_line(param_rec.parameter);
    dbms_output.put_line(sqlerrm);
  end;

 end loop;
  --commit;
 dbms_output.put_line('Success');
exception
 when others then
  rollback;
  dbms_output.put_line(SQLERRM);
end;
/

Wednesday 25 November 2015

Add a Concurrent Program to a Responsibility using PL/SQL Script


Input:
l_program_name: Give concurrent program name you want to add to a responsibility               
l_responsibility_name: Give responsibility name for which you want add the above program.

Script:
DECLARE
   -- Provide concurrent program name and Responsibility name here:
   l_program_name                VARCHAR2 (240) := '<&>';
   l_responsibility_name         VARCHAR2 (240) := 'XX OKS INQUIRY';

   ---- Private variables to program ----
   l_prog_short_name             VARCHAR2 (240);
   l_prog_appl_short_name        VARCHAR2 (240);

   l_req_group_name              VARCHAR2 (240);
   l_req_group_appl_short_name   VARCHAR2 (240);
BEGIN
   -- Fetch Request group details from Responsibility
   BEGIN
      SELECT rga.application_short_name rg_appl_short_name,
             rg.request_group_name
        INTO l_req_group_appl_short_name, l_req_group_name
        FROM fnd_responsibility_vl resp,
             fnd_request_groups rg,
             fnd_application rga
       WHERE     UPPER (resp.responsibility_name) LIKE
                    UPPER (l_responsibility_name || '%')
             AND resp.group_application_id = rg.application_id
             AND resp.request_group_id = rg.request_group_id
             AND rga.application_id = rg.application_id;
   EXCEPTION
      WHEN OTHERS
      THEN
         DBMS_OUTPUT.put_line (
            'Exception when fetching request group details:' || SQLERRM);
         RETURN;
   END;

   -- Fetch Program details from Conc program name
   BEGIN
      SELECT cp.concurrent_program_name, cpa.application_short_name
        INTO l_prog_short_name, l_prog_appl_short_name
        FROM fnd_concurrent_programs_vl cp, fnd_application cpa
       WHERE     1 = 1
             AND cp.user_concurrent_program_name LIKE l_program_name || '%'
             AND cp.application_id = cpa.application_id;
   EXCEPTION
      WHEN OTHERS
      THEN
         DBMS_OUTPUT.put_line (
            'Exception when fetching program details:' || SQLERRM);
         RETURN;
   END;


   FND_PROGRAM.add_to_group (l_prog_short_name           -- program_short_name
                                              ,
                             l_prog_appl_short_name -- application name/ application short name
                                                   ,
                             l_req_group_name            -- Request Group Name
                                             ,
                             l_req_group_appl_short_name); --Request Group Application
   COMMIT;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Exception :' || SQLERRM);
      ROLLBACK;
END;
/

Tuesday 24 November 2015

Query to get list of parameters of a concurrent program


Input: 
Replace <&Conc Program Name> in the following query with the concurrent program name:

Query:

select
 params.column_seq_num sequence
,params.end_user_column_name parameter
,params.description
,params.enabled_flag enabled
,vs.flex_value_set_name value_set
,params.default_type
,params.default_value
,params.required_flag required
,params.security_enabled_flag enable_security
,params.range_code range
,params.display_flag display
,params.display_size
,params.maximum_description_len description_size
,params.concatenation_description_len concatenated_description_size
,params.form_left_prompt prompt
,params.srw_param token
,'N'    cd_parameter  --cp.cd_parameter
from FND_DESCR_FLEX_COL_USAGE_VL params, fnd_flex_value_sets vs, fnd_concurrent_programs_vl fcp
where 1=1
and fcp.user_concurrent_program_name like '<&Conc Program Name>'||'%'
and descriptive_flexfield_name = '$SRS$.'||fcp.concurrent_program_name
and vs.flex_value_set_id=params.flex_value_set_id(+)

Query to get RTF/XSL-FO layout template or data template file


Background: In most cases, you will not have access to UI for higher level instances and you want to check the RTF or XSL-FO layout template registed in XML Publisher responsibility.

The XML publisher layout templates are stored in the following tables:
XDO

XDO_LOBS table stores the documents uploaded to both Template defintion and Data Defintion.


Input:
LOB_TYPE--> For Data template give it as DATA_TEMPLATE, For template give it as  'TEMPLATE_SOURCE', For preview XML give 'XML_SAMPLE'
APPLICATION_SHORT_NAME --> Application_short_name
LOB_CODE--> Template code/Data Defintion code

SELECT xdo_file_type,
       file_content_type,
       file_data -- Actual content.
FROM XDO_LOBS
WHERE LOB_TYPE = '<LOB_TYPE >'
  AND APPLICATION_SHORT_NAME = '<APPLICATION_SHORT_NAME >'
  AND LOB_CODE = <LOB_CODE >



NOTE: You must use SQL Developer or Toad or any tool which supports exporting/viewing blob data.

Query to get list of responsibilities that have access to a concurrent program


Background:
Some times you know the concurrent program but you do not know how to access (do not to which responsibility it is attached). In this case, the following query can be helpful

Input:
Concurrent program name

 SELECT frv.responsibility_name,fcp.user_concurrent_program_name, frg.*
  FROM fnd_request_groups frg,
      fnd_request_group_units frgu,
      fnd_concurrent_programs_vl fcp,
      fnd_responsibility_vl frv
      WHERE frg.request_group_id    = frgu.request_group_id
    AND frg.application_id          = frgu.application_id
    AND frgu.request_unit_id        = fcp.concurrent_program_id
    AND frgu.unit_application_id    = fcp.application_id
    AND fcp.user_concurrent_program_name like '<conc program name>'||'%'
    and frv.request_group_id=frg.request_group_id

Monday 23 November 2015

Defaulting value on a DFF Segment using sql


Here are the steps to default a value on a DFF segment:

1) Go to DFF definition screen and open the segment which you want to add/update:




2) Click on Open button, then you see following screen:



3)  For default type select “SQL Statement” and in the default value give your sql:       

4) If you want to reference other fields in the flex you can do by using :$FLEX$.segment1
Example:
Select  col1   From sk_temp xt
Where 1=1 And  :$FLEX$.segment1 = xt.col2

Use :$FLEX$.valueset name if segement1 is based on a value set

Friday 20 November 2015

Difference between dba_* and all_* and user_* dictionary views


Difference between dba_* and all_* and user_* dictionary views

  • An ALL_* view displays all the information accessible to the current user, including information from the current user's schema as well as information from objects in other schemas, if the current user has access to those objects by way of grants of privileges or roles.
  • A DBA_* view displays all relevant information in the entire database. DBA_ views are intended only for administrators. They can be accessed only by users with the SELECT ANY TABLE privilege. This privilege is assigned to the DBA role when the system is initially installed.
  • A USER_* view displays all the information from the schema of the current user. No special privileges are required to query these views.

PLSQL Script to Set MOAC Context



PLSQL Script to Set MOAC Context:

declare

  l_user_id fnd_user.user_id%type;
  l_resp_id fnd_responsibility.responsibility_id%type;
  l_appl_id fnd_application.application_id%type;
  l_appl_short_name fnd_application_vl.application_short_name%type;
  l_ou_value fnd_profile_option_values.profile_option_value%type;
  l_sp_value fnd_profile_option_values.profile_option_value%type;
  l_prg varchar2(3) := '000';
begin

select user_id into l_user_id
from fnd_user
where user_name = upper('&user_name');
l_prg  := '010';

select responsibility_id into l_resp_id
from fnd_responsibility_vl
where responsibility_name = ('&resp_name');
l_prg  := '020';

select application_id, application_short_name into l_appl_id, l_appl_short_name
from fnd_application_vl
where application_short_name = upper('&appl_short_name');
l_prg  := '030';

l_ou_value := fnd_profile.value_specific(
  'ORG_ID',l_user_id, l_resp_id, l_appl_id);
l_sp_value := fnd_profile.value_specific(
  'XLA_MO_SECURITY_PROFILE_LEVEL', l_user_id, l_resp_id, l_appl_id);

dbms_output.put_line('MO: Operating Unit: '||l_ou_value);
dbms_output.put_line('MO: Security Profile: '||l_sp_value);

if l_sp_value is null and l_ou_value is null then
  dbms_output.put_line('No operating unit or security profile information 
    found');
else
 l_prg  := '040';
  mo_global.set_org_access(l_ou_value, l_sp_value, l_appl_short_name);
  
end if;

exception when others then
  dbms_output.put_line('Error: '||sqlerrm);
  dbms_output.put_line('Exception at: '||l_prg );
end;
/

Apps Initialization script R12

Introduction:

Many times before executing standard APIs or querying from org stripped views, you need to initialize apps context.


Script:

set serveroutput on;
declare
l_user_name varchar2(240) := 'SERU'; -- Replace this with Oracle Apps user name
l_resp_name varchar2(240) := 'INV';   -- Responsibility Name
l_prod_short_name varchar2(240) := 'INV';  -- Product Short Name
l_resp_appl_id number;
l_user_id number;
l_resp_id number;
begin

-- Get the user id
begin
select user_id
 into l_user_id
 from fnd_user
where user_name=l_user_name;
exception
 when no_data_found then
  dbms_output.put_line('user '|| l_user_name ||' not found');
  return;
 when others then
 dbms_output.put_line('exception :'||sqlerrm);
 return;
end;

-- Get the resp id and resp application id
begin
select application_id, Responsibility_id
into l_resp_appl_id, l_resp_id
from fnd_responsibility_vl
where responsibility_name like l_resp_name||'%';
exception
 when no_data_found then
  dbms_output.put_line('Responsibility '|| l_resp_name ||' not found');
  return;
when others then
 dbms_output.put_line('exception :'||sqlerrm);
 return;
end;


-- call apps init
FND_GLOBAL.APPS_INITIALIZE(USER_ID => l_user_id,RESP_ID => l_resp_id,RESP_APPL_ID=>l_resp_appl_id);

-- set mo global context.
--mo_global.set_org_context(P_ORG_ID_CHAR=> '',P_SP_ID_CHAR=> null,P_APPL_SHORT_NAME=>'');
mo_global.set_org_context(l_prod_short_name);
--mo_global.set_policy_context ('S', v_org_id);

end;

/




Introduction to Oracle apps contracts


Introduction:
Nowa a days everything runs on contract. In indvidauls life examples are opening a bank account, credit card, taking loan, internet connection etc.. In business when you are purchasing or selling goods, they will have contracts with suppliers/customers.

So what is a contract?
Contract is made from set of clauses that govern a business transaction or set of transactions. Business transaction can be a RFQ,Purchase order, Blanket Purchase Agreement, Sales Order  or Sales Agreement or Sales Quote etc.

Clauses are also called articles or terms and conditions.

Coming to Oracle apps contract solution, it has following offers:

1) Oracle Contracts Core
    Oracle contracts core forms the technical foundation for other contract modules.
    Coming to the functional offering, It offers Library management (Articles, Contract Expert, Templates),  Repository contracts. - Mainly drafting part.
    Contracts Core library is the foundation for procurement contract and service contracts. (Execution or applying above terms on the document)
    We will discuss more in the future posts.

   This product is mainly deals with authoring and little of transaction processing. Not a convention ERP product.

2) Oracle Service Contracts
     Using this product, you can create Service Agreements, Subscription Agreement and Warranty and Extended warrenty contracts. Very powerful product can be useful across many industries.


3) Oracle Project Contracts
     This prodcut mainly used in Aerospace and defenese companies. Integrates with Projects.
      Plan and author in Project contracts and do accoutning(costing/revenue) part in Projects.





Thursday 19 November 2015

Script to Open Inventory periods till current month for all organizations


Intro:

Open Inventory accounting periods till current month for all the organizations.

This is useful when working in lower instances (non production instances) where the data or system is not maintained properly.


Script:

-- Oracle Applications Contracts blog ---
DECLARE
   l_organization_id             NUMBER ;
   l_period_set_name             VARCHAR2 (50);
   l_accounted_period_type       VARCHAR2 (50);
   l_last_scheduled_close_date   DATE;
   l_prior_period_open           BOOLEAN;
   l_new_acct_period_id          NUMBER;
   l_duplicate_open_period       BOOLEAN;
   l_commit_complete             BOOLEAN := TRUE;
   l_return_status               VARCHAR2 (1);
   l_last_period_end_date        DATE;

   CURSOR acct_period_list (
      org_id                        IN NUMBER,
      periodsetname                 IN VARCHAR2,
      acctperiodtype                IN VARCHAR2,
      l_last_scheduled_close_date   IN DATE)
   IS
        SELECT glp.PERIOD_SET_NAME,
               glp.PERIOD_NAME,
               glp.START_DATE,
               glp.END_DATE,
               glp.PERIOD_TYPE ACCOUNTED_PERIOD_TYPE,
               glp.PERIOD_YEAR,
               glp.PERIOD_NUM PERIOD_NUMBER
          FROM GL_PERIODS glp
         WHERE     glp.ADJUSTMENT_PERIOD_FLAG = 'N'
               AND glp.period_type = acctperiodtype
               AND glp.PERIOD_SET_NAME = periodsetname
               AND glp.PERIOD_NAME NOT IN (SELECT OAP.PERIOD_NAME
                                             FROM ORG_ACCT_PERIODS OAP
                                            WHERE     OAP.PERIOD_SET_NAME =
                                                         glp.PERIOD_SET_NAME
                                                  AND OAP.PERIOD_NAME =
                                                         glp.PERIOD_NAME
                                                  AND OAP.organization_id =
                                                         org_id)
               AND glp.end_date >= l_last_scheduled_close_date
               AND glp.end_date <= LAST_DAY (SYSDATE)
      ORDER BY glp.start_date ASC;

   CURSOR cur_inv_org
   IS
        SELECT organization_id, organization_code
          FROM mtl_parameters
      ORDER BY organization_code;
BEGIN
   FOR inv_rec IN cur_inv_org
   LOOP
      l_organization_id := inv_rec.organization_id;
      DBMS_OUTPUT.put_line ('Processing org ' || inv_rec.organization_code);

      SELECT glsob.period_set_name, accounted_period_type
        INTO l_period_set_name, l_accounted_period_type
        FROM cst_organization_definitions cod, gl_sets_of_books glsob
       WHERE     glsob.set_of_books_id = cod.set_of_books_id
             AND cod.organization_id = l_organization_id;

      SELECT MAX (schedule_close_date)
        INTO l_last_scheduled_close_date
        FROM org_acct_periods
       WHERE organization_id = l_organization_id;

      DBMS_OUTPUT.put_line ('l_period_set_name : ' || l_period_set_name);
      DBMS_OUTPUT.put_line (
         'l_accounted_period_type : ' || l_accounted_period_type);
      DBMS_OUTPUT.put_line (
         'l_last_scheduled_close_date : ' || l_last_scheduled_close_date);


      FOR per_rec IN acct_period_list (l_organization_id,
                                       l_period_set_name,
                                       l_accounted_period_type,
                                       l_last_scheduled_close_date)
      LOOP


         CST_AccountingPeriod_PUB.open_period (
            p_api_version                 => 1.0,
            p_org_id                      => l_organization_id,
            p_user_id                     => -1,
            p_login_id                    => -1,
            p_acct_period_type            => per_rec.ACCOUNTED_PERIOD_TYPE,
            p_org_period_set_name         => per_rec.PERIOD_SET_NAME,
            p_open_period_name            => per_rec.PERIOD_NAME,
            p_open_period_year            => per_rec.PERIOD_YEAR,
            p_open_period_num             => per_rec.PERIOD_NUMBER,
            x_last_scheduled_close_date   => l_last_scheduled_close_date,
            p_period_end_date             => per_rec.end_date,
            x_prior_period_open           => l_prior_period_open,
            x_new_acct_period_id          => l_new_acct_period_id,
            x_duplicate_open_period       => l_duplicate_open_period,
            x_commit_complete             => l_commit_complete,
            x_return_status               => l_return_status);

         IF l_return_status <> FND_API.g_ret_sts_success
         THEN
            DBMS_OUTPUT.put_line ('Error while opening period ');
         ELSE
            --DBMS_OUTPUT.put_line ('Period(s) Opened Successfully');
            COMMIT;
         END IF;
      END LOOP;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (SQLERRM);

END;