1. 程式人生 > >BAPI--使用HR_INFOTYPE_OPERATION函式批量匯入HR資訊紀錄程式碼樣例(0759資訊型別)

BAPI--使用HR_INFOTYPE_OPERATION函式批量匯入HR資訊紀錄程式碼樣例(0759資訊型別)

report  zp_pa_ecm_conv_0759
        no standard page heading.
 
* tables
tables:
       pernr.  "Standard Selections for HR Master Data
 
* infotypes
infotypes:
    0001,    "Org Assignment
    0008,    "Basic Pay  "SD1K911053
    0758,    "Compensation Program
    0759.    "Compensation Process
 
* data declarations
* Types
type-pools : slis.   "Global data for ALV
 
* alv field catalog
data: t_fieldcat type slis_t_fieldcat_alv with header line.
 
*constants
constants:
      c_usd   type waers             value 'USD',     "Currency  "SD1K913769
      c_pernr(5)                     value 'PERNR',   "Pers no
      c_sname(5)                     value 'SNAME',   "Emp Name
      c_werks(5)                     value 'WERKS',   "Pers Area
      c_btrtl(5)                     value 'BTRTL',   "Pers Subarea
      c_persg(5)                     value 'PERSG',   "Emp Grp
      c_persk(5)                     value 'PERSK',   "Emp Subgrp
      c_orgeh(5)                     value 'ORGEH',   "Org Unit
      c_citem(5)                     value 'CITEM',   "Comp Review Item
      c_effdt(5)                     value 'EFFDT',   "Effective date
      c_0759  type infty             value '0759',    "Comp Process
      c_tclas type pspar-tclas       value 'A',       "Transaction class for data storage
      c_actio type pspar-actio       value 'INS',     "Infotype operation
      c_10    type ecm_carea         value '10',      "Comp Area
      c_background_id type bds_typeid value 'PMMN_BACKGROUND'.  "ALV background
 
 
* work fields
data:
       w_title type lvc_title,                      "#EC NEEDED  "Title
       w_count type i.      "no of recs
 
* field strings
* return structure
data: rec_return type bapiret1.   "return code
 
* internal tables
data:
     begin of t_out occurs 0,
      pernr   type pernr_d,         "Pers. No
      sname   type smnam,           "Employee name
      werks   type persa,           "Pers Area
      btrtl   type btrtl,           "Pers Subarea
      persg   type persg,           "Emp Group
      persk   type persk,           "Emp Subgrp
      orgeh   type orgeh,           "Org. Unit
      citem   type ecm_citem,       "Compensation Review Item
      effdt   type ecm_effdt,       "Effective date
      bssal   type ecm_bssal,       "Caluclation Base  "SD1K913769
      curre   type waers,           "Currency          "SD1K913769
end of t_out.
 
* error table
data:
      begin of t_error occurs 0,
       pernr type pernr_d,   "Pers no
       sname type sname,     "Emp Name
       citem type ecm_citem, "Review item
       effdt type ecm_effdt, "effective date
      end of t_error.
 
data t_events  type slis_t_event.   "ALV top of page
 
 
* temp table to store comp data
data:
     begin of t_citem occurs 0,
      cplan type ecm_cplan,   "Comp Plan
      citem type ecm_citem,   "Review Item
      effdt type ecm_effdt,   "Effective date
      cpgr1 type ecm_cpgr1,   "1st Program grouping
      cpgr2 type ecm_cpgr2,   "2nd Program grouping
     end of t_citem.
 
 
* selection screen
selection-screen begin of block abc with frame title text-001.
parameters:
             p_crevi like t71adm08-crevi.  "Comp Review "SD1K913769
* begin of change  "SD1K911053
select-options:
             s_trfst for p0008-trfst.  "Pay Scale Level
parameters:
* end of change  "SD1K911053
             p_test as checkbox.                 "Test option
selection-screen end of block abc.
 
