Function to return Job History from the Employee Assignment Form (EBS)

Hi All,
I was hoping to get some help from some SQL and PL/SQL experts on a problem which I’ve been battling to solve, without lots of subquery and self joins and performance problems.
I would ideally like to create a PL/SQL function that would return an Assignment Effective Start Date from an employees record in HR eBusiness Suite based on a few conditions.
I find it easiest to explain with the below table example, which is for a single person, lets say person_id = 3546:
*<PRE> ID Effective Start Date Effective End Date </PRE>*
<PRE> 01 01-DEC-2009 31-DEC-2009 </PRE>
<PRE> 01 *01-NOV-2009* 30-NOV-2009 </PRE>
<PRE> 88 01-OCT-2009 31-OCT-2009 </PRE>
<PRE> 01 01-SEP-2009 30-SEP-2009 </PRE>
<PRE> 67 01-AUG-2009 31-AUG-2009 </PRE>
Above are all the assignments for person_id 3546 with the ID of the Job/Grade they have been assigned. What I need to achieve is, that if I run a report as of the 15-DEC-2009, I would like see the 'Effective Start Date' of '01-NOV-2009' for the most recent ID that has been assigned to the person, in this case ID 01. It shouldn't group ID 01 and give the the date of '01-SEP-2009'.
Some more examples:
If I change the as of date to '10-NOV-2009' and run the report, i would get an 'Effective Start Date' of '01-NOV-2009' for ID 01.
If I change the as of date to '15-OCT-2009' and run the report, i would get an 'Effective Start Date' of '01-OCT-2009' for ID 88.
If I change the as of date to '29-SEP-2009' and run the report, i would get an 'Effective Start Date' of '01-SEP-2009' for ID 01 .
Have i explained enough?? And has anyone some ideas?
Many thanks,
Lance

The logic behind this, is that for an employee I need to determine how long that employee has been in there current job for. In the example I gave, the ID relates to the job ID and walking through the assignments this is what happens.
At '01-AUG-2009' the employee was at job id 67.
At '01-SEP-2009' the employee changed jobs and therefore their new ID was 01.
At '01-OCT-2009' the employee was temporarily promoted to job D of 88.
However at '01-NOV-2009' they returned to the previous grade ID of 01.
Therefore if I ask the question, as of today’s date, how long has the person been in their current job for. I would need to calculate the days from today - '01-NOV-2009'. I wouldn't take '01-DEC-2009' into consideration, because the employee was in the same job the previous month/assignment as well, therefore I need to take the min of these two dates to show the date of when the person first had a job ID of 01.
With regards to the logic shown below, this is similar to the date track function found across HR eBusiness forms. Depending on that 'As of Date' is entered, should return the date when that person was first in their current job.
as of 15-DEC-2009 should give 01-NOV-2009
as of 10-NOV-2009 should give 01-NOV-2009
as of 29-SEP-2009 should give 01-SEP-2009
Within the long winded SQL I have written, it contains the following condition: 'As of Date' >= 'Effective Start Date'. This is acting as my date track feature to only show assignments available to the employee at a particular date. The below code is taken from Oracle’s view called hrfg_job_history. I have had to use this to get my data, but at a cost of performance.
SELECT /* unique attributes */ bgrt.NAME business_group_name,
        peo.full_name person_name, job.NAME job_name,
        ass.effective_start_date effective_start_date,
        hr_discoverer.check_end_date
                                   (asf.effective_end_date)
                                                           effective_end_date /* foreign key resolutions */,
        peo.employee_number employee_number,
        ass.assignment_number assignment_number /* ids */,
        ass.assignment_id assignment_id,
        ass.business_group_id + 0 business_group_id, ass.job_id job_id,
        ass.person_id person_id
  FROM hr_all_organization_units bgr,
       hr_all_organization_units_tl bgrt,
       per_jobs job,
       per_people_x peo,
       per_assignments_f asf,
       per_assignments_f ass
