white paper oracle otl hxc timestore deposit

46
WHITE PAPER Oracle OTL HXC TimeStore Deposit API Control Number: TSDepApi 1.0 Version: 1.12

Upload: saurabh-sonkusare

Post on 15-Jun-2015

3.637 views

Category:

Documents


98 download

DESCRIPTION

API related to Oracle OTL. This document is also available on metalink doc id: 223987.1

TRANSCRIPT

Page 1: White Paper Oracle Otl Hxc Timestore Deposit

WHITE PAPER Oracle OTL HXC TimeStore Deposit API Control Number: TSDepApi 1.0 Version: 1.12

Page 2: White Paper Oracle Otl Hxc Timestore Deposit

Oracle OTL Timestore Deposit API, Release 11i Copyright 2000, 2001 Oracle Corporation All rights reserved. Primary Author: Mark Vilrokx Contributors: Andrew Rundell, Andrew Ioannou This software was not developed for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It is the customer's responsibility to take all appropriate measures to ensure the safe use of such applications if the programs are used for such purposes. This software/documentation contains proprietary information of Oracle Corporation; it is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright law. Reverse engineering of the software is prohibited. If this software/documentation is delivered to a U.S. Government Agency of the Department of Defense, then it is delivered with Restricted Rights and the following legend is applicable: Restricted Rights Legend Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software (October 1988). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065. If this software/documentation is delivered to a U.S. Government Agency not within the Department of Defense, then it is delivered with “Restricted Rights", as defined in FAR 52.227-14, Rights in Data - General, including Alternate III (June 1987). The information in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is error free. No part of this document may be reproduced or transmitted in any form or by any means electronic or mechanical, for any purpose without the express written permission of Oracle Corporation. Oracle is a registered trademark and ConText, Enabling the Information Age, Oracle7, Oracle8, Oracle8i, Oracle Access, Oracle Application Object Library, Oracle Financials, Oracle Discoverer, Oracle Web Customers, Oracle Web Employees, Oracle Workflow, Oracle Work in Process, PL/SQL, Pro*C, SmartClient, SQL*, SQL*Forms, SQL*Loader, SQL*Menu, SQL*Net, SQL*Plus, and SQL*Report are trademarks or registered trademarks of Oracle Corporation. All other products or company names are used for identification purposes only, and may be trademarks of their respective owners.

Page 2

Page 3: White Paper Oracle Otl Hxc Timestore Deposit

Terms and Definitions

Abbreviations used in this document.

TBB: Time Building Block

SS: Self service

OVN: Object Version Number

Page 3

Page 4: White Paper Oracle Otl Hxc Timestore Deposit

Contents

Terms and Definitions 3 Introduction 5

Who Should Read This Document? .............................................................................................. 5 Structure of the Document............................................................................................................. 5 What the API Can Do .................................................................................................................... 5

Quick Start 6 Creating Time in the TimeStore the Easy Way................................................................................. 6

The API procedures 10 CREATE_TIMECARD_BB.............................................................................................................. 10 CREATE_DAY_BB.......................................................................................................................... 10 CREATE_DETAIL_BB .................................................................................................................... 10 CREATE_ATTRIBUTE.................................................................................................................... 11 UPDATE_BUILDING_BLOCK ........................................................................................................ 11 UPDATE_ATTRIBUTE.................................................................................................................... 11 DELETE_TIMECARD ..................................................................................................................... 12 DELETE_DETAIL_BB..................................................................................................................... 12 EXECUTE_DEPOSIT_PROCESS.................................................................................................. 12 Other procedures ............................................................................................................................ 13

Examples 13 Insert a completely new Timecard .................................................................................................. 13

Create the TIMECARD Time Building Block ............................................................................... 14 Create the DAY Time Building Blocks......................................................................................... 14 Create the DETAIL Time Building Blocks.................................................................................... 17 Create the Attributes.................................................................................................................... 18 Deposit the Timecard .................................................................................................................. 21 Reviewing the messages............................................................................................................. 21

Update an existing Timecard .......................................................................................................... 22 Update the Time Building Blocks ................................................................................................ 22 Deposit the Timecard .................................................................................................................. 24 Reviewing the messages............................................................................................................. 24

Update an existing Attribute ............................................................................................................ 24 Update the Attributes................................................................................................................... 25 Deposit the Timecard .................................................................................................................. 25 Reviewing the messages............................................................................................................. 26

Deleting a DETAIL Time Building Block.......................................................................................... 26 Delete the Time Building Block.................................................................................................... 26 Deposit the Timecard .................................................................................................................. 27 Reviewing the messages............................................................................................................. 28

Deleting a complete timecard.......................................................................................................... 29 Delete the timecard ..................................................................................................................... 29

Appendixes............................................................................................................................................. 30

Page 4

Page 5: White Paper Oracle Otl Hxc Timestore Deposit

Introduction

This whitepaper explains how to use the TimeStore API. You can use this API to store Time information in the TimeStore. The system stores this time data in the TimeStore the same as it would if you used the timecard screen in Self Service OTL, including validation, if applicable. You also can use the API to update or remove existing time data.

Note that throughout this text ‘TIMECARD’ (all uppercase) refers to Time Building Blocks with scope TIMECARD. The abbreviation TC is used for a timecard as such (a collection of multiple Time Building Blocks of different scopes).

Requirements Prior to Using This API Whitepaper

This paper coincides with the version of the API, which was shipped with Oracle Patch 2811404. The versions needed are:

• hxctsdp.pkb – equal to or greater than version 115.5

• hxctsdp.pkh – equal to or greater than version 115.4.

Who Should Read This Document?

A technical person should use this document as a starting point for creating PL/SQL scripts to manipulate timecards.

Structure of the Document

The document is in two major parts. The first part shows how you can use the API to store and manipulate timecards. As the API offers many interfaces to store time, ranging from easy to complex, this document starts with the easy interfaces (and lowest flexibility) and gradually progress to the more complex interfaces (with highest flexibility).

The second part of this document shows more detail as to how the API works and what happens in the database when you deposit a timecard using the API.

What the API Can Do

You can use the API can to insert complete timecards in the TimeStore. You also can add individual Time Building Blocks off any scope (DAY or DETAIL, including their associated attributes (if any) ), to an existing timecard. You also can use the API to update existing Time Building Blocks and their associated attributes. And finally, you can use the API to delete a complete timecard or a specific Time Building Block and its attributes from a timecard.

Page 5

It is important to remember that the API can only manipulate one timecard at a time. If you want to work with multiple timecards, you need to complete all your

Page 6: White Paper Oracle Otl Hxc Timestore Deposit

changes first on the one timecard. You then save this timecard in the database (“deposited”) and only then you can start working on the next timecard.

If you do not follow these steps, then you might loose the changes you made on the first timecard, or you might add data to one timecard that was intended for another timecard. The API provides procedures to help you with this, but you always need to keep this in mind. This will be mentioned throughout this document.

Quick Start

This chapter provides information to allow you to start depositing time straight away, without having any prior knowledge of timecard construction or how it is stored in the database. The procedures used here, are the simplest to use but also provide the least amount of flexibility.

Creating Time in the TimeStore the Easy Way

When depositing time you always have to perform 3 steps:

1. Create the Time

2. Classify the Time

3. Deposit the Time

You can create time simply by using the procedure called CREATE_TIME_ENTRY. If you want to create 8 hours on Monday the 2nd of September 2002 for Projects, you can do this by calling the procedure like this:

hxc_timestore_deposit.create_time_entry ( p_measure=> 8, p_day => FND_DATE.CANONICAL_TO_DATE ('2002/09/02'), p_resource_id=> 9389, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_deposit_process_id=> 'OTL Deposit Process' p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id );

Note: You will need to define l_tbl_timecard_info and l_time_building_block_id like this:

l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; l_time_building_block_id hxc_time_building_blocks.time_building_block_id%TYPE;

Page 6

Page 7: White Paper Oracle Otl Hxc Timestore Deposit

Here is a summary of all the parameters you can use: Name IN/OUT Description Data Type Mand Default p_measure IN The time you

want to store HXC_TIME_BUILDING_BLOCKS.MEASURE%TYPE Yes

p_day IN The day you want to store this time against

HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE Yes

p_resource_id IN person_id (no other resource id’s are accepted at the moment)

HXC_TIME_BUILDING_BLOCKS.RESOURCE_ID%TYPE

Yes

p_resource_type IN At the moment we only support person so leave this to default

HXC_TIME_BUILDING_BLOCKS.RESOURCE_TYPE%TYPE

No PERSON

p_deposit_process IN The deposit process that should be used for depositing the time

HXC_DEPOSIT_PROCESSES.NAME%TYPE No OTL Deposit Process

p_comment_text IN The comment you want to add on the time

HXC_TIME_BUILDING_BLOCKS.COMMENT_TEXT%TYPE

No NULL

p_app_blocks IN OUT This will be used to return the PL/SQL table with your TIMECARD Time Building Block in it

HXC_SELF_SERVICE_TIME_DEPOSIT. TIMECARD_INFO

Yes

p_app_attributes IN OUT This will be used to return the PL/SQL table with your application attribute in it

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

p_time_building_block_id

OUT This will be used to return the TBB id assigned to your (DETAIL) Time Building Block

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

Page 7

Page 8: White Paper Oracle Otl Hxc Timestore Deposit

After defining the time, you must ‘classify’ the time so it is recognized by projects. In this example you define the time as normal time, linked to a specific Task, Project and Expenditure Type. You do this by assigning attributes to the time like this:

-- Projects needs 5 attribute fields so we need to call the procedure 5 times, -- on time for every attribute field -- Attribute1 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id,--returned by create_time_entry p_attribute_name=> 'Task_Id', p_attribute_value=> 221, --ID of a Task on our DB, REPLACE WITH YOUR IDs p_app_attributes=> l_tbl_attributes_info, ); -- Attribute2 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id,--returned by create_time_entry p_attribute_name=> 'Project_Id', p_attribute_value=> 215, --ID of a Project on our DB, REPLACE WITH YOUR IDs p_app_attributes=> l_tbl_attributes_info, ); -- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id,--returned by create_time_entry p_attribute_name=> 'Expenditure_Type', p_attribute_value=> 'Professional', p_app_attributes=> l_tbl_attributes_info, ); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id,--returned by create_time_entry p_attribute_name=> 'Expenditure_Comment', p_attribute_value=> NULL, p_app_attributes=> l_tbl_attributes_info, ); -- Attribute5 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id,--returned by create_time_entry p_attribute_name=> 'SYSTEM_LINKAGE_FUNCTION', p_attribute_value=> 'ST', p_app_attributes=> l_tbl_attributes_info, );

Note: You must define l_time_building_block_id and l_tbl_attributes_info like this:

l_time_building_block_id hxc_time_building_blocks.time_building_block_id%TYPE; l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info;

Page 8

Page 9: White Paper Oracle Otl Hxc Timestore Deposit

Here is a summary of all the parameters you can use: Name IN/OUT Description Data Type Mand Default p_building_block_id IN This is the id of the Time

Building Block to which this attribute belong

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

p_attribute name IN The name of the attribute you want to insert

HXC_MAPPING_COMPONENTS.FIELD_NAME%TYPE

Yes

p_attribute_value IN The value you want to assign to the attribute

HXC_TIME_ATTRIBUTES.ATTRIBUTE1%TYPE

Yes

p_deposit_process IN The deposit process that should be used for depositing the attributes

HXC_DEPOSIT_PROCESSES.NAM%TYPE

No OTL Deposit Process

p_app_attributes IN OUT This will be used to return the PL/SQL table with your application attribute in it

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

Note: If you want to find out which attributes you can load for a certain timecard, determine which mapping is linked to your deposit process. In our example, the mapping for ‘OTL Deposit Process’ is the ‘OTL Deposit Process Mapping’. Query the mapping and you will see all the fields you can load. In our example you see Task_ID, Project_ID… (among others) in the OTL Deposit Process Mapping.

And finally you submit the time to the TimeStore by calling HXC_SELF_SERVICE_TIMECARD_API.EXECUTE_DEPOSIT_PROCESS. This call looks like this:

hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_retrieval_process=> 'Projects Retrieval Process', -- Only used for MIGRATION p_timecard_id=> l_new_timecard_id, p_timecard_ovn=> l_new_timecard_ovn );

Note: You must define l_new_timecard_id and l_new_timecard_ovn like this: l_new_timecard_id NUMBER; -- Will hold TC_ID, returned by the deposit process l_new_timecard_ovn NUMBER; -- Will hold TC ovn, returned by the deposit process

You should be able to find the information in OTL Self Service now. Look for the Timecard that would hold this time data. The complete script can be found in Appendix A.

There is a different version of CREATE_TIME_ENTRY available that you can use to create time with a date range instead of a measure. It is very similar to the procedure above. Here is an example of how you could use it to load time information. This example loads time starting from 9am on Monday the 2nd of September 2002 till 5pm on the same day.

hxc_timestore_deposit.create_time_entry ( p_start_time=> fnd_date.canonical_to_date('2002/09/02 09:00:00'), p_stop_time=> fnd_date.canonical_to_date('2002/09/02 17:00:00'), p_resource_id=> 9389, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id );

Page 9

Page 10: White Paper Oracle Otl Hxc Timestore Deposit

A complete script can be found in Appendix B. You can add time by doing exactly the same steps for a different day, e.g. for Tuesday 3 September, range or measure.

The API procedures

This chapter gives a short explanation of the most commonly used procedures provided by the API and what they can do. If you are not familiar with how a timecard is constructed, use the previous chapter to start loading timecards quickly.

You can “describe” HXC_TIMESTORE_DEPOSIT_API in SQL*Plus to look at the procedures provided.

The procedures described here allow much greater flexibility in constructing a timecard. They give you the power to construct a timecard from top-to-bottom. However, it requires knowledge of the timecard’s hierarchical structure, so this approach is only recommended for experienced users.

CREATE_TIMECARD_BB

Use this procedure to add a Time Building Block of scope TIMECARD to the timecard. This is the top level Time Building Block of your timecard and every timecard needs one and only one. If you are creating a completely new timecard, then this will be the first procedure you need to call to create your TIMECARD Time Building Block.

With this procedure, you decide what the timecard’s span is, i.e. a week, a month… As this is the highest level of Time Building Block of your timecard, you must decide for whom this timecard belongs (a person) and what approval style you want to use. You can also add a comment to the TIMECARD Time Building Block.

CREATE_DAY_BB

Use this procedure to add a Time Building Block of scope DAY to the timecard. A DAY Time Building Block must be linked to a TIMECARD Time Building Block. You should create one and only one DAY Time Building Block for every day in your TIMECARD Time Building Block. That is, if your TIMECARD Time Building Block runs from 01-JUL-2002 till 07-JUL-2002, then you must create 7 DAY Time Building Blocks. If you are creating a completely new timecard, then you will need to call this procedure multiple times, one time for every DAY Time Building Block you are creating (as oppose to the CREATE_TIMECARD_BB which you only need to call once for a timecard).

With this procedure, you can only set for which day the Time Building Block is and a comment for that day.

CREATE_DETAIL_BB

Use this procedure to add a Time Building Block of scope DETAIL to the timecard. A DETAIL Time Building Block needs to be linked to a DAY Time Building Block. However, you can have as many DETAIL Time Building Blocks

Page 10

Page 11: White Paper Oracle Otl Hxc Timestore Deposit

linked to any DAY Time Building Block as you want. This is because a DETAIL Time Building Block represents a part of a DAY and you can divide a day in as many parts as you want. If you are creating a completely new timecard, then you need to call this procedure multiple times, one time for every DETAIL Time Building Block you are creating.

With this procedure, you can create Time Building Blocks that represent part of a day. You can do this in one of two ways:

• You can provide the exact length of the part, e.g. 8 hours.

• You can provide the start and stop time of the part, e.g. from 01-JUL-2002 09:00 till 01-JUL-2002 17:00 (which is also 8 hours).

Later you will see that you can add ‘attributes’ to this kind of Time Building Block that will categorize the time as overtime or holiday, for example. You can also add a comment to the DAY Time Building Block.

Note: Do not confuse this procedure with the one discussed earlier with the same name. This procedure is a lower level procedure and requires different parameters than the ones discussed earlier. In fact, the higher-level procedures call this procedure.

CREATE_ATTRIBUTE

Use this procedure to add an attribute to a Time Building Block. An attribute must be linked to a Time Building Block, and every Time Building Block can have multiple attributes linked to it. However not every Time Building Block needs an attribute. For example, a DAY Time Building Block usually has no attribute attached to it. If you are creating a completely new timecard, then you will need to call this procedure multiple times. Usually every DETAIL Time Building Block has one attribute, in that case you will have to call this procedure at least as many times as you call CREATE_DETAIL_BB.

The attribute holds information about the time to which it is linked (whereas the Time Building Block only holds time as such). So the combination of a Time Building Block and its attribute tell you the time and what the time was for, e.g. 8 hours (held in a DETAIL Time Building Block) of standard time (held in the attribute). Attributes are fed to the procedure in so-called name-value pairs. You pass the name of the attribute (e.g. ‘Project_Id’) and its value (e.g. ‘212’).

UPDATE_BUILDING_BLOCK

Use this procedure to make a change to a Time Building Block. You can use this procedure to update Time Building Blocks with a scope of TIMECARD, DETAIL and DAY.

With this procedure, you can change any Time Building Block. You provide the (existing) Time Building Block ID and the new values you want to store.

UPDATE_ATTRIBUTE

Use this procedure to make a change to an attribute. You can use this procedure to update attributes linked to TIMECARD, DETAIL and DAY Time Building Blocks.

Page 11

Page 12: White Paper Oracle Otl Hxc Timestore Deposit

With this procedure, you can change any attribute. You provide the (existing) attribute name and the new value you want to store.

DELETE_TIMECARD

Use this procedure to delete an existing timecard. It deletes the complete timecard, including all the Time Building Blocks that belong to this timecard (DAY and DETAIL Time Building Blocks). You must provide the Time Building Block id of a TIMECARD Time Building Block or else the procedure returns an error and no delete will happen.

Note: The timecards are not actually deleted (purged) from the TimeStore they merely are end-dated (soft-delete).

DELETE_DETAIL_BB

Use this procedure to delete a single DETAIL Time Building Block. You must provide the Time Building Block id of a DETAIL Time Building Block, or else the procedure will return an error and no delete will happen. If you need to delete several DETAIL Time Building Blocks on one timecard, then you can call this procedure for every delete.

With this procedure, you can delete the details of a day, for example, delete the time you recorded for Wednesday.

Note: There is no delete procedure for DAY Time Building Blocks. Days do not disappear in real life, so they cannot be deleted.

Also note that this deletes all the attributes associated with the Time Building Blocks. Because the time data does not exist anymore, the attributes that define the time have no meaning and therefore will be deleted automatically. This means that there is no need for a procedure to delete attributes. Because attributes cannot exist without a Time Building Block, and once you link an attribute to a Time Building Block, it does not make any sense to delete it from the Time Building Block, as the time has no meaning anymore. You can update it to ‘re-classify’ the time, but not delete it.

Note: The Time Building Blocks are not actually deleted (purged) from the TimeStore they merely are end-dated (soft-delete).

EXECUTE_DEPOSIT_PROCESS

