Wednesday, July 2, 2014

SQL query to find Open/Close Periods in Oracle Apps R12


Query to find the Gl Set of Books.


To find SET_OF_BOOKS_ID:

SELECT * FROM gl_sets_of_books

Inventory


SELECT DISTINCT opu.name AS operating_unit
                , per.organization_id AS inv_org_id
                , par.organization_code AS inv_org_code
                , org1.name AS Organization_name
                , per.period_name
                , per.period_year
                , flv.meaning AS status
    FROM org_acct_periods per
       , fnd_lookup_values flv
       , mtl_parameters par
       , hr_all_organization_units org1
       , hr_all_organization_units_tl otl
       , hr_organization_information org2
       , hr_organization_information org3
       , hr_operating_units opu
   WHERE 1 = 1
     AND flv.lookup_type(+) = 'MTL_ACCT_PERIOD_STATUS'
     AND flv.enabled_flag(+) = 'Y'
     AND per.organization_id = par.organization_id
     AND flv.lookup_code(+) =
            DECODE (
               NVL (per.period_close_date, SYSDATE)
             , per.period_close_date, DECODE (
                                         per.open_flag
                                       , 'N', DECODE (summarized_flag
                                                    , 'N', 65
                                                    , 66)
                                       , 'Y', 4
                                       , 'P', 2
                                       , 4)
             , 3)
     AND flv.language = 'US'
     AND UPPER (flv.meaning) != 'CLOSED'
     AND per.organization_id = org1.organization_id
     AND org1.organization_id = otl.organization_id
     AND org1.organization_id = org2.organization_id
     AND org1.organization_id = org3.organization_id
     AND org2.org_information_context = 'Accounting Information'
     AND org3.org_information_context = 'CLASS'
     AND org3.org_information1 = 'INV'
     AND org3.org_information2 = 'Y'
     AND org2.org_information3 = opu.organization_id
     AND PER.PERIOD_NAME = '&Period_Name'
     and opu.set_of_books_id = '&SOB'
ORDER BY opu.name
       , per.organization_id;

To Check whether Periods of AP/AR/GL/FA/PO is closed?


  SELECT DISTINCT (SELECT sob.NAME
                     FROM gl_sets_of_books sob
                    WHERE sob.set_of_books_id = a.set_of_books_id)
                     "SOB_Name"
                , a.period_name "Period_Name"
                , a.period_num "Period_Num"
                , a.gl_status "GL_Status"
                , b.po_status "PO_Status"
                , c.ap_status "AP_Status"
                , d.ar_status "AR_Status"
                , e.fa_status "FA_Status"
    FROM (SELECT period_name
               , period_num
               , DECODE (closing_status
                       , 'O', 'Open'
                       , 'C', 'Closed'
                       , 'F', 'Future'
                       , 'N', 'Never'
                       , closing_status)
                    gl_status
               , set_of_books_id
            FROM gl_period_statuses
           WHERE application_id = 101
             AND UPPER (period_name) = UPPER ('&period_name')
             AND set_of_books_id = '&sob') a
       , (SELECT period_name
               , DECODE (closing_status
                       , 'O', 'Open'
                       , 'C', 'Closed'
                       , 'F', 'Future'
                       , 'N', 'Never'
                       , closing_status)
                    po_status
               , set_of_books_id
            FROM gl_period_statuses
           WHERE application_id = 201
             AND UPPER (period_name) = UPPER ('&period_name')
             AND set_of_books_id = '&sob') b
       , (SELECT period_name
               , DECODE (closing_status
                       , 'O', 'Open'
                       , 'C', 'Closed'
                       , 'F', 'Future'
                       , 'N', 'Never'
                       , closing_status)
                    ap_status
               , set_of_books_id
            FROM gl_period_statuses
           WHERE application_id = 200
             AND UPPER (period_name) = UPPER ('&period_name')
             AND set_of_books_id = '&sob') c
       , (SELECT period_name
               , DECODE (closing_status
                       , 'O', 'Open'
                       , 'C', 'Closed'
                       , 'F', 'Future'
                       , 'N', 'Never'
                       , closing_status)
                    ar_status
               , set_of_books_id
            FROM gl_period_statuses
           WHERE application_id = 222
             AND UPPER (period_name) = UPPER ('&period_name')
             AND set_of_books_id = '&sob') d
       , (SELECT fdp.period_name
               , DECODE (fdp.period_close_date, NULL, 'Open', 'Closed')
                    fa_status
               , fbc.set_of_books_id
            FROM fa_book_controls fbc, fa_deprn_periods fdp
           WHERE fbc.set_of_books_id = '&sob'
             AND fbc.book_type_code = fdp.book_type_code
             AND UPPER (fdp.period_name) = UPPER ('&period_name')) e
   WHERE a.period_name = b.period_name(+)
     AND a.period_name = c.period_name(+)
     AND a.period_name = d.period_name(+)
     AND a.period_name = e.period_name(+)
     AND a.set_of_books_id = b.set_of_books_id(+)
     AND a.set_of_books_id = c.set_of_books_id(+)
     AND a.set_of_books_id = d.set_of_books_id(+)
     AND a.set_of_books_id = e.set_of_books_id(+)
