Tuesday, May 29, 2018

utl_smtp.mail sample code

CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_to varchar2, 
msg_subject varchar2,
msg_text varchar2 )
IS
c utl_smtp.connection;
rc integer; 
msg_from varchar2(50) := 'Oracle9.2'; 
mailhost VARCHAR2(30) := '127.0.0.1'; -- local database host 

BEGIN
c := utl_smtp.open_connection(mailhost, 25); -- SMTP on port 25 
utl_smtp.helo(c, mailhost);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);

utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject || 
utl_tcp.crlf || msg_text);
utl_smtp.quit(c);

EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt 
using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again'); 
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.'); 
END;
/

Tuesday, February 20, 2018

How to Configure Forms Builder

Introduction

I wrote this document because so many people in the Oracle Technology Network (OTN) Forms Forum have asked “How do I run a form from the Forms Builder?” or “I just installed Forms 10g and all I get is a blank browser window when I run a form.” After I responded to numerous posts (always writing the instructions from scratch) I decided to write this document. As they say, “It is always better to reuse then to recreate!”

Disclaimer

First and foremost, this document targets the following Oracle Developer Suite (Forms/Reports) versions:  10g R1 (9.0.4.x.x) and 10g R2 (10.1.2.x.x). 
Many of the concepts apply to the Oracle Fusion Middleware (FMw) 11g suite (Forms and Reports), but this document is not intended to help you with FMw configuration. 
 
The information in this document could be adapted to Oracle Forms 9i, but I do not currently have access to this version of Forms so there is no guarantee that these methods will work for Forms 9i.
 
Secondly, this document is NOT all inclusive – meaning it is not a full reference to all setup options available.  This document is meant only to get you up and running.  If you need to use features that are not listed in this document, please refer to the appropriate Oracle document available at the Oracle Technology Network (OTN).
 
Lastly, this article assumes you have successfully installed the Oracle Developer Suite (ODS) 10g R2 (10.1.2.x.x).  If you have not already installed the ODS then you will need to do this before you can proceed.

Background

If you have used Oracle Forms long enough, you will remember the day when you could run a Form locally from the Forms Builder with the Forms Runtime.  This was a very nice feature that enabled you to perform incremental development and testing; the Forms Debugger utility; not to mention the Forms Runtime Diagnostics (FRD).  With the advent of Forms 9i – when Oracle made Forms web deployed only – many developers thought the ability to run a form from the Forms Builder was lost.  This is not true; it is just a little harder to do now and requires some configuration setup on your workstation to make it work.  Forms 10g use the OC4J Forms Servlet to emulate a Forms Service web process on your workstation that allows you to “serve” a web form from the Forms Builder.  This is a very generic description of what OC4J is and what it does, but it will suffice for the purpose of this document.  In order to run a form from the Forms Builder, Oracle has included two new program items (among others) in Oracle Developer Suite Program group of the installed Oracle Developer Suite 10g.  These two program items are the “Start OC4J Instance” and “Stop OC4J Instance.”  Both are critical to the running of forms from the Forms Builder. 

Let’s get started…

There are two parts to configuring Forms Builder to run forms.  The first relates to Forms Builder and the second relates to the OC4J Forms Servlet.  Most forms developers will be familiar with configuring the Forms Builder as this involves setting up key environment/registry variables so the Forms Builder can find libraries (PL/SQL libraries [.pll] and Forms Object Libraries [.olb]).  However, fewer developers are familiar with setting up the OC4J environment variables which enable you to run a form from the Forms Builder.
 
There are two Java Runtimes (JREs) supported by Forms Builder;  Oracle Jinitiator and the Oracle (Sun) Java Runtime Environment (Sun JRE).  By default, Forms Builder is configured to use the Oracle Jinitiator and in most cases this should be sufficient for your needs.  Configuration is simply to install the Oracle Jinitiator (make sure you install the right version because each Forms version defaults to different version.  For example, Oracle Forms 10g R2 (10.1.2.0.2) defaults to using Oracle Jinitiator 1.3.1.22.  If you install the version found in your Oracle DevSuite home directory (\%DEV_SUITE_HOME%\jinit) you should be OK.  If you decide to use the Sun JRE, again, you will need to install the appropriate version as the Forms Builder ships configured to a specific version of the Sun JRE.  For example, Oracle Forms 10g R2 (10.1.2.0.2) defaults to Sun JRE version 1.4.2 update 6 (1.4.2_06).  Most likely, you will have to update the default settings as you likely do have the Sun JRE installer for 1.4.2 and it is no longer available for download.  Therefore, you will likely be installing the latest version of the Sun JRE which is Java 6 (1.6.0). 
 
Which JRE you use is also dependent on your Operating System (OS) version and your Internet Browser version.  This document focuses on setup for the Microsoft Windows Operating System and Internet Explorer and Mozilla Firefox browsers.  The following is the Oracle certified supported configurations.
 
 OS Java Runtime
 Windows Jinitiator Sun JRE
 Internet Explorer   
 version 5
 1.3.1.x+  1.4.1+
 version 6
 1.3.1.22+ 1.4.2_06+
 version 7
 1.3.1.28 1.5.0_06+
 version 8
 1.6.0_16+ 1.6.0_16+
 FireFox 3.5+ NS 1.6.0_16+
+ = indicates a higher version can be used
NS = Not Supported
 
This list is an abbreviated list.  For a complete list – review the appropriate Oracle Certification Matrix document on OTN.
 
Alright, enough background.  It’s time to get the heart of this document. 
 
This document will be focused into three sections:  Forms Builder config, OC4J with Jinitiator, and OC4J with Sun JRE.
 

Forms Builder Configuration

Forms Builder is dependent on the following variables (there are others, but these are the most important):
• FORMS_PATH
• FORMS_BUILDER_CLASSPATH
• TNS_ADMIN
FORMS_PATH is used by Forms Builder to record the location of attached libraries (.pll) and subclassed objects (such as items from a Template.fmb or Object Library [.olb]).  You can also include your Forms working directory in this variable and Forms runtime will be able to find your compiled Forms binaries when you run a form from the Forms Builder.  This saves you having to modify the “formsweb.cfg” file to include a configuration for each form you develop (I’ll include a brief discussion of custom configurations at the end of this document).
 
This variable is mandatory if you use attached libraries or subclassed objects.
 
FORMS_BUILDER_CLASSPATH is used by Forms Builder to record the location of any Java Pluggable Components or Java Beans that are implemented in a form. 
 
This variable is optional, but you will receive a Forms Builder error during design time indicating that Forms Builder can’t find the implemented Java source.  This is a design time error only and does not affect runtime.
 
TNS_ADMIN is used by Forms Builder to find your TNSNAMES.ora and SQLNET.ora files.  This variable is handy if you have multiple Oracle Homes installed because it allows you to share a single set of TNS configuration files.
 
This variable is optional, but if you have multiple Oracle homes you will have to maintain separate copies of the TNS files for each Oracle home.
 
These variables can be set in either the Windows Registry (Windows XP) through the Windows System Environment Variables.  This document will describe both methods of setting these variables.
 

Windows Registry

1. Open the Windows Registry Editor (regedit.exe or reged32.exe)
2. Navigate to the appropriate Oracle Home
• HKEY_LOCAL_MACHINE
• SOFTWARE
• Oracle
• HEY_DevSuiteHome10g
3. FORMS_PATH: In the Key listing, scroll through and find the FORMS_PATH string variable and double-click or right-click and select “Modify” to edit the variable.
a. DO NOT delete the existing value.  Add directory information by separating it with semicolons “;”. 
b. Example:
        FORMS_PATH=C:\DevSuiteHome10g\cgenf61\admin;C:\Forms_Dev\*;
 
        Note: I have found that I can include a wildcard reference in the FORMS_PATH.  This allows me organize all of my Forms development into a
        single directory.  In my Forms_Dev directory, I have a Forms_Lib directory where I store all of my referenced items such as; attached libraries (.pll),
        object libraries (.olb) and object referenced from a Forms Template file (template.fmb).  Additionally, if I am working on different projects, I can
        create a subdirectory for each project.
 
4. FORMS_BUILDER_CLASSPATH:  find the existing entry for this key and open the key editor. 
a. Again – DO NOT delete any existing values
b. Add to the exiting directory and .jar file listing by separating each entry with a semicolon.
5. TNS_ADMIN:  This entry does not exist, you will have to create this entry in each of the Oracle Homes. 
a. In the key listing, right-click somewhere and New => String Value from the context menu
b. This will create an empty string entry.
c. Open the editor for the string and enter the full path to your TNS configuration files.  Eg: C:\DevSuiteHome10g\NETWORK\Admin
 

Windows Environment Variables

1. Open the System Properties control panel applet. (Start Menu => Control Panel => System)
2. Click on the Advanced tab.
3. Click on the Environment Variables button towards the bottom.
4. If more than one person uses the workstation, I recommend you add the FORMS_PATH variable to the set of User Variables rather than add it to the list of System Variables.  This allows each user to set their own preferences.
a. Click on the New button and enter the Variable Name and Variable Value
i. Variable Name = FORMS_PATH
ii. Variable Value = full path to your working and library directories
iii. You do not have to worry about the default value of this variable in the registry as this environment variable augments the registry.
5. Do the same thing for the FORMS_BUILDER_CLASSPATH and TNS_ADMIN variables.
 
This completes the Forms Builder setup. 

OC4J Servlet setup

The OC4J Servlet setup is a bit more complex in that all of the variables are stored one of two files.  These files are:
• DEFAULT.ENV
• FORMSWEB.CFG
These file can be found in the \%DEV_SUITE_HOME%\forms\server directory.  I strongly recommend you make a back up copy of the original file before you modify these files.
 
Note:  These files should only be modified on the application server using the Oracle Enterprise Manager (OEM).  The Developer Suite installation does not include the OEM so modifications must be made manually with a text editor.

DEFAULT.env

– This file is used to set Forms runtime environment parameters.  There are only two parameters that I have had to modify to enable running a form from the Forms Builder. They are:  FORMS_PATH and CLASSPATH.

The FORMS_PATH needs to have the same directories listed as stated above for the equivalent Registry or Environment variable.
The CLASSPATH only need to be modified if you implement a PJC or Java Bean in your form.   You will need to list the full path, to include the file name, in this parameter listing.  This parameter has a maximum character length of 256 characters.
 

FORMSWEB.cfg

– This file contains the parameter values used by the Forms Servlet.  There are two types of parameters: SYSTEM and USER defined.  System parameters are static in that they can not be overridden at run time.  User parameters have an entry in the baseHTML file and can be overridden in the URL query string. 
 
This file is where the bulk of changes are needed the enable running a form from the Forms Builder.  I will not list all of the parameters as there are too many.  Refer to the Application Server Forms Services Deployment Guide (see references) for a complete listing of all parameters and more detailed information.
 
Configuration will be separated by Java Runtime used.  I’ll list Sun JRE first and Jinitiator second.  Bear in mind, that Oracle has retired the Jinitiator and no longer supports its use. 
 
The formsweb.cfg is broke up into separate defined configurations.  Each configuration is named and can be identified by the name in square brackets.  For example, the ‘Default” configuration is listed as: [default].  This is the configuration that is used unless it is overridden through the URL query string. 
 
I’ll list later in the document how you can override a User parameter or specify a custom configuration later in the document.
 
Conventions used:Settings listed in Green are code comments
Settings listed in Blue are original settings
Settings listed in Red are recommend changes
Settings listed in Purple are optional changes
 
Sun JRE
Modify the following settings to use a JRE version different from the default if 1.4.2.  The following JRE changes instruct the Forms Runtime to use the JRE version 1.6.0 update 22 (1.6.0_22).  The following settings are all found in the [default] configuration section.
# System parameter: base HTML file for use with JInitiator client
# baseHTMLjinitiator=basejini.htm
baseHTMLjinitiator=basejpi.htm

Oracle Forms is hardwired (so to speak) to use the Oracle Jinitiator. Therefore, to instruct the Forms Runtime to use the JRE without passing a URL query string parameter, it is recommended you change the “baseHTMLinitiator” parameter to point to the Java Plug-In (JPI) html file. You could also expand the existing [jpi] section and instruct the Forms runtime to use this configuration in the URL. Personally, I find this to be the easier solution.

# Page displayed to users to allow them to download Sun's Java Plugin.
# Sun's Java Plugin is typically used for non-Windows clients.
# (NOTE: you should check this page and possibly change the settings)

# Original setting
#jpi_download_page=http://java.sun.com/products/archive/j2se/1.4.2_06/index.html
# New – points to the generic ( non-version specific) JRE download web site
jpi_download_page=http://www.oracle.com/technetwork/java/javase/downloads/index.html

# Parameter related to the version of the Java Plugin
# Original setting
#jpi_classid=clsid:CAFEEFAC-0014-0002-0006-ABCDEFFEDCBA
# This setting is specific to JRE 1.6.0_22
jpi_classid=clsid:CAFEEFAC-0016-0000-0022-ABCDEFFEDCBA
# Optional – Generic to any version of JRE 1.6.0.   Note the difference between these two settings.
jpi_classid=clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA

# Parameter related to the version of the Java Plugin
# Original setting
#jpi_codebase=http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,06
# New – specific to JRE 1.6.0_22
jpi_codebase=http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab#Version=1,6,0,22
# Optional – Generic to JRE 1.6.0
jpi_codebase=http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab#Version=1,6,0

# Parameter related to the version of the Java Plugin
# Original Setting
#jpi_mimetype=application/x-java-applet;jpi-version=1.4.2_06
# New – specific to JRE 1.6.0_22
jpi_mimetype=application/x-java-applet;jpi-version=1.6.0_22
# Optional – Generic to JRE 1.6.0
jpi_mimetype=application/x-java-applet;jpi-version=1.6.0

Oracle JinitiatorModify the following settings to use a Jinitiator version different from the default if 1.3.1.26.  There  are no optional settings for Jinitiator.
# Page displayed to Netscape users to allow them to download Oracle JInitiator.
# Oracle JInitiator is used with Windows clients.

# If you create your own page, you should set this parameter to point to it.
# jinit_download_page=/forms/jinitiator/us/jinit_download.htm
# Parameter related to the version of JInitiator
jinit_classid=clsid:CAFECAFE-0013-0001-0026-ABCDEFABCDEF
jinit_classid=clsid:CAFECAFE-0013-0001-0028-ABCDEFABCDEF
# Parameter related to the version of JInitiator
# jinit_exename=jinit.exe#Version=1,3,1,26
jinit_exename=jinit.exe#Version=1,3,1,28
# Parameter related to the version of JInitiator
# jinit_mimetype=application/x-jinit-applet;version=1.3.1.26
jinit_mimetype=application/x-jinit-applet;version=1.3.1.28

Default URL Query String and parameters

The default URL query string used by the Forms Builder is:

With reference to the aforementioned JPI change for the “baseHTMLjinitiator=” parameter, alternatively, you could pass the JPI configuration in the URL query string.  To do this, simply add “config=jpi” to the default URL query string.  Passing this additional parameter, the default URL would look like:

However, I prefer to make the change in the formsweb.cfg file as this is a more permanent change. 

Custom Configurations

If you have installed the Oracle Demo’s you will find that Oracle modifies the formsweb.cfg to add a configuration for each form included in the demo.  While this works fine for demo’s, it is a real pain in everyday development to add a configuration section for each form you work on (which is why I edit all of my forms in a directory that is in my FORMS_PATH).  However, there are times when it is good to create a configuration for a specific form.  For example, if I want to run a form with the Forms Runtime Diagnostics (FRD) enabled, I have created a configuration that enables this.  Then I simply add the parameter to the url to enable FRD (?config=my_frd).
To create a custom configuration, open the formsweb.cfg file and scroll to the bottom of the file.  Always add additionally configurations to the end of the file.  Custom configurations will use all of the variables in the [default] section and then override any you specify in your custom configuration.  The following is based on my reference to use Forms Runtime Diagnostics (FRD).  The configuration listed below also uses a configuration specific environment file (default.env) as well.
[my_frd]
otherparams=record=collect log=my_frd.txt
envFile=my_frd.env
form=<YOUR_FORM_NAME_HERE.fmb>
To create a specific environment file, I simply copied the default.env to my_frd.env and added the following variable:
 
FORMS_TRACE_DIR=C:\DevSuiteHome10g\NETWORK\log
 

References courtesy: Craig's Oracle Stuff

Friday, June 9, 2017

WHEN-VALIDATE-RECORD WHEN-VALIDATE-ITEM triggers in OAF

I was recently helping a friend in a customization in OAF, where through personalization, he wanted to put a ppr action in a seeded page in a seeded item. He was trying to do that customization using fire action, which was not acceptable by customer due to obvious reasons. Since, I think this section is missing in developers' guide, and is quite simple to approach, here is code you can write in process request of CO to attach programmatic PPR. lets take a simple example of attaching PPR to a message choice bean :

//In Process Request() 
{
//Please attach PPR only to those UIX beans which support it
//otherwise it may not work
OAMessageChoiceBean mcb=(OAMessageChoiceBean)webBean.findChildRecursive("");
FireAction firePartialAction = new FirePartialAction("empPositionChange");
mcb.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR,firePartialAction);
}

