Skip to Content

Creating an Upload for Infotype 25[Appraisals] in ABAP

Abap Developers,as you are no doubt aware that creating an upload for Infotype 25[Appraisals] is not as straight forward as it apparently looks. You cannot create an upload via the BDC recording route. So how do we manage that. For starters,this upload can be accomplished by a set of BAPI’s,which when used in conjunction with each other can provide the solution for creating the upload program.
Here is the list of BAPI’s that will be utilized in this context:
> BAPI_APPRAISAL_CREATE
> BAPI_APPRAISAL_GETDETAIL
> BAPI_APPRAISAL_CHANGE
> BAPI_APPRAISAL_STATUS_CHANGE

Apart from these BAPI’s,a couple of functions would be utilized for uploading the Tab delimited text file,using the File API in abap:
> WS_FILENAME_GET
> WS_UPLOAD

When you are creating an appraisal,you need to select an appraisal model,which has already been created by the HR consultants,using the transaction ‘OOAM‘[Appraisal Model Catalogue]. Appraisal Models are Models on which you base an appraisal[Each Appraisal Model is represented by a fixed id called Appraisal Model ID]  and it consists of ‘Criteria Group‘[For Group Category rating e.g: summing all sub-criterians] and ‘Criterion‘(also known as objectives are sub ratings for the given criteria group).
Appraisal Model Anatomy

01_Appraisal_Model_Terms.png

Note:

When ever a new appraisal entry is created in infotype 25[Appraisals],each appraisal for an employee is represented by a Unique 8 character ID,automatically generated at runtime[This ID is of Object type = ‘BA(Appraisal)‘]. This id is generated each time,where as the ID’s generated while creating the appraisal model are fixed for their lifetime[These ID’s include Appraisal Model ID’s(of Object type = ‘BS(Appraisal Model)‘),Criteria Group(of Object type = ‘BG(Criteria Group)‘) and Criterion or Objectives(of Object type = ‘BK(Criterion)‘)].

Appraisal Model ID’s as shown in the Appraisal screen in Infotype 25[Appraisals]
02_Appraisal_Model_ID's_in_IT0025.png
Appraisal ID – Autogenerated for each Appraisal at runtime
03_AppraisalID's[Autogenerated at runtime for each Appraisal].png

The Plan – Overview:

Step 01 – Create an Initial Entry for our Upload in IT25.

Step 02 – Extract Appraisal Model based on the Appraisal ID generated in the first step.

Step 03 – Utilizing Apppraisal Structure in creating the entries for ratings,on top of the initial entry created in Step 01.

Step 04 – Finally changing the status of the appraisal,in this case ‘COMPLETED

Overview of the Infotype 25 Appraisal Upload Plan
01_ThePlan-Overview.png

The Steps:

Step 01 – Creating an Initial Entry:

> Adding an Appraisee in Appraisees Table

     > Planversion = ’01’

     > Type(Appraisee)= ‘P’

     > ID = Employee Number of Employee who is to be appraised

> Adding an Appraiser in Appraisers Table

     > Planversion = ’01’

     > Type(Appraiser)= ‘P’

     > ID = Employee Number of Employee who is performing the appraisal for the given appraisee(Supervisor)

These entries are appended to respective internal tables and passsed in the BAPI named ‘BAPI_APPRAISAL_CREATE‘.

Note:

Both Appraisee and Appraiser Numbers are to be prvoided in the Flat Upload Text file.

  CALL FUNCTION ‘BAPI_APPRAISAL_CREATE

    EXPORTING

      plan_version             = ’01’ “Current Plan can also be used,or plan version could be provided in the file

      appraisal_model_id  = ‘50000770’”For Forced Ranking Method-ABAP”To be passed in case,multiple appraisal models are to be created

      start_date               =   t_start_date”to be provided in the file

      end_date                 =  t_end_date”to be provided in the file

     TEXT                     =     ‘Forced Ranking Method-ABAP’ “If we dont pass the text, an entry will not be created

     CREATION_DATE            = SY-DATUM “Current Date set as the creation date

*     ANONYMOUS                = ‘ ‘

*     NOCOMMIT                 =

   IMPORTING

     APPRAISAL_ID             = APPRAISAL_ID“Appraisal ID generated at the time of creation at runtime[Dynamically created at ID]

*     RETURN                   =

   TABLES

     APPRAISERS               = it_APPRAISERS“One entry for each Appraisal.For Multiple entries can also be passed for more than one supervisor

     APPRAISEES               = it_APPRAISEES“For Employee who is to be appraised

            .

Note:

> Appraisal_ID is autogenerated at runtime,when this BAPI ‘BAPI_APPRAISAL_CREATE‘ is used.

> For in depth look at the entire code see the section titled  ‘Source Code for Utilizing the Upload program for a Single Appraisal Model[In this Case ‘For Forced Ranking Method-ABAP’]’.

Step 02 – Extract the Appraisal Model  with Ratings:

> Now use the BAPI named

     ‘BAPI_APPRAISAL_GETDETAIL

to extract the entire contents of the appraisal model in context,including its ratings and the appraisal model structure in its entirety. Since the Bapi in step 01 has only created a Basic Appraisal Entry based on the following parameters:

Appraisal Dates(Both Start and End Dates),Appraisee,Appraiser,Appraisal_Model_ID,Plan Version,Appraisal Model Text.

This BAPI(BAPI_APPRAISAL_GETDETAIL) is normally used for reporting purposes,but it is used here to also extract the strutcure for that particular employee. This structure is extracted in the Appraisal Data Internal table(it_appraisal_data),which would be used later on in step 03.

      “Extract details of the created appraisal,based on the auto generated Appraisal ID

      CALL FUNCTION ‘BAPI_APPRAISAL_GETDETAIL

        EXPORTING

          plan_version         = ’01’

          appraisal_id         = APPRAISAL_ID

*       IMPORTING

*         APPRAISAL            =

*         RETURN               =

       TABLES

         APPRAISERS           = it_appraisers

         APPRAISEES           = it_appraisees

         APPRAISAL_DATA       = it_appraisal_dataInternal Table that will be used as a structure for passing in Rating values from the flat upload text file

Note:
> For in depth look at the entire code see the section titled ‘Source Code for Utilizing the Upload program for a Single Appraisal Model[In this Case ‘For Forced Ranking Method-ABAP’]’.

Step 03 – Updating Ratings in the Appraisal Model Data:

> Now use the BAPI named

     ‘BAPI_APPRAISAL_CHANGE

to supply the ratings,missing in step 01. But before using this bapi,the appraisal table extracted in step 02,must first be repopulated with ratings and then finally modifying its content and passing the appraisal internal table to this BAPI.

“Code Snippet for Modifying the appraisal Internal Table – [START]


LOOP AT it_appraisal_data into wa_appraisal_data.

“Each Rating has an Object ID which can easily be viewed in IT0025[Appraisal] by going to the menu path:

          “View > Keyon


  “1. Performance against Job Objectives/KPI – Ratings

    if wa_appraisal_data-element_id = ‘50000773‘.”1.1 Objective # 1

         wa_appraisal_data-rating = wa_0025-rating1_1.

         wa_appraisal_data-not_rated = ”.

    elseif wa_appraisal_data-element_id = ‘50000774‘.”1.2 Objective # 2

         wa_appraisal_data-rating = wa_0025-rating1_2.

         wa_appraisal_data-not_rated = ”.

Note:

If wa_appraisal_data-not_rated is not set to ,that particular rating would not be counted,even if the rating is provided in the flat file.

……….[code discarded for brevity]

……….[code discarded for brevity]


“Automatically calculated ratings

    elseif wa_appraisal_data-element_id = ‘50000771‘.”[1. Performance against Job Objectives] [Average]

***      wa_appraisal_data-rating = ‘1.000’.

         wa_appraisal_data-not_rated = ”.

         wa_appraisal_data-rating =

                                    ( wa_0025-rating1_1 +

                                    wa_0025-rating1_2 +

                                    wa_0025-rating1_3 +

                                    wa_0025-rating1_4 +

                                    wa_0025-rating1_5 +

                                    wa_0025-rating1_6 +

                                    wa_0025-rating1_7 +

                                    wa_0025-rating1_8 +

                                    wa_0025-rating1_9 +

                                    wa_0025-rating1_10 ) / 10.

         rating1_average = wa_appraisal_data-rating.

    elseif wa_appraisal_data-element_id = ‘50000772‘.”[2. behavioural Skills] [Average]

***      wa_appraisal_data-rating = ‘1.000’.

         wa_appraisal_data-not_rated = ”.

         wa_appraisal_data-rating =

                                    ( wa_0025-rating2_1 +

                                    wa_0025-rating2_2 +

                                    wa_0025-rating2_3 +

                                    wa_0025-rating2_4 +

                                    wa_0025-rating2_5 +

                                    wa_0025-rating2_6 +

                                    wa_0025-rating2_7 +

                                    wa_0025-rating2_8 +

                                    wa_0025-rating2_9 +

                                    wa_0025-rating2_10 ) / 10.

        rating2_average = wa_appraisal_data-rating.

    elseif ( wa_appraisal_data-element_id = ‘50000770’).”[Force ranking Method – ABAP] [Total= 50000772 rating + 50000771 rating ]

         wa_appraisal_data-not_rated = ”.

      wa_appraisal_data-rating = rating3.

    endif.

         rating3 = ( rating1_average + rating2_average ).

       modify it_appraisal_data from wa_appraisal_data.

       at last.

           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = ‘50000770’.

           IF sy-subrc = 0.

***                    wa_appraisal_data-element_id = ‘50000770’.”[Force ranking Method – ABAP]

***                    wa_appraisal_data-not_rated = ”.

                    wa_appraisal_data-rating = rating3.

                    modify it_appraisal_data from wa_appraisal_data index 1.

           ENDIF.

       endat.

  ENDLOOP.

“Code Snippet for Modifying the appraisal Internal Table – [END]


CALL FUNCTION ‘BAPI_APPRAISAL_CHANGE

  EXPORTING

    plan_version         = ’01’

    appraisal_id         = appraisal_id“Auto generated Appraisal ID generated in step 01

   TEXT                 = ‘Forced Ranking Method-ABAP’

   CREATION_DATE       = sy-datum

*   ANONYMOUS            = ‘ ‘

   NOCOMMIT             = ””Should be set to ”,for changing the entry

*** IMPORTING

***   RETURN               =

TABLES

   APPRAISERS           = it_appraisers

   APPRAISEES           = it_appraisees

   APPRAISAL_DATA       = it_appraisal_data “Re-passed,with ratings by looping through its contents,assigning ratings and modifying this from step 02

          .

The ratings calculated above are based on the operations provided by the criteria groups. Some Possible operations are Total, Average, Percentage,Without e.t.c.

Mathematical Operations applicable on Criteria Groups and Appraisal Models
04_Operations_provided_byCriteriaGroups_for_operating_on_criterions_or_Objectives.png

Note:
> For in depth look at the entire code see the section titled ‘Source Code for Utilizing the Upload program for a Single Appraisal Model[In this Case ‘For Forced Ranking Method-ABAP’]’.

Step 04 – Last but not the least,changing the appraisal Status:

In my scenario at NBP,i had to change the status to ‘COMPLETED’,after all previous steps have been completed. You use the BAPI:

     ‘BAPI_APPRAISAL_STATUS_CHANGE’

to change the status of an appraisal.

CALL FUNCTION ‘BAPI_APPRAISAL_STATUS_CHANGE

  EXPORTING

    plan_version       = ’01’

    appraisal_id       = appraisal_id

    status             = ‘03‘”Complete Status

***01    In Preparation

***02    In Process

***03    Completed

***04    Approved

***05    Rejected

   NOCOMMIT           = ”

IMPORTING

*   STATUS_TEXT        =

   RETURN             = return_status

          .

Note:
> For in depth look at the entire code see the section titled ‘Source Code for Utilizing the Upload program for a Single Appraisal Model[In this Case ‘For Forced Ranking Method-ABAP’]’.

More Ideas about the Upload Program:

> For dynamic Appraisal Uploads,you can pass in the appraisal model ID’s along with criteria group and criterion ID’s. This way the upload program can be        catered for different Appraisal Models. But each Appraisal Model would be different and would require it’s own Data Upload File.

> Using the BAPI : BAPI_APPRAISAL_GETDETAIL

you can get a dynamic view of the appraisal model used for the particular employee’s,even if the same appraisal model is assigned to them but with different    Objectives for each employee.

> In this Program,one employee is appraised by one supervisor only,in order for multiple supervisor’s to appraise a single appraisee ,each line should be added in the upload file for each of the supervisor’s and they should be appended in the appraiser’s internal table  ‘it_appraisers‘.

Updates[version 2]:

> After transporting this upload program to QA,it has been observed that the appraisal model needs to be created from scratch on each client i.e. Dev,QAS,PRD e.t.c. Since appraisal model creation is a user end activity,and besides there is no transport mechanism through which we can transport the appraisal model to another client as it is. Secondly,replication of an appraisal model in another client generates unique Object ID’s for each model,criteriagroup and criterias(or objectives). Keeping this in mind the upload now takes the object id for each rating as well,so that it can be uploaded on any client. Also see the heading ‘Source Code for Utilizing the Upload program for a Single Appraisal Model[In this Case ‘For Forced Ranking Method-ABAP’] – Version 02′ for changes in source code.

> I had already created a BADI called ‘HRPDV00APPRAISAL0003’ for standard Infotype 25(Appraisals). The Badi and any error checks won’t work in this upload program, as this upload program is Back-end one and not a front end Upload program for example as created via BDC Recording. You will need to re-implement any checks within this upload,lets say create a Log file of any error or omissions for Appraisal while creating an entry in infotype 25(Appraisals).

Extras:

> How to delete an Appraisal Entry,if its status is ‘completed’?:

When ever you try to delete an entry in appraisal infotype with status ‘Completed’,and when you save it,it will not delete that entry and show up a pop-up menu with the message ‘Appraisal “[Appraisal Model Name]” cannot be edited anymore’ as shown in the screen shot given below:

Deleting an Appraisal entry in Infotype 0025(Appraisals)
05a_Deleting_an_appraisal_entry_with_status_completed.png

As you can see,we are unable to delete an appraisal entry. So,to be able to delete an appraisal entry with the Completed status,we will need to open up the appraisal model creation transaction called ‘S_AHR_61003969’(Edit Appraisals Catalog). Now double click on the appraisal model for which you want to allow the deletion of an entry. In the change appraisal Pop-up,choose the ‘Processing’ tab and select ‘Reset and delete‘,to allow deletion of an appraisal entry for the given appraisal model with the status ‘COMPLETED‘,as shown below:

Changing the Appraisal Model Settings,to allow deletion of an Appraisal entry with ‘completed’ status
05b_Changing_Settings_in_Appraisal_model_to_allow_deletion_of_appraisal_entry.png

After setting this, when you go back to infotype 25 and delete that entry and save it,it will allow the deletion as show below:

Appraisal Entry can now be deleted with status Completed
05c_Appraisal_entry_with_completed_status_deleted.png

Source Code for Utilizing the Upload program for a Single Appraisal Model[In this Case ‘For Forced Ranking Method-ABAP’]

*&———————————————————————*
*& Report  ZFJ_HR_PD_IT0025_UPLOAD
*&
*&———————————————————————*
*&  Developer = Fahad Javed
*&  Module = Human Resource(HR)
*&  Sub-Module = Personnel Development(PD)
*&  Development Type = Upload[based on BAPI’s not BDC recording]
*&  Upload For = Infotype 0025[Appraisals]
*&  Description =  HR upload for uploading data for Force
*&                 Ranking curve method – ABAP
*&  Completed on = 20th September 2012
*&  Transaction Code = “ZIT25_UPL”
*&———————————————————————*
REPORT  ZFJ_HR_PD_IT0025_UPLOAD.
“For creation of Appraisals based on the provided appraisal Model
“BAPI used = BAPI_APPRAISAL_CREATE
“Note:
“—–
“This BAPI will create an initial entry with basics such as:
“> Appraisee
“> Appraiser(s)
“> Appraisal Model ID
“> Entry created with the Appraisal Status of = ‘In Process’
TYPES :
      begin of st_0025,
        “Appraisal Creation – [START]
***         PLAN_VERSION type c length 2,”Hard coded to ’01’ as it is used by NBP
***         app_model_id type n length 8,”Hardcoded to 50000770 as only created for appraisal model
***         app_model_id type BAPIAPPMODEL-ID,
***         app_model_id type c length 8,
***         app_model_text type c LENGTH 40,
***         start_date type BAPIPERIODAPP-start_date,
         start_date type c length 10,
***         end_date type BAPIPERIODAPP-end_date,
         end_date type c length 10,
         appraisee_id type c length 45,
         appraiser_id type c length 45,
        “Appraisal Creation – [END]
        “Appraisal Ratings – Updation – [START]
        “1. Performance against Job Objectives/KPI – Ratings
        rating1_1 type n length 19,”1.1 Objective # 1
        rating1_2 type n length 19,”1.2 Objective # 2
        rating1_3 type n length 19,”1.3 Objective # 3
        rating1_4 type n length 19,”1.4 Objective # 4
        rating1_5 type n length 19,”1.5 Objective # 5
        rating1_6 type n length 19,”1.6 Objective # 6
        rating1_7 type n length 19,”1.7 Objective # 7
        rating1_8 type n length 19,”1.8 Objective # 8
        rating1_9 type n length 19,”1.9 Objective # 9
        rating1_10 type n length 19,”1.10 Objective # 10
        “2. Behavioural Skills – Ratings
***        rating2_0 type c length 19,”2. Behavioural Skills
        rating2_1 type n LENGTH 19,”2.1 Job Knowledge
        rating2_2 type n LENGTH 19,”2.2 Communication Skills
        rating2_3 type n LENGTH 19,”2.3 Attitude, Behavior & Response to Control
        rating2_4 type n LENGTH 19,”2.4 Initiative
        rating2_5 type n LENGTH 19,”2.5 Attendance & Punctuality
        rating2_6 type n LENGTH 19,”2.6 Commitment to Job & Organization
        rating2_7 type n LENGTH 19,”2.7 Team work
        rating2_8 type n LENGTH 19,”2.8 Analytical ability
        rating2_9 type n LENGTH 19,”2.9 Development of subordinates
        rating2_10 type n LENGTH 19,”2.10 Personal appearance and grooming
        “3. Ranking by Supervisor
        rating3 type c LENGTH 19,
        “Appraisal Ratings – Updation – [END]
***        app_status type n length 2,
      end of st_0025.
“temporary variables for datatype conversion
DATA:
      t_start_date type BAPIPERIODAPP-start_date,
      t_end_date type BAPIPERIODAPP-end_date,
      rating1_average type BAPIAPPDATA-rating,”1. Performance against Job Objectives/KPI[ID = 50000771]
      rating2_average type BAPIAPPDATA-rating,”2. Behavioural Skills
      rating3 type BAPIAPPDATA-rating”Forced Ranking Method-ABAP”rating3 = rating1_average + rating2_average
      .
***         end_date type BAPIPERIODAPP-end_date,
“Final Processed Internal Table
DATA :
      it_0025 type standard table of st_0025,
***      it_0025 type STANDARD TABLE OF st_0025,
      wa_0025 like line of it_0025.
DATA:
      APPRAISAL_ID type BAPIAPPRAISAL-ID,”For Extraction of appraisal ID generated at runtime
                                         “FOR further processing
      return_status like BAPIRETURN1.”Returns a message with the success or failure of
                                     “the appraisal status change
DATA:
      it_appraisers type STANDARD TABLE OF BAPIAPPRAISER,”Pass in the Appraisers Data[Employee who has been appraised]
      wa_appraisers like line OF it_appraisers,”
      it_APPRAISEES type standard table of BAPIAPPRAISEE, “Pass in the Appraisees Data[Supervisor who has carried out the appraisal]
      wa_APPRAISEES like line of it_appraisees, “
      it_appraisal_data type standard table of BAPIAPPDATA,”Holds the Appraisals Data,containing the rating
      wa_appraisal_data like line of it_appraisal_data”
      .
SELECTION-SCREEN: BEGIN OF BLOCK a WITH FRAME TITLE title.
    PARAMETERS :filename LIKE rlgrap-filename
    DEFAULT ‘c:\Desktop\test1.txt’.
SELECTION-SCREEN: END OF BLOCK a.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
  CALL FUNCTION ‘WS_FILENAME_GET’
    EXPORTING
      def_path         = ‘c:\ ‘
      mask             = ‘*.*,*.*.’
      mode             = ‘O’
      title            = ‘Select File’
    IMPORTING
      filename         = filename
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.
  IF sy-subrc NE 0.
**    filename = sy-subrc.
  ENDIF.
START-OF-SELECTION.
    CALL FUNCTION ‘WS_UPLOAD’
     EXPORTING
*   CODEPAGE                      = ‘IBM’
       filename                      = filename
       filetype                      = ‘DAT’
*   HEADLEN                       = ‘ ‘
*   LINE_EXIT                     = ‘ ‘
*   TRUNCLEN                      = ‘ ‘
*   USER_FORM                     = ‘ ‘
*   USER_PROG                     = ‘ ‘
*   DAT_D_FORMAT                  = ‘ ‘
* IMPORTING
*   FILELENGTH                    =
      TABLES
        data_tab                      = it_0025
     EXCEPTIONS
       conversion_error              = 1
       file_open_error               = 2
       file_read_error               = 3
       invalid_type                  = 4
       no_batch                      = 5
       unknown_error                 = 6
       invalid_table_width           = 7
       gui_refuse_filetransfer       = 8
       customer_error                = 9
       no_authority                  = 10
       OTHERS                        = 11
              .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
END-OF-SELECTION.
Loop at it_0025 into wa_0025.
  “______Appraisal Creation – [START]
  “Sample Data Population for Appraisers
  wa_appraisers-plan_version = ’01’.