************************************************************************
* PROCESSING
************************************************************************
* initialization.
initialization.
  perform eventtab_build using t_events[].
 
* start of selection
start-of-selection.
 
* get all the relevant Comp Review items for the comp review entered on
* the selection screen
  perform fill_citem.
 
 
get pernr.
  clear: p0001,p0758,p0008.                                 "SD1K911053
* Validate Pay Scale level with selection screen values     "SD1K911053
  rp-provide-from-last p0008 space pn-begda pn-endda.       "SD1K911053
  check p0008-trfst in s_trfst.                             "SD1K911053
 
* Obtain Org Info from infotype 0001
  rp-provide-from-last p0001 space pn-begda pn-endda.
  check pnp-sw-found eq 1.
 
* Obtain Compensation Program details from infotype 0758
  rp-provide-from-last p0758 space pn-begda pn-endda.
  check pnp-sw-found eq 1.
 
* fill the output table with info from 0001 , 0758 & the
* temp table t_citem
  loop at t_citem where cpgr1 = p0758-cpgr1
                    and cpgr2 = p0758-cpgr2.
    t_out-pernr   =   pernr-pernr.
    t_out-sname   =   p0001-sname.
    t_out-werks   =   p0001-werks.
    t_out-btrtl   =   p0001-btrtl.
    t_out-persg   =   p0001-persg.
    t_out-persk   =   p0001-persk.
    t_out-orgeh   =   p0001-orgeh.
    t_out-citem   =   t_citem-citem.
    t_out-effdt   =   t_citem-effdt.
    rp-provide-from-last p0008 space t_citem-effdt t_citem-effdt."SD1K913769
    t_out-bssal   =   p0008-ansal.                          "SD1K913769
    t_out-curre   =   c_usd.                                "SD1K913769
    append t_out.
    clear t_out.
  endloop.
 
end-of-selection.
* check if any data selected for processing
  if t_out[] is initial.
* no data found.
    write:/ 'No data found'(004).
  else.
    if p_test eq space.
* If test option is not selected, create infotype 0759 records
* using standard function module.
      perform create_0759.
      if not t_error[] is initial.
* display errors
        perform write_error.
      endif.
      if w_count eq 1.
        message s016(rp) with  w_count 'record was updated'(002).
* ALV display of records that will be updated
        perform list_display.
      else.
        message s016(rp) with w_count 'records were updated'(003).
* ALV display of records that will be updated
        perform list_display.
      endif.
    else.
* ALV display of records that will be updated
      perform list_display.
    endif.
  endif.
 
*&---------------------------------------------------------------------*
*&      Form EVENTTAB_BUILD
*&---------------------------------------------------------------------*
form eventtab_build using t_lt_events type slis_t_event.
  data: rec_event type slis_alv_event.
  constants: c_top_of_page(11) value 'TOP_OF_PAGE'.
  call function 'REUSE_ALV_EVENTS_GET'
    exporting
      i_list_type = 0
    importing
      et_events   = t_lt_events.
  read table t_lt_events with key name =  slis_ev_top_of_page
                           into rec_event.
  if sy-subrc = 0.
    move c_top_of_page to rec_event-form.
    append rec_event to t_lt_events.
  endif.
endform.                    "EVENTTAB_BUILD
 
*&---------------------------------------------------------------------*
*&      Form  fill_citem
*&---------------------------------------------------------------------*
form fill_citem .
  select a~cplan a~citem b~effdt c~cpgr1 c~cpgr2 into table t_citem
                  from t71adm09 as a
                       inner join t71adm10 as b on a~citem = b~citem
                       inner join t71adm07 as c on a~cplan = c~cplan
                                               and b~carea = c~carea
                                             where a~crevi = p_crevi
                                               and b~carea = c_10.
 
  if sy-subrc ne 0.
    clear t_citem[].
  else.
    sort t_citem.
  endif.