ORDER BY 1;

Oracle E-Business Suite Free Access Practice Instance



Solution Beacon, LLC is a leading provider of expert-level resources for the most widely used Enterprise Management Systems and Technologies. Use Solution Beacon vision Instance freely for your own Practice in 11i and R12 Apps.



For 11i Instance:
Release 11.5.10.2 (a510vis5)
URL: http://vis11510ext5.solutionbeacon.net/OA_HTML/AppsLocalLogin.jsp
User name: VT1560
Password: 1560VT

Solution beacon has deleted the user oeag01, So i have shared a new username for R12 instance.

For R12 Instance: (Updated 24-OCT-2013)
Release 12.1.3 Vision (vis1213)
URL: http://vis1213.solutionbeacon.net/OA_HTML/AppsLogin

Note: R12.1.3 User Id/Password Not Available now! Try below method to register your own id.

If you want to separate account for yours, try below steps:
Step 1: Go to the following Link for 11i new user creation:
http://vis11510ext5.solutionbeacon.net/sbreguser.html


Go to the following Link for R12.1.3 new user creation

http://vis1213.solutionbeacon.net/cgi-bin/sbreguser?p=01

Step 2: Enter First Name,Last Name,Email Address(Email address should be Valid),Oracle CSI* ( Just Simply enter any eight digit number which you mostly like.) Now there is no validation in CSI number.

Step 3: Submit, Your Userid and password will be sent to your Email Id.

Note: Solution beacon not providing back-end access to Oracle Apps Instance. If you need, you must have your own instance.

Please ask me if you are facing any problem in that.. Hope you like this Post... :)

Thursday, June 26, 2014

All about Host Concurrent Programs

One of the things to remember while registering a host concurrent program is that the first five parameters are reserved by Oracle E-Business Suite for its own use. The sixth parameter onwards is used for user-defined concurrent program parameters. The first five parameters refer to the following:

$0: The shell script to be executed
$1: Oracle user/password
$2: Applications user_id
$3: Application user_name
$4: Concurrent program request_id

In addition to these, the environment variable FCP_LOGIN is also used to store the Oracle user/password. The steps required to register a shell script as a concurrent program are:

1. Create the shell script in the $APPLBIN directory of the specific application top. In this example, I have created the script under $CS_TOP/bin and named it myscr.prog(Oracle documentation mentions that the extension should be .prog). Its contents are listed below:
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh
echo 'Printing parameters....'
echo '0:'$0
echo '1:'$1
echo '2:'$2
echo '3:'$3
echo '4:'$4
echo '5:'$5
echo 'FCPLOGIN:'$FCP_LOGIN
echo 'Finished printing parameters.'
2. Define the concurrent executable with Execution Method ‘Host’. In the Execution File Name field, specify the name of the shell script without extension(‘myscr’ for this example)

3. Define the concurrent program with parameters as required. For this example, I have defined one parameter with default value ‘ABCDEF’

4. Add the concurrent program to a request group

5. Make a symbolic link using the execution file name to fndcpesr, which is located in the $FND_TOP/$APPLBIN directory. The symbolic link is created in the same directory as the shell script.
1
[oracle@myapps bin]$ ln -s $FND_TOP/bin/fndcpesr  myscr
Ensure that all files have execute permissions to prevent any ‘Permission denied’ errors. You should now be able to execute the concurrent program which in turn will run the shell script. Executing the concurrent program for this example results in a log file containing the following output. Note that the values of FCP_LOGIN, the reserved parameters and the user-defined parameter are all printed.

Printing parameters….
0:/u01/oracle/visappl/cs/11.5.0/bin/myscr.prog
1:APPS/APPS
2:1001530
3:EBUSINESS
4:2721361
5:ABCDEF
FCPLOGIN:APPS/APPS
Finished printing parameters.
Return codes for host concurrent program

