Friday 1 December 2017

EBS: Learning Management Query

EBS: Learning Management Query
To get the Oracle Learning Management details.


  SELECT   oe.title event_name,
           TO_CHAR (oe.course_start_date, 'DD-Mon-RRRR') stdate,
           TO_CHAR (oe.course_end_date, 'DD-Mon-RRRR') enddate,
           oe.course_start_time stime,
           oe.course_end_time etime,
           papf.email_address emp_mail,
           papf.full_name emp_name,
           papf1.email_address sup_mail,
           papf1.full_name sup_name,
           oe.evt_information2 class_location
    FROM   ota_events oe,
           ota_delegate_bookings odb,
           per_all_people_f papf,
           per_all_assignments_f paaf,
           per_all_people_f papf1
   WHERE       1 = 1
           AND odb.event_id(+) = oe.event_id
           AND papf.person_id = odb.delegate_person_id
           AND odb.internal_booking_flag = 'Y'
           AND paaf.primary_flag = 'Y'
           AND papf.current_employee_flag = 'Y'
           AND paaf.person_id = papf.person_id
           AND papf1.person_id = paaf.supervisor_id
           AND papf1.current_employee_flag = 'Y'
           AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
                                   AND  paaf.effective_end_date
           AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
                                   AND  papf.effective_end_date
           AND TRUNC (SYSDATE) BETWEEN papf1.effective_start_date
                                   AND  papf1.effective_end_date
ORDER BY   1;

EBS: Employee Performance Query

EBS: Employee Performance Query
To get the Employee Performance Band.



  SELECT   DISTINCT papf.employee_number,
                    papf.full_name,
                    ppr.RATING_MEANING,
                    ppr.review_date,
                    hrv.name
    FROM   PER_ALL_PEOPLE_F papf,
           PER_all_ASSIGNMENTS_F paaf,
           PER_PERFORMANCE_REVIEWS_V ppr,
           PER_PERIODS_OF_SERVICE_V pps,
           HR_ORGANIZATION_UNITS_V hrv
   WHERE       1 = 1
           AND papf.person_id = ppr.person_id
           AND PPS.PERSON_ID = papf.person_id
           AND Paaf.PERSON_ID = papf.person_id
           AND HRV.ORGANIZATION_ID = paaf.ORGANIZATION_ID
           AND PPS.ACTUAL_TERMINATION_DATE IS NULL
           AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
                                   AND  papf.effective_end_date
           AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
                                   AND  paaf.effective_end_date
           AND TO_CHAR (ppr.review_date, 'YYYY') = '2014'
--and  to_number(ppr.RATING_MEANING) between 0 and  0.8    -
ORDER BY   papf.employee_number

Thursday 30 November 2017

Organization Manager Script

Organization Manager Script

select
    org_tl.name                                                         "Organization",
    ppf.full_name                                                       "Manager",
    fnd_date.canonical_to_date (org_info2.org_information3)             "Start Date",
    fnd_date.canonical_to_date (org_info2.org_information4)             "End Date",
    --
    org.organization_id,
    org.business_group_id,
    ppf.person_id
from
    hr_all_organization_units org,
    hr_all_organization_units_tl org_tl,
    hr_organization_information org_info2,
    per_all_people_f ppf
where
    1=1
and org_info2.organization_id = org.organization_id
and org_info2.org_information_context = 'Organization Name Alias'
and org_info2.org_information2 = to_char (ppf.person_id(+))
and org.organization_id = org_tl.organization_id
and org_tl.language = userenv ('LANG')
and exists (select null
    from hr_org_info_types_by_class oitbc, hr_organization_information org_info
    where org_info.organization_id = org.organization_id
    and org_info.org_information_context = 'CLASS'
    and org_info.org_information2 = 'Y'
    and oitbc.org_classification = org_info.org_information1
    and oitbc.org_information_type = 'Organization Name Alias')
and (decode(hr_security.view_all,
        'Y', 'TRUE',
        hr_security.show_record('HR_ALL_ORGANIZATION_UNITS',org.organization_id)) = 'TRUE'
    and decode (hr_general.get_xbg_profile,
            'Y', org.business_group_id,
            hr_general.get_business_group_id) = org.business_group_id
    or decode (hr_security.view_all,
            'Y', 'TRUE',
            hr_security.show_record ('PER_ALL_PEOPLE_F',
                               ppf.person_id,
                               ppf.person_type_id,
                               ppf.employee_number,
                               ppf.applicant_number)) = 'TRUE'
        and decode(hr_general.get_xbg_profile,
                'Y', ppf.business_group_id,
                hr_general.get_business_group_id) = ppf.business_group_id)
--
--and org_tl.name = 'Sales'
order by
    1,2

Tuesday 14 November 2017

Calculate Leave Between Two Dates


Calculate Leave Between Two Dates

Following function will help you to get the number of leaves between two dates.

CREATE OR REPLACE function APPS.lsg_get_lv_btw_two_dates(p_person_id number,P_Period_Start_date date,P_Period_End_date date,p_leave_name varchar2) return number
is
ln_lv_curr_mnth_cnt number:=0;
ln_lv_curr_mnth_cnt1 number:=0;
ln_lv_curr_mnth_cnt2 number:=0;
ln_lv_curr_mnth_cnt3 number:=0;
ln_lv_curr_mnth_cnt4 number:=0;
p_lv_st_dt date;
p_lv_end_date date;

date1 date;
date2 date;

–Created on December 5, 2016 by Syed Farhan Ashraf
–This Function calcuates the leaves taken by employee between two dates

–Leave Starting and Ending in Same Period
cursor c_emp_lvs1
is
select paa.person_id ,paa.date_start,paa.date_end
from per_absence_attendances paa, per_absence_attendance_types paat
where paa.ABSENCE_ATTENDANCE_TYPE_ID = paat.ABSENCE_ATTENDANCE_TYPE_ID
and paa.person_id = p_person_id
and UPPER (NAME) = upper(p_leave_name)
and paa.DATE_START >= date1 and paa.DATE_END <=date2;

–Leave Starting in Last Period and Ending in Current Period
cursor c_emp_lvs2
is
select paa.person_id ,paa.date_start,paa.date_end
from per_absence_attendances paa, per_absence_attendance_types paat
where paa.ABSENCE_ATTENDANCE_TYPE_ID = paat.ABSENCE_ATTENDANCE_TYPE_ID
and paa.person_id = p_person_id
and UPPER (NAME) = upper(p_leave_name)
and paa.DATE_START < date1 and paa.DATE_END between date1 and date2;

–Leave Starting in Current Period but Ending in Next Period

cursor c_emp_lvs3 is
select paa.person_id ,paa.date_start,paa.date_end
from per_absence_attendances paa, per_absence_attendance_types paat
where paa.ABSENCE_ATTENDANCE_TYPE_ID = paat.ABSENCE_ATTENDANCE_TYPE_ID
and paa.person_id = p_person_id and UPPER (NAME) = upper(p_leave_name)
and paa.DATE_START between date1 and date2 and paa.DATE_END > date2;