//In process form request
if ("empPositionChange".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
{
//ur logic on PPR

//if PPR is attached in a table/hgrid child then we can find the row
//reference by
String rowReference =pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
}



or

OAMessageTextInputBean SupplierItem_Bean = (OAMessageTextInputBean)webBean.findChildRecursive("SupplierItem");
FireAction firepartialaction = new FireAction("Supplier_Item_Change");
SupplierItem_Bean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, firepartialaction);
pageContext.writeDiagnostics(this, "About to set partial action for Supplier Item ", OAFwkConstants.STATEMENT);


I hope this helps. Happy oaf extensions :)!


courtasy - http://mukx.blogspot.in/2009/12/programatic-ppr-in-oaf.html

Thursday, May 18, 2017

List of HRMS APIs and sample code from oracle

List of APIs

HR_APPLICANT_API (peappapi.pkb/peappapi.pkh)

hr_applicant_api.create_gb_applicant
hr_applicant_api.hire_applicant
HR_APPLICATION_API (peaplapi.pkb/peaplapi.pkh)

hr_application_api.update_apl_details
HR_ASSIGNMENT_API (peasgapi.pkb/peasgapi.pkh)

hr_assignment_api.delete_assignment
hr_assignment_api.create_secondary_emp_asg
hr_assignment_api.update_emp_asg
hr_assignment_api.update_emp_asg_criteria
hr_assignment_api.create_gb_secondary_emp_asg
hr_assignment_api.set_new_primary_asg
hr_assignment_api.actual_termination_emp_asg
HR_CONTACT_REL_API (pecrlapi.pkb/pecrlapi.pkh)

hr_contact_rel_api.create_contact
hr_contact_rel_api.delete_contact_relationship
HR_CONTINGENT_WORKER (pecwkapi.pkb/pecwkapi.pkh)

hr_contingent_worker.convert_to_cwk
HR_CONTRACT_API (hrctcapi.pkb/hrctcapi.pkh)

hr_contract_api.create_contract
HR_EMPLOYEE_API (peempapi.pkb/peempapi.pkh)

hr_employee_api.create_gb_employee
HR_EX_EMPLOYEE_API (peexeapi.pkb/peexeapi.pkh)

hr_ex_employee_api.actual_termination_emp
HR_GRADE_RATE_VALUE_API (pygrrapi.pkb/pygrrapi.pkh)

hr_grade_rate_value_api.update_grade_rate_value
HR_ORGANIZATION_API (hrorgapi.pkb/hrorgapi.pkh)

hr_organization_api.create_organization
HR_LOCATION_API (hrlocapi.pkb/hrlocapi.pkh)

hr_location.api_create_location
HR_MAINTAIN_PROPOSAL_API

hr_maintain_proposal_api.insert_salary_proposal
HR_PERSON_ABSENCE_API (peabsapi.pkb/pkh)

hr_person_absence_api.create_person_absence
hr_person_absence_api.update_person_absence


HR_PERSON_API (peabsapi.pkb/pkh)

hr_person_api.delete_person
hr_person_api.update_gb_person
hr_person_api.update_person
HR_PERSON_EXTRA_INFO_API (pepeiapi.pkb/pepeiapi.pkh)

hr_person_extra_info.create_person_extra_info
hr_person_extra_info.update_person_extra_info
HR_POSITION_API (peposapi.pkb/peposapi.pkh)

hr_position_api.create_position
hr_position_api.delete_position
hr_position_api.update_position
HR_SIT_API (pesitapi.pkb/pesitapi.pkh)

hr_sit_api.create_sit
hr_sit_api.update_sit
HR_USER_ACCT_API (hrusrapi.pkb/hrusrapi.pkh)

hr_user_acct_api.create_user_acct
HR_UPLOAD_PROPOSAL_API (hrpypapi.pkb/hrpypapi.pkh)

hr_upload_proposal_api.upload_salary_proposal
 PER_QUALIFICATIONS_API (pequaapi.pkb/pequaapi.pkh)

per_qualifications_api.update_qualification
PER_VACANCY_API (pevacapi.pkb/pevacapi.pkh)

create_vacancy


The following are examples only.  Do not cut and paste these to use in your instances as is. They are not warranted to work in this manner. 

You will need to write your own code for your instance based on whether you are a fully installed Oracle Human Resources environment or a shared HR installed Oracle Human Resources environment. 

Shared HR installed Oracle Human Resources environments are limited as to what can and cannot be used within API's. 

If you are unaware of what data can and cannot be used within your environment, please go to the following note for validation. 

Note 462586.1How To Access API References via the Oracle Integration Repository


 hr_maintain_proposal_api.insert_salary_proposal