***  wa_appraisers-plan_version = wa_0025-plan_version.
*  **wa_appraisers-plan_version = ’01’.
  wa_appraisers-type = ‘P’.
  wa_appraisers-ID = wa_0025-APPRAISER_ID.
*  **wa_appraisers-ID = ‘00000001’.
*  **wa_appraisers-name = ”.”Name of the employee,would overwrite the name of the employee who has to be appraised
  append wa_appraisers to it_appraisers.
  clear wa_appraisers.
  “Sample Data populatin for Appraisees
  wa_appraisees-plan_version = ’01’.
***  wa_appraisees-plan_version = wa_0025-plan_version.
*  **wa_appraisees-plan_version = ’01’.
  wa_appraisees-type = ‘P’.
  wa_appraisees-ID = wa_0025-appraisee_id.
*  **wa_appraisees-ID = ‘00000340’.
*  **wa_appraisees-name = ”.”Name of the employee,would overwrite the name of the supervisor who has to be appraised
  append wa_appraisees to it_appraisees.
  clear wa_appraisees.
“For Conversion of date from character type to date type to avoid exception in the BAPI
t_start_date = wa_0025-start_date.
t_end_date = wa_0025-end_date.
  CALL FUNCTION ‘BAPI_APPRAISAL_CREATE’
    EXPORTING
      plan_version             = ’01’
***      plan_version             = wa_0025-PLAN_VERSION
*  **    plan_version             = ’01’
      appraisal_model_id       = ‘50000770’”For Forced Ranking Method-ABAP
***      appraisal_model_id       = wa_0025-app_model_id”For Forced Ranking Method-ABAP
***      appraisal_model_id       = ‘50000770’”For Forced Ranking Method-ABAP
      start_date               = t_start_date”to be provided in the file
***    start_date               = ‘20120912’”to be provided in the file
      end_date                 = t_end_date”to be provided in the file
***    end_date                 = ‘20120912’”to be provided in the file
     TEXT                     = ‘Forced Ranking Method-ABAP'”If we dont pass the text,
***     TEXT                     = wa_0025-app_model_text”If we dont pass the text,
***     TEXT                     = ‘Forced Ranking Method-ABAP'”If we dont pass the text,
                                                            “an entry will not be created
     CREATION_DATE            = SY-DATUM
*     ANONYMOUS                = ‘ ‘
*     NOCOMMIT                 =
   IMPORTING
     APPRAISAL_ID             = APPRAISAL_ID”Appraisal ID generated at the time of creation at runtime[Dynamically created at ID]
*     RETURN                   =
   TABLES
     APPRAISERS               = it_APPRAISERS”One entry for each Appraisal.For Multiple entries confirm
     APPRAISEES               = it_APPRAISEES”For Employee who is to be appraised
            .
    IF sy-subrc = 0.
      “Extract details of the created appraisal,based on the auto generated Appraisal ID
      CALL FUNCTION ‘BAPI_APPRAISAL_GETDETAIL’
        EXPORTING
          plan_version         = ’01’
***          plan_version         = wa_0025-PLAN_VERSION
          appraisal_id         = APPRAISAL_ID
*       IMPORTING
*         APPRAISAL            =
*         RETURN               =
       TABLES
         APPRAISERS           = it_appraisers
         APPRAISEES           = it_appraisees
         APPRAISAL_DATA       = it_appraisal_data
                .
“______Change or Update Appraisal – [START]
“For updation of Appraisals based on the provided appraisal Model
“BAPI used = BAPI_APPRAISAL_CHANGE
“Note:
“—–
“This BAPI will change entry with basics such as:
“> Plan Version
“> Appraisel ID
“> Text
“> Creation Date
“> Pass in the Same data for Appraisers and Appraisees tables here
“> Pass in a new table ‘APPRAISAL_DATA’ with all the ratings provided in the
”  appraisal model by looping throgh the existing Upload internal table
”  named ‘IT_0025’
“> Appraisal_data structure
***COUNTER”Counter
***ELEMENT_TYPE “Object Type – Appraisal Element
***ELEMENT_ID “Object ID – Appraisal Element
***ELEMENT_TEXT “Numbering + Text – Appraisal Element
***WEIGHTING “Weighting
***RATING “Rating of an Appraisal Element
***RATING_TEXT “Rating text of an appraisal element
***NOT_RATED “Flag: Without Rating
***INPUT_TYPE “Flag: Type of input option for appraisal result
***PARENT “Reference to Counter of Parent
“Modify the appraisal data Internal Table with the Ratings – [START]
LOOP AT it_appraisal_data into wa_appraisal_data.
  “1. Performance against Job Objectives/KPI – Ratings
    if wa_appraisal_data-element_id = ‘50000773’.”1.1 Objective # 1
         wa_appraisal_data-rating = wa_0025-rating1_1.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000774’.”1.2 Objective # 2
         wa_appraisal_data-rating = wa_0025-rating1_2.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000775’.”1.3 Objective # 3
         wa_appraisal_data-rating = wa_0025-rating1_3.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000776’.”1.4 Objective # 4
         wa_appraisal_data-rating = wa_0025-rating1_4.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000777’.”1.5 Objective # 5
         wa_appraisal_data-rating = wa_0025-rating1_5.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50002525’.”1.6 Objective # 6
         wa_appraisal_data-rating = wa_0025-rating1_6.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50002526’.”1.7 Objective # 7
         wa_appraisal_data-rating = wa_0025-rating1_7.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50002527’.”1.8 Objective # 8
         wa_appraisal_data-rating = wa_0025-rating1_8.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50002528’.”1.9 Objective # 9
         wa_appraisal_data-rating = wa_0025-rating1_9.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50002529’.”1.10 Objective # 10
         wa_appraisal_data-rating = wa_0025-rating1_10.
         wa_appraisal_data-not_rated = ”.
          “2. Behavioural Skills – Ratings
    elseif wa_appraisal_data-element_id = ‘50000778’.”2.1 Job Knowledge
       wa_appraisal_data-rating = wa_0025-rating2_1.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000779’.”2.2 Communication Skills
       wa_appraisal_data-rating = wa_0025-rating2_2.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000780’.”2.3 Attitude, Behavior & Response to Control
       wa_appraisal_data-rating = wa_0025-rating2_3.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000781’.”2.4 Initiative
       wa_appraisal_data-rating = wa_0025-rating2_4.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000782’.”2.5 Attendance & Punctuality
       wa_appraisal_data-rating = wa_0025-rating2_5.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000783’.”2.6 Commitment to Job & Organization
       wa_appraisal_data-rating = wa_0025-rating2_6.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000784’.”2.7 Team work
       wa_appraisal_data-rating = wa_0025-rating2_7.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000785’.”2.8 Analytical ability
       wa_appraisal_data-rating = wa_0025-rating2_8.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000786’.”2.9 Development of subordinates
       wa_appraisal_data-rating = wa_0025-rating2_9.
         wa_appraisal_data-not_rated = ”.
    elseif wa_appraisal_data-element_id = ‘50000787’.”2.10 Personal appearance and grooming
       wa_appraisal_data-rating = wa_0025-rating2_10.
         wa_appraisal_data-not_rated = ”.
          “3. Ranking by Supervisor
    elseif wa_appraisal_data-element_id = ‘50002522’.”2.10 Personal appearance and grooming
       wa_appraisal_data-rating = wa_0025-rating3.
         wa_appraisal_data-not_rated = ”.