endform.                    " fill_citem
*&---------------------------------------------------------------------*
*&      Form  list_display
*&---------------------------------------------------------------------*
form list_display .
* fill ALV filed catalog ( column names )
  perform fill_fieldcat using c_pernr  9  'Pers. No'(005).
  perform fill_fieldcat using c_sname  40 'Employee Name'(006).
  perform fill_fieldcat using c_werks  10 'Pers. Area'(007).
  perform fill_fieldcat using c_btrtl  13 'Pers. Subarea'(008).
  perform fill_fieldcat using c_persg  14 'Employee Group'(009).
  perform fill_fieldcat using c_persk  17 'Employee Subgroup'(010).
  perform fill_fieldcat using c_orgeh  9  'Org. Unit'(011).
  perform fill_fieldcat using c_citem  9  'Comp Review Item'(012).
  perform fill_fieldcat using c_effdt  10 'Effectiev Date'(013).
  w_title = sy-title.
  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_background_id    = c_background_id
      i_callback_program = sy-repid
      i_grid_title       = w_title
      it_fieldcat        = t_fieldcat[]
      it_events          = t_events[]
    tables
      t_outtab           = t_out
    exceptions
      program_error      = 1
      others             = 2.
  if sy-subrc ne 0.
    message e208(00) with 'Error in FM REUSE_ALV_GRID_DISPLAY'(014).
  endif.
 
endform.                    " list_display
*&---------------------------------------------------------------------*
*&      Form  fill_fieldcat
*&---------------------------------------------------------------------*
form fill_fieldcat  using    p_fieldname type c
                             p_length type i
                             p_header type c.
  t_fieldcat-fieldname     = p_fieldname.
  t_fieldcat-outputlen     = p_length.
  t_fieldcat-seltext_m     = p_header.
  t_fieldcat-seltext_l     = p_header.
  t_fieldcat-reptext_ddic  = p_header.
  append t_fieldcat.
  clear t_fieldcat.
endform.                    " fill_fieldcat
*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
form top_of_page .                                          "#EC CALLED
  data: t_list_top_of_page type slis_t_listheader.
  data: ls_line type slis_listheader.
*
  constants: c_h value 'H'.
 
* List Type
  clear ls_line.
  ls_line-typ  = c_h.
* LS_LINE-KEY:  not used for this type
  ls_line-info = sy-title.
  append ls_line to t_list_top_of_page.
 
  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      it_list_commentary = t_list_top_of_page.
 
* end of change SD1K910827
endform.                    " top_of_page
 
*&---------------------------------------------------------------------*
*&      Form  create_0759
*&---------------------------------------------------------------------*
form create_0759 .
  refresh p0759.
  clear p0759.
  loop at t_out.
* Enqueue personnel number
    call function 'BAPI_EMPLOYEE_ENQUEUE'
      exporting
        number = t_out-pernr
      importing
        return = rec_return.
    if not rec_return is initial.
* fill the error tab & continue with the next loop pass
      t_error-pernr = t_out-pernr.
      t_error-sname = t_out-sname.
      t_error-citem = t_out-citem.
      t_error-effdt = t_out-effdt.
      append t_error.
      clear t_error.
    else.
* fill the p0759 record structure
      p0759-pernr         = t_out-pernr.
      p0759-infty         = c_0759.
      p0759-citem         = t_out-citem.
      p0759-begda         = t_out-effdt.
      p0759-endda         = t_out-effdt.
      p0759-cstat         = 1.
      p0759-carea         = c_10.
      p0759-cpamt         = 0.
      p0759-bssal         = t_out-bssal.                    "SD1K913769
      p0759-curre         = t_out-curre.                    "SD1K913769
* update infotype 0759 using std function module
      call function 'HR_INFOTYPE_OPERATION'
        exporting
          infty         = c_0759
          number        = t_out-pernr
          record        = p0759
          validityend   = p0759-endda
          validitybegin = p0759-begda
          operation     = c_actio
          tclas         = c_tclas
        importing
          return        = rec_return.