DECLARE
l_pay_proposal_id              number;
l_element_entry_id             number;
l_inv_next_sal_date_warning    boolean;
l_proposed_salary_warning      boolean;
l_approved_warning             boolean;
l_payroll_warning              boolean;
l_object_version_number        number;

BEGIN

hr_maintain_proposal_api.insert_salary_proposal
(p_pay_proposal_id        =>l_pay_proposal_id 
,p_assignment_id        => 5093    -- *** Enter your assignment_id here
,p_business_group_id        => 1496    -- *** Enter your business_group_id here
,p_change_date            => to_date('01-APR-2001','DD-MON-YYYY')
,p_proposal_reason        => 'NEWH'  -- *** Enter your own reason here     
,p_proposed_salary_n        => 17500  
,p_object_version_number    => l_object_version_number
,p_multiple_components        => 'N'
,p_approved            => 'Y'
,p_validate            => FALSE
,p_element_entry_id        => l_element_entry_id
,p_inv_next_sal_date_warning    => l_inv_next_sal_date_warning
,p_proposed_salary_warning    => l_proposed_salary_warning
,p_approved_warning        => l_approved_warning
,p_payroll_warning        => l_payroll_warning);

END;
/

-- Go to API List
hr_location_api.create_location

set serveroutput on;
DECLARE
  l_location_id           NUMBER;
  l_object_version_number NUMBER;
BEGIN
apps.hr_location_api.create_location (
  p_effective_date        =>  SYSDATE,
  p_validate              =>  FALSE,
  p_location_code         =>  'TEST_LOCATION',
  p_description           =>  'TEST Location',
  p_address_line_1        =>  'TEST Avenue',
  p_country               =>  'GB',
  p_postal_code           =>  'XXXX',
  p_telephone_number_1    =>  '1234567',
  p_town_or_city          =>  'TEST Town',
  -- p_business_group_id  =>  '626',
  p_style                 =>  'GB',
  p_location_id           =>  l_location_id,
  p_object_version_number =>  l_object_version_number
);
END;

-- Go to API List
hr_person_extra_info.update_person_extra_info

set serveroutput on;

DECLARE
  l_true                 BOOLEAN      :=FALSE;
  l_PERSON_EXTRA_INFO_ID NUMBER       :=101041;
  l_PEI_INFORMATION3     VARCHAR(200) := TO_CHAR(to_date('01-JAN-2012','DD-MON-YYYY'),'YYYY/MM/DD HH24:MI:SS') ; 
  l_OBJ                  NUMBER;

CURSOR csr_ovn
IS
  SELECT MAX(object_version_number)
  FROM per_people_extra_info
  WHERE PERSON_EXTRA_INFO_ID = l_PERSON_EXTRA_INFO_ID;
BEGIN
  OPEN csr_ovn;
  FETCH csr_ovn INTO l_obj;
  CLOSE csr_ovn;

HR_PERSON_EXTRA_INFO_API.UPDATE_PERSON_EXTRA_INFO
(
 p_validate                          =>    l_true
,P_PERSON_EXTRA_INFO_ID         =>    l_PERSON_EXTRA_INFO_ID
,p_PEI_INFORMATION3             =>    l_PEI_INFORMATION3
,p_object_version_number        =>    l_obj
);
END;


-- Go to API List


hr_person_extra_info.create_person_extra_info

set serveroutput on;

DECLARE
  l_true                     BOOLEAN        :=FALSE;
  l_PERSON_ID                NUMBER         :=31785;
  l_INFORMATION_TYPE         VARCHAR2(2000) := 'LAST_NAME_DETAILS';
  l_pei_information_category VARCHAR2(2000) := 'LAST_NAME_DETAILS';
  l_PEI_INFORMATION1         VARCHAR2(2000) := 'Test1';
  l_PEI_INFORMATION2         VARCHAR2(2000) := 'Test2';
  l_PEI_INFORMATION3         VARCHAR(200)   := TO_CHAR(to_date('01-JAN-1999','DD-MON-YYYY'),'YYYY/MM/DD HH24:MI:SS');
-- Output Variables
  l_PERSON_EXTRA_INFO_ID     NUMBER;
  l_OBJ                      NUMBER;


CURSOR csr_ovn
IS
  SELECT MAX(object_version_number)
  FROM per_all_people_f
  WHERE person_id=l_person_id;
BEGIN
  OPEN csr_ovn;
  FETCH csr_ovn INTO l_obj;
  CLOSE csr_ovn;

HR_PERSON_EXTRA_INFO_API.CREATE_PERSON_EXTRA_INFO
(
 p_validate                     =>    l_true
,p_person_id                    =>    l_person_id
,p_INFORMATION_TYPE             =>    l_INFORMATION_TYPE
,p_pei_information_category     =>    l_pei_information_category
,p_PEI_INFORMATION1             =>    l_PEI_INFORMATION1
,p_PEI_INFORMATION2             =>    l_PEI_INFORMATION2
,p_PEI_INFORMATION3             =>    l_PEI_INFORMATION3
,p_PERSON_EXTRA_INFO_ID         =>    l_PERSON_EXTRA_INFO_ID
,p_object_version_number        =>    l_obj
);
end;

-- Go to API List

hr_position_api.update_position

DECLARE
  l_true                         BOOLEAN        :=FALSE;
  l_obj                          NUMBER;
  l_DATE_EFFECTIVE               DATE           :=to_date('01-Jan-2012','DD-MON-YYYY');
  l_POSITION_ID                  NUMBER         :=110471;
  l_POSITION_DEFINITION_ID       NUMBER;
  l_NAME                         VARCHAR2(500)  :='NJ Single.';
  l_position_type                VARCHAR2(100)  := 'NONE';
  L_EFFECTIVE_DATE_START         DATE;
  L_EFFECTIVE_DATE_END           DATE; 
  L_VALID_GRADES_CHANGED_WARNING BOOLEAN;
  l_datetrack_mode               VARCHAR2(100)  :='CORRECTION';

CURSOR csr_ovn
IS
  SELECT MAX(object_version_number)
  FROM hr_all_positions_f
  WHERE position_id=l_POSITION_ID;
  
BEGIN
  OPEN csr_ovn;
  FETCH csr_ovn INTO l_obj;
  CLOSE csr_ovn;

HR_POSITION_API.UPDATE_POSITION
(
p_validate                        =>    l_true
,p_position_id                    =>    l_POSITION_ID
,p_effective_start_date           =>    l_EFFECTIVE_DATE_START
,p_effective_end_date             =>    l_EFFECTIVE_DATE_END
,p_position_definition_id         =>    l_POSITION_DEFINITION_ID 
,p_valid_grades_changed_warning   =>    L_VALID_GRADES_CHANGED_WARNING
,p_name                           =>    l_NAME
,p_position_type                  =>    l_position_type -- changing position type
,p_object_version_number          =>    l_obj
,p_effective_date                 =>    l_DATE_EFFECTIVE 
,p_datetrack_mode                 =>    l_datetrack_mode
);
END;


-- Go to API List
hr_position_api.delete_position

set serveroutput on;

declare

l_true                    boolean     :=false;
l_POSITION_ID             NUMBER        := 75502;
l_DATE                       DATE        := to_date('01-feb-2013', 'DD-MON-YYYY');
l_obj                   NUMBER;
l_datetrack_mode        varchar(30)  := 'ZAP';
l_date1      Date;
l_date2      Date;

cursor csr_ovn is
       select max(object_version_number)
       from hr_All_positions_f where position_id=l_POSITION_ID;
begin
open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;

            hr_position_api.delete_position
            (
              p_validate                 => l_true   
             ,p_position_id              => l_POSITION_ID 
             ,p_object_version_number     => l_obj
             ,p_datetrack_mode             => l_datetrack_mode
             ,p_effective_date          => l_date
             ,p_security_profile_id      => 42
             ,p_effective_start_date           => l_date1
             ,p_effective_end_date             => l_date2
            );
end;
/


-- Go to API List
per_qualifications_api.update_qualification

set serveroutput on;
declare
l_date                            date          := to_date('27-JAN-2012', 'DD-MON-YYYY');
l_true                            boolean     := false;
l_QUALIFICATION_ID                 number      := 56905;
l_obj                              NUMBER;
l_title        varchar2(100)        := 'UPDATED_API' ;

cursor csr_ovn is
       select max(object_version_number)
       from per_qualifications where person_id=32063;
begin
open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;

per_qualifications_api.UPDATE_QUALIFICATION(
        p_effective_date        =>    l_date
       ,p_qualification_id        =>  l_QUALIFICATION_ID
       ,p_title                    =>  l_title
       ,p_object_version_number    =>  l_obj
);
end;
/

-- Go to API List
hr_contract_api.create_contract 

set serveroutput on;
Declare

 /* Out variables */
   p_validate                       boolean    default false;
   p_contract_id                    number;
   p_effective_start_date           date;
   p_effective_end_date             date;
   p_object_version_number          number;
   l_date                            date := to_date('01-JAN-2013','DD-MON-YYYY');
   /* In variables*/
   
   p_person_id                      number;
   p_reference                      varchar2(240);
   p_type                           varchar2(240);
   p_status                         varchar2(240);
   p_effective_date                 date;

BEGIN

hr_contract_api.create_contract (
p_validate                        => false
,p_contract_id                    => p_contract_id
,p_effective_start_date           => p_effective_start_date
,p_effective_end_date             => p_effective_end_date
,p_object_version_number          => p_object_version_number
,p_person_id                      => 18689
,p_reference                      => 9874  -- Random number
,p_type                           => 'UNSPECIFIED_PERIOD'  -- defined by the CONTRACT_TYPE lookup type.
,p_status                         => 'A-ACTIVE'   -- defined by the CONTRACT_STATUS lookup type.
,p_effective_date                 => l_date
);
END;
/

-- Go to API List
hr_ex_employee_api.actual_termination_emp

set serveroutput on;

declare

    l_period_of_service_id         number := 3123;
    l_date                date   := to_date('01-AUG-2000', 'DD-MON-YYYY');
    l_true                    boolean  := false;
    l_leaving_reason        varchar2(2000) := 'QPJ';
    l_term_date            date   := to_date('31-AUG-2000', 'DD-MON-YYYY');
    l_lsp_date            date   := to_date('31-AUG-2000', 'DD-MON-YYYY');
    l_batch_id            number := 103;
    l_fp_date            date   := to_date('31-AUG-2000', 'DD-MON-YYYY');
    l_obj                number;
    l_actual_termination_date    date := to_date('31-AUG-2000', 'DD-MON-YYYY');
    l_SUPERVISOR_WARNING           BOOLEAN;                
    l_EVENT_WARNING                BOOLEAN;                 
    l_INTERVIEW_WARNING            BOOLEAN;               
    l_REVIEW_WARNING               BOOLEAN;               
    l_RECRUITER_WARNING            BOOLEAN;              
    l_ASG_FUTURE_CHANGES_WARNING   BOOLEAN;            
    l_ENTRIES_CHANGED_WARNING      VARCHAR2(30);             
    l_PAY_PROPOSAL_WARNING         BOOLEAN;         

