QUERY GL Opening and Closing Balance

on Thursday, August 12, 2010

OPENING BALANCE

SELECT     
      cc.concatenated_segments   "GL Account"
     ,cc.gl_account_type         "Account Type"
     ,nvl(sum(bal.begin_balance_dr - bal.begin_balance_cr),0)   "Begin Balance"
     ,bal.period_name            "Period Name"
FROM  gl_code_combinations_kfv cc
     ,gl_balances bal
WHERE cc.code_combination_id = bal.code_combination_id
AND   bal.period_name        = [Period Name]
AND   bal.set_of_books_id    = [Set of Book ID]
GROUP BY
      cc.concatenated_segments
     ,cc.gl_account_type
     ,bal.period_name
ORDER by
      cc.concatenated_segments


CLOSING BALANCE

SELECT
      cc.concatenated_segments   "GL Account"

     ,cc.gl_account_type         "Account Type"
     ,nvl(sum(bal.begin_balance_dr - bal.begin_balance_cr +
          bal.period_net_dr - bal.period_net_cr),0)  "Closing Balance"
     ,bal.period_name            "Period Name"
FROM  gl_code_combinations_kfv cc
     ,gl_balances bal
WHERE cc.code_combination_id = bal.code_combination_id
AND   bal.period_name        = [Period Name]
AND   bal.set_of_books_id    = [Set of Book ID]
GROUP BY
      cc.concatenated_segments

     ,cc.gl_account_type
     ,bal.period_name
ORDER BY
      cc.concatenated_segments

bal.period_name = [Period Name]  Here you should enter the period name you want to see. You can check the table GL_PERIOD_STATUSES to see which period you want. If you do not define a period the query will return a bunch of records without any sense.
bal.set_of_books_id =[Set of Book ID] Here you should enter your set of books id (each company has a set of books id), You can check table GL_SETS_OF_BOOKS to check which company you want to see. Otherwise the query will return all companies data mixed.

Script to remove Descriptive Flexfield Segments

on Thursday, August 5, 2010


This is useful in cases where FNDLOAD does not perform a delete of segments. Hence such a script can be used for cleanup of the DFF. Simply replace the contents in "bold" text below to make this work on your environment

--Script to clean up DFF Segments

set serveroutput on size 100000;
DECLARE

l_flexfield_type fnd_flex_key_api.flexfield_type;l_structure_type fnd_flex_key_api.structure_type;l_segment_type fnd_flex_key_api.segment_type;l_flex_num VARCHAR2(1000);

BEGIN

FOR p_rec IN (SELECT end_user_column_name,descriptive_flexfield_name,descriptive_flex_context_code
FROM   fnd_descr_flex_col_usage_vl
WHERE (application_id = 100)
AND   (descriptive_flexfield_name = 'Person Info DDF')
AND   (descriptive_flex_context_code LIKE 'XX_DFF_CONTEXT_HERE'))

LOOP


fnd_flex_dsc_api.delete_segment
(appl_short_name => 'PER',

 flexfield_name  => p_rec.descriptive_flexfield_name,
 CONTEXT         => p_rec.descriptive_flex_context_code,
 SEGMENT         => p_rec.end_user_column_name);

dbms_output.put_line('Segment'||p_rec.end_user_column_name||deleted ');
END LOOP;
END;

Integration of APEX with APPS

on Saturday, July 31, 2010

Oracle Application Express (Oracle Apex) is a rapid web application development tool for the Oracle database. Using only a web browser and limited programming experience, you can develop and deploy professional applications. We wanted to extend the E-Business Suite functionality with Apex features. Apex functions need to be available from the EBS user menu. Users have to be able to move seamlessly from EBS to Apex, without logging in twice. The context of the EBS user needs to specify which data the user is allowed to see in Apex. Our goal was to develop a calendar in Apex which shows a team's absences for the logged in supervisor. In EBS the "supervisor -> employee" relation has a hierarchical structure, which has to be available in the calendar.

The first challenge we have to deal with is authentication. Apex users have to log in to access an application. We used the EBS security to allow users to logon to Apex using their EBS username and password. In Apex we created a custom authentication scheme which calls an external function to validate the username and password. The authentication scheme calls our plsql function "apex_authorise" which uses the EBS "fnd_web_sec.validate_login" to validate the username and password. At this point we are able to log in to an Apex application using any valid EBS username and password combination.

Now we want to link Apex forms from the EBS menu. The first problem is that Apex requires a valid password for the user and the EBS database does not contain passwords, it holds a hash of the username/password combination. You can handle this by creating an alternative password using the DBMS_OBFUSCATION_TOOLKIT md5 function. The password will be generated by hashing the username, a time component and a key held within the database. This mechanism will be handled in two functions: "apex_generate_hash" and "apex_validate_hash". To check if the password is valid, we extend the already created function "apex_authorise".

Now we want to login in Apex automatically. We use a cookie to achieve this. The form function we use in EBS, sets a cookie containing the username and password and redirects to the Apex URL to launch the Apex application. In EBS we have to create a web enabled mod_plsql procedure to achieve this. This form function can then be added to the EBS menu. In Apex we use a "before header" process to read the cookie and log the user in.

The cookie we used:

OWA_COOKIE.send
(name=>'APEX_APPS_'||application,
value=>FND_GLOBAL.user_name||':'||
apex_generate_hash(FND_GLOBAL.user_name)||':'||
FND_GLOBAL.user_id||':'||
FND_GLOBAL.resp_id||':'||
FND_GLOBAL.resp_appl_id
);

We store the FND_GLOBAL values in global variables in Apex. We use these variables in the page query of an Apex application to only show the results for this specific user. In our case we used the standard calendar feature of Apex. In this calendar you can specify a sql query which selects the data to publish.

Ideally we want to save the context of the environment an APPS user is working in and seamlessly use this context in our Apex application. This way we don't have to care about which data is visible for the user, the APPS security mechanism will take care of that. This is something which has to be investigated. In our project we send the user information in the cookie, and use this information for our data selection.