Use this procedure to save your new timecard, your updates or deletes to the database.

You must call this procedure after you finished work on your (one) timecard to commit your timecard to the database. If you do not call this procedure, then you will loose all your work on that timecard.

If you want to create or work on multiple timecards, then you must call this procedure after you finished work on one timecard but before you start working on the next timecard, that is, in between. It saves the timecard to the database and prepares for the next timecard. This procedure should be the last call in your script or in your loop to manipulate multiple timecards.

Be aware that this procedure does NOT perform a commit. You need to explicitly add a commit to your script in order to save the data in the database.

Page 12

Page 13: White Paper Oracle Otl Hxc Timestore Deposit

Other procedures

The API provides some more procedures that you can use, but to start building a timecard, this is all you need. If you want to know more about the other procedures please refer to later chapters that explain the API in more detail. Also refer to the package header file (.pkh) for more information on all the parameters that can be used with every procedure.

Examples

This chapter explains how to use some of the above-mentioned procedures in a working example. Use these examples as a starting point for your own scripts, or just to help you understand how the API works.

NOTE: These are just examples, and although they work on our database, they will not work on your databases as some of the Ids will differ. However the logic should apply to all installations.

Not all procedures mentioned above are explained using an example but these examples should cover most usages. Given this, you should find it easy to understand how to use the procedures not used in these examples.

NOTE: Before you start with the examples, there is one more detail you need to know: All the procedures described before, use PL/SQL tables to hold the Time Building Blocks and attributes. Although their use in the API is completely transparent to the user (and therefore you should not worry about them), you must declare the PL/SQL tables so the procedures and your script can use them. Copy and past the following declarations in your scripts DECLARE section, together with other variables you declare:

-- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info HXC_SELF_SERVICE_TIME_DEPOSIT.TIMECARD_INFO; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info HXC_SELF_SERVICE_TIME_DEPOSIT.APP_ATTRIBUTES_INFO; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages HXC_SELF_SERVICE_TIME_DEPOSIT.MESSAGE_TABLE;

You can change the name of the PL/SQL table variables, but these names will be used throughout the examples.

Insert a completely new Timecard

For this example, you will create a Weekly timecard. It covers Monday 01-JUL-2002 till Sunday 07-JUL-2002, the first workweek in July. You will use the project layout and the person works a normal 40-hour week from 9 till 5, 8 hours a day, from Monday to Friday, with 3 hours overtime, 1 on Tuesday and 2 on Wednesday. The end result should look like this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun, Jul 1 Jul 2 Jul 3 Jul 4 Jul 5 Jul 6 Jul 7 Project Task Expenditure Type ------------ ------ ---------------- Test Project Task 1 Professional 8 8 8 8 8 Test Project Task 1 Overtime 1 2

Page 13

Page 14: White Paper Oracle Otl Hxc Timestore Deposit

Create the TIMECARD Time Building Block

First you must create a Time Building Block with a scope of TIMECARD. This is the top-level Time Building Block of the timecard and details the timecard time period for our timecard. Use CREATE_TIMECARD_BB to create the TIMECARD Time Building Block. It takes the following parameters:

Name IN/OUT Description Data Type Mand Default p_start_time IN The day your

timecard starts (inclusive)

HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE

Yes

p_stop_time IN The day your timecard ends (inclusive)

HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE Yes

p_resource_id IN person_id (no other resource id’s are accepted at the moment)

HXC_TIME_BUILDING_BLOCKS.RESOURCE_ID%TYPE

Yes

p_resource_type IN At the moment we only support person so leave this to default

HXC_TIME_BUILDING_BLOCKS.RESOURCE_TYPE%TYPE

No PERSON

p_approval_style IN The approval style for the timecard

HXC_TIME_BUILDING_BLOCKS.APPROVAL_STYLE_ID%TYPE

Yes NULL

p_comment_text IN The comment you want to add on the timecard

HXC_TIME_BUILDING_BLOCKS.COMMENT_TEXT%TYPE

No NULL

p_app_blocks IN OUT This will be used to return the PL/SQL table with your TIMECARD Time Building Block in it

HXC_SELF_SERVICE_TIME_DEPOSIT. TIMECARD_INFO

Yes

p_time_building_block_id

OUT This will be used to return the TBB id assigned to your TIMECARD Time Building Block

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

For our example you get: hxc_timestore_deposit.create_timecard_bb ( p_start_time => fnd_date.canonical_to_date ('2002/07/01 00:00:00'), p_stop_time => fnd_date.canonical_to_date ('2002/07/07 23:59:59'), p_resource_id => 9389, -- Test person on my DB, CHANGE for your DB p_comment_text => 'Created using API: Weekly Project TC', p_app_blocks => l_tbl_timecard_info, p_time_building_block_id => l_tc_bb_id );

If you do not provide the approval style (recommended), then the approval style will automatically be read from the person’s (resource_id) preferences.

Create the DAY Time Building Blocks

Next you must create a Time Building Block with a scope of DAY for every day in our timecard (7). As mentioned before, these DAY Time Building Blocks must be linked to a TIMECARD Time Building Block, and that is the one you just created. Use CREATE_DAY_BB to create the DAY Time Building Block.

Page 14

Page 15: White Paper Oracle Otl Hxc Timestore Deposit

It takes the following parameters:

Name IN/OUT Description Data Type Mand Default p_day IN The day this DAY

Time Building Block is intended for

HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE Yes

p_parent_building_block_id

IN The building block id of a TIMECARD Time Building Block

HXC_TIME_BUILDING_BLOCKS.PARENT_BUILDING_BLOCK_ID%TYPE

Yes NULL

p_comment_text IN The comment you want to add on the day

HXC_TIME_BUILDING_BLOCKS.COMMENT_TEXT% No NULL

p_parent_building_block_ovn

IN The ovn of a TIMECARD Time Building Block

HXC_TIME_BUILDING_BLOCKS.PARENT_BUILDING_BLOCK_OVN%TYPE

No 1

p_deposit_process IN The deposit process that should be used for depositing the TBB

HXC_DEPOSIT_PROCESSES.NAM%TYPE No OTL Deposit Process

p_app_blocks IN OUT This will be used to return the PL/SQL table with your DAY Time Building Block in it

HXC_SELF_SERVICE_TIME_DEPOSIT. TIMECARD_INFO

Yes

p_time_building_block_id

OUT This will be used to return the TBB id assigned to your DAY Time Building Block

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

For our example for Wednesday you will get (you will need to do one for every day of course):

hxc_timestore_deposit.create_day_bb ( p_day => fnd_date.canonical_to_date('2002/07/03'), p_parent_building_block_id => l_tc_bb_id, -- returned by create_timecard_bb p_comment_text => 'Created using API', p_app_blocks => l_tbl_timecard_info, p_time_building_block_id => l_day_bb_id );

There is an alternative call you can use if you do not know the TIMECARD Time Building Block IDs. This is very likely when you run the API on a daily basis. It creates the TIMECARD Time Building Block in the first run. In the subsequent runs, you will not run CREATE_TIMECARD_BB and therefore not get the handle to the TIMECARD Time Building Block.

The parameters for this procedure are exactly the same except for p_parent_building_block_id, which is now replaced by the p_resource_id. This will be used, together with the date, to find the parent (TIMECARD) Time Building Block.

Page 15

Page 16: White Paper Oracle Otl Hxc Timestore Deposit

It takes the following parameters: Name IN/OUT Description Data Type Mand Default p_day IN The day this DAY

Time Building Block is intended for

HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE Yes

p_resource_id IN person_id (no other resource id’s are accepted at the moment)

HXC_TIME_BUILDING_BLOCKS.RESOURCE_ID%TYPE

Yes

p_resource_type IN At the moment we only support person so leave this to default

HXC_TIME_BUILDING_BLOCKS.RESOURCE_TYPE%TYPE

No PERSON

p_comment_text IN The comment you want to add on the day

HXC_TIME_BUILDING_BLOCKS.COMMENT_TEXT% No NULL

p_deposit_process IN The deposit process that should be used for depositing the TBB

HXC_DEPOSIT_PROCESSES.NAM%TYPE No OTL Deposit Process

p_app_blocks IN OUT This will be used to return the PL/SQL table with your DAY Time Building Block in it

HXC_SELF_SERVICE_TIME_DEPOSIT. TIMECARD_INFO

Yes

p_time_building_block_id

OUT This will be used to return the TBB id assigned to your DAY Time Building Block

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

For our example for Wednesday you will get (you will need to do one for every day of course):

hxc_timestore_deposit.create_day_bb ( p_day => fnd_date.canonical_to_date('2002/07/03'), p_resource_id => 9389, p_comment_text => 'Created using API', p_app_blocks => l_tbl_timecard_info, p_time_building_block_id => l_day_bb_id );

This will produce exactly the same result as the previous call.

Page 16

Page 17: White Paper Oracle Otl Hxc Timestore Deposit

Create the DETAIL Time Building Blocks

Next you must create a Time Building Block with a scope of DETAIL for every day in our timecard that you want to assign some time too. As mentioned before, these DETAIL Time Building Blocks must be linked to a DAY Time Building Block, but not every DAY Time Building Block will have a DETAIL Time Building Block. Use CREATE_DETAIL_BB to create the DETAIL Time Building Blocks. It takes the following parameters:

Name IN/OUT Description Data Type Mand Default p_type IN MEASURE or

RANGE HXC_TIME_BUILDING_BLOCKS.TYPE%TYPE Yes

p_measure

IN The measure you want to store (use when type = MEASURE, else you do not have to provide this parameter)

HXC_TIME_BUILDING_BLOCKS.MEASURE%TYPE

No NULL

p_start_time IN The time you want this Time Building Block to start (use when type = RANGE, else you do not have to provide this parameter)

HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE

No NULL