cursor csr_ovn is
       select max(object_version_number)
       from per_periods_of_Service where period_of_service_id=3123;

begin

open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;

  --  execute API to insert leave date
        
    hr_ex_employee_api.actual_termination_emp
    (
    p_validate                =>  l_true
       ,p_effective_date        =>  l_date
       ,p_period_of_service_id    =>  l_period_of_service_id
       ,p_object_version_number   =>  l_obj
       ,p_leaving_reason          =>  l_leaving_reason
       ,p_actual_termination_date => l_actual_termination_date
    ,p_SUPERVISOR_WARNING     =>    l_SUPERVISOR_WARNING                
    ,p_EVENT_WARNING          =>    l_EVENT_WARNING                    
    ,p_INTERVIEW_WARNING      =>    l_INTERVIEW_WARNING                 
    ,p_REVIEW_WARNING         =>     l_REVIEW_WARNING                 
    ,p_RECRUITER_WARNING      =>    l_RECRUITER_WARNING              
    ,p_ASG_FUTURE_CHANGES_WARNING =>  l_ASG_FUTURE_CHANGES_WARNING            
    ,p_ENTRIES_CHANGED_WARNING    =>  l_ENTRIES_CHANGED_WARNING             
    ,p_PAY_PROPOSAL_WARNING       =>  l_PAY_PROPOSAL_WARNING     
    );
end;
/

-- Go to API List
hr_person_absence_api.create_person_absence

set serveroutput on;

DECLARE
l_absence_days            Number :=2;
l_absence_hours            Number;
l_absence_attendance_id        Number;                                                   
l_object_version_number        Number;                                                    
l_occurance            Number;                                                    
l_dur_dys_less_warning        boolean;                                                   
l_dur_hrs_less_warning        boolean;                                                   
l_exceeds_pto_entit_warning    boolean;                                                   
l_exceeds_run_total_warning    boolean;                                                   
l_abs_overlap_warning        boolean;                                                   
l_abs_day_after_warning        boolean;                                                   
l_dur_overwritten_warning    boolean;  
BEGIN
HR_PERSON_ABSENCE_API.create_person_absence                                                                     
  (p_validate                => FALSE                                    
  ,p_effective_date            => to_date('01-APR-2002','DD-MON-YYYY')                                                      
  ,p_person_id                => 2831                                               
  ,p_business_group_id            => 1379                                                 
  ,p_absence_attendance_type_id        => 272                                                  
  ,p_abs_attendance_reason_id        => 443                                                                      
  ,p_date_start                => to_date('01-APR-2002','DD-MON-YYYY')                                                                       
  ,p_date_end                => to_date('02-APR-2002','DD-MON-YYYY')                                                                      
  ,p_absence_days            => l_absence_days                                                   
  ,p_absence_hours            => l_absence_hours                                                                                      
  ,p_absence_attendance_id        => l_absence_attendance_id                                                   
  ,p_object_version_number        => l_object_version_number                                                     
  ,p_occurrence             => l_occurance                                                    
  ,p_dur_dys_less_warning        => l_dur_dys_less_warning                                                  
  ,p_dur_hrs_less_warning        => l_dur_hrs_less_warning                                                  
  ,p_exceeds_pto_entit_warning        => l_exceeds_pto_entit_warning                                                   
  ,p_exceeds_run_total_warning        => l_exceeds_run_total_warning                                                   
  ,p_abs_overlap_warning        => l_abs_overlap_warning                                                   
  ,p_abs_day_after_warning        => l_abs_day_after_warning      
  ,p_dur_overwritten_warning        => l_dur_overwritten_warning                                                  
  );                                                                                                
END;
/

-- Go to API List
hr_contact_rel_api.create_contact

set serveroutput on;

DECLARE
l_validate_mode          BOOLEAN := FALSE;
l_datetrack_update_mode  VARCHAR2(30);
l_row_id                 ROWID;
l_business_group_id     NUMBER;
l_contact_type         VARCHAR2(30);
l_contact_title             VARCHAR2(30);
l_primary_flag             VARCHAR2(30);
l_attribute16             VARCHAR2(150);
l_contact_full_name             VARCHAR2(240);
l_person_type_id        NUMBER;
l_sex                VARCHAR2(30);
l_per_start_date    DATE;
l_per_end_date        DATE;
l_per_comment_id    NUMBER;
l_name_comb_warning    BOOLEAN;
l_contact_relationship_id NUMBER;
l_contact_rel_ovn NUMBER;
l_contact_person_id NUMBER;
l_contact_person_ovn NUMBER;
l_errors VARCHAR2(100);
L_ORIG_HIRE_WARNING boolean;
BEGIN
HR_CONTACT_REL_API.CREATE_CONTACT
( P_VALIDATE                 =>    FALSE
, P_DATE_START              =>  '04-AUG-1999'
, P_START_DATE                  =>    '04-AUG-1999'
, P_BUSINESS_GROUP_ID         =>    626
, P_PERSON_ID                 =>    367
-- , P_CONTACT_PERSON_ID         =>    NULL
, P_CONTACT_TYPE              =>     'F'
, P_PRIMARY_CONTACT_FLAG     =>    'N'
, P_CONT_ATTRIBUTE16        =>    NULL
, P_LAST_NAME                 =>    'BLOGGY1'
, P_SEX                      =>    'M'
, P_PERSON_TYPE_ID        =>    101
, P_DATE_OF_BIRTH             =>    '12-SEP-1977'
, P_FIRST_NAME                 =>    'FRED'
--, P_TITLE                  =>    l_contact_title
, P_CONTACT_RELATIONSHIP_ID     =>    l_contact_relationship_id
, P_CTR_OBJECT_VERSION_NUMBER     =>     l_contact_rel_ovn 
, P_PER_PERSON_ID        =>    l_contact_person_id
, P_PER_OBJECT_VERSION_NUMBER     =>     l_contact_person_ovn
, P_PER_EFFECTIVE_START_DATE     =>    l_per_start_date
, P_PER_EFFECTIVE_END_DATE       =>     l_per_end_date
, P_FULL_NAME            =>    l_contact_full_name
, P_PER_COMMENT_ID        =>    l_per_comment_id
, P_NAME_COMBINATION_WARNING    =>    l_name_comb_warning
, P_ORIG_HIRE_WARNING    => L_ORIG_HIRE_WARNING
);
END;
/


-- Go to API List
hr_applicant_api.create_gb_applicant

set serverout on;
declare
    l_person_id            per_people_f.person_id%TYPE;
    l_assignment_id            per_assignments_f.assignment_id%TYPE;
    l_per_object_version_number    per_people_f.object_version_number%TYPE;
    l_asg_object_version_number    per_people_f.object_version_number%TYPE;
    l_apl_object_version_number    per_applications.object_version_number%TYPE;
    l_per_effective_start_date    per_people_v.effective_start_date%TYPE;
    l_per_effective_end_date    per_people_v.effective_end_date%TYPE;
    l_full_name            per_people_f.full_name%TYPE;
    l_per_comment_id        per_people_f.comment_id%TYPE;
    l_application_id        per_applications.application_id%TYPE;
    l_assignment_sequence        per_people_assignments_view.assignment_sequence%TYPE;
    l_applicant_number        per_people_f.applicant_number%TYPE;
    l_name_combination_warning    boolean;
    l_assign_payroll_warning    boolean;
    l_orig_hire_warning        boolean;
begin
hr_applicant_api.create_gb_applicant
(
P_VALIDATE               =>     FALSE
,P_DATE_RECEIVED        =>    to_date('31-DEC-1999','DD-MON-YYYY')
,P_DATE_OF_BIRTH        =>    to_date('01-OCT-1985','DD-MON-YYYY')
,P_BUSINESS_GROUP_ID        =>    1379    
,P_LAST_NAME                    =>    'VF-TEST3'   
,P_APPLICANT_NUMBER             =>    l_applicant_number
,P_PERSON_ID                    =>    L_PERSON_ID   
,P_ASSIGNMENT_ID                =>    L_ASSIGNMENT_ID   
,P_APPLICATION_ID               =>    l_application_id   
,P_PER_OBJECT_VERSION_NUMBER    =>    L_PER_OBJECT_VERSION_NUMBER   
,P_ASG_OBJECT_VERSION_NUMBER    =>    L_ASG_OBJECT_VERSION_NUMBER   
,P_APL_OBJECT_VERSION_NUMBER    =>    L_APL_OBJECT_VERSION_NUMBER   
,P_PER_EFFECTIVE_START_DATE     =>    L_PER_EFFECTIVE_START_DATE   
,P_PER_EFFECTIVE_END_DATE       =>    L_PER_EFFECTIVE_END_DATE   
,P_FULL_NAME                    =>    L_FULL_NAME   
,P_PER_COMMENT_ID               =>    L_PER_COMMENT_ID   
,P_ASSIGNMENT_SEQUENCE          =>    L_ASSIGNMENT_SEQUENCE   
,P_NAME_COMBINATION_WARNING     =>    L_NAME_COMBINATION_WARNING   
,P_ORIG_HIRE_WARNING            =>    L_ORIG_HIRE_WARNING
);
end;
/


-- Go to API List
hr_employee_api.create_gb_employee

set serverout on;
declare
    l_employee_number        per_people_f.employee_number%TYPE;
    l_person_id            per_people_f.person_id%TYPE;
    l_assignment_id            per_assignments_f.assignment_id%TYPE;
    l_per_object_version_number    per_people_f.object_version_number%TYPE;
    l_asg_object_version_number    per_people_f.object_version_number%TYPE;
    l_per_effective_start_date    per_people_v.effective_start_date%TYPE;
    l_per_effective_end_date    per_people_v.effective_end_date%TYPE;
    l_full_name            per_people_f.full_name%TYPE;
    l_per_comment_id        per_people_f.comment_id%TYPE;
    l_assignment_sequence        per_people_assignments_view.assignment_sequence%TYPE;
    l_assignment_number        per_people_assignments_view.assignment_number%TYPE;
    l_name_combination_warning    boolean;
    l_assign_payroll_warning    boolean;
    
begin
    hr_employee_api.create_gb_employee
    (
    p_validate        =>    FALSE
    ,p_hire_date        =>    to_date('01-Jul-2000','DD-MON-YYYY')
    ,p_business_group_id    =>    1021
    ,p_first_name        =>    'FONGY'
    ,p_last_name        =>    'FONGY'
    ,p_sex            =>    'M'
    ,p_ni_number        =>    'WP934486A'
    ,p_employee_number    =>    l_employee_number
    ,p_person_id        =>    l_person_id
    ,p_assignment_id    =>    l_assignment_id
    ,p_per_object_version_number    =>    l_per_object_version_number    
    ,p_asg_object_version_number    =>    l_asg_object_version_number
    ,p_per_effective_start_date    =>    l_per_effective_start_date
    ,p_per_effective_end_date    =>    l_per_effective_end_date
    ,p_full_name            =>    l_full_name
    ,p_per_comment_id        =>    l_per_comment_id
    ,p_assignment_sequence        =>    l_assignment_sequence
    ,p_assignment_number        =>    l_assignment_number
    ,p_name_combination_warning    =>    l_name_combination_warning
    ,p_assign_payroll_warning    =>    l_assign_payroll_warning
    );
    dbms_output.put_line ('Person ID: ' || to_char(l_person_id));