“Automatically calculated ratings
    elseif wa_appraisal_data-element_id = ‘50000771’.”[1. Performance against Job Objectives]
***      wa_appraisal_data-rating = ‘1.000’.
         wa_appraisal_data-not_rated = ”.
         wa_appraisal_data-rating =
                                    ( wa_0025-rating1_1 +
                                    wa_0025-rating1_2 +
                                    wa_0025-rating1_3 +
                                    wa_0025-rating1_4 +
                                    wa_0025-rating1_5 +
                                    wa_0025-rating1_6 +
                                    wa_0025-rating1_7 +
                                    wa_0025-rating1_8 +
                                    wa_0025-rating1_9 +
                                    wa_0025-rating1_10 ) / 10.
         rating1_average = wa_appraisal_data-rating.
    elseif wa_appraisal_data-element_id = ‘50000772’.”[2. behavioural Skills]
***      wa_appraisal_data-rating = ‘1.000’.
         wa_appraisal_data-not_rated = ”.
         wa_appraisal_data-rating =
                                    ( wa_0025-rating2_1 +
                                    wa_0025-rating2_2 +
                                    wa_0025-rating2_3 +
                                    wa_0025-rating2_4 +
                                    wa_0025-rating2_5 +
                                    wa_0025-rating2_6 +
                                    wa_0025-rating2_7 +
                                    wa_0025-rating2_8 +
                                    wa_0025-rating2_9 +
                                    wa_0025-rating2_10 ) / 10.
        rating2_average = wa_appraisal_data-rating.
    elseif ( wa_appraisal_data-element_id = ‘50000770’).”[Force ranking Method – ABAP]
         wa_appraisal_data-not_rated = ”.
      wa_appraisal_data-rating = rating3.
“Note:
“—–
“Not_rated must be set to ”,otherwise it won’t cound the rating values provided
    endif.
         rating3 = ( rating1_average + rating2_average ).
       modify it_appraisal_data from wa_appraisal_data.
       at last.
           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = ‘50000770’.
           IF sy-subrc = 0.
***                    wa_appraisal_data-element_id = ‘50000770’.”[Force ranking Method – ABAP]
***                    wa_appraisal_data-not_rated = ”.
                    wa_appraisal_data-rating = rating3.
                    modify it_appraisal_data from wa_appraisal_data index 1.
           ENDIF.
       endat.
  ENDLOOP.
“Modify the appraisal data Internal Table with the Ratings – [END]
CALL FUNCTION ‘BAPI_APPRAISAL_CHANGE’
  EXPORTING
    plan_version         = ’01’
***    plan_version         = wa_0025-PLAN_VERSION
***    plan_version         = wa_0025-PLAN_VERSION
    appraisal_id         = appraisal_id
***    appraisal_id         = ‘50002856’
   TEXT                 = ‘Forced Ranking Method-ABAP’
***   TEXT                 = wa_0025-app_model_text
***   TEXT                 = ‘changed’
   CREATION_DATE       = sy-datum
*   ANONYMOUS            = ‘ ‘
   NOCOMMIT             = ””Should be set to ”,for changing the entry
*** IMPORTING
***   RETURN               =
TABLES
   APPRAISERS           = it_appraisers
   APPRAISEES           = it_appraisees
   APPRAISAL_DATA       = it_appraisal_data
          .
“______Change or Update Appraisal – [END]
“______Set Appraisal Status – [START]
break abapdev.
CALL FUNCTION ‘BAPI_APPRAISAL_STATUS_CHANGE’
  EXPORTING
    plan_version       = ’01’
***    plan_version       = wa_0025-PLAN_VERSION
    appraisal_id       = appraisal_id
    status             = ’03′”Complete Status
***    status             = wa_0025-app_status
***01    In Preparation
***02    In Process
***03    Completed
***04    Approved
***05    Rejected
   NOCOMMIT           = ”
IMPORTING
*   STATUS_TEXT        =
   RETURN             = return_status
          .
“______Set Appraisal Status – [END]
***        MESSAGE ‘Appraisal Created Successfully’ type ‘I’.
    ENDIF.
“______Appraisal Creation – [END]
    refresh : it_appraisers,it_appraisees.
    clear : wa_appraisees,wa_appraisers.
    clear : t_start_date,t_end_date,rating1_average,rating2_average,rating3.
ENDLOOP.
***write : appraisal_id.
****break abapdev.
“______Change or Update Appraisal – [END]
INITIALIZATION.
  title = ‘Upload File Selection’.
Source Code for Utilizing the Upload program for a Single Appraisal Model[In this Case ‘For Forced Ranking Method-ABAP’] – Version 02

   *&———————————————————————*
*& Report  ZFJ_HR_PD_IT0025_UPLOAD
*&
*&———————————————————————*
*&  Developer = Fahad Javed
*&  Module = Human Resource(HR)
*&  Sub-Module = Personnel Development(PD)
*&  Development Type = Upload[based on BAPI’s not BDC recording]
*&  Upload For = Infotype 0025[Appraisals]
*&  Description =  HR upload for uploading data for Force
*&                 Ranking curve method – ABAP
*&  Completed on = 20th September 2012
*&  version 2 = Updated on 30th November 2012
*&  version 8 = Updated on 4th December 2012
*&  Transaction Code = “ZIT25_UPL”
*&———————————————————————*

REPORT  ZFJ_HR_PD_IT0025_UPLOAD.

“For creation of Appraisals based on the provided appraisal Model
“BAPI used = BAPI_APPRAISAL_CREATE
“Note:
“—–
“This BAPI will create an initial entry with basics such as:
“> Appraisee
“> Appraiser(s)
“> Appraisal Model ID
“> Entry created with the Appraisal Status of = ‘In Process’

TYPES :
      begin of st_0025,
        “Appraisal Creation – [START]
***         PLAN_VERSION type c length 2,”Hard coded to ’01’ as it is used by NBP
***         app_model_id type BAPIAPPMODEL-ID,
***         app_model_id type c length 8,
***         app_model_text type c LENGTH 40,
***         start_date type BAPIPERIODAPP-start_date,
         start_date type c length 10,
***         end_date type BAPIPERIODAPP-end_date,
         end_date type c length 10,
         app_model_id type n length 8,“Hardcoded to 50000770 as only created for appraisal model”Added on 30th November 2012
         app_model_text type BAPIAPPRAISAL-text,“Appraisal Model text
         appraisee_id type c length 45,
         appraiser_id type c length 45,

        “Appraisal Creation – [END]

        “Appraisal Ratings – Updation – [START]
        “1. Performance against Job Objectives/KPI – Ratings
        rating1_0_id TYPE n LENGTH 8,“1. Performance against Job Objectives/KPI_ID(Average of all objectives under this category is calculated)”Added on 30th November 2012

        rating1_1_id type n length 8,“1.1 Objective # 1 ID”Added on 30th November 2012
        rating1_1 type n length 19,“1.1 Objective # 1

        rating1_2_id type n length 8,“1.2 Objective # 2 ID”Added on 30th November 2012
        rating1_2 type n length 19,“1.2 Objective # 2

        rating1_3_id type n length 8,“1.3 Objective # 3 ID”Added on 30th November 2012
        rating1_3 type n length 19,“1.3 Objective # 3

        rating1_4_id type n length 8,“1.4 Objective # 4 ID”Added on 30th November 2012
        rating1_4 type n length 19,“1.4 Objective # 4

        rating1_5_id type n length 8,“1.5 Objective # 5 ID”Added on 30th November 2012
        rating1_5 type n length 19,“1.5 Objective # 5

        rating1_6_id type n length 8,“1.6 Objective # 6 ID”Added on 30th November 2012
        rating1_6 type n length 19,“1.6 Objective # 6