* if the update is successful increment the count, else
* pass the record to error table for display in the end
      if rec_return is initial.
        w_count = w_count + 1.
      else.
        t_error-pernr = t_out-pernr.
        t_error-sname = t_out-sname.
        t_error-citem = t_out-citem.
        t_error-effdt = t_out-effdt.
        append t_error.
        clear t_error.
      endif.
    endif.
  endloop.
 
endform.                    " create_0759
*&---------------------------------------------------------------------*
*&      Form  write_error
*&---------------------------------------------------------------------*
form write_error .
  skip.
  write:/3 'List of records that were not updated'(015).
  loop at t_error.
    if sy-tabix eq 1.
      uline /(80).
      write:/ sy-vline,       'Pers. No'(016),
           12 sy-vline,    13 'Emp. Name'(017),
           47 sy-vline,    48 'Comp Review Item'(018),
           58 sy-vline,    59 'Effective Date'(019),
           80 sy-vline.
      uline /(80).
    endif.
    write:/ sy-vline,          t_error-pernr under text-016,
         12 sy-vline,          t_error-sname under text-017,
         47 sy-vline,          t_error-citem under text-018,
         58 sy-vline,          t_error-effdt under text-019 mm/dd/yyyy,
         80 sy-vline.
    uline /(80).
  endloop.
 
endform.                    " write_error

相關推薦

BAPI--使用HR_INFOTYPE_OPERATION函式批量匯入HR資訊紀錄程式碼(0759資訊型別)

report  zp_pa_ecm_conv_0759        no standard page heading. * tablestables:       pernr.  "Standard Selections for HR Master Data * infot

C#VS中一個函式呼叫另一個函式程式碼

//主函式 說明:下面的函式是想求許可證的十六位編號,最後一位是許可編號的校驗碼,是以本體碼("JY" + xukbh)為基礎來計算 entities[0].XuKeZhengBianHao = "JY" + xukbh + xukebianhaojiaoyanma(xukbh);  

快學Scala學習筆記及習題解答(12-14高階函式、集合、模式匹配和類)

本文Scala使用的版本是2.11.8 第12章 高階函式 12.1 基本用法 作為值得函式 import scala.math._ val num = 3.14 // ceil函式後的_表示這是個函式,而不是忘記傳參 val fun =

ABAP--HR的工資計算程式碼

report zporgr0030 line-size 193 message-id zndc. *********************************************************************** * Database Tables ***************

foxmail 批量匯入收件人郵箱資訊

問題產生的背景: 用foxmail發郵件時,填寫收件人,每次輸入別人的郵箱時要換成英文輸入,有時還要得判斷是不是我想找的那個人,確實麻煩。怎樣將一份別人發過來的郵件中的收件人資訊一次性全匯入foxmail呢? foxmail郵箱的聯絡人可用cs