end;
/


-- Go to API List
hr_organization_api.create_organization

set serveroutput on;

declare
l_date                    date           := to_date('01-jan-2000','DD-MON-YYYY');
l_true                    boolean     := false;
l_business_group_id        number        := 626;
l_language_code            varchar2(10)    := 'US';
l_name                    varchar2(80)    := 'NJ TEST ORG';
l_internal_external_flag    varchar2(80)    := 'INT';
l_organization_id         number;
l_object_version_number        number;
l_duplicate_org_warning        boolean;

begin
hr_organization_api.create_organization
   (  p_validate                      =>     l_true
     ,p_effective_date                =>    l_date
     ,p_language_code                 =>    l_language_code
     ,p_business_group_id             =>    l_business_group_id
     ,p_date_from                     =>    l_date
     ,p_name                          =>    l_name
     ,p_internal_external_flag        =>    l_internal_external_flag
     ,p_organization_id               =>    l_organization_id
     ,p_object_version_number         =>    l_object_version_number
     ,P_duplicate_org_warning          =>    l_duplicate_org_warning
);
end;
/


-- Go to API List
hr_position_api.create_position

set serveroutput on;

declare

l_true                    boolean     :=false;
l_obj                      NUMBER;
l_JOB_ID                        NUMBER        :=614;  
l_ORGANIZATION_ID                  NUMBER        :=1379;
l_DATE_EFFECTIVE                DATE        := to_date('01-DEC-2000', 'DD-MON-YYYY');
l_POSITION_ID                   NUMBER;
l_POSITION_DEFINITION_ID        NUMBER;
l_NAME                          VARCHAR2(30);
l_segment1            VARCHAR(30)    :='NJ TEST POSITION';
l_segment2            VARCHAR2(30)    :='10';

begin


hr_position_api.create_position
(
        p_validate              =>    l_true
,       p_object_version_number        =>    l_obj
,    p_JOB_ID            =>    l_JOB_ID
,    p_ORGANIZATION_ID         =>    l_ORGANIZATION_ID 
,    p_DATE_EFFECTIVE        =>    l_DATE_EFFECTIVE
,    p_POSITION_ID            =>    l_POSITION_ID
,     p_POSITION_DEFINITION_ID    =>    l_POSITION_DEFINITION_ID
,     p_NAME                 =>    l_NAME 
,    p_segment1            =>    l_segment1
,    p_segment2            =>    l_segment2
,    p_location_id            =>    2694
);
end;
/

-- Go to API List
hr_assignment_api.create_secondary_emp_asg

set serveroutput on;

declare
l_date                        date := to_date('01-MAR-2012','DD-MON-YYYY');
l_assignment_number         varchar2(30);
l_group_name                 varchar2(100);
l_concatenated_segments        varchar2(100);
l_cagr_grade_def_id         number;
l_cagr_concatenated_segments varchar2(100);
l_assignment_id                number;
l_soft_coding_keyflex_id    number;
l_effective_end_date        date;
l_assignment_sequence        number;
l_comment_id                number;
l_other_manager_warning        boolean;
l_hourly_salaried_warning    boolean;
l_gsp_post_process_warning    varchar2(100);
l_people_group_id             number := 169; 
l_ovn                        number;
l_person_id                    number    := 367;
l_organization_id            number     :=    647;
l_payroll_id                number    := 112;
l_location_id                 number := 431;

begin
hr_assignment_api.create_secondary_emp_asg
                (p_validate                        => FALSE,
                 p_effective_date                  => to_date('01-MAR-2012','DD-MON-YYYY'),
                 p_person_id                       => l_person_id,
                 p_organization_id                 => l_organization_id,
                 p_payroll_id                      => l_payroll_id,
                 p_location_id                     => l_location_id,
                 p_assignment_number               => l_assignment_number,
                 p_group_name                      => l_group_name,
                 p_concatenated_segments           => l_concatenated_segments,
                 p_cagr_grade_def_id               => l_cagr_grade_def_id,
                 p_cagr_concatenated_segments      => l_cagr_concatenated_segments,
                 p_assignment_id                   => l_assignment_id,
                 p_soft_coding_keyflex_id          => l_soft_coding_keyflex_id,
                 p_people_group_id                 => l_people_group_id,
                 p_object_version_number           => l_ovn,
                 p_effective_start_date            => l_date,
                 p_effective_end_date              => l_effective_end_date,
                 p_assignment_sequence             => l_assignment_sequence,
                 p_comment_id                      => l_comment_id,
                 p_other_manager_warning           => l_other_manager_warning,
                 p_hourly_salaried_warning         => l_hourly_salaried_warning,
                 p_gsp_post_process_warning        => l_gsp_post_process_warning
                );
end;
/
   

-- Go to API List
hr_sit_api.create_sit

declare
l_date                date           := to_date('02-DEC-2002', 'DD-MON-YYYY');
l_true                    boolean     := false;
l_person_id              number      := 2831;
l_obj                      NUMBER;
l_business_group_id        number        := 1379;
l_id_flex_num            number        := 51058;
l_analysis_criteria_id        number;
l_person_analysis_id        number;
l_p_segment1            varchar2(250)    := '30';
l_p_segment2            varchar2(250)    := '30';
l_p_segment3            varchar2(250)    := '10';
l_p_segment4            varchar2(250)    := '30-jan-2002';
cursor csr_ovn is
       select max(object_version_number)
       from per_people_f where person_id=l_person_id;
begin
open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;
hr_sit_api.create_sit
(
        p_validate              =>    l_true
,       p_effective_date              =>    l_date
,       p_person_id                  =>    l_person_id
,       p_pea_object_version_number        =>    l_obj
,    p_business_group_id        =>    l_business_group_id
,    p_id_flex_num            =>    l_id_flex_num
,    p_analysis_criteria_id        =>    l_analysis_criteria_id
,    p_person_analysis_id        =>    l_person_analysis_id
,    p_segment1            =>    l_p_segment1
,    p_segment2            =>    l_p_segment2
,    p_segment3            =>    l_p_segment3
,    p_segment4            =>    l_p_segment4
);
end;
/

-- Go to API List
hr_user_acct_api.create_user_acct

set serveroutput on;

declare

    l_business_group_id         number := 1379;
    l_user_id            number := 123456;
    l_true                    boolean  := false;
    l_per_effective_start_date    date   := to_date('26-JUL-2001', 'DD-MON-YYYY');
    l_per_effective_end_date    date   := to_date('31-DEC-4712', 'DD-MON-YYYY');
        l_assignment_id            number := 3976;
    l_asg_effective_start_date    date := to_date('26-JUL-2001', 'DD-MON-YYYY');
    l_asg_effective_end_date    date := to_date('31-DEC-4712', 'DD-MON-YYYY');
    l_date_from            date := to_date('26-JUL-2001', 'DD-MON-YYYY');
    l_date_to            date := to_date('31-DEC-4712', 'DD-MON-YYYY');
    l_hire_date            date := to_date('26-JUL-2001', 'DD-MON-YYYY');
    l_org_structure_id        number := 192;
    l_org_structure_version_id    number := 249;
    l_parent_org_id            number := 1;
    l_single_org_id            number := 1;
    l_run_type            varchar2(30) := 'Bum';

begin

       
    hr_user_acct_api.create_user_acct
    (
   p_validate                  =>  l_true   
  ,p_business_group_id         =>  l_business_group_id                         
  ,p_user_id                   =>  l_user_id
  ,p_per_effective_start_date  =>  l_per_effective_start_date
  ,p_per_effective_end_date    =>  l_per_effective_end_date
  ,p_assignment_id             =>  l_assignment_id
  ,p_asg_effective_start_date  =>  l_asg_effective_start_date
  ,p_asg_effective_end_date    =>  l_asg_effective_end_date
  ,p_date_from                   =>  l_date_from    
  ,p_date_to                   =>  l_date_to
  ,p_hire_date                 =>  l_hire_date
  ,p_org_structure_id           =>  l_org_structure_id    
  ,p_org_structure_version_id  =>  l_org_structure_version_id    
  ,p_parent_org_id           =>  l_parent_org_id    
  ,p_single_org_id             =>  l_single_org_id
  ,p_run_type                  =>  l_run_type
    );
end;
/


-- Go to API List
hr_assignment_api.delete_assignment

set serveroutput on;
declare
    v_date  date := to_date('21052012','ddmmyyyy');
    v_assignment_id number;
    v_person_id number;
    l_aantal number;
    l_effective_start_date       per_all_assignments_f.effective_start_date%TYPE;
    l_effective_end_date         per_all_assignments_f.effective_end_date%TYPE;
    l_loc_change_tax_inssues     boolean;
    l_delete_asg_budgets         boolean;
    l_org_now_no_manager_warning boolean;
    l_element_salary_warning     boolean;
    l_element_entries_warning    boolean;
    l_spp_warning                boolean;
    l_cost_warning               Boolean;
    l_life_events_exists         Boolean;
    l_cobra_coverage_elements    Boolean;
    l_assgt_term_elements        Boolean;
    l_object_version_number      number;
    l_fout                       varchar2(3);
    l_assignment_id              per_all_assignments_f.assignment_id%type;
    l_asg_obj_version_number     per_all_assignments_f.object_version_number%type;
    l_assignment_sequence        number;
    l_assignment_number          per_all_assignments_f.assignment_number%type;
    l_assign_payroll_warning     boolean;
    l_ontslag                    per_periods_of_service%rowtype;
    l_rowid                      varchar2(2000);
    l_dodwarning                 boolean;
    l_s_final_process_date       date;
    l_s_actual_termination_date  date;
    l_assignment_status_type_id  per_all_assignments_f.assignment_status_type_id%type;
    l_requery_required           varchar2(1);
    l_rowid                      rowid;
  cursor c_obj is
     select object_version_number
     from per_all_assignments_f paaf
     where paaf.person_id = v_person_id
      and  paaf.assignment_id = v_assignment_id
      and  v_date between paaf.effective_start_date and paaf.effective_end_date;