p_stop_time IN The time you want this Time Building Block to stop (use when type = RANGE, else you do not have to provide this parameter)

HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE

No NULL

p_parent_building_block_id

IN The building block id of a DAY Time Building Block

HXC_TIME_BUILDING_BLOCKS.PARENT_BUILDING_BLOCK_ID% TYPE

Yes

p_comment_text IN The comment you want to add on the detail

HXC_TIME_BUILDING_BLOCKS.COMMENT_TEXT%TYPE

No NULL

p_parent_building_block_ovn

IN The ovn of a TIMECARD Time Building Block

HXC_TIME_BUILDING_BLOCKS.PARENT_BUILDING_BLOCK_OVN% TYPE

No 1

p_deposit_process IN The deposit process that should be used for depositing the Time Building Block

HXC_DEPOSIT_PROCESSES.NAM%TYPE No OTL Deposit Process

p_app_blocks IN OUT This will be used to return the PL/SQL table with your DAY Time Building Block in it

HXC_SELF_SERVICE_TIME_DEPOSIT. TIMECARD_INFO

Yes

p_app_attributes IN OUT This will be used to return the PL/SQL table with your application attribute in it

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

p_time_building_block_id

OUT This will be used to return the TBB id assigned to your DETAIL Time Building Block

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

For our example for Wednesday you will get (you will need to do one for every DETAIL Time Building Block of course):

Page 17

Page 18: White Paper Oracle Otl Hxc Timestore Deposit

-- Professional Time hxc_timestore_deposit.create_detail_bb ( p_type => 'MEASURE' p_measure => 8, p_parent_building_block_id => l_day_bb_id, -- ID for Wednesday p_comment_text => 'Created using API: ST', p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info, p_time_building_block_id => l_detail_bb_st_id );

As for DAY Time Building Blocks, there is an alternative procedure you can use, if you do not know the DAY Time Building Block IDs. It is the same call you used in the Quick Start chapter: CREATE_TIME_ENTRY. This call does not need a parent (DAY) Time Building Block Id, it uses the resource Id and day parameter to find the parent Time Building Block. Of course you can use the RANGE version or the MEASURE version.

Please see the Quick Start chapter for information on how to use these procedures and which parameters you can use.

For the example for Wednesday you will get (you will need to do one for every DETAIL Time Building Block of course):

-- Overtime hxc_timestore_deposit.create_time_entry ( p_measure => 2, p_day => fnd_date.canonical_to_date('2002/07/03'), p_resource_id => 9389, p_comment_text => 'Created using API: OT', p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info, p_time_building_block_id => l_detail_bb_id );

Create the Attributes

NOTE: It is a good practice to create the attribute straight after its building block to which it belongs (as we do in the example script) because then you have the Time Building Block id handy. It is listed here just for documentation purposes.

You now add attributes to the DETAIL Time Building Blocks so the time has a meaning. You recorded time when you created the Time Building Blocks, however now you define what this time means and for what it is used.

For every attribute field you need in the database, you create an application attribute using the procedure CREATE_ATTRIBUTE. You need to do it this way because you have no idea how many attributes you would want to add to any Time Building Block, and this way you can add as many as you want. Eventually, using the mapping tables, these multiple attribute records will end up in the database as one (or more) attribute record. You must remember that for every attribute field you want to populate, you must call CREATE_ATTRIBUTE.

Page 18

Page 19: White Paper Oracle Otl Hxc Timestore Deposit

It takes the following parameters:

Name IN/OUT Description Data Type Mand Defaultp_building_block_id IN This is the id of

the Time Building Block to which this attribute belongs

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

p_attribute name

IN The name of the attribute you want to insert or update

HXC_MAPPING_COMPONENTS.FIELD_NAME%TYPE Yes

p_attribute_value IN The value you want to assign to the attribute

HXC_TIME_ATTRIBUTES.ATTRIBUTE1%TYPE Yes

p_deposit_process IN The deposit process that should be used for depositing the attribute

HXC_DEPOSIT_PROCESSES.NAM%TYPE No OTL Deposit Process

p_attribute_id IN Use this to provide an attribute id for your application attribute. All application attributes that belong to the same attribute in the DB need to get the same id.

HXC_TIME_ATTRIBUTES.TIME_ATTRIBUTE_ID%TYPE No NULL

p_app_attributes IN OUT This will be used to return the PL/SQL table with your application attribute in it

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

For the example for Wednesday you will get (you will need to do one for every day of course):

-- 5 attribute fields for Professional Time -- Attribute1 hxc_timestore_deposit. create_attribute ( p_building_block_id => l_detail_bb_st_id, -- make sure this points to Wednesdays TBB for all attributes mentioned here p_attribute_name => 'Task_Id', p_attribute_value => '221', -- Replace with your own Id p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, ); -- Attribute2 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_st_id, p_attribute_name => 'Project_Id', p_attribute_value => '221', -- Replace with your own Id p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, ); -- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_st_id, p_attribute_name => 'Expenditure_Type', p_attribute_value => 'Professional', -- Replace with your own p_category => 'PROJECTS', p_deposit_process => 'Projects Deposit Process',

Page 19

Page 20: White Paper Oracle Otl Hxc Timestore Deposit

p_app_attributes => l_tbl_attributes_info, ); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_st_id, p_attribute_name => 'Expenditure_Comment', p_attribute_value => '', -- Replace with your own p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, ); -- Attribute5 hxc_timestore_deposit.create_attribute( p_building_block_id => l_detail_bb_st_id, p_attribute_name => 'SYSTEM_LINKAGE_FUNCTION', p_attribute_value => 'ST'; -- Replace with your own p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, ); -- 5 attribute fields for Overtime -- Attribute1 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_ot_id, p_attribute_name => 'Task_Id', p_attribute_value => '221', -- Replace with your own Id p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, ); -- Attribute2 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_ot_id, p_attribute_name => 'Project_Id', p_attribute_value => '221', -- Replace with your own Id p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, ); -- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_ot_id, p_attribute_name => 'Expenditure_Type', p_attribute_value => 'Overtime', -- Replace with your own p_app_attributes => l_tbl_attributes_info, ); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_ot_id, p_attribute_name => 'Expenditure_Comment', p_attribute_value => '', -- Replace with your own p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, ); -- Attribute5 hxc_timestore_deposit.create_attribute ( p_building_block_id => l_detail_bb_ot_id, p_attribute_name => 'SYSTEM_LINKAGE_FUNCTION', p_attribute_value => 'OT'; -- Replace with your own p_deposit_process => 'Projects Deposit Process', p_app_attributes => l_tbl_attributes_info, );

Page 20

Page 21: White Paper Oracle Otl Hxc Timestore Deposit

Deposit the Timecard

If you are happy with your timecard, you can save it (‘deposit’) to the TimeStore using EXECUTE_DEPOSIT_PROCESS. It takes the following parameters:

Name IN/OUT Description Data Type Mand Default p_validate IN This can be used to indicate if

you only want to validate your timecard or if you actually want to store it in the TimeStore.

BOOLEAN No FALSE

p_app_blocks

IN OUT The PL/SQL holding your complete timecard

HXC_SELF_SERVICE_TIME_DEPOSIT. TIMECARD_INFO

Yes

p_app_attributes IN The PL/SQL table holding all your attributes

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

p_messages OUT This will be used to return the PL/SQL table that holds all the messages raised during the deposit process (errors, warnings…)

HXC_SELF_SERVICE_TIME_DEPOSIT. MESSAGE_TABLE

Yes

p_mode IN ‘SUBMIT’, ‘SAVE’ or ‘MIGRATE’

VARCHAR2 Yes

p_deposit_process IN The name of the deposit process you want to use

VARCHAR2 Yes

p_retrieval_process IN The name of the retrieval process you want to use

VARCHAR2 No NULL

p_timecard_id OUT The Time Building Block id of the timecard as it exists in the database (in case of an insert this will be different than the one you assigned to it)

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID

Yes

p_timecard_ovn OUT The object version number of the timecard as it exists in the database

HXC_TIME_BUILDING_BLOCKS. OBJECT_VERSION_NUMBER

Yes

In our example this will look like this:

HXC_TIMESTORE_DEPOSIT.EXECUTE_DEPOSIT_PROCESS ( p_validate => FALSE, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info, p_messages => l_tbl_messages, p_mode => 'SUBMIT', p_deposit_process => 'OTL Deposit Process', p_retrieval_process => 'Projects Retrieval Process', p_timecard_id => l_new_timecard_id, p_timecard_ovn => l_new_timecard_ovn );

Reviewing the messages

The API provides a procedure you can use to review the messages that are returned by the deposit process. If a deposit fails, the API records the error in a table that can be read at the end. You can use LOG_MESSAGES for this. In the example this would look like:

hxc_timestore_deposit.log_messages ( p_messages => l_tbl_messages );

See Appendix C for the complete script.

NOTE: this script uses variables and constants for better maintainability. In the code snippets above, the values assigned to the variables are for readability, so

Page 21

Page 22: White Paper Oracle Otl Hxc Timestore Deposit

the code in the appendix will not match word for word the code in this chapter, but functionally it is exactly the same.

Update an existing Timecard

You are now going to update the timecard you just deposited. You will change the time worked on Monday from 8 hours to 4 hours and on Tuesday, you will change the overtime from 1 hour to 2 hours. The end result should look like this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun, Jul 1 Jul 2 Jul 3 Jul 4 Jul 5 Jul 6 Jul 7 Project Task Expenditure Type ------------ ------ ---------------- Test Project Task 1 Professional 4 8 8 8 8 Test Project Task 1 Overtime 2 2