–Leave Starting in Last Period and Ending in Next Period
cursor c_emp_lvs4
is
select paa.person_id ,paa.date_start,paa.date_end
from per_absence_attendances paa, per_absence_attendance_types paat
where paa.ABSENCE_ATTENDANCE_TYPE_ID = paat.ABSENCE_ATTENDANCE_TYPE_ID
and paa.person_id = p_person_id
and UPPER (NAME) = upper(p_leave_name)
and paa.DATE_START < date1 and paa.DATE_END > date2;

BEGIN

date1 := P_Period_Start_date;
date2 := P_Period_End_date;

dbms_output.put_line(‘start’);
–Leave Starting and Ending in Same Period
for r_emp_lv in c_emp_lvs1 loop
ln_lv_curr_mnth_cnt1 := r_emp_lv.date_end – r_emp_lv.date_start + 1;
ln_lv_curr_mnth_cnt := ln_lv_curr_mnth_cnt + ln_lv_curr_mnth_cnt1;
end loop;
dbms_output.put_line(‘test ln_lv_curr_mnth_cnt 1 ‘||ln_lv_curr_mnth_cnt);

–Leave Starting in Last Period and Ending in Current Period
for r_emp_lv2 in c_emp_lvs2 loop
ln_lv_curr_mnth_cnt2 := r_emp_lv2.date_end – P_Period_Start_date +1 ;
ln_lv_curr_mnth_cnt := ln_lv_curr_mnth_cnt + ln_lv_curr_mnth_cnt2;
end loop;
dbms_output.put_line(‘test ln_lv_curr_mnth_cnt 2 ‘||ln_lv_curr_mnth_cnt);

–Leave Starting in Current Period but Ending in Next Period
for r_emp_lv in c_emp_lvs3 loop
ln_lv_curr_mnth_cnt3 := P_Period_End_date – r_emp_lv.date_start +1;
ln_lv_curr_mnth_cnt := ln_lv_curr_mnth_cnt + ln_lv_curr_mnth_cnt3;
end loop;

–Leave Starting in Last Period and Ending in Next Period
dbms_output.put_line(‘test ln_lv_curr_mnth_cnt 3 ‘||ln_lv_curr_mnth_cnt);
for r_emp_lv in c_emp_lvs4 loop
ln_lv_curr_mnth_cnt4 := P_Period_End_date – P_Period_Start_date +1;
ln_lv_curr_mnth_cnt := ln_lv_curr_mnth_cnt + ln_lv_curr_mnth_cnt4;
end loop;
dbms_output.put_line(‘test ln_lv_curr_mnth_cnt 4 ‘||ln_lv_curr_mnth_cnt);
— ln_lv_curr_mnth_cnt := ln_lv_curr_mnth_cnt1 + ln_lv_curr_mnth_cnt2 + ln_lv_curr_mnth_cnt3 + ln_lv_curr_mnth_cnt4 ;

return ln_lv_curr_mnth_cnt;

end;
/

Sample to use the above Function

select lsg_get_lv_btw_two_dates(68567,’01-JAN-2016′,’31-JUL-2016′,’Annual Leave’)
from dual

Functions Used in Oracle HRMS Fast Formula

Functions Used in Oracle HRMS


In previous article of Fast Formula, we understood the concept, its usage and different types of Fast Formulas in Oracle HRMS. In this article i am going to explain the functions that we can use in Fast formula to make the desired logic. Following are different types of functions that can be used in the formula

Text Functions
Date Functions
Data Conversion Functions
Number Functions
Functions to Get values from Tables
External Formula Function
Functions Used in Fast Formula


Text Functions

CHR

CHR(n)
The CHR function returns the character having the binary equivalent to number operand n in the database character set.
Example
/* CHR (10) used to add a newline to the end of REPORT_TEXT2. */
REPORT_TEXT2 = ‘Warning the Transaction Limit has been exceeded’ Back to Top
DEBUG

DEBUG(expr)
This function accepts a string and uses a DBMS_OUTPUT statement to output the string to the console. Use this function when you are testing a new formula to track its
processing and identify where it is failing.Back to Top
GREATEST

GREATEST(expr, expr [, expr] . . .)
GREATEST_OF(expr, expr [, expr] . . .)
The GREATEST function compares the values of all the text string operands. It returns the value of the operand that is alphabetically last. If there are two or more operands that meet the criteria, Oracle FastFormula returns the first.Back to Top
INITCAP

INITCAP(expr)
The INITCAP function returns the expression expr with the first letter of each word in
uppercase, all other letters in lowercase. Words are delimited by white space or
characters that are not alphanumeric.Back to Top
INSTR

INSTR(expr1,expr2[,n[,m]])
The INSTR searches expr1 beginning with its nth character for the nth occurrence of expr2 and returns the position of the character in expr1 that is the first character of this occurrence. If n is negative, Oracle FastFormula counts and searches backward from the end of expr1. The value of m must be positive. The default values of both n and m are 1, meaning Oracle FastFormula begins searching at the first character of expr1 for the first occurrence of expr2. The return value is relative to the beginning of expr1, regardless of the value of n, and is expressed in characters. If the search is unsuccessful (if expr2 does not appear m times after the nth character of expr1) the return value is 0.Back to Top
INSTRB

INSTRB(expr1,expr2[,n[,m]])
The same as INSTR, except that n and the return value are expressed in bytes, rather than in characters. For a single-byte database character set, INSTRB is equivalent to INSTR.Back to Top
LEAST

LEAST(expr, expr [, expr] . . .)
LEAST_OF(expr, expr [, expr] . . .)
The LEAST function compares the values of all the text string operands. It returns the value of the operand that is alphabetically first. If there are two or more operands that meet the criteria, Oracle FastFormula returns the first.Back to Top
LENGTH

LENGTH(expr)
The LENGTH function returns the number of characters in the text string operand expr. Note: The data type of the result of this function is numeric.Back to Top
LENGTHB

LENGTHB(char)
The LENGTHB function returns the length of char in characters. If char has datatype CHAR, the length includes all trailing blanks. If char is null, this function returns null.Back to Top
LOWER

LOWER(expr)
The LOWER function returns the string operand expr with all letters lowercase. The return value has the same datatype as the argument expr.Back to Top
LPAD

(expr, n [,pad])
The LPAD function returns the text string operand expr left-padded to length n with the sequence of characters in pad. The default for pad is a blank. If expr is longer than n, then LPADreturns the portion of expr that fits in n.
Examples:
/* A is set to ‘XYXYXhello’ */
A = LPAD (‘hello, 10, ‘XY’)
/* A is set to ‘hell’ */
A = LPAD (‘hello’, 4 )Back to Top
LTRIM

(expr [,set])
The LTRIM function returns the text string operand expr with all the leftmost characters that appear in set removed. The default for set is a blank. If none of the leftmost characters of expr appear in set then expr is returned
Examples:
/* A is set to ‘def’ */
A = LTRIM (‘abcdef’,’abc’)
/* A is set to ‘abcdef’ */
A = LTRIM (‘abcdef’,’bc’)Back to Top
REPLACE