***        rating1_7_id type n length 8,”1.7 Objective # 7 ID”Added on 30th November 2012
***        rating1_7 type n length 19,”1.7 Objective # 7
***
***        rating1_8_id type n length 8,”1.8 Objective # 8 ID”Added on 30th November 2012
***        rating1_8 type n length 19,”1.8 Objective # 8
***
***        rating1_9_id type n length 8,”1.9 Objective # 9 ID”Added on 30th November 2012
***        rating1_9 type n length 19,”1.9 Objective # 9
***
***        rating1_10_id type n length 8,”1.10 Objective # 10 ID”Added on 30th November 2012
***        rating1_10 type n length 19,”1.10 Objective # 10

        “2. Behavioural Skills – Ratings
***        rating2_0 type c length 19,”2. Behavioural Skills
        rating2_0_id TYPE n LENGTH 8,“2. Behavioural Skills – Ratings(Average of all objectives under this category is calculated)”Added on 30th November 2012

        rating2_1_id type n LENGTH 8,“2.1 Job Knowledge ID”Added on 30th November 2012
        rating2_1 type n LENGTH 19,“2.1 Job Knowledge

        rating2_2_id type n LENGTH 8,“2.2 Communication Skills ID”Added on 30th November 2012
        rating2_2 type n LENGTH 19,“2.2 Communication Skills

        rating2_3_id type n LENGTH 8,“2.3 Attitude, Behavior & Response to Control ID”Added on 30th November 2012
        rating2_3 type n LENGTH 19,“2.3 Attitude, Behavior & Response to Control

        rating2_4_id type n LENGTH 8,“2.4 Initiative ID”Added on 30th November 2012
        rating2_4 type n LENGTH 19,“2.4 Initiative

***        rating2_5_id type n LENGTH 8,”2.5 Attendance & Punctuality ID”Added on 30th November 2012
***        rating2_5 type n LENGTH 19,”2.5 Attendance & Punctuality
***
***        rating2_6_id type n LENGTH 8,”2.6 Commitment to Job & Organization ID”Added on 30th November 2012
***        rating2_6 type n LENGTH 19,”2.6 Commitment to Job & Organization
***
***        rating2_7_id type n LENGTH 8,”2.7 Team work ID”Added on 30th November 2012
***        rating2_7 type n LENGTH 19,”2.7 Team work
***
***        rating2_8_id type n LENGTH 8,”2.8 Analytical ability ID”Added on 30th November 2012
***        rating2_8 type n LENGTH 19,”2.8 Analytical ability
***
***        rating2_9_id type n LENGTH 8,”2.9 Development of subordinates ID”Added on 30th November 2012
***        rating2_9 type n LENGTH 19,”2.9 Development of subordinates
***
***        rating2_10_id type n LENGTH 8,”2.10 Personal appearance and grooming ID”Added on 30th November 2012
***        rating2_10 type n LENGTH 19,”2.10 Personal appearance and grooming

        “3. Ranking by Supervisor
        rating3_id type n LENGTH 8,“ID”Added on 30th November 2012
        rating3 type c LENGTH 19,“Score”Added on 30th November 2012

        “Appraisal Ratings – Updation – [END]

***        app_status type n length 2,
      end of st_0025.

“temporary variables for datatype conversion
DATA:
      t_start_date type BAPIPERIODAPP-start_date,
      t_end_date type BAPIPERIODAPP-end_date,
      rating1_average type BAPIAPPDATA-rating,“1. Performance against Job Objectives/KPI[ID = 50000771]
      rating2_average type BAPIAPPDATA-rating,“2. Behavioural Skills
      rating3 type BAPIAPPDATA-rating,“Forced Ranking Method-ABAP”rating3 = rating1_average + rating2_average

      “As added on 2nd December 2012 – [START]
      no_of_objectives type i,“For finding the number of objectives,based on a criteria group[Objectives are of appraisal type BK ]
      flag_criteria_group type c length 1,“Flag for Criteria group
      “As added on 2nd December 2012 – [END]

      “As added on 4th December 2012 – [START]
      ob_cg_counter type i,“Objectives counter(1 = Objectives/KPIs,2 = Behavioural Skills)
      no_of_objectives_cg1 type i,“1. Objectives/KPIs(all objectives,zero based ratings are not considered an objective)
      no_of_objectives_cg2 type i,“2. Behavioural Skills
      temp_index_cg1 type i,“”1. Objectives/KPIs(all objectives,zero based ratings are not considered an objective)(index for finally modifying it_appraisal_data)
      temp_index_cg2 type i“”2. Behavioural Skills(index for finally modifying it_appraisal_data)
      “As added on 4th December 2012 – [END]
      .
***         end_date type BAPIPERIODAPP-end_date,
“Final Processed Internal Table
DATA :
      it_0025 type standard table of st_0025,
***      it_0025 type STANDARD TABLE OF st_0025,
      wa_0025 like line of it_0025.

DATA:
      APPRAISAL_ID type BAPIAPPRAISAL-ID,“For Extraction of appraisal ID generated at runtime
                                         “FOR further processing

      return_status like BAPIRETURN1.“Returns a message with the success or failure of
                                     “the appraisal status change

DATA:
      it_appraisers type STANDARD TABLE OF BAPIAPPRAISER,“Pass in the Appraisers Data[Employee who has been appraised]
      wa_appraisers like line OF it_appraisers,
      it_APPRAISEES type standard table of BAPIAPPRAISEE, “Pass in the Appraisees Data[Supervisor who has carried out the appraisal]
      wa_APPRAISEES like line of it_appraisees,

      it_appraisal_data type standard table of BAPIAPPDATA,“Holds the Appraisals Data,containing the rating
      wa_appraisal_data like line of it_appraisal_data
      .

SELECTION-SCREEN: BEGIN OF BLOCK a WITH FRAME TITLE title.
    PARAMETERS :filename LIKE rlgrap-filename
    DEFAULT ‘c:\Desktop\test1.txt’.
SELECTION-SCREEN: END OF BLOCK a.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
  CALL FUNCTION ‘WS_FILENAME_GET’
    EXPORTING
      def_path         = ‘c:\ ‘
      mask             = ‘*.*,*.*.’
      mode             = ‘O’
      title            = ‘Select File’
    IMPORTING
      filename         = filename
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.
  IF sy-subrc NE 0.
**    filename = sy-subrc.
  ENDIF.

START-OF-SELECTION.

    CALL FUNCTION ‘WS_UPLOAD’
     EXPORTING
*   CODEPAGE                      = ‘IBM’
       filename                      = filename
       filetype                      = ‘DAT’
*   HEADLEN                       = ‘ ‘
*   LINE_EXIT                     = ‘ ‘
*   TRUNCLEN                      = ‘ ‘
*   USER_FORM                     = ‘ ‘
*   USER_PROG                     = ‘ ‘
*   DAT_D_FORMAT                  = ‘ ‘
* IMPORTING
*   FILELENGTH                    =
      TABLES
        data_tab                      = it_0025
     EXCEPTIONS
       conversion_error              = 1
       file_open_error               = 2
       file_read_error               = 3
       invalid_type                  = 4
       no_batch                      = 5
       unknown_error                 = 6
       invalid_table_width           = 7
       gui_refuse_filetransfer       = 8
       customer_error                = 9
       no_authority                  = 10
       OTHERS                        = 11
              .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