NOTE: You cannot always update a Time Building Block. The preference “Self-Service timecard status that allows user edits” controls whether or not you can update a Time Building Block. Throughout the examples in this document you use the OTL Auto Approval mechanism for approving the timecards. This means that the timecards are approved on submission. If you want to update such a timecard, then you must set the preference to ‘RETRO’ or else you will get an error (HXC_VLD_TC_STATUS_CHANGED). Ensure you check this setting and set it accordingly to allow updates on Time Building Blocks.

Update the Time Building Blocks

First you need to find the id of the Time Building Block you want to update in the database. Unfortunately there is no easy way of doing this other then querying the database. Once you know the Time Building Block id, performing an update can be done using the procedure UPDATE_BUILDING_BLOCK.

Page 22

Page 23: White Paper Oracle Otl Hxc Timestore Deposit

It takes the following parameters:

Name IN/OUT Description Data Type Mand Default p_time_building_block_id

IN The id of the Time Building Block you want to update

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

p_measure IN Use this if you want to update the measure of your Time Building Block

HXC_TIME_BUILDING_BLOCKS.MEASURE%TYPE

No hr_api.g_number

p_unit_of_measure IN We only support HOURS at the moment so use default

HXC_TIME_BUILDING_BLOCKS.UNIT_OF_MEASURE%TYPE

No HOURS

p_start_time IN Use this if you want to update the start time of your Time Building Block

HXC_TIME_BUILDING_BLOCKS.START_TIME%TYPE

No hr_api.g_date

p_stop_time IN Use this if you want to update the stop time of your Time Building Block

HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE

No hr_api.g_date

p_comment_text IN Use this if you want to update the comments of your Time Building Block

HXC_TIME_BUILDING_BLOCKS.COMMENT_TEXT%TYPE

No hr_api.g_varchar2

p_deposit_process IN The deposit process that should be used for depositing the timecard

HXC_DEPOSIT_PROCESSES.NAM%TYPE No OTL Deposit Process

p_app_blocks IN OUT This will be used to return the PL/SQL table with your updated Time Building Block in it

HXC_SELF_SERVICE_TIME_DEPOSIT.TIMECARD_INFO

Yes

p_app_attributes IN OUT This will be used to return the PL/SQL table with your application attribute in it

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

Note that this procedure defaults most parameters to a system default value. The system interprets these defaults as ‘I do not want to perform an update on this field of the Time Building Block’ and they retain their old values. This prevents you from passing all the values for all fields, even the ones you do not want to update.

For our example we will get:

hxc_timestore_deposit.update_building_block( p_building_block_id => l_block_to_update_on_monday, p_measure => 4, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info ); hxc_timestore_deposit.update_building_block( p_building_block_id => l_block_to_update_on_tuesday, p_measure => 2, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info );

We declared l_block_to_update_on_monday and l_block_to_update_on_Tuesday as

Page 23

Page 24: White Paper Oracle Otl Hxc Timestore Deposit

HXC_TIME_BUILDING_BLOCKS.TIME_BUILDING_BLOCK_ID and assigned them the Time Building Block ids of the 2 blocks you want to update.

Deposit the Timecard

Once you update the timecard (remember you can update only one timecard at a time), then you deposit the timecard as a whole into the TimeStore, which is the same as an insert. This is done using HXC_SELF_SERVICE_TIMECARD_API.EXECUTE_DEPOSIT_PROCESS passing in the PL/SQL tables.

In our example this will look like this:

HXC_TIMESTORE_DEPOSIT.EXECUTE_DEPOSIT_PROCESS ( p_validate => FALSE, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info, p_messages => l_tbl_messages, p_mode => 'SUBMIT', p_deposit_process => 'OTL Deposit Process', p_retrieval_process => 'Projects Retrieval Process', p_timecard_id => l_new_timecard_id, p_timecard_ovn => l_new_timecard_ovn );

Reviewing the messages

The API provides a procedure you use to review the messages returned by the deposit process. The API will not error out when a deposit fails, it will record the error in a table that can be read at the end. You can use LOG_MESSAGES for this. In our example this would look like:

hxc_timestore_deposit.log_messages ( p_messages => l_tbl_messages );

See Appendix D for the complete script

Update an existing Attribute

You are now going to update another entry on the timecard you just deposited. You will change the Task that the overtime was logged against on Tuesday from Task 1 to Task 2. The end result should look like this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun, Jul 1 Jul 2 Jul 3 Jul 4 Jul 5 Jul 6 Jul 7 Project Task Expenditure Type ------------ ------ ---------------- Test Project Task 1 Professional 4 8 8 8 8 Test Project Task 1 Overtime 2 Test Project Task 2 Overtime 2

Page 24

Page 25: White Paper Oracle Otl Hxc Timestore Deposit

Update the Attributes

First you must find the id of the attribute record that holds the field you want to update in the database. Unfortunately there is no easy way of doing this other then querying the database. Once you know the attribute id, you can update he timecard using the procedure UPDATE_ATTRIBUTE.

It takes the following parameters:

Name IN/OUT Description Data Type Mand Default p_time_attribute_id

IN The id of the attribute you want to update

HXC_TIME_ATTRIBUTES.TIME_ATTRIBUTE_ID%TYPE

Yes

p_attribute_name

IN The name of the attribute you want to update

HXC_MAPPING_COMPONENTS.FIELD_NAME%TYPE

Yes

p_attribute_value

IN The new value you want to store in the attribute field

HXC_TIME_ATTRIBUTES.ATTRIBUTE1%TYPE No hr_api.g_number

p_deposit_process

IN The deposit process that should be used for depositing the timecard

HXC_DEPOSIT_PROCESSES.NAM%TYPE No OTL Deposit Process

p_app_blocks IN OUT This will be used to return the PL/SQL table with your updated Time Building Block in it

HXC_SELF_SERVICE_TIME_DEPOSIT.TIMECARD_INFO

Yes

p_app_attributes

IN OUT This will be used to return the PL/SQL table with your application attribute in it

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

NOTE: this procedure defaults most parameters to a system default value. These system interprets this as ‘I do not want to perform an update on this field of the Time Building Block’ and they retain their old value. This prevents you from having to pass in all the values for all fields, even the ones you do not want to update.

For our example we will get:

hxc_timestore_deposit.update_attribute ( p_time_attribute_id=> 252369, p_attribute_name=> 'Task_Id', p_attribute_value=> 282, -- Task 2 p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info );

Deposit the Timecard

Once you update the timecard (remember you only update one timecard at a time), then you deposit the timecard as a whole into TimeStore, the same as for an insert. This is done using HXC_SELF_SERVICE_TIMECARD_API.EXECUTE_DEPOSIT_PROCESS passing in the PL/SQL tables.

Page 25

Page 26: White Paper Oracle Otl Hxc Timestore Deposit

In our example this will look like this:

HXC_TIMESTORE_DEPOSIT.EXECUTE_DEPOSIT_PROCESS ( p_validate => FALSE, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info, p_messages => l_tbl_messages, p_mode => 'SUBMIT', p_deposit_process => 'OTL Deposit Process', p_timecard_id => l_new_timecard_id, p_timecard_ovn => l_new_timecard_ovn );

Reviewing the messages

The API provides a procedure you use to review the messages returned by the deposit process. When a deposit fails, the API does not error out, it records the error in a table that can be read at the end. You can use LOG_MESSAGES for this. In our example this would look like:

hxc_timestore_deposit.log_messages ( p_messages => l_tbl_messages );

See Appendix E for the complete script.

Deleting a DETAIL Time Building Block

You will delete time from the timecard we just deposited. You will remove the overtime time off the timecard. The end result should look like this:

Mon, Tue, Wed, Thu, Fri, Sat, Sun, Jul 1 Jul 2 Jul 3 Jul 4 Jul 5 Jul 6 Jul 7 Project Task Expenditure Type ------------ ------ ---------------- Test Project Task 1 Professional 4 8 8 8 8

Delete the Time Building Block

First you must find the id of the Time Building Block you want to delete in the database. Unfortunately there is no easy way of doing this other then querying the database. Once you know the Time Building Block id, performing a delete can be done using the procedure DELETE_DETAIL_BB.

Page 26

Page 27: White Paper Oracle Otl Hxc Timestore Deposit

It takes the following parameters:

Name IN/OUT Description Data Type Mand Default P_time_building_block_id IN The id of the Time

Building Block you want to delete

HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

P_deposit_process IN The deposit process that should be used for depositing the delete Time Building Block

HXC_DEPOSIT_PROCESSES.NAM%TYPE No OTL Deposit Process

P_effective_date IN The date used to end date the Time Building Block

HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE

No sysdate

P_app_blocks IN OUT This will be used to return the PL/SQL table with your deleted Time Building Block removed from it.

HXC_SELF_SERVICE_TIME_DEPOSIT. TIMECARD_INFO%TYPE

Yes

p_app_attributes IN OUT This will be used to return the PL/SQL table with your deleted application attribute removed from it

HXC_SELF_SERVICE_TIME_DEPOSIT. APP_ATTRIBUTE_INFO

Yes

In the example this will look like this:

hxc_timestore_deposit.DELETE_DETAIL_BB ( p_time_building_block_id => l_tbb_to_delete1, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info ); hxc_timestore_deposit.DELETE_DETAIL_BB ( p_time_building_block_id => l_tbb_to_delete2, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info );

We declared l_tbb_to_delete1 and l_tbb_to_delete2 as HXC_TIME_BUILDING_BLOCKS.TIME_BUILDING_BLOCK_ID and assigned them the Time Building Block ids of the 2 blocks you want to delete.

Deposit the Timecard

Once you have performed all your deletes on the timecard (remember you delete only one timecard at a time) you can deposit (deleted) the timecard as a whole into TimeStore, same as for an insert. You do this using HXC_SELF_SERVICE_TIMECARD_API.EXECUTE_DEPOSIT_PROCESS passing in the PL/SQL tables.