(expr, search_string [,replacement_string])
The REPLACE function returns the text string operand expr with every occurrence of search_string replaced with replacement_string. If replacement_string is omitted or null, all occurrences of search_string are removed. If search_string is NULL, expr is returned. REPLACE allows you to substitute one string for another as well as to remove character strings.
Example:
SELECT REPLACE (‘JACK and JUE’,’J’,’BL’) “Changes”
FROM DUAL
Changes
————–
BLACK and BLUE
RPAD

(expr, n [,pad])
The RPAD function returns the text string operand expr right-padded to length n with the sequence of characters in pad. The default for pad is a blank. If expr is longer than n, then RPADreturns the portion of expr that fits in n.
Examples:
/* A is set to ‘helloXYXYX’ */
A = RPAD (‘hello, 10, ‘XY’)
/* A is set to ‘hell’ */
A = RPAD (‘hello’, 4 )Back to Top
RTRIM

(expr [,set])
The RTRIM function returns the text string operand expr with all the rightmost characters that appear in set removed. The default for set is a blank. If none of the
rightmost characters of expr appear in set then expr is returned
Examples:
/* A is set to ‘abc’ */
A = RTRIM (‘abcdef’,’def’)
/* A is set to ‘abcdef’ */
A = RTRIM (‘abcdef’,’de’)
SUBSTRING

SUBSTR(expr, m [,n])
SUBSTRING(expr, m [,n])
The SUBSTRING function returns a substring of the text string operand expr of length n characters beginning at the mth character. If you omit the third operand, the substring starts from m and finishes at the end of expr.
Note: The first operand is a text operand. The second and third operands are numeric operands. The resulting data type of this function is text.
Tip: Always check string length before you start to substring.

For example:
/* Check that the tax code starts with GG */
IF length(Tax_code) <= 2
THEN
(message = ‘Tax code is too short’
RETURN message
)
IF substr( Tax_code, 1, 2) = ‘GG’ THEN …
Or, to check if Tax_code is a string of at least two characters starting
with ‘GG’:
IF Tax_code LIKE ‘GG%’ THEN …
SUBSTRB
(expr, m [,n])

The same as SUBSTR, except that the arguments m and n are expressed in bytes, rather than in characters. For a single-byte database character set, SUBSTRB is equivalent to SUBSTR.Back to Top
TRANSLATE

(expr, from, to)
The TRANSLATE function returns the text string operand expr with all occurrences of each character in from replaced by its corresponding character in to. Characters in expr that are not in from are not replaced. The argument from can contain more characters than to. In this case, the extra characters at the end of from have no corresponding characters in to. If these extra characters appear in expr, they are removed from the return value. Oracle FastFormula interprets the empty string as null, and if this function has a null argument, it returns null.Back to Top
TRIM

TRIM(trim_character FROM trim_source)
The TRIM function allows you to trim heading or trailing characters (or both) from a character string. If trim_character or trim_source is a character literal, you must enclose it in single quotes. You can specify LEADING or TRAILING to remove leading or trailing characters. If you specify none of these, both leading and trailing characters are removed equal to trim_character.Back to Top
UPPER

UPPER(expr)
The UPPER function converts a text string to upper case. Back to Top
Numeric Functions

ABS

ABS(n)
The ABS function returns the magnitude of a numeric operand n as a positive numeric value. If the value of the operand is positive, its value returns unchanged. If the operand is negative then the value’s sign inverts, and the value returns as a positive number.
Example:
ABS (-17) returns 17Back to Top
CALCULATE_HOURS_WORKED

CALCULATE_HOURS_WORKED(n, date1, date2, standard_frequency)
The CALCULATE_HOURS_WORKED function returns the total number of hours worked in a given date range. The function works by calculating the total number of hours worked for an employee between date1 and date2, taking into account that the employee works n hours in the standard working period standard_frequency. This parameter gives the unit of measurement for the standard working period. It can be one of:
• W (weekly)
• M (monthly)
• Y (yearly)
Example:
CALCULATE_HOURS_WORKED (40, 01-FEB-2003, 28-FEB-2003, W) returns 160
This indicates that the employee has worked 160 hours in the month of February 2003, based on a 40-hour week and taking into account the number of working days in that month.Back to Top
FLOOR

FLOOR(n)
The FLOOR function returns the integer part of a numeric operand n. If the value of the operand contains information after the decimal point, Oracle
FastFormula discards that information and returns a whole number.
Example:
FLOOR(35.455) returns 35Back to Top
GREATEST

GREATEST(n, n [, n] . . .)
GREATEST_OF(n, n [, n] . . .)
The GREATEST function compares all the operands and returns the largest value.Back to Top
LEAST

LEAST(n, n [, n] . . .)
LEAST_OF(n, n [, n] . . .)
The LEAST function compares all the operands and returns the smallest value.Back to Top
POWER

POWER(m,n)
Returns m raised to the nth power. The base m and the exponent n can be any numbers, but if m is negative, n must be an integer.Back to Top
ROUND

ROUND(n [, m])
The ROUND function rounds off a numeric value n to m decimal places and a date depending on the format of m. For numeric values, the first operand is the value Oracle FastFormula rounds off, the second the number of places Oracle FastFormula rounds off to. For dates, ROUND returns n rounded to the unit specified by the format model of m such as Year or Day. Refer to the SQL Language Reference Manual for details of the
valid formats you can specify.
Examples:
ROUND(2.3401, 2) returns 2.34
ROUND (2.3461, 2) returns 2.35
ROUND (TO_DATE(’27-OCT-1992′, ‘DD-MON-YYYY’), ‘YEAR’) returns 01-JAN-1993Back to Top
ROUNDUP

ROUNDUP(n [, m])
ROUND_UP(n [, m])
The ROUNDUP function rounds a numeric value n up to m decimal places. The first operand is the value to be rounded up, the second the number of places to round to. If the digits after the rounding point are zero, the value is unchanged. If the digits are not zero, the value is incremented at the rounding point.
Examples:
ROUND_UP(2.3401, 2) returns 2.35
ROUND_UP(2.3400, 2) returns 2.34.Back to Top
TRUNC

TRUNC(n [, m])
TRUNCATE(n [, m])
The TRUNC function rounds a numeric value n down to m decimal places. The first operand is the value to be rounded down, the second the number of places to round to. TRUNC also returns n with the time portion of the day truncated to the unit specified by the format model of m. If you omit m, d is truncated to the nearest day The default model, ‘DD’, returns the date rounded or truncated to the day with a time of midnight. Oracle FastFormula drops all digits (if any) after the specified truncation point.
Examples:
TRUNC(2.3401, 2) returns 2.34.
TRUNC(TO_DATE(’27-OCT-1992′, ‘DD-MON-YYYY’), ‘YEAR’) returns 01-JAN-1992Back to Top
Date Functions

Date Functions
ADD_DAYS

ADD_DAYS(date, n)
The ADD_DAYS function adds a number of days to a date. The resulting date accords with the calendar. Note: Oracle FastFormula ignores any fractional part of the number n.
Example:
ADD_DAYS (’30-DEC-1990′ (date), 6) returns 5 JAN 1991Back to Top
ADD_MONTHS