批量匯入(單檔案的檔案上傳 + 解析上傳的csv檔案 ,匯入至資料庫 ,反饋資訊

freemaker 部分 <form action="${base}/lot/save" method="post" enctype="multipart/form-data" > <input type="file" name="file" class

批量匯入資料(Mysql)報MySQL server has gone away 問題的解決方法

問題分析 首先度娘:mysql出現ERROR : (2006, 'MySQL server has gone away') 的問題意思就是指client和MySQL server之間的連結斷開了。    造成這樣的原因一般是sql操作的時間過長,或者是傳送的資料太大(例如使用inser

C++批量匯入檔案

如果這樣做: for (int i = 1; i<= 100; i++) { img = imread(“D:\低解析度截圖重新命名\%d.jpg”, i); imgs.push_back(img); } 看似不報錯,但是如果imshow一下,就會發現根本沒有讀圖。 對於檔案流,和普通

jdbc百萬資料批量匯入,流式讀取

Connection connReader = null; Connection connWrite = null; String url = "jdbc:mysql://XX:3306/XX?" + "user=XX&password=XX&

CAS統一登入認證(13): ldap 批量匯入使用者

cas登入後臺驗證賬號來自ldap,需要批量匯入賬號到ldap,這個問題幾經研究,最後方法如下:  先編寫程式生成ldif格式檔案,然後再在ldapadmin.exe程式或 phpldapadmin網頁中匯入這個ldif檔案 1. 生成的ldif檔案格式: 【空行】 dn: u

使用kettle來根據時間戳或者批次號來批量匯入資料,達到增量的效果。

1、Kettle是一款國外開源的ETL工具,純java編寫,可以在Window、Linux、Unix上執行,資料抽取高效穩定。下載圖形化介面的zip包格式的,直接解壓縮使用即可。安裝部署模式這裡不說了,自己可以根據自己的需求安裝為單機模式或者叢集模式。    Kettle的社群官

C# 批量匯入 SqlBulkCopy

  快速批量匯入方法 SqlBulkCopy 1 public string InsertSqlBulkCopy(DataTable dt, string tableName, ref string errinfo) 2 {

【轉載】QP02檢驗計劃批量匯入

其他參考: https://archive.sap.com/discussions/thread/3430191 *&---------------------------------------------------------------------* *& PROGRAM

使用solr批量匯入mysql資料庫,以及Unable to read: dataimport.properties等坑

折騰了一下午終於成功了!先放一張成功圖: 成功把mysql的資料新增進去了,我這裡是整合了tomcat9,整合步驟挺麻煩的,百度一大堆! 這裡主要介紹批量匯入資料,這裡有些坑,所以記錄一下: 步驟: 第一: 引入需要的jar包 我這裡把home目錄放外面了,所以核心配置檔案引入jar包需要改一下

Solr批量匯入資料

1、從solr 4.10.3 的dist 下 所需Jar包複製一份到 solr_home的索引庫(db1 是我自己新建的索引庫)下lib下 如果沒有就新建 2、在索引庫(db1)的核心配置檔案(solrconfig.xml)中 新增請求處理器。 <requestHand

將根據時間戳增量資料方案修改為根據批次號增量資料方案 使用kettle來根據時間戳或者批次號來批量匯入資料,達到增量的效果。

1、之前寫過根據時間戳來增量資料,時間戳增量資料存在一定的缺點,就是如果開啟自動的話,以後如果因為某個外在因素出錯了,那麼這個開始時間和結束時間不好控制,那麼就可能造成一些其他資料量不準的情況,但是根據批次號不會出現這個問題: 使用kettle來根據時間戳或者批次號來批量匯入資料,達到增量的效果。

Matlab繪圖基礎——用print函式批量儲存圖片到檔案(Print figure or save to file)

Matlab繪圖基礎——用print函式批量儲存圖片到檔案(Print figure or save to file) 一、用法解析 1.1. 解析度-rnumber 1.2.  輸出圖片的“格式”formats 二、用法示例 2.1. 設

銷售訂單批量匯入(1)

    注意:數量和金額必須用字元,否則 0.81 會變成81 *&---------------------------------------------------------------------

【Springboot+mybatis】 解析Excel並批量匯入到資料庫

【Springboot+mybatis】 解析Excel並批量匯入到資料庫 置頂 2018年01月16日 20:05:52 冉野丶 閱讀數:4060 標籤: excel匯入資料庫 檔案上傳 excel解析 更多 個人分類: POI 工作問題歸納 版權宣告:本文為博主原創文章,未經博主允許不得

react下批量匯入資料無法覆蓋原資料中的input值的問題(利用antd design外掛)

最近在寫一個需求,要求批量匯入資料後要把原來的列表資料全部覆蓋,包括匯入的資料與原來的列表資料重複的值。 如果匯入的資料中與原來列表的資料沒有重複的值,那就重新setState一下就好;那如果列表中有資料A,並且A的一個屬性通過input編輯過,此時再批量匯入資料包含資料A的話,那就不能覆蓋已經