WHERE ass.job_id = job.job_id
   AND ass.person_id = peo.person_id
   AND ass.business_group_id + 0 = bgr.organization_id
   AND bgr.organization_id = bgrt.organization_id
   AND bgrt.LANGUAGE = USERENV ('LANG')
   AND ass.assignment_type = 'E'
   AND NOT EXISTS (
          SELECT NULL
            FROM per_assignments_f ass1
           WHERE ass1.assignment_id = ass.assignment_id
             AND NVL (ass1.job_id, 9.9) + 0 = NVL (ass.job_id, 9.9) + 0
             AND ass1.effective_start_date =
                    (SELECT MAX (ass2.effective_start_date)
                       FROM per_assignments_f ass2
                      WHERE ass2.assignment_id = ass1.assignment_id
                        AND ass2.effective_start_date <
                                                      ass.effective_start_date)
             AND ass1.assignment_type = 'E')
   AND ass.assignment_id = asf.assignment_id
   AND asf.effective_end_date =
          (SELECT MAX (assf.effective_end_date)
             FROM per_assignments_f ass3, per_assignments_f assf
            WHERE ass3.assignment_id = ass.assignment_id
              AND ass3.assignment_id = assf.assignment_id
              AND NVL (ass3.job_id, 9.9) + 0 = NVL (ass.job_id, 9.9) + 0
              AND assf.assignment_type = 'E'
              AND ass3.assignment_type = 'E' /* check for end of time dates */
              AND (   (    assf.effective_start_date =
                                                      ass.effective_start_date
                       AND ass.effective_end_date =
                                          TO_DATE ('31-12-4712', 'DD-MM-YYYY')
                       AND assf.effective_end_date = ass.effective_end_date
                      ) /* check for rows which have changes after */
                   OR (    ass3.effective_start_date >=
                                                      ass.effective_start_date
                       AND (assf.effective_end_date =
                               (SELECT MIN (ass4.effective_start_date) - 1
                                  FROM per_assignments_f ass4
                                 WHERE ass4.assignment_id = ass.assignment_id
                                   AND ass4.effective_start_date >=
                                                     ass3.effective_start_date
                                   AND ass4.assignment_type = 'E'
                                   AND (NVL (ass4.job_id, 9.9) + 0 <>
                                                      NVL (ass.job_id, 9.9)
                                                      + 0
                      ) /* check for rows which do not have changes after */
                   OR (    ass3.effective_start_date =
                                                      ass.effective_start_date
                       AND NOT EXISTS (
                              SELECT NULL
                                FROM per_assignments_f ass7
                               WHERE ass7.assignment_id = ass.assignment_id
                                 AND ass7.effective_start_date >
                                                     ass3.effective_start_date
                                 AND ass7.assignment_type = 'E'
                                 AND (NVL (ass7.job_id, 9.9) + 0 <>
                                                      NVL (ass.job_id, 9.9)
                                                      + 0
                       AND (assf.effective_end_date =
                                          TO_DATE ('31-12-4712', 'DD-MM-YYYY')
   AND ass.business_group_id + 0 =
                 NVL (hr_general.get_business_group_id, ass.business_group_id)Any more ideas?
thanks,
Lance

Similar Messages

  • How to fetch Positon and Job text for the employee

    Hi all,
    How can I fetch the Postion and Job text from the infotype HRP1001 contains in last fields.
    When I'm picking it takes from the last latest record, but in PA30 picks the next to the latest records some times.
    Please help me in this.
    Thank you!
    Prasad

    Hi,
    You can use standard function:
    With object id got from infotype 1001 (sobid) u can fetch descriptiosn from infotype 1000.
    data: ti_i1000 LIKE p1000 OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'RH_READ_INFTY_1000'
          EXPORTING
            plvar            = '01'                   " Version plan usually 01
            otype           = 'C'                     " C = Funcion, S = Position
            objid            = p_objid              " Object ID function or position
            begda          = p_begda
            endda            = p_endda
          TABLES
            i1000            =  ti_i1000        " Inoftype 1000 structure
          EXCEPTIONS
            nothing_found    = 1
            wrong_condition  = 2
            wrong_parameters = 3
            OTHERS           = 4.
    Then you can use field ti_i1000-stext.
    Hope this helps.
    Daniel
    Edited by: Daniel Siñani Cardenas on Jun 30, 2009 11:05 PM

  • How to check my job name from the database...

    I have written one job scheduler which is as follows :
    SQL> ED
    Wrote file afiedt.buf
    1 DECLARE
    2 X NUMBER;
    3 JobNumber NUMBER;
    4 BEGIN
    5 SYS.DBMS_JOB.SUBMIT
    6 (
    7 job => X
    8 ,what => 'scott.SPLITSMS;'
    9 ,next_date => SYSDATE+1/1440
    10 ,interval => 'SYSDATE+1/1440 '
    11 ,no_parse => FALSE
    12 );
    13 JobNumber := to_char(X);
    14* END;
    15 /
    PL/SQL procedure successfully completed.
    Now I want to check whether the job has been really created or not?
    so for that I have used the following command line:
    SQL> SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS';
    SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS'
    ERROR at line 1:
    ORA-00942: table or view does not exist
    how to check my job name from the database...
    what is the command used to check the job_name ????
    and how can i ensure that my job scheduler is running properly...???
    please help ........my dear friends.....!

    957029 wrote:
    Now I want to check whether the job has been really created or not?
    so for that I have used the following command line:
    SQL> SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS';
    SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS'
    ERROR at line 1:
    ORA-00942: table or view does not existYou can use DBA_* views only if the User has been Granted a DBA Privilege.
    how to check my job name from the database...
    what is the command used to check the job_name ????You can use USER_JOBS view to check. But, is it not that you have just created the Job, so you must be knowing it?
    and how can i ensure that my job scheduler is running properly...???If USER_JOBS.FAILURES is Non Zero, that means the Job has encountered a problem that needs to be Investigated. Similarly, the LAST_DATE, LAST_SEC, NEXT_DAY, NEXT_SEC can be used to determine if the Job has been running successfully.
    if you are on 11g, you should consider using DBMS_SCHEDULER.

  • HT201401 I had restored my iPhone 4 but after restore my camera can't function well after take picture from the camera it's didn't display in the Photo Gallery even can't take a video record,how to solve this?and i had tried to restore again,still the sam

    I had restored my iPhone 4 but after restore my camera can't function well after take picture from the camera it's didn't display in the Photo Gallery even can't take a video record,how to solve this?and i had tried to restore again,still the same
    kindly reply and fix this for me
    reply to my email,tq

    Most likely you have Office 2004 which are PPC-only applications and will not work in Lion. Upgrade to Office 2011. Other alternatives are:
    Apple's iWork suite (Pages, Numbers, and Keynote.)
    Open Office (Office 2007-like suite compatible with OS X.)
    NeoOffice (similar to Open Office.)
    LibreOffice (a new direction for the Open Office suite.)

  • Function for getting password with *** from the cmd?

    Hey all,
    i am trying to find a function to get a password from the user using the command prompt in a hidden way... e.g. i want the function to take the password from the user but simultaneously apear * on the screen..?
    is any function doing that ?
    thx a lot!

    Java SE 6 has a new class Console that does not echo password input. It does not print *, it prints nothing, which is tradition of console app.
    http://java.sun.com/javase/6/docs/api/java/io/Console.html

  • Job logs from the original system after Unicode conversion.

    Dear Globalization experts,
    We are doing Unicode conversion and would like to know, if the Job logs from the batch jobs, executed before conversion (system with a 1100 code page), would be readable  in the Unicode system after the conversion.  We will move job log files from the source to the target  system. I .  Thank you in advance for your help.
    Best regards,
    Alik Shapiro

    Hi Alik,
    I have strong doubts that this will work ...
    From SAP notes 842767 and 901004 you can see, that spool data will not be converted properly by default.
    In general this is valid for data stored in TemSe, as this is by definition temporary data (see for example http://help.sap.com/saphelp_nw70/helpdata/en/d9/4a8f9c51ea11d189570000e829fbbd/content.htm ).
    However I actually did not test it, so I am not 100% sure.
    Best regards,
    Nils Buerckel
    SAP AG

  • Is there a functional advantage in downloading Lightroom from the Mac app store vs from elsewhere?

    Is there a functional advantage in downloading Lightroom from the Mac app store vs from elsewhere?

    No...and in fact there are several disadvantages (notably the easy ability of updating).
    If you have the choice between a regular (real) license and an App Store license, buy the real thing…the App store is a problem...

  • I am turning in a MacBook, I need to keep my TimeMachine backups on TimeMachine but want to delete TimeMachine history from the MacBook

    I am turning in a MacBook, I need to keep my TimeMachine backups on TimeMachine but want to delete TimeMachine history from the MacBook. How can I do this?

    Local snapshots
    http://support.apple.com/kb/HT4878
    TimeMachine>preferences
    how to disable the local snapshot:
    1.click the time machine menubar icon
    2.open TM preference...
    3.Option...
    4.uncheck the ’create local snapshot‘
    This will keep normal (remote) Time Machine back ups on, but disable local ones. It will also delete the current local cache automatically.
    or
    copy and paste into terminal :
    sudo tmutil disablelocal

  • HT204088 Why can't I see the purchase history from the ipad? I mean, I can buy apps and in game content directly from my iPad, but I have have to install iTunes on my PC to see the purchase history? What kind of deal is that?

    Why can't I see the purchase history from the ipad? I mean, I can buy apps and in game content directly from my iPad, but I have have to install iTunes on my PC to see the purchase history? What kind of deal is that?

    Welcome to Apple Communities
    You don't need to install iTunes for the purchase history. You can see it in your iPad (iTunes > Purchased), but you need to install it if you want the order numbers

  • After a fresh reinstallation of FF3.6.8 I'm unable to restore bookmarks, passwords, and browsing history from the saved profile data.

    I have followed all the guidelines to transfer bookmarks, passwords, and browsing history from the copied Profile Folder. I did a fresh reinstall per directions of FF3.6.8.
    == I did a fresh reinstall of FFox, now Im unable to transfer Bookmarks, Passwords, Browsing History.

    Please continue with the original question [/questions/992628]
    We are nearly all volunteers and fellow users. Please allow some time to elapse for a reply.

  • I am setting up a new Time Capsule to replace another hard drive.  Is there any way to include the the Time Machine history from the old drive on the new Time Capsule?

    I am setting up a new Time Capsule to replace another hard drive.  Is there any way to include the the Time Machine history from the old drive on the new Time Capsule?

    Check item #18 of Time Machine FAQ, particularly the material in #3 of the "How to" section.
    By the way, you've been misled by poor field labeling on this forum into typing a large part of your message into the field intended for the subject.  In the future just type a short summary of your post into that field and type the whole message into the field below that.

  • HR-ABAP.How to Find the Employees assigned to the Appraisal Template

    Hi ,
    Please help me out.how to find the employees assigned to the Appraisal template.
    Ex. 7825232 is a appraisal template id and i want to know in the system how many employees assigned to it..
    Please let me know if the post is missing something.
    Suggestion also appreciated ...
    Thanks Inadvance!
    Law.

    check this fm HRHAP_DOCUMENT_GET_LIST_XXL
    Thanks
    Bala Duvvuri

  • What is the easiest way to get the data from the mailmerge to form Pages files that can be saved separately?

    Using Iwork 09 I have spent several hours setting up a mail merge from a spread sheet in Numbers to create receipts for my customers from a Pages template.
    After the merge I am left with one long Pages document that will not save as separate files; one per customer, it will only save the whole document of several receipts.
    What is the easiest way to get the data from the mailmerge to form Pages files that can be saved separately?
    Many thanks in advance.
    Richard

    Mr. Clark,
    You will probably be more pleased with the iWork apps when you begin to learn your way around. Until you learn such basic things as how to print only one page of a document, you will probably continue to be disappointed.
    Does your Print dialog look like this:
    Or like this:
    If it looks like the first one, then you will want to click this expander control:
    Regards,
    Jerry

  • F4IF_INT_TABLE_VALUE_REQUEST - how can I return all values from the line?

    Hi,
    I'm using FM F4IF_INT_TABLE_VALUE_REQUEST to show a pop-up with my internal table values.  The internal table has 3 fields, ATINN, ATZHL and a description field ATWTB.  ATINN and ATZHL are needed to complete the unique table key, however this FM will only return the value of one field in any line I select.
    How can I see all the values in the line I select in the return table?
    My code is as follows:
      DATA: tbl_cawnt LIKE cawnt OCCURS 0,
            wa_cawnt LIKE cawnt,
            BEGIN OF tbl_list OCCURS 0,
              atinn LIKE cawnt-atinn,
              atzhl LIKE cawnt-atzhl,
              atwtb LIKE cawnt-atwtb,
            END OF tbl_list,
            wa_list LIKE tbl_list,
            tbl_return LIKE ddshretval OCCURS 0,
            wa_return LIKE ddshretval,
            tbl_fields LIKE dfies OCCURS 0,
            tbl_dynp LIKE dselc OCCURS 0.
      REFRESH: tbl_list, tbl_cawnt.
      SELECT atinn atzhl atwtb
        FROM cawnt
        INTO CORRESPONDING FIELDS OF TABLE tbl_cawnt
        WHERE spras EQ sy-langu.
      LOOP AT tbl_cawnt INTO wa_cawnt.
        CLEAR wa_list.
        MOVE: wa_cawnt-atwtb TO wa_list-atwtb,
              wa_cawnt-atinn TO wa_list-atinn,
              wa_cawnt-atzhl TO wa_list-atzhl.
        APPEND wa_list TO tbl_list.
      ENDLOOP.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'ATWTB'
          dynpprog        = sy-repid
          dynpnr          = sy-dynnr
          value_org       = 'S'
        TABLES
          value_tab       = tbl_list
          return_tab      = tbl_return
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Thanks!

    Hi,
      Use the structure DYNPFLD_MAPPING
    With this internal table you can easily define that you want to return
    other columns of the hit list in addition to field RETFIELD to the
    screen.
    In this IT you can MAP the screen fields to the serch help screen fields this has three fields
    FLDNAME this is the field anme from the search help
    FLDINH This has to be blank which would be field with the field value that you want to map
    DYFLDNAME THis is the screen field name.
    So here you can get the values for the other fields that you want which are on the search help just populate the name of the fields in FLDNAME.
    Regards,
    Himanshu

  • Function module to get name of the employee

    hi friends
      I am working in HCM workflows. Is there any function module which gives the name of the employee when i pass pernr and userid.
    Regards
    vijay

    hi,
    use HR_READ_INFOTYPE on infotype 0002
    CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr           = p_pa0002-pernr  -----------> your pernr
          infty           = '0002'
        TABLES
          infty_tab       = t_pa0002
        EXCEPTIONS
          infty_not_found = 1.
    the fields
    INITS NACHN NAME2 NACH2 VORNA CNAME
    TITEL TITL2 NAMZU VORSW VORS2 RUFNM MIDNM
    KNZNM
    stores different parts of employee's name.
    you check your required one.
    Regards,
    Anirban

Maybe you are looking for

  • How do I share a 3G USB modem connected to my Macbook Pro with my Airport Express?

    Hi. I have a 3g USB modem connected to my macbook pro, and I want to try share the signal with my Airport Express (latest model). Now before everybody screams that it can't be done, I was searching the forums and found a discussion in which someone d

  • Using Safari on iPad Links Redirect

    My ipad is fairly new, Dec 31. I didn't have any problems at first. I don't know if the problem is apps or internet. When I try to click on links in Safari, sometimes it redirects. Not every single time, but enough to be a big problem. I click on nor

  • TS4079 none of that worked for me

    SIRI.... has a SIRI0ous problem!  This program is messed up.  It does NOT hear me.  My calls are fine. My mic is fine...I have wifi.  I have turned off phone reset it.... I rebooted, restored and screamed into it!  Nothing!!!!!  The screaming was onl

  • Adding fields to SHIPPING tab

    Hi All, I have a requirement to add a field VSART to the shipping tab on standard order create screen.  Any help how to achieve this? Thanks in advance. SMA

  • Updates/1.4.2 Download

    Hi, On the JRocket front page is a hyperlink to download JRockit 1.4.2. I followed the links and there isn't a download for this. Is this right? Will JRockit support RH 8/9/AES3 in the near future? i.e. in months... TIA, -Allen