ADD_MONTHS(date, n)
The ADD_MONTHS function adds a number of months to a date. The resulting date accords with the calendar. Note: Oracle FastFormula ignores any fractional part of the number n.Back to Top
ADD_YEARS

ADD_YEARS(date, n)
The ADD_YEARS function adds a number of years to a date. The resulting date accords with the calendar. Note: Oracle FastFormula ignores any fractional part of the number n.Back to Top
GREATEST

GREATEST(date1, date2[, date3] . . .)
The GREATEST function compares all the operands and returns the latest date.Back to Top
LAST_DAY

LAST_DAY(d)
The LAST_DAY function returns the date of the last day of the month that contains d. You might use this function to determine how many days are left in the current month.Back to Top
LEAST

LEAST(date1, date2 [, date3] . . .)
The LEAST function compares all the operands and returns the earliest date.Back to Top
DAYS_BETWEEN

DAYS_BETWEEN(date1, date2)
The DAYS_BETWEEN function returns the number of days between two dates. If the later date is first, the result is a positive number. If the earlier date is first, the result is a negative number. The number returned is also based on the real calendar.
Note: The result is a numeric data type.
Example:
DAYS_BETWEEN(‘1995/06/27 00:00:00’ (date), ‘1995/07/03 00:00:00’ (date)) returns -5Back to Top
MONTHS_BETWEEN

MONTHS_BETWEEN(date1, date2)
The MONTHS_BETWEEN function returns the number of months between two dates. If the later date is first, the result is a positive number. If the earlier date is first, the result is a negative number. The number returned is also based on the real calendar. If the result is not a whole number of months (that is, there are some days as well), the days part is shown as a decimal.
Note: The result is a numeric data type.Back to Top
NEW_TIME

NEW_TIME(d, zl, z2)
Returns the date and time in zone z2 when the date and time in zone z1 are d. The arguments z1 and z2 can be any one of these text strings:
AST or ADT Atlantic Standard or Daylight Time
BST or BDT Bering Standard or Daylight Time
CST or CDT Central Standard or Daylight Time
EST or EDT Eastern Standard or Daylght Time
GMT Grenwich Mean Time
HST or HDT Alaska-Hawaii Standard Time or Daylight Time
MST or MDT Mountain Standard or Daylight Time
NST Newfoundland Standard Time
PST or PDT Pacific Standard or Daylight Time
YST or YDT Yukon Standard or Daylight TimeBack to Top
NEXT_DAY

NEXT_DAY(d, expr)
The NEXT_DAY function returns the date of the first weekday named by expr that is later than the date d. The argument expr must be a day of the week in your session’s date language. The return value has the same hours, minutes, and seconds component as the argument d.
Back to Top
Data Conversion Functions


Use data conversion functions to convert from one data type to another data type. For example, you could have an expression returning a number value for salary, which you want to include in a printed message (that is, a character value). To print the number as part of the message, you need to convert the value of salary from a number to a character value, using the TO_TEXT function.
CONVERT

(expr, dest_char_set [,source_char_set])
The CONVERT function converts a character string from one character set to another. The expr argument is the value to be converted. The dest_char_set argument is the name of the character set to which expr is converted. The source_char_set argument is the name of the character set in which expr is stored in the database. The default value is the database character set.Back to Top
INSTR

(expr1,expr2[,n[,m]])
The INSTR function searches expr1 beginning with its nth character for the mth occurrence of expr2 and returns the position of the character in expr1 that is the first
character of this occurrence. If n is negative, Oracle FastFormula counts and searches backwards.Back to Top
NUM_TO_CHAR

NUM_TO_CHAR(n, format)
Converts the number n from number data type to text data type using the specified format. This function is equivalent to the SQL TO_CHAR function. For example:
NUM_TO_CHAR(amount, ‘$9,990.99’) This returns the amount with a leading dollar sign, commas every three digits, and two decimal places. Refer to the SQL Language Reference Manual for a full list of the valid number formats you can specify.Back to Top
TO_DATE

TO_DATE (expr [, format])
Converts the expression expr of text data type to a date data type. The text expression must be of the form ‘YYYY/MM/DD HH24:MI:SS’ if no format is provided. The day and year must be in numeric form. For example:

* legal */
date_1 = TO_DATE (’12 January 89′, ‘DD Month YY’)

/* illegal */
date_1 = TO_DATE (’12 January Nineteen-Eighty-Nine’,’DD Month Year’)

Note: When assigning date variables from constants it is much more efficient to say:

date_1 = ‘1989/01/12 00:00:00′(date)
Note: The text expression must be in the format of either YYYY/MM/DD HH24:MI:SS or DD-MON-YYYY if no format is provided.Back to Top
TO_NUMBER

TO_NUM(expr)
TO_NUMBER(expr)
Converts the expression expr of text data type to a number data type. The expression must represent a valid number. So for example, you cannot convert an expression such as `Type 24′ but you can convert the text expression `1234′. For decimal values, you must always use a period as a decinal point, for example ‘4.5’.Back to Top
TO_TEXT

TO_TEXT(n) TO_TEXT (date1 [, format])
TO_CHAR(n) TO_CHAR(date1 [, format])
DATE_TO_TEXT(n) (date1 [, format])
The TO_TEXT function converts:
• the number n from number data type to text data type. The default number format has the decinal point as a period, for example ‘4.5’.
• the date date1 from date data type to text data type. The optional format should be a text string like ‘DD/MM/YYYY’. The default format is ‘YYYY/MM/DD HH24:MI:SS’.

For example:
birthdate = ’21-JAN-1960′ (date)
mesg = ‘Birthdate is: ‘ + TO_CHAR (birthdate)

/* sets mesg to ‘Birthdate is: 1960/01/21 00:00:00’ */
mesg = ‘Birthdate is: ‘ + TO_CHAR (birthdate, ‘DD-MON-YY’)

/* sets mesg to ‘Birthdate is: 21-JAN-60’ */
mesg = ‘Birthdate is: ‘ + TO_CHAR (birthdate, ‘DD Month Year’)

/* sets mesg to ‘Birthdate is: 21 January Nineteen-Sixty’ */ Back to Top
Functions to Get values from Tables

GET_LOOKUP_ MEANING

GET_LOOKUP_MEANING(lookup_type , lookup_code)
The GET_LOOKUP_MEANING function enables Oracle FastFormula to translate a lookup code into a meaning. This can be used for any descriptive flexfield items or
developer flexfield items that are based on lookups.
Example:
GET_LOOKUP_MEANING (‘ETH_TYPE’, PEOPLE_GB_ETHNIC_ORIGIN)Back to Top
GET_TABLE_VALUE

GET_TABLE_VALUE(table_name, column_name, row_value [,effective date])
The GET_TABLE_VALUE function returns the value of a cell in a user-defined table. The three text operands, which identify the cell (table_name, column_name, and
row_value), are mandatory. The date operand is optional. If it is not supplied, the function returns the cell value as of the effective date. You cannot use this function in formulas for user table validation or QuickPaint reports.