Page 27

Page 28: White Paper Oracle Otl Hxc Timestore Deposit

In our example this will look like this: HXC_TIMESTORE_DEPOSIT.EXECUTE_DEPOSIT_PROCESS ( p_validate => FALSE, p_app_blocks => l_tbl_timecard_info, p_app_attributes => l_tbl_attributes_info, p_messages => l_tbl_messages, p_mode => 'SUBMIT', p_deposit_process => 'OTL Deposit Process', p_timecard_id => l_new_timecard_id, p_timecard_ovn => l_new_timecard_ovn );

Reviewing the messages

The API provides a procedure you to review the messages returned by the deposit process. When a deposit fails, the API will not error out, it records the error in a table that can be read at the end. You can use LOG_MESSAGES for this. In our example this would look like:

hxc_timestore_deposit.log_messages ( p_messages => l_tbl_messages );

Having declared l_tbl_messages as HXC_SELF_SERVICE_TIME_DEPOSIT.MESSAGE_TABLE.

The API messages are written to the table: FND_LOG_MESSAGES. The API messages then can be viewed by querying this table.

For this to work you will have to set the profile options FND: Debug Log Enabled = Yes and FND: Debug Log Level = Statement.

Also your code must contain a line in the beginning that looks like this: FND_GLOBAL.APPS_INITIALIZE ( user_id => <user id you are loggin msg under>, resp_id => <responsibility id of the user> resp_appl_id => 809 ) ;

Alternatively you can read the messages from the PL/SQL message table (l_tbl_messages). As an example:

IF (l_tbl_messages.COUNT <> 0) THEN -- messages have been returned i := l_tbl_messages.FIRST; LOOP EXIT WHEN (NOT l_tbl_messages.EXISTS (i)); l_message := fnd_message.get_string ( appin => l_tbl_messages (i).application_short_name, namein=> l_tbl_messages (i).message_name ); DBMS_OUTPUT.put_line (l_message); i := l_tbl_messages.NEXT (i); END LOOP; END IF;

See Appendix F for the complete script

Page 28

Page 29: White Paper Oracle Otl Hxc Timestore Deposit

Deleting a complete timecard

You are now going to delete the complete timecard you just deposited.

Delete the timecard

First you must find the id of the TIMECARD Time Building Block you want to delete in the database. Unfortunately there is no easy way of doing this other then querying the database. Once you know the Time Building Block id, performing a delete can be done using the procedure DELETE_TIMECARDB.

It takes the following parameters: Name Description Data Type Mand Default p_time_building_block_id The id of the Time Building Block you

want to update HXC_TIME_BUILDING_BLOCKS. TIME_BUILDING_BLOCK_ID%TYPE

Yes

p_mode Use default, DELETE VARCHAR2 No DELETE p_deposit_process The name of the deposit process you

want to use HXC_DEPOSIT_PROCESSES.NAM%TYPE

No OTL Deposit Process

p_retrieval_process The name of the retrieval process you want to use

VARCHAR2 No Null

p_effective_date The date you want this Time Building Block to be deleted (leave blank please)

HXC_TIME_BUILDING_BLOCKS.STOP_TIME%TYPE

No Sysdate

In our example this will look like this:

hxc_timestore_deposit.DELETE_TIMECARD ( p_time_building_block_id => l_timecard_to_delete, );

We declared l_timecard_to_delete as HXC_TIME_BUILDING_BLOCKS.TIME_BUILDING_BLOCK_ID and assigned to it the Time Building Block id of the TIMECARD Time Building Block you want to delete. That is the only line you will need in your script so there is no example in the appendixes.

There is no need to deposit this deleted timecard; this is done for you by the API, because you delete one timecard at a time. If you want to delete multiple timecards, just call this procedure multiple times without depositing anything.

Page 29

Page 30: White Paper Oracle Otl Hxc Timestore Deposit

Appendixes

APPENDIX A: Quickly Creating a Timecard with a measure DECLARE -- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages hxc_self_service_time_deposit.message_table; -- Will hold TC_ID, returned by the deposit process l_new_timecard_id NUMBER; -- Will hold TC ovn, returned by the deposit process l_new_timecard_ovn NUMBER; l_time_building_block_id hxc_time_building_blocks.time_building_block_id%TYPE; BEGIN -- First initialize your session, this needs to be done for internal reasons so -- the TimeStore knows who is trying to deposit the information. When you log -- into SS, the same is done for you by the framework, here however we have to do -- it manually. FND_GLOBAL.APPS_INITIALIZE( user_id => 12345 -– Replace with your own ID ,resp_id => 56789 -– Replace with your own ID ,resp_appl_id => 809 );-- This is the appl_id for OTL, do not change ------------------------- -- PART 1: CREATE TIME -- ------------------------- hxc_timestore_deposit.create_time_entry ( p_measure=> 7, p_day => fnd_date.canonical_to_date ('2002/09/02'), p_resource_id=> 9389, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id ); -- Classify Time -- Attribute1 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Task_Id', p_attribute_value=> '221', p_app_attributes=> l_tbl_attributes_info ); -- Attribute2 -- (l_project_id is NOT the same as task id, they just happen to have the same ID -- on our database) hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Project_Id', p_attribute_value=> '221', p_app_attributes=> l_tbl_attributes_info ); -- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id,

Page 30

Page 31: White Paper Oracle Otl Hxc Timestore Deposit

p_attribute_name=> 'Expenditure_Type', p_attribute_value=> 'Professional', p_app_attributes=> l_tbl_attributes_info ); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Expenditure_Comment', p_attribute_value=> 'Expenditure Comment created by API', p_app_attributes=> l_tbl_attributes_info ); -- Attribute5 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'SYSTEM_LINKAGE_FUNCTION', p_attribute_value=> 'ST', p_app_attributes=> l_tbl_attributes_info ); -------------------------------- -- END OF PART 1: CREATE TIME -- -------------------------------- ------------------------------ -- PART 2: DEPOSIT TIMECARD -- ------------------------------ -- Now we call the deposit process, passing in the PL/SQL tables we just created -- and populated hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_timecard_id=> l_new_timecard_id, p_timecard_ovn=> l_new_timecard_ovn ); ------------------------------------- -- END OF PART 2: DEPOSIT TIMECARD -- ------------------------------------- END;

Page 31

Page 32: White Paper Oracle Otl Hxc Timestore Deposit

APPENDIX B: Quickly Creating a Timecard with a range DECLARE -- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages hxc_self_service_time_deposit.message_table; -- Will hold TC_ID, returned by the deposit process l_new_timecard_id NUMBER; -- Will hold TC ovn, returned by the deposit process l_new_timecard_ovn NUMBER; l_time_building_block_id hxc_time_building_blocks.time_building_block_id%TYPE; BEGIN -- First initialize your session, this needs to be done for internal reasons so -- the TimeStore knows who is trying to deposit the information. When you log -- into SS, the same is done for you by the framework, here however we have to do -- it manually. FND_GLOBAL.APPS_INITIALIZE( user_id => 12345 -– Replace with your own ID ,resp_id => 56789 -– Replace with your own ID ,resp_appl_id => 809 );-- This is the appl_id for OTL, do not change ------------------------- -- PART 1: CREATE TIME -- ------------------------- hxc_timestore_deposit.create_time_entry ( p_start_time=> fnd_date.canonical_to_date ('2002/09/02 09:00:00'), p_stop_time=> fnd_date.canonical_to_date ('2002/09/02 17:00:00'), p_resource_id=> 9389, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id ); -- Classify Time -- Attribute1 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Task_Id', p_attribute_value=> '221', p_app_attributes=> l_tbl_attributes_info ); -- Attribute2 -- (l_project_id is NOT the same as task id, they just happen to have the same ID -- on our database) hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Project_Id', p_attribute_value=> '221', p_app_attributes=> l_tbl_attributes_info ); -- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Expenditure_Type', p_attribute_value=> 'Professional', p_app_attributes=> l_tbl_attributes_info

Page 32

Page 33: White Paper Oracle Otl Hxc Timestore Deposit

); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Expenditure_Comment', p_attribute_value=> 'Expenditure Comment created by API', p_app_attributes=> l_tbl_attributes_info ); -- Attribute5 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'SYSTEM_LINKAGE_FUNCTION', p_attribute_value=> 'ST', p_app_attributes=> l_tbl_attributes_info ); -------------------------------- -- END OF PART 1: CREATE TIME -- -------------------------------- ------------------------------ -- PART 2: DEPOSIT TIMECARD -- ------------------------------ -- Now we call the deposit process, passing in the PL/SQL tables we just created -– and populated hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_timecard_id=> l_new_timecard_id, p_timecard_ovn=> l_new_timecard_ovn ); ------------------------------------- -- END OF PART 2: DEPOSIT TIMECARD -- ------------------------------------- END;

Page 33

Page 34: White Paper Oracle Otl Hxc Timestore Deposit