begin

        v_assignment_id := 35158;
        v_person_id     := 34634;
        open c_obj;
        fetch c_obj into  l_object_version_number;
        close c_obj;

        begin
            hr_assignment_api.delete_assignment
                       (p_validate                => FALSE
                                           ,p_effective_date          => v_date -1
                       ,p_datetrack_mode          => 'DELETE_NEXT_CHANGE'
                       ,p_assignment_id           => v_assignment_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_loc_change_tax_issues   => l_loc_change_tax_inssues
                       ,p_delete_asg_budgets      => l_delete_asg_budgets
                       ,p_org_now_no_manager_warning  => l_org_now_no_manager_warning
                       ,p_element_salary_warning  => l_element_salary_warning
                       ,p_element_entries_warning  => l_element_entries_warning
                       ,p_spp_warning              => l_spp_warning
                       ,P_cost_warning             => l_cost_warning
                       ,p_life_events_exists        => l_life_events_exists
                       ,p_cobra_coverage_elements  => l_cobra_coverage_elements
                       ,p_assgt_term_elements      => l_assgt_term_elements);
--
         exception
         when others then
               dbms_output.put_line(substr(sqlerrm,1,200));
         end;


end;
/



-- Go to API List
hr_person_absence_api.update_person_absence


DECLARE
l_absence_days            Number :=3;
l_absence_hours            Number;
l_absence_attendance_id        Number :=194537;                                                   
l_obj                        Number;
l_dur_dys_less_warning        boolean;                                                
l_dur_hrs_less_warning        boolean;                                                   
l_exceeds_pto_entit_warning    boolean;                                                   
l_exceeds_run_total_warning    boolean;                                                   
l_abs_overlap_warning        boolean;                                                   
l_abs_day_after_warning        boolean;                                                   
l_dur_overwritten_warning    boolean;  
l_del_element_entry_warning   boolean;
l_date_start     date :=to_date('01-sep-2011','DD-MON-YYYY');
l_date_end      date:=to_date('15-sep-2011','DD-MON-YYYY');

cursor csr_ovn is
       select max(object_version_number)
       from per_absence_attendances where absence_attendance_id=l_absence_attendance_id; 
begin
open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;

        hr_person_absence_api.update_person_absence
             (p_validate                      =>    FALSE
             ,p_effective_date                =>   to_date('01-SEP-2011','DD-MON-YYYY')    
             ,p_absence_attendance_id          =>    l_absence_attendance_id 
             ,p_abs_attendance_reason_id      =>    74                     -- the reason before was null - now changing to id 74 (COLD)
             ,p_absence_days                  =>   l_absence_days   
             ,p_absence_hours                 =>   l_absence_hours    
             ,p_object_version_number         =>   l_obj        
             ,p_dur_dys_less_warning          =>   l_dur_dys_less_warning   
             ,p_dur_hrs_less_warning          =>   l_dur_hrs_less_warning   
             ,p_exceeds_pto_entit_warning     =>   l_exceeds_pto_entit_warning  
             ,p_exceeds_run_total_warning     =>   l_exceeds_run_total_warning  
             ,p_abs_overlap_warning           =>   l_abs_overlap_warning   
             ,p_abs_day_after_warning         =>   l_abs_day_after_warning     
             ,p_dur_overwritten_warning       =>   l_dur_overwritten_warning 
             ,p_del_element_entry_warning      =>   l_del_element_entry_warning   
           );
END;
/


-- Go to API List
hr_application_api.update_apl_details

set serveroutput on;

declare

l_true                    boolean     := false;
l_application_id          number      := 2592;
l_obj                      NUMBER;
l_person_id            number        :=7814;
l_attrib4            varchar2(30)    :='Applicant';


cursor csr_ovn is
       select max(object_version_number)
       from per_people_f where person_id=l_person_id;

begin

open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;


hr_application_api.update_apl_details
(
        p_validate              =>    l_true
,       p_application_id              =>    l_application_id
,       p_object_version_number        =>    l_obj
,    p_appl_attribute4        =>    l_attrib4
);
end;
/


-- Go to API List
hr_assignment_api.update_emp_asg_criteria

set serveroutput on;

declare
l_date                date   := to_date('01-OCT-2009', 'DD-MON-YYYY');
l_true                    boolean  := false;
l_assign_id              number  := 32923;
l_obj                      NUMBER;
l_datetrack_update_mode      VARCHAR2(30);
l_organization_id         number;
l_special_ceiling_step_id     number;
l_EFFECTIVE_START_DATE        DATE;
l_EFFECTIVE_END_DATE          DATE;
l_people_group_id             number;
l_group_name              varchar2(30);
l_org_now_no_manager_warning    BOOLEAN;
l_other_manager_warning        boolean;
l_spp_delete_warning        boolean;
l_entries_changed_warning    varchar2(30);
l_tax_district_changed_warning    boolean;


cursor csr_ovn is
       select max(object_version_number)
       from per_assignments_f where assignment_id=32923;

begin

open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;

hr_assignment_api.update_emp_asg_criteria
(
  P_VALIDATE                     => l_true
 ,P_EFFECTIVE_DATE               => l_date
 ,P_DATETRACK_UPDATE_MODE        => 'CORRECTION'
 ,P_ASSIGNMENT_ID                => l_assign_id
 ,P_OBJECT_VERSION_NUMBER        => l_obj
-- ,p_organization_id           => 626
 ,p_special_ceiling_step_id       => l_special_ceiling_step_id
 ,P_effective_start_date       => l_effective_start_date
 ,p_effective_end_date           => l_effective_end_date
 ,p_people_group_id              => l_people_group_id 
 ,p_group_name                   => l_group_name
 ,p_org_now_no_manager_warning   => l_org_now_no_manager_warning
 ,p_other_manager_warning        => l_other_manager_warning
 ,p_spp_delete_warning           => l_spp_delete_warning
 ,p_entries_changed_warning      => l_entries_changed_warning
 ,p_tax_district_changed_warning => l_tax_district_changed_warning
, p_segment11             => 'Abbott, Mr. John'
);
end;
/


-- Go to API List
hr_person_api.update_gb_person

set serveroutput on;

declare
l_date                date           := to_date('01-SEP-2002', 'DD-MON-YYYY');
l_true                    boolean     := false;
l_person_id              number      := 367
l_employee_number        varchar2(30)    := '4';
l_obj                      NUMBER;
l_attribute1        VARCHAR2(30)     := 'Yes';
l_comment_id            number;
l_datetrack_update_mode      VARCHAR2(30);
l_EFFECTIVE_START_DATE        DATE        := to_date('01-DEC-2002', 'DD-MON-YYYY');
l_EFFECTIVE_END_DATE          DATE;
l_name_combination_warning    BOOLEAN;
l_assign_payroll_warning    boolean;
l_full_name            VARCHAR2(30)    := '-Anthony--Ambrose';
l_orig_hire_warning        BOOLEAN; 

cursor csr_ovn is
       select max(object_version_number)
       from per_people_f where person_id=l_person_id;

begin

open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;


hr_person_api.update_gb_person
(
        p_validate              =>    l_true
,       p_effective_date              =>    l_date
,       p_datetrack_update_mode        =>    'CORRECTION'
,       p_person_id                  =>    l_person_id
,       p_object_version_number        =>    l_obj
,       p_employee_number        =>    l_employee_number
,       p_attribute1            =>    l_attribute1
,    p_effective_start_date        =>    l_effective_start_date
,       p_effective_end_date        =>    l_effective_end_date
,       p_full_name            =>    l_full_name
,       p_comment_id            =>    l_comment_id
,       p_name_combination_warning    =>    l_name_combination_warning
,       p_assign_payroll_warning    =>    l_assign_payroll_warning
,    p_orig_hire_warning        => l_orig_hire_warning
);
end;
/

-- Go to API List
hr_sit_api.update_sit

set serveroutput on;

declare

l_date                date           := to_date('01-DEC-2000', 'DD-MON-YYYY');
l_true                    boolean     := false;
l_person_id              number      := 2831;
l_obj                      NUMBER;
l_business_group_id        number        := 1379;
l_id_flex_num            number        := 51058;
l_analysis_criteria_id        number        := 2029;
l_person_analysis_id        number        := 1735;



cursor csr_ovn is
       select max(object_version_number)
       from per_people_f where person_id=l_person_id;

begin

open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;


hr_sit_api.update_sit
(
        p_validate              =>    l_true
,       p_effective_date              =>    l_date
,       p_person_id                  =>    l_person_id
,       p_pea_object_version_number        =>    l_obj
,    p_business_group_id        =>    l_business_group_id
,    p_id_flex_num            =>    l_id_flex_num
,    p_analysis_criteria_id        =>    l_analysis_criteria_id
,    p_person_analysis_id        =>    l_person_analysis_id
,    p_segment1            =>    '30'
,    p_segment2            =>    '40'
,    p_segment3            =>    '10'
,    p_segment4            =>    '21-JUL-2001'        

);

end;
/


-- Go to API List
hr_upload_proposal_api.upload_salary_proposal

set serveroutput on;

declare

L_VALIDATE                     BOOLEAN  := FALSE;
L_BUSINESS_GROUP_ID            NUMBER := 626;     
L_PROPOSAL_REASON              VARCHAR2(20) := 'COL';  
L_PAY_PROPOSAL_ID              NUMBER := null;
L_OBJECT_VERSION_NUMBER        NUMBER := null;
L_COMPONENT_REASON             VARCHAR2(10) := null;
L_APPROVED_1                   VARCHAR2(10) := null;
L_COMPONENT_ID_1               NUMBER      := null;
L_PPC_OBJECT_VERSION_NUMBER_1  NUMBER       := null;
L_APPROVED_2                   VARCHAR2(10) := null;
L_COMPONENT_ID_2               NUMBER     := null;
L_PPC_OBJECT_VERSION_NUMBER_2  NUMBER      := null;
L_APPROVED_3                   VARCHAR2(10) := null;
L_COMPONENT_ID_3               NUMBER     := null;
L_PPC_OBJECT_VERSION_NUMBER_3  NUMBER     := null;
L_APPROVED_4                   VARCHAR2(10) := null;
L_COMPONENT_ID_4               NUMBER    := null;
L_PPC_OBJECT_VERSION_NUMBER_4  NUMBER   := null;
L_APPROVED_5                   VARCHAR2(10) := null;
L_COMPONENT_ID_5               NUMBER      := null;
L_PPC_OBJECT_VERSION_NUMBER_5  NUMBER      := null;
L_APPROVED_6                   VARCHAR2(10) := null;
L_COMPONENT_ID_6               NUMBER       := null;
L_PPC_OBJECT_VERSION_NUMBER_6  NUMBER       := null;
L_APPROVED_7                   VARCHAR2(10) := null;
L_COMPONENT_ID_7               NUMBER        := null;
L_PPC_OBJECT_VERSION_NUMBER_7  NUMBER        := null;
L_APPROVED_8                   VARCHAR2(10) := null;
L_COMPONENT_ID_8               NUMBER        := null;
L_PPC_OBJECT_VERSION_NUMBER_8  NUMBER         := null;
L_APPROVED_9                   VARCHAR2(10) := null;
L_COMPONENT_ID_9               NUMBER        := null;
L_PPC_OBJECT_VERSION_NUMBER_9  NUMBER         := null;
L_APPROVED_10                   VARCHAR2(10) := null;
L_COMPONENT_ID_10              NUMBER       := null;
L_PPC_OBJECT_VERSION_NUMBER_10 NUMBER        := null;
L_PYP_PROPOSED_SAL_WARNING     BOOLEAN       := FALSE;
l_ADDITIONAL_COMP_WARNING      BOOLEAN        := FALSE;