Example:
GET_TABLE_VALUE(‘WAGE RATES’, ‘Wage Rate’, Rate_Code)Back to Top
RAISE_ERROR

RAISE_ERROR(application_ID, message name)
This function allows you to raise a functional error message from within a formula. It accepts an Application ID and the message_name of an Oracle Applications error
message to raise.

Example:
ERROR = RAISE_ERROR(800, ‘error_name’)Back to Top
RATES_HISTORY

RATES_HISTORY(element or rate type name, date, element or rate type indicator, time dimension)
This function uses information stored in the UK Element Attribution Information EIT and information about the assignment’s contract type to calculate a payment rate as of the given date and expressed for the selected time dimension (such as hourly or annual). If the element or rate type indicator is R, the function sums the rates for all elements classified with the given rate type (which is stored against the element in the Rate Type Information EIT).

The time dimension parameter must be A (annual), D (daily), H (hourly), or P (periodic). The element or rate type parameter must be R (rate type) or E (element).
The function can also adjust the returned rate for FTE and length of service, if these factors are set to Yes in the Element Attribution Information.Back to Top
External Formula Function


External Functions refers to logic written in database package and calling in fast formula by defining it through Define Function in Oracle HRMS. I shall write a seperate article on it.

Friday 13 October 2017

API to Create Organization Manager

API to Create Organization Manager


/* Formatted on 2017/10/02 12:34 (Formatter Plus v4.8.8) */
DECLARE
   v_org_information_id      NUMBER;
   v_object_version_number   NUMBER;
   v_warning                 BOOLEAN;
   l_start_date              DATE;
   l_org_id                  NUMBER;
   l_person_id               NUMBER;
   l_error                   VARCHAR2 (2500);

   CURSOR cur_ee
   IS
      SELECT *
        FROM xxkq_org_manager_api_stg
       WHERE status IS NULL AND sno <= 1;
BEGIN
   FOR c1_ee_rec IN cur_ee
   LOOP
      BEGIN
         SELECT papf.person_id, paaf.effective_start_date
           INTO l_person_id, l_start_date
           FROM per_all_people_f papf, per_all_assignments_f paaf
          WHERE 1 = 1
            AND papf.person_id = paaf.person_id
            AND papf.employee_number = c1_ee_rec.org_owner_staff_no
            AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
                                    AND papf.effective_end_date
            AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
                                    AND paaf.effective_end_date;
      EXCEPTION
         WHEN OTHERS
         THEN
            l_error := 'Invalid Emp Details' || SQLERRM;
      END;

      BEGIN
         SELECT organization_id
           INTO l_org_id
           FROM hr_all_organization_units
          WHERE NAME = TRIM (c1_ee_rec.NAME);
      EXCEPTION
         WHEN OTHERS
         THEN
            l_error := 'Invalid Org Details' || SQLERRM;
      END;

      IF l_error IS NULL
      THEN
         BEGIN
            hr_organization_api.create_org_manager
                     (p_validate                   => FALSE,
                      p_effective_date             => l_start_date,
                      p_organization_id            => l_org_id,
                      p_org_info_type_code         => 'Organization Name Alias',
                      p_org_information2           => l_person_id,
                      p_org_information3           => TO_CHAR
                                                         (l_start_date,
                                                          'YYYY/MM/DD HH24:MI:SS'
                                                         ),
                      p_org_information4           => '4712/12/31 00:00:00',
                      p_org_information_id         => v_org_information_id,
                      p_object_version_number      => v_object_version_number,
                      p_warning                    => v_warning
                     );

            UPDATE xxkq_org_manager_api_stg
               SET status = 'S'
             WHERE sno = c1_ee_rec.sno;
         EXCEPTION
            WHEN OTHERS
            THEN
               l_error := SQLERRM;

               UPDATE xxkq_org_manager_api_stg
                  SET status = 'E',
                      error_msg = l_error
                WHERE sno = c1_ee_rec.sno;
         END;
      ELSE
         UPDATE xxkq_org_manager_api_stg
            SET status = 'E',
                error_msg = l_error
          WHERE sno = c1_ee_rec.sno;
      END IF;
   END LOOP;

   COMMIT;
END;

API to Create HR Organization and Cost Allocation Segment

API to Create HR Organization and Cost Allocation Segment


/* Formatted on 2017/10/01 21:41 (Formatter Plus v4.8.8) */
DECLARE
   p_effective_date          DATE;
   p_object_version_number   NUMBER;
   p_duplicate_org_warning   BOOLEAN;
   v_err                     VARCHAR2 (1000);
   l_org_id                  NUMBER;
   lb_record_status          BOOLEAN;
   lv_error_message          VARCHAR2 (2400);

   CURSOR c1
   IS
      SELECT *
        FROM xxkq_org_cost_stg
       WHERE 1 = 1 AND status IS NULL AND sno <= 400;
BEGIN
   FOR i IN c1
   LOOP
      lb_record_status := TRUE;
      lv_error_message := '';

      BEGIN
         SELECT org.organization_id, org.date_from, org.object_version_number
           INTO l_org_id, p_effective_date, p_object_version_number
           FROM hr_all_organization_units org
          WHERE 1 = 1 AND NAME = TRIM (i.ORGANIZATION);
      EXCEPTION
         WHEN OTHERS
         THEN
            l_org_id := NULL;
      END;

      IF l_org_id IS NULL
      THEN
         lb_record_status := FALSE;
         lv_error_message := 'Unable to find the Organization Details';
      END IF;

      IF lb_record_status = TRUE
      THEN
         BEGIN
            hr_organization_api.update_organization
                         (p_validate                   => FALSE,
                          p_effective_date             => p_effective_date,
                          p_organization_id            => l_org_id,
                          p_segment1                   => TO_CHAR (i.company),
                          p_segment2                   => TO_CHAR (i.LOCATION),
                          p_segment3                   => TO_CHAR
                                                                (i.cost_centre),
                          p_object_version_number      => p_object_version_number,
                          p_duplicate_org_warning      => p_duplicate_org_warning
                         );

            UPDATE xxkq_org_cost_stg
               SET status = 'S',
                   error_msg = ''
             WHERE sno = i.sno;

            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               lv_error_message := SUBSTR (SQLERRM, 1, 239);
               ROLLBACK;

               UPDATE xxkq_org_cost_stg
                  SET status = 'E',
                      error_msg = lv_error_message
                WHERE sno = i.sno;
         END;
      ELSE
         UPDATE xxkq_org_cost_stg
            SET status = 'E',
                error_msg = lv_error_message
          WHERE sno = i.sno;

         COMMIT;
      END IF;
   END LOOP;

   COMMIT;

END;

Query to get the Menu,Submenu and function details For Oracle Menus

Query to get the Menu,Submenu and function details For Oracle Menus