APPENDIX C: Creating a Timecard manually DECLARE -- Constant declarations ------------------------ -- This is the appl_id for OTL, do not change c_otl_appl_id CONSTANT NUMBER (3) := 809; c_proj_attr1 CONSTANT VARCHAR2 (7) := 'Task_Id'; c_proj_attr2 CONSTANT VARCHAR2 (10) := 'Project_Id'; c_proj_attr3 CONSTANT VARCHAR2 (16) := 'Expenditure_Type'; c_proj_attr4 CONSTANT VARCHAR2 (19) := 'Expenditure_Comment'; c_proj_attr5 CONSTANT VARCHAR2 (23) := 'SYSTEM_LINKAGE_FUNCTION'; -- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages hxc_self_service_time_deposit.message_table; -- person ID that this TC belongs to, Replace with your own l_person_id per_all_people_f.person_id%TYPE := 9389; -- Replace with your own IDs l_task_id VARCHAR2 (3) := '221'; -- (l_project_id is NOT the same as task id, they just happen to have the -- same ID on our database) l_project_id VARCHAR2 (3) := '221'; -- Replace with your own values l_expenditure_type VARCHAR2 (15) := 'Professional'; l_ot_expenditure_type VARCHAR2 (15) := 'Overtime'; l_system_linkage_id VARCHAR2 (15) := 'ST'; l_ot_system_linkage_id VARCHAR2 (15) := 'OT'; -- Will hold TC_ID, returned by the deposit process l_new_timecard_id NUMBER; -- Will hold TC ovn, returned by the deposit process l_new_timecard_ovn NUMBER; l_message fnd_new_messages.message_text%TYPE; l_start_time DATE := fnd_date.canonical_to_date ('2002/11/11 00:00:00'); l_stop_time DATE := fnd_date.canonical_to_date ('2002/11/17 23:59:59'); l_tc_bb_id hxc_time_building_blocks.time_building_block_id%TYPE; l_day_bb_id hxc_time_building_blocks.time_building_block_id%TYPE; l_detail_bb_id hxc_time_building_blocks.time_building_block_id%TYPE; l_time_attribute_id hxc_time_attributes.time_attribute_id%TYPE; BEGIN -- First initialize your session, this needs to be done for internal reasons so -- the TimeStore knows who is trying to deposit the information. When you log -- into SS, the same is done for you by the framework, here however we have to do -- it manually. FND_GLOBAL.APPS_INITIALIZE( user_id => 12345 -– Replace with your own ID ,resp_id => 56789 -– Replace with your own ID ,resp_appl_id => 809 );-- This is the appl_id for OTL, do not change ----------------------------- -- PART 1: POPULATE TABLES -- -----------------------------

Page 34-- First populate the timecard PL/SQL table:

Page 35: White Paper Oracle Otl Hxc Timestore Deposit

-- Start with the TIMECARD BB hxc_timestore_deposit.create_timecard_bb ( p_start_time=> l_start_time, p_stop_time=> l_stop_time, p_resource_id=> l_person_id, p_comment_text=> 'Created using API: Weekly Project TC', p_app_blocks=> l_tbl_timecard_info, p_time_building_block_id=> l_tc_bb_id ); -- Now we create the DAY BB, 7 in total, and since they are all the same we -- will loop 7 times FOR i_day IN 0 .. 6 LOOP hxc_timestore_deposit.create_day_bb ( p_day => TRUNC (l_start_time) + i_day, p_parent_building_block_id=> l_tc_bb_id, -- returned by create_timecard_bb p_comment_text=> 'Created using API', p_app_blocks=> l_tbl_timecard_info, p_time_building_block_id=> l_day_bb_id ); -- The next call would also work but we choose to use the first one -- since we know the TIMECARD's Id. If you do not know the ID you should -- use this next call commented out here. /* hxc_timestore_deposit.create_day_bb ( p_day => TRUNC (l_start_time) + i_day, p_resource_id=> l_person_id, p_comment_text=> 'Created using API', p_app_blocks=> l_tbl_timecard_info, p_time_building_block_id=> l_day_bb_id ); */ -- We can attache the DETAIL BB for every DAY BB that represents 'normal' -- work hours as well here as they are all the same -- We only need to do this for weekdays though IF i_day < 5 THEN hxc_timestore_deposit.create_detail_bb ( p_type=> 'MEASURE', p_measure=> 8, p_parent_building_block_id=> l_day_bb_id, p_comment_text=> 'Created using API: NT', p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_detail_bb_id ); -- The next call would also work but we choose to use the first one -- since we know the DAY's Id. If you do not know the ID you should -- use this next call commented out here. In fact we use it ourselves -- later to add the overtime. /* hxc_timestore_deposit.create_time_entry ( p_measure=> 8, p_day => TRUNC (l_start_time) + i_day, p_resource_id=> l_person_id, p_comment_text=> 'Created using API: NT', p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_detail_bb_id ); */ -- We can also attach the attributes to every BB that represent -- 'normal' work hours

Page 35

Page 36: White Paper Oracle Otl Hxc Timestore Deposit

-- Attribute1 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr1, p_attribute_value=> l_task_id, p_app_attributes=> l_tbl_attributes_info ); -- Attribute2 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr2, p_attribute_value=> l_project_id, p_app_attributes=> l_tbl_attributes_info ); -- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr3, p_attribute_value=> l_expenditure_type, p_app_attributes=> l_tbl_attributes_info ); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr4, p_attribute_value=> 'Expenditure Comment created by API', p_app_attributes=> l_tbl_attributes_info ); -- Attribute5 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr5, p_attribute_value=> l_system_linkage_id, p_app_attributes=> l_tbl_attributes_info ); END IF; -- Only for weekdays END LOOP; -- End creating normal working days + time -- And now we add the Overtime to Tuesday and Wednesday -- We have to use create_time_entry here because we do not have the ID -- for the Wednesday TBB anymore, using create_time_entry we do not need it -- Tuesday hxc_timestore_deposit.create_time_entry ( p_measure=> 1, p_day => TRUNC (l_start_time) + 1, p_resource_id=> l_person_id, p_comment_text=> 'Created using API: OT', p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_detail_bb_id ); -- Attribute1 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr1, p_attribute_value=> l_task_id, p_app_attributes=> l_tbl_attributes_info ); -- Attribute2 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr2, p_attribute_value=> l_project_id, p_app_attributes=> l_tbl_attributes_info );

Page 36

Page 37: White Paper Oracle Otl Hxc Timestore Deposit

-- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr3, p_attribute_value=> l_ot_expenditure_type, p_app_attributes=> l_tbl_attributes_info ); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr4, p_attribute_value=> 'Expenditure Comment created by API', p_app_attributes=> l_tbl_attributes_info ); -- Attribute5 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr5, p_attribute_value=> l_ot_system_linkage_id, p_app_attributes=> l_tbl_attributes_info ); -- Wednesday hxc_timestore_deposit.create_time_entry ( p_measure=> 2, p_day => TRUNC (l_start_time) + 2, p_resource_id=> l_person_id, p_comment_text=> 'Created using API: OT', p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_detail_bb_id ); -- Attribute1 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr1, p_attribute_value=> l_task_id, p_app_attributes=> l_tbl_attributes_info ); -- Attribute2 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr2, p_attribute_value=> l_project_id, p_app_attributes=> l_tbl_attributes_info ); -- Attribute3 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr3, p_attribute_value=> l_ot_expenditure_type, p_app_attributes=> l_tbl_attributes_info ); -- Attribute4 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr4, p_attribute_value=> 'Expenditure Comment created by API', p_app_attributes=> l_tbl_attributes_info ); -- Attribute5 hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_detail_bb_id, p_attribute_name=> c_proj_attr5, p_attribute_value=> l_ot_system_linkage_id, p_app_attributes=> l_tbl_attributes_info

Page 37

Page 38: White Paper Oracle Otl Hxc Timestore Deposit

); ------------------------------------ -- END OF PART 1: POPULATE TABLES -- ------------------------------------ ------------------------------ -- PART 2: DEPOSIT TIMECARD -- ------------------------------ -- Now we call the deposit process, passing in the PL/SQL tables we just -- created and populated hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_timecard_id=> l_new_timecard_id, p_timecard_ovn=> l_new_timecard_ovn ); ------------------------------------- -- END OF PART 2: DEPOSIT TIMECARD -- ------------------------------------- END;

Page 38

Page 39: White Paper Oracle Otl Hxc Timestore Deposit

APPENDIX D: Updating a Timecard DECLARE -- Constant declarations ------------------------ -- This is the appl_id for OTL, do not change c_otl_appl_id CONSTANT NUMBER (3) := 809; -- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages hxc_self_service_time_deposit.message_table; l_out_timecard_id hxc_time_building_blocks.time_building_block_id%TYPE; l_out_timecard_ovn hxc_time_building_blocks.object_version_number%TYPE; BEGIN -- First initialize your session, this needs to be done for internal reasons so -- the TimeStore knows who is trying to deposit the information. When you log -- into SS, the same is done for you by the framework, here however we have to do -- it manually. FND_GLOBAL.APPS_INITIALIZE( user_id => 12345 -– Replace with your own ID ,resp_id => 56789 -– Replace with your own ID ,resp_appl_id => 809 );-- This is the appl_id for OTL, do not change ----------------------------- -- PART 1: CHANGE TIMECARD -- ----------------------------- hxc_timestore_deposit.update_building_block ( p_building_block_id=> 205789, p_measure=> 4, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info ); hxc_timestore_deposit.update_building_block ( p_building_block_id=> 205784, p_measure=> 2, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info ); ------------------------------------ -- END OF PART 1: CHANGE TIMECARD -- ------------------------------------ ------------------------------ -- PART 2: DEPOSIT TIMECARD -- ------------------------------ hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_timecard_id=> l_out_timecard_id,

Page 39 p_timecard_ovn=> l_out_timecard_ovn

Page 40: White Paper Oracle Otl Hxc Timestore Deposit

); ------------------------------------- -- END OF PART 2: DEPOSIT TIMECARD -- ------------------------------------- END;

Page 40

Page 41: White Paper Oracle Otl Hxc Timestore Deposit