If the script traps an error, use the UNIX exit command ‘exit 1′ to return failure (status code 1) to the Concurrent Manager running the program. Of course, code sections after the exit command will not be executed.
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
echo 'Printing parameters....'
echo '0:'$0
echo '1:'$1
echo '2:'$2
echo '3:'$3
echo '4:'$4
echo '5:'$5
exit 1
echo 'FCPLOGIN:'$FCP_LOGIN
echo 'Finished printing parameters.'
The concurrent program will complete with status ‘Error’ and the log file will contain the following:

Printing parameters….
0:/u01/oracle/visappl/cs/11.5.0/bin/myscr.prog
1:APPS/APPS
2:1001530
3:EBUSINESS
4:2721405
5:ABCDEF
/u01/oracle/visappl/cs/11.5.0/bin/myscr
Program exited with status 1
There are no defined exit commands to return a warning status. However, it can be done by using the FND_CONCURRENT.SET_COMPLETION_STATUS API to set the completion status of the request to ‘Warning’. Gareth Roberts deserves a big ‘Thank You’ for posting this on Oracle Forums.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
echo 'Printing parameters....'
echo '0:'$0
echo '1:'$1
echo '2:'$2
echo '3:'$3
echo '4:'$4
echo '5:'$5
MYSTATUS=`sqlplus -s $1 <<!
SET HEADING FEEDBACK OFF PAGESIZE 0
declare
l_result boolean;
l_session_id number;
begin
fnd_global.INITIALIZE(l_session_id, null, null, null,null, -1, null, null, null, null, $4, null,null,null,null,null,null,-1);
l_result := fnd_concurrent.set_completion_status('WARNING','Review log file for details.');
commit;
end;
/
exit;
!`
echo 'FCPLOGIN:'$FCP_LOGIN
echo 'Finished printing parameters.'
This solution makes use of a SQL script to initialize a session with the request_id of the concurrent program using FND_GLOBAL.INITIALIZE and then sets the completion status. Upon execution, the concurrent program ends with a ‘Warning’ status and generates the following output:

Printing parameters….
0:/u01/oracle/visappl/cs/11.5.0/bin/myscr.prog
1:APPS/APPS
2:1001530
3:EBUSINESS
4:2721408
5:ABCDEF
FCPLOGIN:APPS/APPS
Finished printing parameters.
One important thing to notice is that echoing the parameters $1 and $FCP_LOGIN leads to the Oracle user/password being written to the log file. This can be prevented by using the options ENCRYPT and SECURE while defining the concurrent program. ENCRYPT signals the Concurrent Manager to pass the Oracle password in the environment variable FCP_LOGIN. The Concurrent Manager leaves the password in the argument $1 blank. To prevent the password from being passed, enter SECURE in the Execution Options field. With this change, Concurrent Manager does not pass the password to the program.

For this example specifying SECURE in the concurrent program options:

and then running the concurrent program does not set the completion status to ‘Warning’ since the Oracle user/password is not passed and the SQL script cannot run. This can be observed from the contents of the log file.

Printing parameters….
0:/u01/oracle/visappl/cs/11.5.0/bin/myscr.prog
1:APPS/
2:1001530
3:EBUSINESS
4:2721412
5:ABCDEF
FCPLOGIN:
Finished printing parameters.
If we set the options field in the concurrent program to ENCRYPT

then the Oracle user/password will be passed only to $FCP_LOGIN and not to $1. We can change the SQL script to use $FCP_LOGIN instead of $1 and execute the concurrent program. It will now complete with a ‘Warning’ status since the Oracle user/password was passed to the script through $FCP_LOGIN. This can be verified from the contents of the log file:

Printing parameters….
0:/u01/oracle/visappl/cs/11.5.0/bin/myscr.prog
1:APPS/
2:1001530
3:EBUSINESS
4:2721409
5:ABCDEF
FCPLOGIN:APPS/APPS
Finished printing parameters.
Note:

1. Use ${10}, ${11} instead of $10,$11 to refer to double-digit parameters
2. The FND_GLOBAL.INITIALIZE procedure is used to set new values for security globals during login or when the responsibility is changed, it accepts the following parameters:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
session_id in out number,
user_id in number,
resp_id in number,
resp_appl_id in number,
security_group_id in number,
site_id in number,
login_id in number,
conc_login_id in number,
prog_appl_id in number,
conc_program_id in number,
conc_request_id in number,
conc_priority_request in number,
form_id in number default null,
form_appl_id in number default null,
conc_process_id in number default null,
conc_queue_id in number default null,
queue_appl_id in number default null,
server_id in number default -1