Your SlideShare is downloading. ×
Abap HR Function
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Abap HR Function

3,027
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,027
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
134
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1.    call function 'RHPA_APPRAISORS_APP_READ'  &quot; 직번을 가지고  BA 를 구함 . *   EXPORTING *     BEGDA               = '19000101' *     ENDDA               = SY-DATUM *     WITH_STEXT          = 'X' *     WITH_ADD_INFO       = 'X'     tables       appraisors          = p_appraisors       appraisals          = p_appraisals *   EXCEPTIONS *     NO_AUTHORITY        = 1 *     UNDEFINED           = 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.   data:         p_appraisors type table of hrsobid,         ls_appraisors type hrsobid,         p_appraisals type table of hrpe_profa,         ls_appraisals type hrpe_profa.   ls_appraisors-plvar = '01'.   ls_appraisors-otype = 'P'.   ls_appraisors-sobid = pernr.  append ls_appraisors to p_appraisors. 직번을 기준으로 자기가 평가자로 속하 모든 BA 문서를 가져온다 . Pernr <= 직번 Otype <= person
  • 2.      ls_appraisals_1-plvar = ls_appraisors-plvar.     ls_appraisals_1-otype = 'BA'.     ls_appraisals_1-objid = ls_appraisals-tobid.     append ls_appraisals_1 to lt_appraisals_1. “BA 로 피평가자 정보 가져온다 .      call function 'RHPA_APP_APPRAISEES_READ' *   EXPORTING *     MAINTAIN           = ' '       tables         appraisals         = lt_appraisals_1         appraisees         = lt_appraisees *   EXCEPTIONS *     NO_AUTHORITY       = 1 *     UNDEFINED          = 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. BA 로 피평가자 정보 가져온다 . ls_appraisals_1-objid <= 피평가자 직번
  • 3. * GET IFT 0000 DATA   call function 'HR_READ_INFOTYPE'        exporting            pernr           = pernr            infty           = c_ift0000            begda           = '19000101'            endda           = '99991231' *      IMPORTING *          SUBRC           = SUBRC        tables            infty_tab       = it_0000        exceptions            infty_not_found = 1            others          = 2. 직번을 기준으로 infotye 에 따른 HR 기본정보를 가져온다 . pernr <= 직번
  • 4.    move : '01' to tmp_plvar,          item_object to tmp_objid.    &quot; 현재 정보 가져오기 .   call function 'RHPA_APPRAISAL_DISPLAY_READ'     exporting       plvar                = tmp_plvar       objid                = tmp_objid *   BEGDA                = *   ENDDA                = *   READ_DB              = ' ' *   MAINTAIN             = ' '  importing    app_attributes       = get_app_attributes  tables *   APPRAISORS           = *   APPRAISEES           =    appraisal            = lt_appraisal *   APPRAISALS           =  exceptions    no_authority         = 1    nothing_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. BA 문서 번호를 가지고 문서의 모든 정보를 가져온다 . Tmp_objid <= 문서 번호 .
  • 5.      move : ls_zhrta01-otype to tmp_act_otype,             ls_zhrta01-objid to tmp_act_objid,             'A047' to tmp_act_wegid,             '01' to tmp_act_plvar.     call function 'RH_STRUC_GET'       exporting         act_otype              = tmp_act_otype         act_objid              = tmp_act_objid         act_wegid              = tmp_act_wegid *       ACT_INT_FLAG           =        act_plvar              = tmp_act_plvar *       ACT_BEGDA              = SY-DATUM *       ACT_ENDDA              = SY-DATUM *       ACT_TDEPTH             = 0        act_tflag              = 'X'        act_vflag              = 'X'        authority_check        = 'X' *       TEXT_BUFFER_FILL       = *       BUFFER_MODE            = *     IMPORTING *       ACT_PLVAR              =      tables *       RESULT_TAB             =        result_objec           = lt_result_objec *       RESULT_STRUC           =      exceptions        no_plvar_found         = 1        no_entry_found         = 2        others                 = 3               . BA 에 정의된 BK 항목들을 가져온다 .
  • 6.    &quot;  평가 항목  READ.   data : ls_hrp1002         type hrp1002,          ls_hrt1002         type hrt1002,          lt_hrt1002         type table of hrt1002,          tmp_string         type string.   loop at lt_question into stru_question.     select single * into corresponding fields of ls_hrp1002       from hrp1002       where plvar eq '01'         and otype eq 'BK'         and objid eq stru_question-obj_id         and subty eq '0001'         and istat eq '1'         and langu eq '3'.     select * into corresponding fields of table lt_hrt1002       from hrt1002       where tabnr eq ls_hrp1002-tabnr.     loop at lt_hrt1002 into ls_hrt1002.       concatenate tmp_string ls_hrt1002-tline into tmp_string.     endloop.               . BK 번호 text 를 읽어 온다 .
  • 7.    data:         tmp_rank                type pt1045-rank,         tmp_index               type sy-tabix,         flag                    type char01.    &quot;BG MODIFY     if ls_appraisal-app_otype eq 'BG'.       move ls_appraisal-rank to tmp_rank.       call function 'RHPA_CALC_VALUE_AVERAGE'         exporting           rank_base                = tmp_rank         importing           new_calculated           = flag         tables           app_pt1045               = set_appraisal         exceptions           error_during_calculation = 1           others                   = 2.     endif.      if ls_appraisal-app_otype eq 'BS'.       move ls_appraisal-rank to tmp_rank.       call function 'RHPA_CALC_VALUE_AVERAGE'         exporting           rank_base                = tmp_rank         importing           new_calculated           = flag         tables           app_pt1045               = set_appraisal         exceptions           error_during_calculation = 1           others                   = 2.     endif. 변경된  BK 값으로  bs bg 값 구합 .
  • 8.    &quot; SAVE LOGIC   call function 'RHPA_APPRAISAL_MODIFY_ACTIVE'     exporting       app_attributes_db           = get_app_attributes       app_attributes_cur          = get_app_attributes     vtask                       = 'S'  tables *   appraisal_db                = lt_appraisal    appraisal_cur               = set_appraisal *   appraisal_cur                = lt_appraisal  exceptions    no_authority                = 1    nothing_found               = 2    invalid_date                = 3    appraisal_table_error       = 4    error_during_insert         = 5    historicized                = 6    others                      = 7 다면평가 결과 값 저장 VTASK = ‘S’ <= 저장 데이터 즉시반영 flag S Synchronous update in the update task V Asynchronous update in the update task D Update in dialog B Update in internal buffer No update via personnel planning update task
  • 9.    &quot;  평가 문서 완료  .   move : '01' to tmp_planversion,         item_object to tmp_appraisal_id.   call function 'RHPA_APPRAISAL_HISTORICIZE'    exporting      i_planversion                  = tmp_planversion      i_appraisal_id                 = tmp_appraisal_id *   TABLES *     PROCESS_ERROR                  =    exceptions      no_authority                   = 1      nothing_found                  = 2      input_duty                     = 3      parts_not_historicized         = 4      error_during_update            = 5      processing_not_processed       = 6      wrong_status                   = 7      others                         = 8 다면평가 문서 완료 (closing)
  • 10.      move : 'PA' to tmp_add_on_application,            '01' to tmp_plan_version,            ls_hrhap_appee-appraisal_id to tmp_appraisal_id.     call function 'HRHAP_DOCUMENT_GET_DETAIL'       exporting      add_on_application            =  tmp_add_on_application *   MODE                          = ' ' *   UI_MODE                       = ' '         plan_version                  = tmp_plan_version         s_appraisal_id                = tmp_appraisal_id *   ADMINISTRATOR                 = ' ' *   S_DISPLAY_UI                  = *   NO_ACTION_LOG                 = ' '    importing *   S_DOC_PROCESSING              = *   S_HEADER_TEXTS                =      t_header_appraiser            =  tmp_header_appraiser  &quot;  평가자       t_header_appraisee            =  tmp_header_appraisee  &quot; 피평가자    T_HEADER_PART_APPRAISER   = tmp_header_part_appraisers “ 부분 평가자 *   T_HEADER_OTHERS               =      s_header_status               =  tmp_header_status  &quot;  상태   2: 계획중 .      s_header_dates                =  tmp_header_dates &quot; 목표세팅일 검토일 .  &quot;  시작일 종료일 *   T_HEADER_ADD_DATA             = *   S_HEADER_DISPLAY              = *   T_BUTTONS                     = *   T_BODY_COLUMNS                =      t_body_elements               =  tmp_body_elements  &quot;va  문서 번호 *   T_BODY_ELEMENT_BUTTONS        = *   T_BODY_ELEMENT_DESCR          = *   T_BODY_CELLS                  = *   T_BODY_CELL_VAL_VALUES        = *   T_BODY_CELL_VAL_RANGES        = *   T_BODY_CELL_VAL_C_LIKE        = *   T_BODY_CELL_VAL_DESCR         = *   T_BODY_CELL_NOTES             = *   T_STATUS_NOTES                = *   S_RETURN                      = . * 직번으로 피평가자로 속한 모든 VA 문서번호 가져온다 .    select * into corresponding fields of table lt_hrhap_appee     from hrhap_appee     where plan_version eq '01'       and type eq 'P'       and id eq id. * 평가자로 속한 모든 문서 가져온다 .   select * into corresponding fields of table lt_hrhap_apper     from hrhap_apper     where plan_version eq '01'       and type eq 'P'       and id eq id. * 부분평가자가 속한 모든 문서 가져온다 .    select * into corresponding fields of table lt_hrhap_p_apper     from hrhap_p_apper     where plan_version eq '01'       and type eq 'P'       and id eq id. 평가 상태 : tmp_header_status-ap_status 1 In Preparation 2 In Planning 3 In Review 4 In Process 5 Completed 6 Approved 7 Closed Approved 8 Rejected 9 Closed Rejected
  • 11.      move : 'PA' to tmp_add_on_application,            '01' to tmp_plan_version,            stru_sel_line-doc_no to ls_appraisal_id-appraisal_id,            '0000' to  ls_appraisal_id-part_ap_id.     .      &quot;  저장 로직 .     call function 'HRHAP_DOCUMENT_SAVE'       exporting         plan_version                   = tmp_plan_version         t_header_appraiser             = tmp_header_appraiser         t_header_appraisee             = tmp_header_appraisee         t_header_others                = tmp_header_others         s_header_texts                 = tmp_header_texts         s_header_dates                 = tmp_header_dates         s_header_status                = tmp_header_status         s_header_display               = tmp_header_display         t_body_columns                 = tmp_body_column         t_body_elements                = tmp_body_elements  &quot;va  문서번호          t_body_cells                   = tmp_body_cells  &quot; 가중치 *   NO_ACTION_LOG                  = *   VTASK                          = 'D‘ “      importing          s_return                       = tmp_return  &quot;  결과        changing         s_appraisal_id                 = ls_appraisal_id         s_doc_processing               = tmp_doc_processing         t_header_part_appraisers       = tmp_header_part_appraisers         t_body_cell_notes              = t_body_cell_notes  &quot;text         t_status_notes                 = tmp_status_note               . ls_appraisal_id-part_ap_id 에 ‘ 0000’ 을 넣어야 저장된다 . 문서 read 할 때는 안넣어도 상관없다 . VTASK type S Synchronous update in the update task V Asynchronous update in the update task D Update in dialog B Update in internal buffer No update via personnel planning update task tmp_body_cells-no_value: flag check 를 초기화 시켜야 한다 . ( 초기값은 ‘ X’ 로 되어있다 )
  • 12.      data : tmp_enqueue type hap_doc_enqueue.     move : 'C' to tmp_enqueue.  &quot;entire        call function 'HRHAP_DOCUMENT_DEQUEUE'         exporting           plan_version         =  tmp_plan_version           s_appraisal_id       =  ls_appraisal_id * IMPORTING *   S_RETURN             =   changing    doc_enqueue          = tmp_enqueue               . 평가 문서가 lock 잡힐때가 있다 . 그때는 강제로 dequeue 를 시켜 줘야 한다 .   tmp_enqueue : 상태 Appraisal Document Not Enqueued C Entire Appraisal Document Enqueued P Part Appraisal Enqueued F Entire Appraisal Document Enqueued (First Time)
  • 13.    call function 'HRHAP_DOCUMENT_CHANGE_STATUS'     exporting       plan_version                 = tmp_plan_version       template_id                  = tmp_template_id       button_id                    = tmp_button_id *       ADMINISTRATOR                = ' '    importing *       T_UI_VAL_DET                 = *       T_VAL_DET_RETURN             = *       DOCUMENT_LEAVE               =      s_return                     = tmp_return     changing       s_appraisal_id               = ls_appraisal_id       s_header_status              = tmp_header_status       s_doc_processing             = tmp_doc_processing       s_header_display             = tmp_header_display       t_header_appraiser           = tmp_header_appraiser       t_header_appraisee           = tmp_header_appraisee       t_header_p_appraiser         = tmp_header_part_appraisers       t_header_others              = tmp_header_others *       T_HEADER_ADD_DATA            =       s_header_texts               = tmp_header_texts       s_header_dates               = tmp_header_dates *       T_BUTTONS                    =       t_body_elements              = tmp_body_elements *       T_BODY_ELEMENT_DESCR         = *       T_BODY_ELEMENT_BUTTONS       =       t_body_columns               = tmp_body_columns       t_body_cells                 = tmp_body_cells *       T_BODY_CELL_VAL_VALUES       = *       T_BODY_CELL_VAL_RANGES       = *       T_BODY_CELL_VAL_C_LIKE       = *       T_BODY_CELL_VAL_DESCR        =       t_body_cell_notes            = tmp_body_cell_notes *       T_STATUS_NOTES               = tmp_status_note           .     . MBO 평가 문서의 상태 변경 계획중 => 검토중으로 .. ls_body_elements-element_id to tmp_template_id, ‘REVIEW' to tmp_button_id. “ 현재 상태를 그대로 두보 버튼 ID 만 변경”    read table tmp_body_elements with key element_type = 'VA'   into ls_body_elements.    &quot; 완료 로직 . &quot;    data :         tmp_template_id          type  hap_template_id,         tmp_button_id            type  ui_func.   move :          ls_body_elements-element_id to tmp_template_id,          'COMPLETE' to tmp_button_id. “ 현 단계에서 complete 하면 다음 단계로 넘어간다 . 검토중 => 평가시작 ls_body_elements-element_id to tmp_template_id, 'START' to tmp_button_id. &quot; 부분 평가 . 'COMPL_P' to tmp_button_id. 
  • 14. “ button_id 참조 . CONSTANTS: * APPRAISAL STATUS DEPENDENT buttons c_button_perform TYPE hap_button_id VALUE 'PERFORM', &quot;Perform app. c_button_start TYPE hap_button_id VALUE 'START', &quot;Start App. Pr c_button_plan_obj TYPE hap_button_id VALUE 'OBJECTIVE',&quot;Plan object. c_button_review TYPE hap_button_id VALUE 'REVIEW', &quot;Review c_button_next_rev TYPE hap_button_id VALUE 'N_REVIEW', &quot;Next Review c_button_complete TYPE hap_button_id VALUE 'COMPLETE', &quot;Complete app. c_button_compl_p TYPE hap_button_id VALUE 'COMPL_P', &quot;Compl.part ap c_button_approve TYPE hap_button_id VALUE 'APPROVE', &quot;Approve app. c_button_reject TYPE hap_button_id VALUE 'REJECT', &quot;Reject app. c_button_close_apr TYPE hap_button_id VALUE 'CLOSEAPR', &quot;CloseApprove c_button_close_rej TYPE hap_button_id VALUE 'CLOSEREJ', &quot;CloseRejected c_button_closeprep TYPE hap_button_id VALUE 'CLOSEPREP'.&quot;Close Prep. CONSTANTS: * STATUS DEPENDENT BUTTON CONTAINERS c_button_status_1 TYPE hap_button_id VALUE 'STATUS_1', c_button_status_2 TYPE hap_button_id VALUE 'STATUS_2', c_button_status_3 TYPE hap_button_id VALUE 'STATUS_3'. CONSTANTS: * ELEMENT buttons c_button_enhance TYPE hap_button_id VALUE 'ENHANCE', &quot;enhance template c_button_delete TYPE hap_button_id VALUE 'DELETE'. &quot;delete element            .     .
  • 15.      call function 'HRHAP_DOCUMENT_GET_LIST_XXL'       exporting *       SEL_FILTER                  = ' '         add_on_application          = tmp_add_on_application        plan_version                =  tmp_plan_version *       T_CATEGORIES                =        t_templates                 =  tmp_templates *       T_TMPL_DETAIL               = *       T_APPRAISERS                =        s_and_or                    = tmp_s_sel_option_and_or *       T_APPRAISEES                =        t_part_appraisers           =  tmp_part_appraisers *       T_OTHERS                    = *       S_SEL_DATE                  = *       S_SEL_STATUS                =        t_sel_status_sub            = tmp_sel_status_sub        s_sel_with_or_without       =  tmp_s_sel_with_or_without *       S_DOCUMENT_FILL             = *       EXTRACT_M_N                 = ' ' *       NO_DIALOG                   =      importing        t_documents                 = tmp_documents *       S_RETURN                    =               .     read table tmp_documents with key appraisal_id = stru_main_list-doc_no     into ls_documents.      move : 'PA' to tmp_add_on_application,            '01' to tmp_plan_version.     move : '01' to ls_templates-plvar,            'VA' to ls_templates-otype,            stru_main_list-va_no to ls_templates-objid.     append ls_templates to tmp_templates.     move : '01' to ls_part_appraisers-plvar,            'P' to ls_part_appraisers-otype,            stru_main_list-appraisee to ls_part_appraisers-sobid.     append ls_part_appraisers to tmp_part_appraisers.     move : '4' to ls_sel_status_sub-ap_status,            stru_main_list-sub_status to ls_sel_status_sub-ap_status_sub.     append ls_sel_status_sub to tmp_sel_status_sub.     tmp_s_sel_option_and_or-apper_and_appee = 'X'.     tmp_s_sel_with_or_without-sel_display_existing = 'X'. “ 해당 도큐먼트 단계별 세부 단계 정보 가져온다 ..      read table tmp_documents with key appraisal_id = stru_main_list-doc_no  into ls_documents.
  • 16.          ls_hri1001-infty = '1001'.         ls_hri1001-plvar = '01'.         ls_hri1001-otype = 'O'.         ls_hri1001-objid = stru_org-org_code.  &quot; 조직 코드          ls_hri1001-begda = item_sdate.  &quot; 시작지정일          ls_hri1001-endda = '99991231'.         ls_hri1001-rsign = 'A'.         ls_hri1001-relat = '031'.         ls_hri1001-sclas = 'Q'.         ls_hri1001-sobid = stru_all_list-q_id.  &quot;QK KEY *        ls_hri1001-priox = record-priox. &quot; PRIORITY *        ls_hri1001-prozt = record-prozt. &quot;WEIGHTINH PERCENTAGE         ls_hri1001-adata = '0003'.       call function 'RH_RELATION_WRITE' *         EXPORTING *           VTASK                      = 'D' *           KEEP_LUPD                  = ' '         tables           relation                   = lt_hri1001 *           ERR_RELATION               =        exceptions          no_authority               = 1          relation_not_allowed       = 2          object_not_found           = 3          wrong_date_format          = 4          time_not_valid             = 5          error_during_insert        = 6          undefined                  = 7          others                     = 8     into ls_documents. 성격지정 항목의 관계를 생성한다 . . ls_hri1001-adata <= 숙련도 정보 0001~0004