ABAP HR 获取薪酬

  1 DATA:
  2     l_index           LIKE sy-tabix,
  3     lt_rgdir          TYPE TABLE OF pc260,  "payroll cluster
  4     lw_rgdir          LIKE LINE OF lt_rgdir,
  5     lt_rgdir_a        TYPE TABLE OF pc260,  "payroll cluster
  6     lw_rgdir_a        LIKE LINE OF lt_rgdir,
  7     lv_relid          TYPE relid_pcl,         "cluster id
  8     lw_molga          TYPE molga,         "country grouping
  9 *    ls_payroll_result TYPE pay99_result,         "pay result
 10     lt_hr_crt         TYPE   hrpay99_crt,
 11     ls_hr_crt         TYPE LINE OF   hrpay99_crt,
 12     ls_payroll_result TYPE paycn_result,         "pay result
 13     lt_rt             LIKE LINE OF payroll-inter-rt,
 14     lt_rt2            LIKE LINE OF payroll-inter-rt,
 15     lt_rt3            LIKE LINE OF payroll-inter-rt,
 16     lt_tcrt           TYPE LINE OF paycn_result-nat-tcrt,
 17     l_taxgp           TYPE p0531-taxgp,
 18     l_lastday         LIKE sy-datum,
 19     lv_field          TYPE string,
 20     lv_seqnr          TYPE pc260-seqnr.
 21 
 22   DATA : lt_pa0531 TYPE TABLE OF pa0531 WITH HEADER LINE  .
 23   DATA:lv_inper(6) TYPE c.
 24   lv_inper = p_year && p_month.
 25 
 26   LOOP AT lt_pernr INTO ls_pernr.
 27     l_index  = sy-tabix.
 28     REFRESH  lt_rgdir.
 29     CLEAR:lv_relid,lw_molga,l_lastday,lv_seqnr.
 30 *获取人员的工资存储的簇表ID
 31     CALL FUNCTION 'CD_READ_RGDIR'     " 获取当前员工编号的工资项
 32       EXPORTING
 33         persnr          = ls_pernr-pernr
 34       TABLES
 35         in_rgdir        = lt_rgdir
 36       EXCEPTIONS
 37         no_record_found = 1
 38         OTHERS          = 2.
 39 *删除不符合当前月份的数据。
 40     LOOP AT lt_rgdir INTO lw_rgdir.
 41       IF lw_rgdir-inper EQ '000000' OR lw_rgdir-fpper EQ '000000'.
 42         IF lw_rgdir-fpbeg IS NOT INITIAL.
 43           lw_rgdir-inper = lw_rgdir-fpbeg+0(6).
 44           lw_rgdir-fpper =  lw_rgdir-fpbeg+0(6).
 45         ENDIF.
 46       ENDIF.
 47       MODIFY lt_rgdir FROM lw_rgdir.
 48     ENDLOOP.
 49     DELETE lt_rgdir WHERE fpper <> lv_inper.
 50     DELETE lt_rgdir WHERE inper <> lv_inper.
 51 *    delete lt_rgdir where srtza <> 'A' or payty ne space.
 52     DELETE lt_rgdir WHERE srtza <> 'A'.
 53     IF lt_rgdir[] IS INITIAL.
 54       DELETE lt_pernr INDEX l_index.
 55       CONTINUE.
 56     ENDIF.
 57     READ TABLE   lt_rgdir INTO lw_rgdir INDEX 1.
 58     IF sy-subrc EQ 0.
 59       IF lw_rgdir-abkrs NOT IN pnpabkrs.
 60         DELETE lt_pernr INDEX l_index.
 61         CONTINUE.
 62       ENDIF.
 63     ENDIF.
 64 
 65 *获取当前员工的
 66     CALL FUNCTION 'PYXX_GET_RELID_FROM_PERNR'  " 获取当前员工编号的工资项
 67       EXPORTING
 68         employee                    = ls_pernr-pernr
 69       IMPORTING
 70         relid                       = lv_relid
 71         molga                       = lw_molga
 72       EXCEPTIONS
 73         error_reading_infotype_0001 = 1
 74         error_reading_molga         = 2
 75         error_reading_relid         = 3
 76         OTHERS                      = 4.
 77 
 78 
 79     CLEAR:ls_alv_detail.
 80     MOVE-CORRESPONDING ls_pernr TO ls_alv_detail.
 81 
 82     SELECT SINGLE kst01 INTO ls_alv_detail-kostl FROM pa0027 WHERE pernr = ls_pernr-pernr AND begda <= lv_begin AND endda >= lv_end.
 83     IF ls_alv_detail-kostl IS INITIAL.
 84       SELECT SINGLE kostl INTO ls_alv_detail-kostl FROM pa0001 WHERE pernr = ls_pernr-pernr AND begda <= lv_begin AND endda >= lv_end.
 85     ENDIF.
 86 
 87     ls_alv_detail-zhrssnd = p_year."年度
 88     ls_alv_detail-zhrssyf = p_month. "月份
 89     ls_alv_detail-waers = 'RMB'."货币码
 90 
 91 
 92     LOOP AT lt_rgdir INTO lw_rgdir .
 93 *取工资相关。
 94       CLEAR  ls_payroll_result .
 95       CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
 96         EXPORTING
 97           clusterid                    = lv_relid
 98           employeenumber               = ls_pernr-pernr
 99           sequencenumber               = lw_rgdir-seqnr