APPENDIX E: Updating a Timecard Attribute DECLARE -- Constant declarations ------------------------ -- This is the appl_id for OTL, do not change c_otl_appl_id CONSTANT NUMBER (3) := 809; -- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages hxc_self_service_time_deposit.message_table; l_out_timecard_id hxc_time_building_blocks.time_building_block_id%TYPE; l_out_timecard_ovn hxc_time_building_blocks.object_version_number%TYPE; BEGIN -- First initialize your session, this needs to be done for internal reasons so -- the TimeStore knows who is trying to deposit the information. When you log -- into SS, the same is done for you by the framework, here however we have to do -- it manually. FND_GLOBAL.APPS_INITIALIZE( user_id => 12345 -- Replace with your own ID ,resp_id => 56789 -- Replace with your own ID ,resp_appl_id => 809 );-- This is the appl_id for OTL, do not change ------------------------------ -- PART 1: CHANGE ATTRIBUTE -- ------------------------------ hxc_timestore_deposit.update_attribute ( p_time_attribute_id=> 252369, -- REPLACE by your own ID p_attribute_name=> 'Task_Id', p_attribute_value=> 282, -- Task 2 (REPLACE by your ID) p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info ); ------------------------------------- -- END OF PART 1: CHANGE ATTRIBUTE -- ------------------------------------- ------------------------------ -- PART 2: DEPOSIT TIMECARD -- ------------------------------ hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_timecard_id=> l_out_timecard_id, p_timecard_ovn=> l_out_timecard_ovn ); ------------------------------------- -- END OF PART 2: DEPOSIT TIMECARD -- ------------------------------------- END;

Page 41

Page 42: White Paper Oracle Otl Hxc Timestore Deposit

APPENDIX F: Delete a Time Building Block DECLARE -- Constant declarations ------------------------ -- This is the appl_id for OTL, do not change c_otl_appl_id CONSTANT NUMBER (3) := 809; -- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages hxc_self_service_time_deposit.message_table; l_out_timecard_id hxc_time_building_blocks.time_building_block_id%TYPE; l_out_timecard_ovn hxc_time_building_blocks.object_version_number%TYPE; BEGIN -- First initialize your session, this needs to be done for internal reasons so -- the TimeStore knows who is trying to deposit the information. When you log -- into SS, the same is done for you by the framework, here however we have to do -- it manually. FND_GLOBAL.APPS_INITIALIZE( user_id => 12345 -– Replace with your own ID ,resp_id => 56789 -– Replace with your own ID ,resp_appl_id => 809 );-- This is the appl_id for OTL, do not change --------------------------------- -- PART 1: MARK TBB FOR DELETE -- --------------------------------- hxc_timestore_deposit.delete_detail_bb ( p_building_block_id =>206394, -- REPLACE with your IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info ); hxc_timestore_deposit.delete_detail_bb ( p_building_block_id =>206393, -- REPLACE with your IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info ); ---------------------------------------- -- END OF PART 1: MARK TBB FOR DELETE -- ---------------------------------------- ------------------------------ -- PART 2: DEPOSIT TIMECARD -- ------------------------------ hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_timecard_id=> l_out_timecard_id, p_timecard_ovn=> l_out_timecard_ovn ); ------------------------------------- -- END OF PART 2: DEPOSIT TIMECARD -- ------------------------------------- END;

Page 42

Page 43: White Paper Oracle Otl Hxc Timestore Deposit

APPENDIX G: Create a Timecard with Payroll Elements DECLARE c_otl_appl_id CONSTANT NUMBER (3) := 809; -- This is the appl_id for OTL, do not change -- Variable declarations ------------------------ -- declare the PL/SQL Table that will hold the complete timecard (all the BBs) l_tbl_timecard_info hxc_self_service_time_deposit.timecard_info; -- declare the PL/SQL Table that will hold all the attributes l_tbl_attributes_info hxc_self_service_time_deposit.app_attributes_info; -- declare the PL/SQL Table that will hold the messages returned by the API l_tbl_messages hxc_self_service_time_deposit.message_table; -- Will hold TC_ID, returned by the deposit process l_new_timecard_id NUMBER; -- Will hold TC ovn, returned by the deposit process l_new_timecard_ovn NUMBER; l_time_building_block_id hxc_time_building_blocks.time_building_block_id%TYPE; l_user NUMBER := 1038012; -- (OTLEXCEPT2) Replace with your own IDs l_responsibility NUMBER := 72589; -- (OTL Time and Expense) Replace with your own IDs l_person_id per_all_people_f.person_id%TYPE := 166610; -- (OTLExcept2,) Replace with your own i PLS_INTEGER; l_message fnd_new_messages.message_text%TYPE; -- l_start_date VARCHAR2 (30) := '2002/12/30'; -- UPGQA11i l_start_date VARCHAR2 (30) := '2002/11/04'; -- HRQA11i BEGIN -- First initialize your session, this needs to be done for internal reasons so -- the TimeStore knows who is trying to deposit the information. When you log -- into SS, the same is done for you by the framework, here however we have to do -- it manually. fnd_global.apps_initialize ( user_id=> l_user, resp_id=> l_responsibility, resp_appl_id=> c_otl_appl_id ); ------------------------- -- PART 1: CREATE TIME -- ------------------------- hxc_timestore_deposit.create_time_entry ( p_start_time=> fnd_date.canonical_to_date (l_start_date||' 10:00:00'), p_stop_time=> fnd_date.canonical_to_date (l_start_date||' 19:00:00'), p_resource_id=> l_person_id, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id ); -- Classify Time -- Cost Center hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'CostSegment1', p_attribute_value=> '1039495', p_app_attributes=> l_tbl_attributes_info ); -- HOURS TYPE hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Dummy Element Context', p_attribute_value=> 'ELEMENT - 105447', -- OTL Regular

Page 43

Page 44: White Paper Oracle Otl Hxc Timestore Deposit

p_app_attributes=> l_tbl_attributes_info ); hxc_timestore_deposit.create_time_entry ( p_start_time=> fnd_date.canonical_to_date (l_start_date||' 09:15:00')+1, p_stop_time=> fnd_date.canonical_to_date (l_start_date||' 17:57:00')+1, p_resource_id=> l_person_id, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id ); -- Classify Time -- Cost Center hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'CostSegment1', p_attribute_value=> '1039495', p_app_attributes=> l_tbl_attributes_info ); -- HOURS TYPE hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Dummy Element Context', p_attribute_value=> 'ELEMENT - 105447', -- OTL Regular p_app_attributes=> l_tbl_attributes_info ); hxc_timestore_deposit.create_time_entry ( p_start_time=> fnd_date.canonical_to_date (l_start_date||' 08:11:00')+2, p_stop_time=> fnd_date.canonical_to_date (l_start_date||' 18:10:00')+2, p_resource_id=> l_person_id, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id ); -- Classify Time -- Cost Center hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'CostSegment1', p_attribute_value=> '1039495', p_app_attributes=> l_tbl_attributes_info ); -- HOURS TYPE hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Dummy Element Context', p_attribute_value=> 'ELEMENT - 105447', -- OTL Regular p_app_attributes=> l_tbl_attributes_info ); hxc_timestore_deposit.create_time_entry ( p_start_time=> fnd_date.canonical_to_date (l_start_date||' 07:59:00')+3, p_stop_time=> fnd_date.canonical_to_date (l_start_date||' 18:01:00')+3, p_resource_id=> l_person_id, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id ); -- Classify Time -- Cost Center hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id,

Page 44

Page 45: White Paper Oracle Otl Hxc Timestore Deposit

p_attribute_name=> 'CostSegment1', p_attribute_value=> '1039495', p_app_attributes=> l_tbl_attributes_info ); -- HOURS TYPE hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Dummy Element Context', p_attribute_value=> 'ELEMENT - 105447', -- OTL Regular p_app_attributes=> l_tbl_attributes_info ); hxc_timestore_deposit.create_time_entry ( p_start_time=> fnd_date.canonical_to_date (l_start_date||' 09:56:00')+4, p_stop_time=> fnd_date.canonical_to_date (l_start_date||' 20:07:00')+4, p_resource_id=> l_person_id, -- Identifies a person on our DB, REPLACE WITH YOUR IDs p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_time_building_block_id=> l_time_building_block_id ); -- Classify Time -- Cost Center hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'CostSegment1', p_attribute_value=> '1039495', p_app_attributes=> l_tbl_attributes_info ); -- HOURS TYPE hxc_timestore_deposit.create_attribute ( p_building_block_id=> l_time_building_block_id, p_attribute_name=> 'Dummy Element Context', p_attribute_value=> 'ELEMENT - 105447', -- OTL Regular p_app_attributes=> l_tbl_attributes_info ); -------------------------------- -- END OF PART 1: CREATE TIME -- -------------------------------- ------------------------------ -- PART 2: DEPOSIT TIMECARD -- ------------------------------ -- Now we call the deposit process, passing in the PL/SQL tables we just created -- and populated hxc_timestore_deposit.execute_deposit_process ( p_validate=> FALSE, p_app_blocks=> l_tbl_timecard_info, p_app_attributes=> l_tbl_attributes_info, p_messages=> l_tbl_messages, p_mode=> 'SUBMIT', p_deposit_process=> 'OTL Deposit Process', p_timecard_id=> l_new_timecard_id, p_timecard_ovn=> l_new_timecard_ovn ); IF (l_tbl_messages.COUNT <> 0) THEN -- messages have been returned i := l_tbl_messages.FIRST; LOOP EXIT WHEN (NOT l_tbl_messages.EXISTS (i)); -- First translate the message as the messagetable returned does not give the actual -- message, only the message_name which doesn't mean anything to the user.

Page 45

Page 46: White Paper Oracle Otl Hxc Timestore Deposit

Page

46

l_message := fnd_message.get_string ( appin => l_tbl_messages (i).application_short_name, namein=> l_tbl_messages (i).message_name ); DBMS_OUTPUT.put_line (l_tbl_messages (i).message_name); DBMS_OUTPUT.put_line (l_message); i := l_tbl_messages.NEXT (i); END LOOP; END IF; ------------------------------------- -- END OF PART 2: DEPOSIT TIMECARD -- ------------------------------------- END;