/* Formatted on 2017/10/13 16:26 (Formatter Plus v4.8.8) */
SELECT   SECOND.application_id "App ID", SECOND.application_name "App Name",
         SECOND.responsibility_id "Resp ID",
         SECOND.responsibility_name "Responsibility",
         SECOND.menu_id "Menu ID", SECOND.user_menu_name "Main Menu Name",
         SECOND.entry_sequence "Seq", SECOND.prompt "Prompt",
         SECOND.function_id "Function ID",
         SECOND.user_function_name "Function",
         SECOND.func_descrip "Function Descrip",
         SECOND.sub_menu_id "SubMenu ID", SECOND.sub_menu_name "SubMenu Name",
         SECOND.sub_seq "Sub Seq", SECOND.sub_prompt "SubPrompt",
         SECOND.sub_func_id "SubFunction ID", SECOND.sub_func "SubFunction",
         SECOND.sub_func_descrip "SubFunction Descrip",
         SECOND.sub_sub_menu_id "Sub-SubMenu ID",
         SECOND.grant_flag "Grant Flag", SECOND.resp_end_date "Resp End Date",
         DECODE (exc.rule_type,
                 'F', (SELECT 'Ex F: ' || exc.action_id
                         FROM fnd_form_functions_vl fnc
                        WHERE fnc.function_id = exc.action_id
                          AND SECOND.function_id = exc.action_id)
                ) excluded_function,
         DECODE (exc.rule_type,
                 'F', (SELECT 'Ex SF: ' || exc.action_id
                         FROM fnd_form_functions_vl fnc
                        WHERE fnc.function_id = exc.action_id
                          AND SECOND.sub_func_id = exc.action_id)
                ) excluded_sub_function,
         DECODE (exc.rule_type,
                 'M', (SELECT 'Ex M: ' || exc.action_id
                         FROM fnd_form_functions_vl fnc
                        WHERE fnc.function_id = exc.action_id
                          AND SECOND.menu_id = exc.action_id)
                ) excluded_menu,
         DECODE (exc.rule_type,
                 'M', (SELECT 'Ex SM: ' || exc.action_id
                         FROM fnd_form_functions_vl fnc
                        WHERE fnc.function_id = exc.action_id
                          AND SECOND.sub_menu_id = exc.action_id)
                ) excluded_sub_menu,
         DECODE (exc.rule_type,
                 'M', (SELECT 'Ex SSM: ' || exc.action_id
                         FROM fnd_form_functions_vl fnc
                        WHERE fnc.function_id = exc.action_id
                          AND SECOND.sub_sub_menu_id = exc.action_id)
                ) excluded_sub_sub_menu
    FROM (SELECT   FIRST.application_id, FIRST.application_name,
                   FIRST.responsibility_id, FIRST.responsibility_name,
                   FIRST.end_date AS resp_end_date, FIRST.menu_id,
                   FIRST.user_menu_name, FIRST.entry_sequence, FIRST.prompt,
                   FIRST.function_id, ffft.user_function_name,
                   ffft.description AS func_descrip, FIRST.sub_menu_id,
                   fmv2.user_menu_name AS sub_menu_name,
                   fme2.entry_sequence AS sub_seq, fmet2.prompt AS sub_prompt,
                   fme2.function_id AS sub_func_id,
                   ffft2.user_function_name AS sub_func,
                   ffft2.description AS sub_func_descrip,
                   fme2.sub_menu_id AS sub_sub_menu_id, FIRST.grant_flag
              FROM (SELECT   fat.application_id, fat.application_name,
                             fr.responsibility_id, frt.responsibility_name,
                             fr.end_date, fr.menu_id, fmv.user_menu_name,
                             fme.entry_sequence, fmet.prompt, fme.sub_menu_id,
                             fme.function_id, fme.grant_flag
                        FROM apps.fnd_application_tl fat,
                             apps.fnd_responsibility fr,
                             apps.fnd_menus_vl fmv,
                             apps.fnd_responsibility_tl frt,
                             apps.fnd_menu_entries fme,
                             apps.fnd_menu_entries_tl fmet
                       --joins and constant selection
                    WHERE    fat.application_id = fr.application_id(+)
                         AND fr.menu_id = fmv.menu_id(+)
                         AND fr.responsibility_id = frt.responsibility_id(+)
                         AND fr.menu_id = fme.menu_id(+)
                         AND fme.menu_id = fmet.menu_id(+)
                         AND fme.entry_sequence = fmet.entry_sequence(+)
                         AND fmet.LANGUAGE = 'US'
                         AND frt.responsibility_name = 'Receivables Manager'
--                     AND fat.application_id = &appid
                    ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) FIRST
                         ---for application, responsibility and main menu info
                                                                         ,
                   apps.fnd_menus_vl fmv2                  ---for submenu info
                                         ,
                   apps.fnd_menu_entries fme2,
                   apps.fnd_menu_entries_tl fmet2,
                   apps.fnd_form_functions_tl ffft        ---for function info
                                                  ,
                   apps.fnd_form_functions_tl ffft2    ---for subfunction info
             --left outer joins keep original records and add any sub menu and function info
          WHERE    FIRST.function_id = ffft.function_id(+)
               AND FIRST.sub_menu_id = fmv2.menu_id(+)
               AND FIRST.sub_menu_id = fme2.menu_id(+)
               AND fme2.menu_id = fmet2.menu_id(+)
               AND fme2.entry_sequence = fmet2.entry_sequence(+)
               AND fme2.function_id = ffft2.function_id(+)
          ORDER BY 1,
                   2,
                   3,
                   4,
                   5,
                   6,
                   7,
                   8,
                   9,
                   10,
                   11,
                   12,
                   13,
                   14,
                   15,
                   16,
                   17,
                   18,
                   19,
                   20,
                   21) SECOND           -- adds any sub menu and function info
         LEFT OUTER JOIN
         apps.fnd_resp_functions exc                         ---for exclusions
         ON (    SECOND.application_id = exc.application_id
             AND SECOND.responsibility_id = exc.responsibility_id
             AND (   SECOND.function_id = exc.action_id
                  OR SECOND.sub_func_id = exc.action_id
                  OR SECOND.menu_id = exc.action_id
                  OR SECOND.sub_menu_id = exc.action_id
                  OR SECOND.sub_sub_menu_id = exc.action_id
                 )
            )
ORDER BY 1,
         2,
         3,
         4,
         5,
         6,
         7,
         8,
         9,
         10,
         11,
         12,
         13,
         14,
         15,
         16,
         17,
         18,
         19,
         20,
         21;

Thursday 1 June 2017

How to Create a Custom Form to Restrict Special Information Types (SIT)

How to Create a Custom Form to Restrict Special Information Types (SIT)


To restrict the number of Special Information Types (SIT) available to an end user.

Often SIT's can hold confidential and sensitive information, therefore this activity of restricting the types forms part of security design.


DETAILS

NAVIGATE Security > CustomForm

Form to be customized = Enter Person Special Information

In Customized version Block, Enter
Name = MYFORM
Standard Title = My SIT
Query Title = My SIT

SAVE

In restrictions block
Type = Restrict by Special Information Type Value = SIT 1
Type = Restrict by Special Information Type Value = SIT 2

SAVE

(This restricts to 2 out of the total number SIT set up)

As Systems Administrator