L_PERSON                       NUMBER       := 517;
L_ASSIGNMENT                   NUMBER       := 524;
L_START_DATE                   DATE         := NULL;
L_END_DATE                     DATE         := NULL;

L_MSG                          VARCHAR2(200) := NULL;
L_STATUS                       VARCHAR2(10) := 'VALID';
L_COUNTER                      NUMBER       := 0;

l_date             date    := to_date('01-Aug-2013', 'DD-MON-YYYY');
l_proposed_salary     VARCHAR2(30)    := '21000.00';

l_err_num                  NUMBER;
l_err_msg                  VARCHAR2(100);

begin
 hr_upload_proposal_api.upload_salary_proposal
 ( p_validate                    => FALSE
 , p_change_date                 => l_date
 , p_business_group_id           => l_business_group_id
 , p_assignment_id               => l_assignment
 , p_proposed_salary             => l_proposed_salary
 , p_proposal_reason             => l_proposal_reason
 , p_pay_proposal_id             => l_pay_proposal_id
 , p_object_version_number       => l_object_version_number
 , p_component_reason_1      => l_component_reason
 , p_approved_1           => l_approved_1
 , p_component_id_1          => l_component_id_1
 , p_ppc_object_version_number_1 => l_ppc_object_version_number_1
 , p_component_reason_2      => l_component_reason
 , p_approved_2           => l_approved_2
 , p_component_id_2          => l_component_id_2
 , p_ppc_object_version_number_2 => l_ppc_object_version_number_2
 , p_component_reason_3      => l_component_reason
 , p_approved_3           => l_approved_3
 , p_component_id_3          => l_component_id_3
 , p_ppc_object_version_number_3 => l_ppc_object_version_number_3
 , p_component_reason_4      => l_component_reason
 , p_approved_4           => l_approved_4
 , p_component_id_4          => l_component_id_4
 , p_ppc_object_version_number_4 => l_ppc_object_version_number_4
 , p_component_reason_5      => l_component_reason
 , p_approved_5           => l_approved_5
 , p_component_id_5          => l_component_id_5
 , p_ppc_object_version_number_5 => l_ppc_object_version_number_5
 , p_component_reason_6      => l_component_reason
 , p_approved_6           => l_approved_6
 , p_component_id_6          => l_component_id_6
 , p_ppc_object_version_number_6 => l_ppc_object_version_number_6
 , p_component_reason_7      => l_component_reason
 , p_approved_7           => l_approved_7
 , p_component_id_7          => l_component_id_7
 , p_ppc_object_version_number_7 => l_ppc_object_version_number_7
 , p_component_reason_8      => l_component_reason
 , p_approved_8           => l_approved_8
 , p_component_id_8          => l_component_id_8
 , p_ppc_object_version_number_8 => l_ppc_object_version_number_8
 , p_component_reason_9      => l_component_reason
 , p_approved_9           => l_approved_9
 , p_component_id_9          => l_component_id_9
 , p_ppc_object_version_number_9 => l_ppc_object_version_number_9
 , p_component_reason_10      => l_component_reason
 , p_approved_10           => l_approved_10
 , p_component_id_10          => l_component_id_10
 , p_ppc_object_version_number_10 => l_ppc_object_version_number_10
 , p_pyp_proposed_sal_warning      =>  l_pyp_proposed_sal_warning
 , p_additional_comp_warning       =>  l_additional_comp_warning
);
end;
/


-- Go to API List
hr_assignment_api.create_gb_secondary_emp_asg

DECLARE
   vv_group_name                   VARCHAR2(150);
   vn_people_group_id              NUMBER;
   vn_assignment_sequence          NUMBER;
   vn_comment_id                   NUMBER;
   vb_other_manager_warning        BOOLEAN;
   vb_hourly_salaried_warning      BOOLEAN;
   vn_cagr_grade_def_id            NUMBER;
   vv_cagr_concatenated_segments   VARCHAR2(150);
   vt_assignment_number            VARCHAR2(50);
   vt_assignment_id                NUMBER;
   vt_ass_object_version_number    NUMBER;
   vt_ass_eff_from_date            DATE;
   vt_ass_eff_to_date              DATE;
BEGIN
   vt_assignment_number := NULL;
   hr_assignment_api.create_gb_secondary_emp_asg(p_validate                    => FALSE,
                                                 p_effective_date              => TRUNC(SYSDATE),
                                                 p_person_id                   => 33255,
                                                 p_organization_id             => 8464,
                                                 --OPTIONAL
                                                 p_job_id                      => 52906,
                                                 p_location_id                 => 519,
                                                 --IN/OUT
                                                 p_assignment_number           => vt_assignment_number,
                                                 --OUT
                                                 p_group_name                  => vv_group_name,
                                                 p_assignment_id               => vt_assignment_id,
                                                 p_people_group_id             => vn_people_group_id,
                                                 p_object_version_number       => vt_ass_object_version_number,
                                                 p_effective_start_date        => vt_ass_eff_from_date,
                                                 p_effective_end_date          => vt_ass_eff_to_date,
                                                 p_assignment_sequence         => vn_assignment_sequence,
                                                 p_comment_id                  => vn_comment_id,
                                                 p_other_manager_warning       => vb_other_manager_warning,
                                                 p_hourly_salaried_warning     => vb_hourly_salaried_warning,
                                                 p_cagr_grade_def_id           => vn_cagr_grade_def_id,
                                                 p_cagr_concatenated_segments  => vv_cagr_concatenated_segments
                                                );
   DBMS_OUTPUT.put_line('ID: ' || vt_assignment_id || ', number: ' || vt_assignment_number);
END;
/


-- Go to API List
hr_assignment_api.set_new_primary_asg

DECLARE


    l_object_version_number      per_all_assignments_f.object_version_number%type;
    l_primary_assignment_id      per_all_assignments_f.assignment_id%type;
    l_primary_ovn                per_all_assignments_f.object_version_number%type;
    x_end_date                   DATE;
    x_start_date                 DATE;
    x_ovn                        per_all_assignments_f.object_version_number%type;



BEGIN
hr_assignment_api.set_new_primary_asg(p_validate => FALSE,
                                                      p_effective_date        => '02-JUN-2010',
                                                      p_person_id             => 60130,
                                                      p_assignment_id         => 59381,
                                                      p_object_version_number => x_ovn,
                                                      p_effective_start_date  => x_start_date,
                                                      p_effective_end_date    => x_end_date);
end;
/


-- Go to API List
hr_assignment_api.actual_termination_emp_asg

DECLARE

    l_object_version_number      per_all_assignments_f.object_version_number%type;
    l_primary_assignment_id      per_all_assignments_f.assignment_id%type;
    l_primary_ovn                per_all_assignments_f.object_version_number%type;
    x_end_date                   DATE;
    x_start_date                 DATE;
    x_ovn                        per_all_assignments_f.object_version_number%type;
    x_asg_future_changes_warning BOOLEAN;
    x_entries_changed_warning    VARCHAR2(100);
    x_pay_proposal_warning       BOOLEAN;


BEGIN
select max(object_version_number)
into l_primary_ovn
from per_all_assignments_f
where assignment_id=59380;
hr_assignment_api.actual_termination_emp_asg
                      (p_validate => FALSE,
                       p_assignment_id              => 59380,
                       p_object_version_number      => l_primary_ovn,
                       p_actual_termination_date    => '03-JUN-2010',
                       p_effective_start_date       => x_start_date,
                       p_effective_end_date         => x_end_date,
                       p_asg_future_changes_warning => x_asg_future_changes_warning,
                       p_entries_changed_warning    => x_entries_changed_warning,
                       p_pay_proposal_warning       => x_pay_proposal_warning);
end;
/


-- Go to API List
hr_employee_api.re_hire_ex_employee

DECLARE

l_object_version_number      per_all_people_f.object_version_number%type;
x_assignment_id              per_all_people_f.assignment_id%type;
x_asg_object_version_number  per_all_people_f.object_version_number%type;
x_effective_start_date       DATE;
x_effective_end_date         DATE;
x_assignment_sequence        per_all_assignments_f.assignment_sequence%type;
x_assignment_number          per_all_assignments_f.assignment_number%type;
x_assign_payroll_warning     BOOLEAN;


BEGIN
select max(object_version_number)
into l_object_version_number
from per_all_people_f
where person_id=72302;

hr_employee_api.re_hire_ex_employee(
              p_validate  => false,
              P_hire_date  => sysdate,
              P_person_id  => 72302,
              p_per_object_version_number => l_object_version_number,
              p_person_type_id => 44,
              p_rehire_reason => null,
              p_assignment_id   => x_assignment_id,
              p_asg_object_version_number  => x_asg_object_version_number,
              p_per_effective_start_date => x_effective_start_date,
              p_per_effective_end_date  => x_effective_end_date,
              p_assignment_sequence => x_assignment_sequence,
              p_assignment_number  => x_assignment_number,
              p_assign_payroll_warning => x_assign_payroll_warning)
end;
/



-- Go to API List
hr_person_api.update_person

set serveroutput on;

DECLARE

l_date date := to_date('01-APR-2010', 'DD-MON-YYYY');
l_true boolean := false;
l_person_id number := 35848;
l_employee_number varchar2(30) := '1178';
l_obj NUMBER :=4;
l_comment_id number;
l_EFFECTIVE_START_DATE DATE;
l_EFFECTIVE_END_DATE DATE;
l_name_combination_warning BOOLEAN;
l_assign_payroll_warning boolean;
l_orig_hire_warning BOOLEAN;
l_full_name VARCHAR2(30);
l_last_name VARCHAR2(30) := 'DIFFERENT';

BEGIN

hr_person_api.update_person
(
  p_validate => l_true
, p_effective_date => l_date
, p_datetrack_update_mode => 'CORRECTION'
, p_person_id => l_person_id
, p_object_version_number => l_obj
,  p_last_name => l_last_name
, p_employee_number => l_employee_number
, p_effective_start_date => l_effective_start_date
, p_effective_end_date => l_effective_end_date
, p_full_name => l_full_name
, p_comment_id => l_comment_id
, p_name_combination_warning => l_name_combination_warning
, p_assign_payroll_warning => l_assign_payroll_warning
, p_orig_hire_warning => l_orig_hire_warning
);
end;
/



-- Go to API List
hr_contact_rel_api.delete_contact_relationship

CONTACT_RELATIONSHIP_ID
OVN

DECLARE
l_true_boolean := FALSE;
l_contact_relationship_id := 147;
l_object_version_number := 7;

BEGIN
hr_contact_rel_api.delete_contact_relationship
(
  l_true_boolean
, l_contact_relationship_id
, l_object_version_number
);
END;
/