END-OF-SELECTION.

Loop at it_0025 into wa_0025.
  “______Appraisal Creation – [START]

  “Sample Data Population for Appraisers
  wa_appraisers-plan_version = ’01’.
***  wa_appraisers-plan_version = wa_0025-plan_version.
*  **wa_appraisers-plan_version = ’01’.
  wa_appraisers-type = ‘P’.
  wa_appraisers-ID = wa_0025-APPRAISER_ID.
*  **wa_appraisers-ID = ‘00000001’.
*  **wa_appraisers-name = ”.”Name of the employee,would overwrite the name of the employee who has to be appraised

  append wa_appraisers to it_appraisers.
  clear wa_appraisers.

  “Sample Data populatin for Appraisees
  wa_appraisees-plan_version = ’01’.
***  wa_appraisees-plan_version = wa_0025-plan_version.
*  **wa_appraisees-plan_version = ’01’.
  wa_appraisees-type = ‘P’.
  wa_appraisees-ID = wa_0025-appraisee_id.
*  **wa_appraisees-ID = ‘00000340’.
*  **wa_appraisees-name = ”.”Name of the employee,would overwrite the name of the supervisor who has to be appraised

  append wa_appraisees to it_appraisees.
  clear wa_appraisees.

“For Conversion of date from character type to date type to avoid exception in the BAPI
t_start_date = wa_0025-start_date.
t_end_date = wa_0025-end_date.

  CALL FUNCTION ‘BAPI_APPRAISAL_CREATE’
    EXPORTING
      plan_version             = ’01’
***      plan_version             = wa_0025-PLAN_VERSION
*  **    plan_version             = ’01’
      appraisal_model_id       = wa_0025-app_model_id“to be passed by the user based on the Appraisal Model used
***      appraisal_model_id       = ‘50000770’”For Forced Ranking Method-ABAP”Disabled on 30th November 2012,as id’s will be required for each client
***      appraisal_model_id       = wa_0025-app_model_id”For Forced Ranking Method-ABAP
***      appraisal_model_id       = ‘50000770’”For Forced Ranking Method-ABAP
      start_date               = t_start_date“to be provided in the file
***    start_date               = ‘20120912’”to be provided in the file
      end_date                 = t_end_date“to be provided in the file
***    end_date                 = ‘20120912’”to be provided in the file
     TEXT                     = wa_0025-app_model_text“If we dont pass the text,
***     TEXT                     = ‘Forced Ranking Method-ABAP'”If we dont pass the text,
***     TEXT                     = wa_0025-app_model_text”If we dont pass the text,
***     TEXT                     = ‘Forced Ranking Method-ABAP'”If we dont pass the text,
                                                            “an entry will not be created
     CREATION_DATE            = SY-DATUM
*     ANONYMOUS                = ‘ ‘
*     NOCOMMIT                 =
   IMPORTING
     APPRAISAL_ID             = APPRAISAL_ID“Appraisal ID generated at the time of creation at runtime[Dynamically created at ID]
*     RETURN                   =
   TABLES
     APPRAISERS               = it_APPRAISERS“One entry for each Appraisal.For Multiple entries confirm
     APPRAISEES               = it_APPRAISEES“For Employee who is to be appraised
            .

    IF sy-subrc = 0.
      “Extract details of the created appraisal,based on the auto generated Appraisal ID

      CALL FUNCTION ‘BAPI_APPRAISAL_GETDETAIL’
        EXPORTING
          plan_version         = ’01’
***          plan_version         = wa_0025-PLAN_VERSION
          appraisal_id         = APPRAISAL_ID
*       IMPORTING
*         APPRAISAL            =
*         RETURN               =
       TABLES
         APPRAISERS           = it_appraisers
         APPRAISEES           = it_appraisees
         APPRAISAL_DATA       = it_appraisal_data
                .

“______Change or Update Appraisal – [START]

“For updation of Appraisals based on the provided appraisal Model
“BAPI used = BAPI_APPRAISAL_CHANGE
“Note:
“—–
“This BAPI will change entry with basics such as:
“> Plan Version
“> Appraisel ID
“> Text
“> Creation Date
“> Pass in the Same data for Appraisers and Appraisees tables here
“> Pass in a new table ‘APPRAISAL_DATA’ with all the ratings provided in the
”  appraisal model by looping throgh the existing Upload internal table
”  named ‘IT_0025’
“> Appraisal_data structure

***COUNTER”Counter
***ELEMENT_TYPE “Object Type – Appraisal Element
***ELEMENT_ID “Object ID – Appraisal Element
***ELEMENT_TEXT “Numbering + Text – Appraisal Element
***WEIGHTING “Weighting
***RATING “Rating of an Appraisal Element
***RATING_TEXT “Rating text of an appraisal element
***NOT_RATED “Flag: Without Rating
***INPUT_TYPE “Flag: Type of input option for appraisal result
***PARENT “Reference to Counter of Parent

“Modify the appraisal data Internal Table with the Ratings – [START]
BREAK abapdev.
LOOP AT it_appraisal_data into wa_appraisal_data.

“As added on 2nd December 2012 – [START]
AT nEW ELEMENT_TYPE.
    IF wa_appraisal_data-Element_TYPE = ‘BG’.“Control Group

    “As added on 4th December 2012 – [START]
    if ob_cg_counter = 1.
      no_of_objectives_cg1 = no_of_objectives.
    ELSEIF ob_cg_counter = 2.
      no_of_objectives_cg2 = no_of_objectives.
    ELSEIF ob_cg_counter = 3.

    endif.
    “As added on 4th December 2012 – [END]

      ob_cg_counter = ob_cg_counter + 1.
***      clear current_criteria_Group_ID.
      flag_criteria_group = ‘X’.
      clear no_of_objectives.
***      current_criteria_Group_ID = wa_app_pt1045-app_objid.
    ENDIF.
endat.

“Iterative Code
      IF wa_appraisal_data-ELEMENT_TYPE = ‘BK’.“For Finding the Criteria Groups[Object type = ‘BG’] for the given control group
        no_of_objectives = no_of_objectives + 1.
        clear flag_criteria_group.
***        average_CG_ratings type n length 40″Creates the average of ratings divided by the no of objectives
      ENDIF.
“Iterative Code