NAVIGATE Application > Functions
In 'Description', Enter
Function = MYFORM
User Function Name = MYFORM
Type = FORM
Description = CUSTOMIZED SIT FORM
Form = Enter Person Special Information
Application = Oracle Human Resources (defaulted from Form name above)
Parameters = HR_CUSTOMIZATION="MYFORM" (The bit in the double quotes MUST be
the same as entered the 'Name' field of block in Customform)


SAVE

NAVIGATE Application > menu

Query up menu e.g. PER_UK_HRMS_FAST

On row for Special Information replace displayed function with MYFORM (selected from Pick List)

SAVE

Monday 27 March 2017

How to find Profile Options Attached in various levels

How to find Profile Options Attached in various levels


select 
b.user_profile_option_name "Long Name"
, a.profile_option_name "Short Name"
, decode(to_char(c.level_id),'10001','Site'
,'10002','Application'
,'10003','Responsibility'
,'10004','User'
,'Unknown') "Level"
, decode(to_char(c.level_id),'10001','Site'
,'10002',nvl(h.application_short_name,to_char(c.level_value))
,'10003',nvl(g.responsibility_name,to_char(c.level_value))
,'10004',nvl(e.user_name,to_char(c.level_value))
,'Unknown') "Level Value"
, c.PROFILE_OPTION_VALUE "Profile Value"
, c.profile_option_id "Profile ID"
, to_char(c.LAST_UPDATE_DATE,'DD-MON-YYYY HH24:MI') "Updated Date"
, nvl(d.user_name,to_char(c.last_updated_by)) "Updated By"
from 
apps.fnd_profile_options a
, apps.FND_PROFILE_OPTIONS_VL b
, apps.FND_PROFILE_OPTION_VALUES c
, apps.FND_USER d
, apps.FND_USER e
, apps.FND_RESPONSIBILITY_VL g
, apps.FND_APPLICATION h
where 1=1
--a.application_id = nvl(401, a.application_id)
--and a.profile_option_name = nvl('INV', a.profile_option_name)
and b.user_profile_option_name like 'HR%Sec%' -- 'AFLOG_ENABLED'
and a.profile_option_name = b.profile_option_name
and a.profile_option_id = c.profile_option_id
and a.application_id = c.application_id
and c.last_updated_by = d.user_id (+)
and c.level_value = e.user_id (+)
and c.level_value = g.responsibility_id (+)
and c.level_value = h.application_id (+)
--and c.PROFILE_OPTION_VALUE=14063
order by 
b.user_profile_option_name, c.level_id, 
decode(to_char(c.level_id),'10001','Site'
,'10002',nvl(h.application_short_name,to_char(c.level_value))
,'10003',nvl(g.responsibility_name,to_char(c.level_value))
,'10004',nvl(e.user_name,to_char(c.level_value))
,'Unknown');

Wednesday 15 March 2017

Absence Action History Details Script

Absence Approval Action History Script:


SELECT hats.information1, hats.information2, hats.information6,
       hats.information8, psa.user_name, psa.action
  FROM hr_api_transactions hat,
       hr_api_transaction_steps hats,
       apps.wf_items wi,
       pqh_ss_approval_history psa
 WHERE hat.selected_person_id = 501
   AND hat.transaction_ref_table = 'PER_ABSENCE_ATTENDANCES'
   AND hat.transaction_id = hats.transaction_id
   AND wi.item_key = hat.item_key
   AND wi.item_key = psa.transaction_item_key
   AND wi.item_type = 'HRSSA'
   AND end_date IS NOT NULL



Absence Pending History Sctipt:


SELECT wfn.notification_id, wi.item_key,
       TO_DATE (hats.information1, 'YYYY-MM-DD'), hats.information2,
       hats.information6, hats.information8, wfn.recipient_role, wfn.status
  FROM hr_api_transactions hat,
       hr_api_transaction_steps hats,
       apps.wf_items wi,
       apps.wf_notifications wfn
 WHERE hat.selected_person_id = 501
   AND hat.transaction_ref_table = 'PER_ABSENCE_ATTENDANCES'
   AND hat.transaction_id = hats.transaction_id
   AND wi.item_key = hat.item_key
--and wi.item_key=psa.TRANSACTION_ITEM_KEY
   AND wi.item_type = 'HRSSA'
   AND wi.end_date IS NULL
   AND wi.item_key = wfn.item_key
   AND wfn.notification_id IN (SELECT MAX (notification_id)
                                 FROM apps.wf_notifications
                                WHERE item_key = wi.item_key)
   AND TO_DATE (hats.information1, 'YYYY-MM-DD') >= '01-JAN-2017'

Tuesday 14 March 2017

Element Input Validation Fast Formula Type

Element Input Validation Fast Formula Type




Element Input Validation

This can be used when we got to validate / restrict the element input value (Date/Number). There various types through which we can enable restriction. That are,

        a) Fast Formula (Date/Money),
        b) Lookup (Character),
        c) Value Set,
        d) Default Value,
        e) Minimum & Maximum

In this article we are going to see how to restrict/validate entry values in element input value.

Scenario 1

Restrict the input value for a element called "One time Bonus" not higher than Rs: 15000 /-
Steps:

1) Write fast formula to validate / restrict desired entry value (Date/ Money) in element input value,
(Navigation: HRMS: -> Total Compensation  ->  Basic  ->  Write Formula)

1.1) Type Formula Name,
1.2) Select Type as "Element Input Validation",
1.3) Enter description for the fast formula.

2) Enter the following formula

Inputs are entry_value (text)
If to_num (entry_value) > 15000
Then
(Formula_Status = 'e'
Formula_Message = 'Value Entered is above the limit')
Else
(Formula_Status = 's'
Formula_Message = 'Fine')
Return Formula_Status, Formula_Message

3) Define an element,
(Navigation: HRMS  -> Total Compensation -> Basic Element Description)

4) Enter input values for the element

4.1) Select "Money" in units,
4.2) Select the formula from the  LOV in the formula field.

5) Testing: try entering values within & above 15000 in element entries
(Navigation: People -> Enter & Maintain -> "Assignment"  ->  Entries  –  Entry Values)


Scenario 2

Restrict Entry date not prior to system date (Can be Today & Tomorrow Onwards)

1) Wirte fast formula to validate element input date,
(Navigation: HRMS:-> Total Compensation -> Basic -> Write Formula)

         1.1) Type Formula Name,
         1.2) Select Type as "Element Input Validation",
         1.3) Enter description for the fast formula.

2) Enter the following formula;

       Default for session_date IS '1900/01/01 00:00:00' (date)
        Inputs are entry_value(text)
        If(to_date(entry_value,'YYYY/MM/DD HH24:MI:SS') < session_date) then
       (formula_status ='e'
        formula_message ='Enter future date')
       else
      (formula_status='s')
      Return formula_status,formula_message

3) Define an element,
      (Navigation: HRMS -> Total Compensation -> Basic Element Description)

4) Enter input values for the element
        4.1) Select "Money" in units,
        4.2) Select the formula from the LOV in the formula field.