-- Go to API List
hr_assignment_api.update_emp_asg

set serveroutput on;
DECLARE
   i_effective_date                 DATE           := to_date('01-DEC-2012', 'DD-MON-YYYY');
   i_datetrack_update_mode          VARCHAR2 (30)  := 'CORRECTION';
   i_assignment_id                  NUMBER         := 34078;
   l_obj                                  NUMBER;
   io_cagr_grade_def_id             NUMBER;
   o_cagr_concatenated_segments     VARCHAR2 (240);
   o_concatenated_segments          VARCHAR2 (240);
   o_comment_id                     NUMBER;
   o_effective_start_date           DATE;
   o_effective_end_date             DATE;
   o_no_managers_warning            BOOLEAN;
   o_other_manager_warning          BOOLEAN;
   o_hourly_salaried_warning        BOOLEAN;
   o_gsp_post_process_warning       VARCHAR2 (240);
   
   l_people_group_id                NUMBER;
   l_object_version_number          NUMBER;
   l_special_ceiling_step_id        NUMBER;
   l_soft_coding_keyflex_id         NUMBER;
   l_group_name                     VARCHAR2 (240);
   l_effective_start_date           DATE;
   l_effective_end_date             DATE;
   l_org_now_no_manager_warning     BOOLEAN;
   l_other_manager_warning          BOOLEAN;
   l_spp_delete_warning             BOOLEAN;
   l_entries_changed_warning        VARCHAR2 (240);
   l_tax_district_changed_warning   BOOLEAN;
   l_concatenated_segments          VARCHAR2 (240);
   l_projected_assignment_end        date;

cursor csr_ovn is
       select max(object_version_number)
       from per_assignments_f where assignment_id=i_assignment_id;
begin
open csr_ovn;
fetch csr_ovn into l_obj;
close csr_ovn;
   
   hr_assignment_api.update_emp_asg
   (
      p_effective_date            => i_effective_date,
      p_datetrack_update_mode        => i_datetrack_update_mode,
      p_assignment_id            => i_assignment_id,
      p_object_version_number        => l_obj,
      p_cagr_grade_def_id        => io_cagr_grade_def_id,
      p_cagr_concatenated_segments    => o_cagr_concatenated_segments,
      p_concatenated_segments        => o_concatenated_segments,
      p_soft_coding_keyflex_id        => l_soft_coding_keyflex_id,
      p_comment_id            => o_comment_id,
      p_effective_start_date        => o_effective_start_date,
      p_effective_end_date        => o_effective_end_date,
      p_no_managers_warning        => o_no_managers_warning,
      p_other_manager_warning        => o_other_manager_warning,
      p_hourly_salaried_warning        => o_hourly_salaried_warning,
      p_gsp_post_process_warning    => o_gsp_post_process_warning
      ,p_assignment_number                => 'YY123'
);
end;
/

-- Go to API List
hr_grade_rate_value_api.update_grade_rate_value

declare
l_rule_id        number := 218;
l_ovn            number;
l_start_date     date;
l_end_date       date;
l_eff_date       date := trunc(sysdate + 2);
begin
select object_version_number into l_ovn 
       from pay_grade_rules_f where grade_rule_id = l_rule_id
       and l_eff_date between effective_start_date and effective_end_date;
hr_grade_rate_value_api.update_grade_rate_value
  (p_effective_date                => trunc(sysdate + 2)
  ,p_datetrack_update_mode         => 'CORRECTION'
  ,p_grade_rule_id                 => l_rule_id
  ,p_object_version_number         => l_ovn
  ,p_minimum                       => 8000
  ,p_effective_start_date          => l_start_date
  ,p_effective_end_date            => l_end_date);
end;
/

-- Go to API List

hr_contingent_worker.convert_to_cwk

DECLARE
    -- Start of Variable declarations, Initialize Variables with appropriate values to test the script
    -- VARCHAR2 size is set to 2000 by default, please enter target table name to retrieve the exact limit
    -- Input Variables
    V_VALIDATE                      BOOLEAN;
    V_EFFECTIVE_DATE                DATE := to_date('01-JAN-2014','DD-MON-YYYY');
    V_PERSON_ID                     NUMBER :=14350;
    -- In Out Variables
    V_OBJECT_VERSION_NUMBER         NUMBER;
    V_NPW_NUMBER                    VARCHAR2(2000);
    -- Input Variables
    V_PROJECTED_PLACEMENT_END       DATE;
    V_PERSON_TYPE_ID                NUMBER;
    V_DATETRACK_UPDATE_MODE         VARCHAR2(2000);
    -- Output Variables
    V_PER_EFFECTIVE_START_DATE      DATE;
    V_PER_EFFECTIVE_END_DATE        DATE;
    V_PDP_OBJECT_VERSION_NUMBER     NUMBER;
    V_ASSIGNMENT_ID                 NUMBER;
    V_ASG_OBJECT_VERSION_NUMBER     NUMBER;
    V_ASSIGNMENT_SEQUENCE           NUMBER;
cursor csr_ovn is
      select max(object_version_number)
      from per_all_people_f where person_id=v_person_id;
begin
open csr_ovn;
fetch csr_ovn into V_OBJECT_VERSION_NUMBER;
close csr_ovn;
    --  Calling API HR_CONTINGENT_WORKER_API.CONVERT_TO_CWK
    HR_CONTINGENT_WORKER_API.CONVERT_TO_CWK(P_VALIDATE                     => FALSE
                                           ,P_EFFECTIVE_DATE               => V_EFFECTIVE_DATE
                                           ,P_PERSON_ID                    => V_PERSON_ID
                                           ,P_OBJECT_VERSION_NUMBER        => V_OBJECT_VERSION_NUMBER
                                           ,P_NPW_NUMBER                   => V_NPW_NUMBER
                                           ,P_PROJECTED_PLACEMENT_END      => V_PROJECTED_PLACEMENT_END
                                           ,P_PERSON_TYPE_ID               => V_PERSON_TYPE_ID
                                           ,P_DATETRACK_UPDATE_MODE        => V_DATETRACK_UPDATE_MODE
                                           ,P_PER_EFFECTIVE_START_DATE     => V_PER_EFFECTIVE_START_DATE
                                           ,P_PER_EFFECTIVE_END_DATE       => V_PER_EFFECTIVE_END_DATE
                                           ,P_PDP_OBJECT_VERSION_NUMBER    => V_PDP_OBJECT_VERSION_NUMBER
                                           ,P_ASSIGNMENT_ID                => V_ASSIGNMENT_ID
                                           ,P_ASG_OBJECT_VERSION_NUMBER    => V_ASG_OBJECT_VERSION_NUMBER
                                           ,P_ASSIGNMENT_SEQUENCE          => V_ASSIGNMENT_SEQUENCE
                                           );
END;
/

-- Go to API List


hr_applicant_api.hire_applicant

set serveroutput on;

declare
L_PERSON_ID   number := 71303;
l_assignment_id number := 74691;
l_object_version_number number := 2;
L_EMPLOYEE_NUMBER varchar2(100);
l_person_type_id number := 95;
l_CONCATENATED_SEGMENTS   VARCHAR2 (1000);
l_CAGR_GRADE_DEF_ID             NUMBER;
l_CAGR_CONCATENATED_SEGMENTS   VARCHAR2 (1000);
l_GROUP_NAME                   VARCHAR2 (1000);
l_COMMENT_ID                   NUMBER;
l_PEOPLE_GROUP_ID               NUMBER;
l_SOFT_CODING_KEYFLEX_ID       NUMBER ;
l_EFFECTIVE_START_DATE         DATE;
l_EFFECTIVE_END_DATE           DATE;
l_ASSIGN_PAYROLL_WARNING boolean;
l_UNACCEPTED_ASG_DEL_WARNING boolean;
l_ORIG_HIRE_WARNING   boolean;

begin

hr_applicant_api.hire_applicant
(P_VALIDATE                     => FALSE,
P_hire_DATE               => trunc(SYSDATE),
P_PERSON_ID => l_person_id,
P_ASSIGNMENT_ID => l_assignment_id,
P_PERSON_TYPE_ID => l_person_type_id,
P_PER_OBJECT_VERSION_NUMBER    => l_object_version_number,
P_EMPLOYEE_NUMBER => l_employee_number,
P_per_EFFECTIVE_START_DATE     => l_effective_start_date,
P_per_EFFECTIVE_END_DATE       => l_effective_end_date,
P_UNACCEPTED_ASG_DEL_WARNING   => l_UNACCEPTED_ASG_DEL_WARNING,
P_ASSIGN_PAYROLL_WARNING       => l_ASSIGN_PAYROLL_WARNING);

end;
/

-- Go to API List
hr_person_api.delete_person

DECLARE
 -- Input Variables
 l_validate BOOLEAN    := FALSE;
 l_effective_date DATE := SYSDATE; -- eneter deletion date - in this case sysdate is used
 l_person_id                 NUMBER    := xxxx; -- enter person_id
 l_perform_predel_validation BOOLEAN   := FALSE;
 -- Output Variables
 l_person_org_manager_warning VARCHAR2(2000);
BEGIN
 --  Calling API HR_PERSON_API.DELETE_PERSON
 hr_person_api.delete_person(p_validate                   => l_validate ,
                             p_effective_date             => l_effective_date ,
                             p_person_id                  => l_person_id ,
                             p_perform_predel_validation  => l_perform_predel_validation ,
                             p_person_org_manager_warning => l_person_org_manager_warning );
 --
 dbms_output.put_line('Person deleted successfully');
 --
EXCEPTION
WHEN OTHERS THEN
 dbms_output.put_line('Error : ' || sqlerrm);
END;
/


-- Go to API List

per_vacancy_api.create_vacancy


DECLARE

l_object_version_number NUMBER;
l_vacancy_id            NUMBER;
l_inv_pos_grade_warning BOOLEAN;
l_inv_job_grade_warning BOOLEAN; 

BEGIN  
   per_vacancy_api.create_vacancy 
   (
      p_validate                => FALSE,
      p_effective_date          => SYSDATE,
      p_requisition_id          => 121231,
      p_date_from               => SYSDATE,
      p_name                    => 'IRCDUMMY',
      p_business_group_id       => 626,
      p_description             => 'Creating Dummy IRC Vac',
      p_position_id             => 1251,
      p_job_id                  => 204,
      p_organization_id         => 1218,
      p_number_of_openings      => 100,
      p_object_version_number   => l_object_version_number,
      p_vacancy_id              => l_vacancy_id,
      p_inv_pos_grade_warning   => l_inv_pos_grade_warning,
      p_inv_job_grade_warning   => l_inv_job_grade_warning
   );
END;


courtasy : https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=449773402267929&parent=SrDetailText&sourceId=3-14922919681&id=1505063.1&_afrWindowMode=0&_adf.ctrl-state=5xyauyvd7_70#hr_contingent_worker.convert_to_cwk