100 *         read_only_international      = 'X'
101 *         check_read_authority         = 'X'
102         CHANGING
103           payroll_result               = ls_payroll_result
104         EXCEPTIONS
105           illegal_isocode_or_clusterid = 1
106           error_generating_import      = 2
107           import_mismatch_error        = 3
108           subpool_dir_full             = 4
109           no_read_authority            = 5
110           no_record_found              = 6
111           versions_do_not_match        = 7
112           error_reading_archive        = 8
113           error_reading_relid          = 9
114           OTHERS                       = 10.
115       CLEAR tax.
116 
117       LOOP AT ls_payroll_result-inter-rt INTO lt_rt.
118         CASE lt_rt-lgart.
119           WHEN '/314'.
120             ls_alv_detail-zhryldwjn = ls_alv_detail-zhryldwjn + lt_rt-betrg."养老金单位缴纳
121           WHEN '9003'.
122             ls_alv_detail-zhryldwbj = ls_alv_detail-zhryldwbj + lt_rt-betrg."养老单位补缴
123           WHEN '/313'.
124             ls_alv_detail-zhrylgrjn = ls_alv_detail-zhrylgrjn + lt_rt-betrg."养老个人缴纳
125           WHEN '9004'.
126             ls_alv_detail-zhrylgrbj = ls_alv_detail-zhrylgrbj + lt_rt-betrg."养老个人补缴
127           WHEN '/334'.
128             ls_alv_detail-zhryldwjn1 = ls_alv_detail-zhryldwjn1 + lt_rt-betrg."医疗单位缴纳
129           WHEN '9013'.
130             ls_alv_detail-zhryldwbj1 = ls_alv_detail-zhryldwbj1 + lt_rt-betrg."医疗单位补缴
131           WHEN '/333'.
132             ls_alv_detail-zhrylgrjn1 = ls_alv_detail-zhrylgrjn1 + lt_rt-betrg."医疗个人缴纳
133           WHEN '9014'.
134             ls_alv_detail-zhrylgrbj1 = ls_alv_detail-zhrylgrbj1 + lt_rt-betrg."医疗个人补缴
135           WHEN '/324'.
136             ls_alv_detail-zhrsydwjn = ls_alv_detail-zhrsydwjn + lt_rt-betrg."失业单位缴纳
137           WHEN '9023'.
138             ls_alv_detail-zhrsydwbj = ls_alv_detail-zhrsydwbj + lt_rt-betrg."失业单位补缴
139           WHEN '/323'.
140             ls_alv_detail-zhrsygrjn = ls_alv_detail-zhrsygrjn + lt_rt-betrg."失业个人缴纳
141           WHEN '9024'.
142             ls_alv_detail-zhrsygrbj = ls_alv_detail-zhrsygrbj + lt_rt-betrg."失业个人补缴
143           WHEN '/344'.
144             ls_alv_detail-zhrgsdwjn = ls_alv_detail-zhrgsdwjn + lt_rt-betrg."工伤单位缴纳
145           WHEN '9032'.
146             ls_alv_detail-zhrgsdwbj = ls_alv_detail-zhrgsdwbj + lt_rt-betrg."工伤单位补缴
147           WHEN '/354'.
148             ls_alv_detail-zhrsydwjn1 = ls_alv_detail-zhrsydwjn1 + lt_rt-betrg."生育单位缴纳
149           WHEN '9042'.
150             ls_alv_detail-zhrsydwbj1 = ls_alv_detail-zhrsydwbj1 + lt_rt-betrg."生育单位补缴
151           WHEN '/363'.
152             ls_alv_detail-zhrzfdwjn = ls_alv_detail-zhrzfdwjn + lt_rt-betrg."住房公积金单位缴纳
153           WHEN '9053'.
154             ls_alv_detail-zhrzfdwbj = ls_alv_detail-zhrzfdwbj + lt_rt-betrg."住房公积金单位补缴
155           WHEN '/362'.
156             ls_alv_detail-zhrzfgrjn = ls_alv_detail-zhrzfgrjn + lt_rt-betrg."住房公积金个人缴纳
157           WHEN '9054'.
158             ls_alv_detail-zhrzfgrbj = ls_alv_detail-zhrzfgrbj + lt_rt-betrg."住房公积金个人补缴
159           WHEN '/CRR'.
160             ls_alv_detail-zhrnjdwjn = ls_alv_detail-zhrnjdwjn + lt_rt-betrg."年金单位缴纳
161           WHEN '9063'.
162             ls_alv_detail-zhrnjdwbj = ls_alv_detail-zhrnjdwbj + lt_rt-betrg."年金单位补缴
163           WHEN '/CRE'.
164             ls_alv_detail-zhrnjgrjn = ls_alv_detail-zhrnjgrjn + lt_rt-betrg."年金个人缴纳
165           WHEN '9064'.
166             ls_alv_detail-zhrnjgrbj = ls_alv_detail-zhrnjgrbj + lt_rt-betrg."年金个人补缴
167           WHEN '7A34'.
168             ls_alv_detail-zhrbcyldwjn = ls_alv_detail-zhrbcyldwjn + lt_rt-betrg."补充医疗单位缴纳
169           WHEN '9073'.
170             ls_alv_detail-zhrbcyldwbj = ls_alv_detail-zhrbcyldwbj + lt_rt-betrg."补充医疗单位补缴
171           WHEN '/3S4'.
172             ls_alv_detail-zhrdbdwjn = ls_alv_detail-zhrdbdwbj + lt_rt-betrg."大病统筹单位缴纳
173           WHEN '9082'.
174             ls_alv_detail-zhrdbdwbj = ls_alv_detail-zhryldwjn1 + lt_rt-betrg."大病统筹单位补缴
175           WHEN '7A35'.
176             ls_alv_detail-zhrdbgrjn = ls_alv_detail-zhrdbgrjn + lt_rt-betrg."大病统筹个人缴纳
177           WHEN '7A20'.
178             ls_alv_detail-zhrzfbt = ls_alv_detail-zhrdbgrjn + lt_rt-betrg."住房补贴单位缴纳(/3H3)
179         ENDCASE.
180 
181         IF lt_rt-lgart = '/403' OR lt_rt-lgart = '/404'.
182           ls_alv_detail-zhrgs = ls_alv_detail-zhrgs + lt_rt-betrg."个人所得税
183         ENDIF.
184 
185       ENDLOOP.
186 
187     ENDLOOP.
188     "公司
189     ls_alv_detail-ac01 = ls_alv_detail-zhryldwjn + ls_alv_detail-zhryldwbj."养老保险
190     ls_alv_detail-ac02 = ls_alv_detail-zhryldwjn1 + ls_alv_detail-zhryldwbj1."医疗保险
191     ls_alv_detail-ac03 = ls_alv_detail-zhrsydwjn + ls_alv_detail-zhrsydwbj."失业保险
192     ls_alv_detail-ac04 = ls_alv_detail-zhrgsdwjn + ls_alv_detail-zhrgsdwbj."工伤保险
193     ls_alv_detail-ac05 = ls_alv_detail-zhrsydwjn1 + ls_alv_detail-zhrsydwbj1."生育保险
194     ls_alv_detail-ac06 = ls_alv_detail-zhrzfdwjn + ls_alv_detail-zhrzfdwbj."公积金
195     ls_alv_detail-ac07 = ls_alv_detail-zhrnjdwjn + ls_alv_detail-zhrnjdwbj."企业年金
196     ls_alv_detail-ac08 = ls_alv_detail-zhrbcyldwjn + ls_alv_detail-zhrbcyldwbj."补充医疗保险
197     ls_alv_detail-ac09 = ls_alv_detail-zhrdbdwjn + ls_alv_detail-zhrdbdwbj."大病统筹
198     ls_alv_detail-ac10 = ls_alv_detail-zhrzfbt."住房单位缴纳
199     "个人
200     ls_alv_detail-ap01 = ls_alv_detail-zhrylgrjn + ls_alv_detail-zhrylgrbj."养老保险
201     ls_alv_detail-ap02 = ls_alv_detail-zhrylgrjn1 + ls_alv_detail-zhrylgrbj1."医疗保险
202     ls_alv_detail-ap03 = ls_alv_detail-zhrsygrjn + ls_alv_detail-zhrsygrbj."失业保险
203     ls_alv_detail-ap06 = ls_alv_detail-zhrzfgrjn + ls_alv_detail-zhrzfgrbj."公积金
204     ls_alv_detail-ap07 = ls_alv_detail-zhrnjgrjn + ls_alv_detail-zhrnjgrbj."企业年金
205     ls_alv_detail-ap09 = ls_alv_detail-zhrdbgrjn."大病统筹
206 
207     ls_alv_detail-az01 = ls_alv_detail-zhrgs.
208 
209 
210     APPEND ls_alv_detail TO lt_alv_detail.
211 
212   ENDLOOP.
213   SORT lt_alv_detail BY zhrfxdw zhrdjdw.
View Code

 

posted @ 2023-08-16 10:25  年轻的小菜鸟  阅读(101)  评论(0编辑  收藏  举报