“As added on 2nd December 2012 – [END]

  “1. Performance against Job Objectives/KPI – Ratings
    if wa_appraisal_data-element_id = wa_0025-rating1_1_id.“1.1 Objective # 1

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating1_1 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_1.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating1_1 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_1.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating1_2_id.“1.2 Objective # 2

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating1_2 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_2.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating1_2 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_2.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating1_3_id.“1.3 Objective # 3

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating1_3 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_3.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating1_3 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_3.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating1_4_id.“1.4 Objective # 4

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating1_4 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_4.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating1_4 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_4.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating1_5_id.“1.5 Objective # 5

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating1_5 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_5.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating1_5 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_5.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating1_6_id.“1.6 Objective # 6

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating1_6 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_6.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating1_6 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating1_6.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

          “2. Behavioural Skills – Ratings
    elseif wa_appraisal_data-element_id = wa_0025-rating2_1_id.“2.1 Job Knowledge

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating2_1 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_1.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating2_1 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_1.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating2_2_id.“2.2 Communication Skills

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating2_2 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_2.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating2_2 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_2.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating2_3_id.“2.3 Attitude, Behavior & Response to Control

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating2_3 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_3.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating2_3 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_3.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

    elseif wa_appraisal_data-element_id = wa_0025-rating2_4_id.“2.4 Initiative

        “Added as on 4th December 2012 – [START]
        if wa_0025-rating2_4 is INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_4.
           wa_appraisal_data-not_rated = ‘X’.
           no_of_objectives = no_of_objectives – 1.
        ELSEIF wa_0025-rating2_4 is not INITIAL.
           wa_appraisal_data-rating = wa_0025-rating2_4.
           wa_appraisal_data-not_rated = .
        endif.
         “Added as on 4th December 2012 – [END]

          “3. Ranking by Supervisor
    elseif wa_appraisal_data-element_id = wa_0025-rating3_id.“3.00 Personal appearance and grooming[Criteria Group rating 3[or category of rating]]
***    elseif wa_appraisal_data-element_id = ‘50002522’.”3.00 Personal appearance and grooming
       wa_appraisal_data-rating = wa_0025-rating3.
         wa_appraisal_data-not_rated = .

“Note:
“—–
“Not_rated must be set to ”,otherwise it won’t count the rating values provided

    endif.

       modify it_appraisal_data from wa_appraisal_data.“Modifies all ratings iteratively

       at last.
“1. Objectives/KPIs rating(average of all objectives) – [START]
           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = wa_0025-rating1_0_id.
***           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = ‘50000770’.
           IF sy-subrc = 0.
         temp_index_cg1 = wa_appraisal_data-counter.
         wa_appraisal_data-not_rated = .
         rating1_average =
                                    ( wa_0025-rating1_1 +
                                    wa_0025-rating1_2 +
                                    wa_0025-rating1_3 +
                                    wa_0025-rating1_4 +
                                    wa_0025-rating1_5 +
                                    wa_0025-rating1_6
***                                    wa_0025-rating1_7 +
***                                    wa_0025-rating1_8 +
***                                    wa_0025-rating1_9 +
***                                    wa_0025-rating1_10
                                    ) / no_of_objectives_cg1.“Added on 4th December 2012
***                                    ) / 6.
***         rating1_average = wa_appraisal_data-rating.

                    wa_appraisal_data-rating = rating1_average.
                    modify it_appraisal_data from wa_appraisal_data index temp_index_cg1.
***                    modify it_appraisal_data from wa_appraisal_data index 1.
           ENDIF.
“1. Objectives/KPIs rating(average of all objectives) – [END]

“2. Behavioural Skills – [START]
           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = wa_0025-rating2_0_id.
***           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = ‘50000770’.
           IF sy-subrc = 0.
         temp_index_cg2 = wa_appraisal_data-counter.
         wa_appraisal_data-not_rated = .
         rating2_average =
                                    ( wa_0025-rating2_1 +
                                    wa_0025-rating2_2 +
                                    wa_0025-rating2_3 +
                                    wa_0025-rating2_4
***                                    wa_0025-rating2_5 +
***                                    wa_0025-rating2_6 +
***                                    wa_0025-rating2_7 +
***                                    wa_0025-rating2_8 +
***                                    wa_0025-rating2_9 +
***                                    wa_0025-rating2_10

                                    ) / no_of_objectives_cg2.“Added on 4th December 2012
***         rating1_average = wa_appraisal_data-rating.

                    wa_appraisal_data-rating = rating2_average.
                    modify it_appraisal_data from wa_appraisal_data index temp_index_cg2.
***                    modify it_appraisal_data from wa_appraisal_data index 1.
           ENDIF.

“2. Behavioural Skills – [END]

          “Appraisal Rating – [START]
           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = wa_0025-app_model_id.
***           READ TABLE it_appraisal_data INTO wa_appraisal_data WITH KEY element_id = ‘50000770’.
           IF sy-subrc = 0.
                    wa_appraisal_data-not_rated = .
***                    wa_appraisal_data-element_id = ‘50000770’.”[Force ranking Method – ABAP]
***                    wa_appraisal_data-not_rated = ”.
                    rating3 = ( rating1_average + rating2_average ).

                    wa_appraisal_data-rating = rating3.
                    modify it_appraisal_data from wa_appraisal_data index 1.
           ENDIF.
          “Appraisal Rating – [END]
       endat.
  ENDLOOP.
“Modify the appraisal data Internal Table with the Ratings – [END]

CALL FUNCTION ‘BAPI_APPRAISAL_CHANGE’
  EXPORTING
    plan_version         = ’01’
***    plan_version         = wa_0025-PLAN_VERSION
***    plan_version         = wa_0025-PLAN_VERSION
    appraisal_id         = appraisal_id
***    appraisal_id         = ‘50002856’
   TEXT                 = wa_0025-app_model_text
***   TEXT                 = ‘Forced Ranking Method-ABAP’
***   TEXT                 = wa_0025-app_model_text
***   TEXT                 = ‘changed’
   CREATION_DATE       = sy-datum
*   ANONYMOUS            = ‘ ‘
   NOCOMMIT             = “Should be set to ”,for changing the entry
*** IMPORTING
***   RETURN               =
TABLES
   APPRAISERS           = it_appraisers
   APPRAISEES           = it_appraisees
   APPRAISAL_DATA       = it_appraisal_data
          .

“______Change or Update Appraisal – [END]

“______Set Appraisal Status – [START]
break abapdev.
CALL FUNCTION ‘BAPI_APPRAISAL_STATUS_CHANGE’
  EXPORTING
    plan_version       = ’01’
***    plan_version       = wa_0025-PLAN_VERSION
    appraisal_id       = appraisal_id
    status             = ’03’“Complete Status
***    status             = ’03′”Complete Status
***    status             = wa_0025-app_status
***01  In Preparation
***02  In Process
***03  Completed
***04  Approved
***05  Rejected

   NOCOMMIT           =
IMPORTING
*   STATUS_TEXT        =
   RETURN             = return_status
          .

“______Set Appraisal Status – [END]

***        MESSAGE ‘Appraisal Created Successfully’ type ‘I’.
    ENDIF.

“______Appraisal Creation – [END]

    refresh : it_appraisers,it_appraisees.
    clear : wa_appraisees,wa_appraisers.
    clear : t_start_date,t_end_date,rating1_average,rating2_average,rating3.
    clear : no_of_objectives,flag_criteria_group,
            no_of_objectives_cg1,no_of_objectives_cg2,ob_cg_counter,
            temp_index_cg1,temp_index_cg2.

   refresh :it_appraisal_data.
   clear : wa_appraisal_data,return_status,appraisal_id,wa_0025.
    “Added on 4th December 2012
ENDLOOP.
***write : appraisal_id.

****break abapdev.
“______Change or Update Appraisal – [END]

INITIALIZATION.
  title = ‘Upload File Selection’.

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Celso Huamani

    Thanks for the very detailed explanation.

    I just want to add one thing:

    you can delete an object BA Appraisal in Complete status (without changing the whole Appraisal Model)

    You just have to delete it as a whole BA object, in transaction PP01 or PP02

    Greetings

    Celso

    (0) 

Leave a Reply