5) Testing: try entering date less than, equal to & greater than the session date.
(Navigation: People -> Enter & Maintain -> "Assignment" -> Entries – Entry Values)


Some Fast Formula Tables:   SQL Query to select tables:-

Select * from all_objects where object_type=’table’ and object_name like ‘ff%';
ff_functions
ff_function_parameters
ff_formulas_f
ff_formula_types
ff_database_items
ff_globals_ff

Thursday 2 February 2017

Oracle HRSSA Workflow – “Notify HR About Commit System Error” Function Error – no data found

Oracle HRSSA Workflow – “Notify HR About Commit System Error” Function Error – no data found




I encountered the “no data found” error in the “Notify HR About Commit System Error” function, in the seeded HR workflow (“HRSSA”). After much googling and metalinking, I discovered the solution below.





The core cause of this issue is the value stored in the attribute “HR Department E-mail ID” (“HR_DEPT_EMAIL”).





In the seeded workflow this attributes default value is “hr@mycompany.com”. However, this attribute is looking for a role that is existing in the wf_roles table and “hr@mycompany.com” does not.


To overcome this error for the current instance of the workflow and allowing the workflow to continue processing, in the “Status Monitor” function of the “Workflow Administrator” responsibility, we need to select the workflow that has the error. Click the “Activity History” button. In the resulting screen we need to now select the “Update Attributes” button. This will navigate us to the screen where the current values of the workflow instance are stored.









Here we need to change the value of the “HR Department E-mail ID” attribute from “hr@mycompany.com“, to an existing role in the wf_roles table. In the example above I have changed it to the SYSADMIN role; however you may create your own role that will distribute the error to the necessary HR or system administration personnel of your organization.
After the change, scroll to the bottom of the screen and click the “Apply” button.





Now that we have corrected our attribute, we need to “Retry” the function in error, so that the workflow may continue processing.







In the “Activity History” screen, select the function that has errors and click the “Retry” button. The resulting screen should look like above; select the “Submit” button. If the function was successfully retried the workflow error should be removed and the workflow should continue processing.






Unfortunately this will have to be done for all of the HR workflows that stopped with this error.
To stop the this error from persisting, you will need to open the “HR” workflow in Oracle Workflow Builder, find the attribute HR Department E-mail ID (HR_DEPT_EMAIL) under the “HR” item type and update the default value to the role you require it to be and thereafter save the workflow back to your database.




Tuesday 31 January 2017

Employee Grade Step Creation API

Employee Grade Step Creation API



declare
-- api parameters
    l_placement_id           NUMBER;
    l_object_version_number NUMBER;
    l_effective_start_date     DATE;
    l_effective_end_date     DATE;
--
    -- local parameters
    l_error_msg             VARCHAR2(1000);
--
    -- Main Cursor
    cursor main_rec
    is
    SELECT   a.s_no,
             b.employee_number,
             c.assignment_id,
             a.effective_start_date,
             b.business_group_id,
             a.basic_salary_amount,
             (SELECT pspsf.step_id
                FROM per_grades pg,
                     per_grade_spines_f pgsf,
                     pay_rates pr,
                     pay_grade_rules_f pgrf,
                     per_spinal_point_steps_f pspsf
               WHERE pg.NAME                 = a.grade
                 AND pr.parent_spine_id     = pgsf.parent_spine_id
                 AND pgsf.grade_id             = pg.grade_id
                 AND pgrf.rate_id             = pr.rate_id
                 AND pspsf.spinal_point_id     = pgrf.grade_or_spinal_point_id
                 AND SYSDATE BETWEEN pgsf.effective_start_date
                                 AND pgsf.effective_end_date
                 AND SYSDATE BETWEEN pgrf.effective_start_date
                                 AND pgrf.effective_end_date
                 AND SYSDATE BETWEEN pspsf.effective_start_date
                                 AND pspsf.effective_end_date
                 AND pgrf.VALUE = a.basic_salary_amount) step_id
        FROM xxnbk_emp_grade_step_load a,
             per_people_x b,
             per_assignments_x c
       WHERE 1 = 1
         AND a.employee_number     = b.employee_number
         AND c.person_id         = b.person_id
--         and s_no <=10
         AND STATUS IS NULL
         order by s_no;
---
    -- begin the process
begin
--
for i in main_rec
loop
--
    IF I.step_id IS NOT NULL THEN  --Checking grade step defined for that salary
        BEGIN
        --
            hr_sp_placement_api.create_spp
              (p_validate                      =>  FALSE
              ,p_effective_date                =>  i.effective_start_date
              ,p_business_group_id             =>  i.business_group_id
              ,p_assignment_id                 =>  i.assignment_id
              ,p_step_id                       =>  i.step_id
              ,p_auto_increment_flag           =>  'N'
              ,p_reason                        =>  null
              ,p_request_id                    =>  null
              ,p_program_application_id        =>  null
              ,p_program_id                    =>  null
              ,p_program_update_date           =>  null
              ,p_increment_number              =>  null
              ,p_information1                  =>  null
              ,p_information2                  =>  null
              ,p_information3                  =>  null
              ,p_information4                  =>  null
              ,p_information5                  =>  null
              ,p_information6                  =>  null
              ,p_information7                  =>  null
              ,p_information8                  =>  null
              ,p_information9                  =>  null
              ,p_information10                 =>  null
              ,p_information11                 =>  null
              ,p_information12                 =>  null
              ,p_information13                 =>  null
              ,p_information14                 =>  null
              ,p_information15                 =>  null
              ,p_information16                 =>  null
              ,p_information17                 =>  null
              ,p_information18                 =>  null
              ,p_information19                 =>  null
              ,p_information20                 =>  null
              ,p_information21                 =>  null
              ,p_information22                 =>  null
              ,p_information23                 =>  null
              ,p_information24                 =>  null
              ,p_information25                 =>  null
              ,p_information26                 =>  null
              ,p_information27                 =>  null
              ,p_information28                 =>  null
              ,p_information29                 =>  null
              ,p_information30                 =>  null
              ,p_information_category          =>  'KE'
              ,p_placement_id                  =>  l_placement_id
              ,p_object_version_number         =>  l_object_version_number
              ,p_effective_start_date          =>  l_effective_start_date
              ,p_effective_end_date            =>  l_effective_end_date
              ,p_replace_future_spp            =>  false
              );
              --
              update xxnbk_emp_grade_step_load
              set Status ='S'
              WHERE S_NO=i.S_NO;
              COMMIT;
              --
      EXCEPTION WHEN OTHERS THEN
      --
         l_error_msg :=sqlerrm;
         --
          update xxnbk_emp_grade_step_load
          set Status ='E',Error_message=l_error_msg
          WHERE S_NO=i.S_NO;
          --
      END;
      --
    ELSE
    --
        update xxnbk_emp_grade_step_load
          set Status ='E',Error_message='Grade Step not defined'
          WHERE S_NO=i.S_NO;
          --
    END IF;
    --
 end loop;
 --
 commit;
 --
  dbms_output.put_line('Success ');
  --
 exception when others then
 dbms_output.put_line('Error in main '||sqlerrm);
 end;