目录
1、新增:RH_INSERT_INFTY / RH_INSERT_INFTY_EXP
说明:这两个函数的用法差不多
代码举例:
data:ls_p9509 type p9509.
data:lt_pt9509 type table of hrt9509,
ls_pt9509 type hrt9509.
data: lt_wplog type standard table of wplog,
ls_wplog type wplog.
loop at it_data into ls_data group by ( objid = ls_data-objid zhr_bzlx = ls_data-zhr_bzlx ) .
*****HRP9509 表赋值
ls_p9509-plvar = '01'.
ls_p9509-otype = 'O'.
ls_p9509-objid = ls_data-objid. "组织编码
ls_p9509-infty = '9509'.
ls_p9509-istat = '1'.
ls_p9509-subty = ls_data-zhr_bzlx.
ls_p9509-begda = iv_bzks . "ls_data-zhr_bzks. "系统当前日期
ls_p9509-endda = '99991231'.
ls_p9509-zhr_bznd = ls_data-zhr_bznd.
"年度编制下达的编制开始和编制结束日期由前端传入,Excel中没有这两个字段了
ls_p9509-zhr_bzks = iv_bzks. "ls_data-zhr_bzks.
ls_p9509-zhr_bzjs = iv_bzjs. "ls_data-zhr_bzjs.
ls_p9509-zhr_gkfs = ls_data-zhr_gkfs.
ls_p9509-guid_p9509 = lv_guid.
ls_p9509-zxgr_p9509 = iv_user.
ls_p9509-zstm_p9509 = sy-datum && sy-uzeit.
clear:ls_wplog.
call method cl_hr_pnnnn_type_cast=>pnnnn_to_wplog
exporting
pnnnn = ls_p9509
importing
wplog = ls_wplog.
loop at group ls_data assigning <fs_data>.
move-corresponding <fs_data> to ls_item.
ls_item-guid = lv_guid.
ls_pt9509-tabseqnr = ls_pt9509-tabseqnr + 1.
ls_pt9509-zhr_bzgwbm = <fs_data>-zgwbm.
ls_pt9509-zhr_bzgwmc = <fs_data>-zgwbm_t.
ls_pt9509-zhr_bzlx = <fs_data>-zhr_bzlx.
ls_pt9509-zhr_bzsl = <fs_data>-zhr_bzsl.
ls_pt9509-guid_p95092 = lv_guid.
ls_pt9509-zxgr_p95092 = iv_user.
ls_pt9509-zstm_p95092 = sy-datum && sy-uzeit.
append ls_pt9509 to lt_pt9509.
append ls_item to lt_item.
clear:ls_pt9509,ls_item.
endloop.
append ls_wplog to lt_wplog.
call function 'RH_INSERT_INFTY_EXP'
exporting
fcode = 'INSE'
vtask = 'B' "'B'代表通过缓存更新 'D'代表直接更新 'S' 代表异步更新
order_flg = ''
commit_flg = '' " 空 表示立即提交 X表示不立即提交
authy = ''
tables
innnn = lt_wplog
tnnnn = lt_pt9509
exceptions
no_authorization = 1
error_during_insert = 2
corr_exit = 3
begda_greater_endda = 4
no_innnn_tnnnn = 5
additional_innnn_tnnnn = 6
others = 7.
if sy-subrc <> 0.
lv_flag = 'X'.
loop at lt_item assigning <fs_item> where objid = ls_data-objid and zhr_bzlx = ls_data-zhr_bzlx.
<fs_item>-msgty = ' E'.
<fs_item>-msgtx = text-013.
move-corresponding <fs_item> to ls_out.
ls_out-msgty = 'E'.
ls_out-msgtx = <fs_item>-msgtx.
append ls_out to et_out.
endloop.
else.
loop at lt_item assigning <fs_item> where objid = ls_data-objid and zhr_bzlx = ls_data-zhr_bzlx.
<fs_item>-msgty = 'S'.
<fs_item>-msgtx = '成功'.
endloop .
endif.
clear:ls_data.
refresh:lt_pt9509,lt_wplog.
endloop.
"是否把数据更新进数据库表
if et_out[] is not initial.
es_message-msgty = 'S'.
es_message-msgtx = '批导失败!'.
else.
if lv_flag is initial.
call function 'RH_UPDATE_DATABASE'
exporting
vtask = 'D'
exceptions
corr_exit = 1
others = 2.
endif.
es_message-msgty = 'S'.
es_message-msgtx = '批导成功!'.
endif.
vtask更新模式介绍:
VTASK | 说明 |
---|---|
D | 直接更新,受COMMIT_FLG制约 |
B | 通过缓存更新,需要调用函数RH_UPDATE_DATABASE进行提交数据库操作 |
S | 同步更新或者实时更新。当更新完成后,系统会自动调用COMMIT WORK and Wait 直接提交。不受参数COMMIT_FLG的制约。 |
V | 异步更新,更新完成后,系统会判断COMMIT_FLG是否设置,如果COMMIT_FLG 有设置会调用COMMIT WORK。然后继续执行,不会等待更新是否完成。 |
FCODE 说明:
INSE :新增
AEND:修改
2、修改:RH_UPDATE_INFTY / RH_UPDATE_INFTY_EXP
data:ls_p9509 type p9509.
data:lt_pt9509 type table of hrt9509,
ls_pt9509 type hrt9509.
data: lt_wplog type standard table of wplog,
ls_wplog type wplog.
loop at it_data into ls_data group by ( objid = ls_data-objid zhr_bzlx = ls_data-zhr_bzlx ) .
ls_p9509-plvar = '01'.
ls_p9509-otype = 'O'.
ls_p9509-objid = ls_data-objid. "组织编码
ls_p9509-subty = lwa_p9509-subty.
ls_p9509-infty = '9509'.
ls_p9509-istat = '1'.
ls_p9509-begda = iv_bzks. "ls_data-zhr_bzks. "接口传入的编制生效日期
ls_p9509-endda = '99991231'.
ls_p9509-zhr_bznd = lwa_p9509-zhr_bznd.
ls_p9509-zhr_bzks = lwa_p9509-zhr_bzks. "上一条记录的开始日期
ls_p9509-zhr_bzjs = lwa_p9509-zhr_bzjs. "ls_data-zhr_bzjs. "接口传入的编制失效日期
ls_p9509-zhr_gkfs = lwa_p9509-zhr_gkfs. "ls_data-zhr_gkfs.
ls_p9509-tabnr = lwa_p9509-tabnr.
ls_p9509-guid_p9509 = lv_guid.
ls_p9509-zxgr_p9509 = iv_user.
ls_p9509-zstm_p9509 = sy-datum && sy-uzeit.
clear:ls_wplog.
call method cl_hr_pnnnn_type_cast=>pnnnn_to_wplog
exporting
pnnnn = ls_p9509
importing
wplog = ls_wplog.
append ls_wplog to lt_wplog.
loop at group ls_data assigning <fs_data>.
move-corresponding <fs_data> to ls_item.
ls_item-guid = lv_guid.
ls_pt9509-tabnr = ls_p9509-tabnr.
read table lt_data into data(ls_data_a) with key zhr_bzgwbm = <fs_data>-zgwbm
zhr_bzlx = <fs_data>-zhr_bzlx.
if sy-subrc = 0.
ls_pt9509-tabseqnr = ls_data_a-tabseqnr.
endif.
ls_pt9509-zhr_bzgwbm = <fs_data>-zgwbm.
ls_pt9509-zhr_bzgwmc = <fs_data>-zgwbm_t.
ls_pt9509-zhr_bzlx = <fs_data>-zhr_bzlx.
ls_pt9509-zhr_bzsl = <fs_data>-zhr_bzsl.
ls_pt9509-guid_p95092 = lv_guid.
ls_pt9509-zxgr_p95092 = iv_user.
ls_pt9509-zstm_p95092 = sy-datum && sy-uzeit.
delete lt_hrt9509_ins where zhr_bzgwbm = <fs_data>-zgwbm.
append ls_pt9509 to lt_pt9509.
append ls_item to lt_item.
clear:ls_pt9509,ls_item.
endloop.
call function 'RH_UPDATE_INFTY_EXP'
exporting
vtask = 'B' "'B'代表通过缓存更新 'D'代表直接更新 'S' 代表异步更新
order_flg = 'X'
commit_flg = 'X'
authy = 'X'
workf_actv = 'X'
tables
innnn = lt_wplog
tnnnn = lt_pt9509
exceptions
error_during_update = 1
no_authorization = 2
corr_exit = 3
no_innnn_tnnnn = 4
additional_innnn_tnnnn = 5
others = 6.
if sy-subrc <> 0.
lv_flag = 'X'.
loop at lt_item assigning <fs_item> where objid = ls_data-objid and zhr_bzlx = ls_data-zhr_bzlx.
<fs_item>-msgty = 'E'.
<fs_item>-msgtx = text-012."'编制调整失败'.
move-corresponding <fs_item> to ls_out.
ls_out-msgty = 'E'.
ls_out-msgtx = <fs_item>-msgtx.
append ls_out to et_out.
endloop.
else.
loop at lt_item assigning <fs_item> where objid = ls_data-objid and zhr_bzlx = ls_data-zhr_bzlx.
<fs_item>-msgty = 'S'.
<fs_item>-msgtx = '成功'.
endloop .
endif.
endif.
clear:ls_data,ls_out,lv_tabseqnr,lv_flag1.
refresh:lt_pt9509,lt_wplog.
endloop.
if et_out[] is not initial.
es_message-msgty = 'S'.
es_message-msgtx = '批导失败!'.
else.
if lv_flag is initial.
call function 'RH_UPDATE_DATABASE'
exporting
vtask = 'D'
exceptions
corr_exit = 1
others = 2.
endif.
es_message-msgty = 'S'.
es_message-msgtx = '批导成功!'.
endif.
3、读取信息类型:RH_READ_INFTY
data:ls_p9507 type p9507.
data:lt_9507 type standard table of p9507.
data:lv_bzlx type zhr_bzlx.
select * from dd07v
where domname = 'ZHR_BZLX'
and ddlanguage = @sy-langu
into table @data(lt_dd07v).
read table lt_dd07v into data(ls_dd07v) with key ddtext = ls_data-zhr_bzlx_t.
if sy-subrc = 0.
lv_bzlx = ls_dd07v-domvalue_l.
endif.
call
function 'RH_READ_INFTY'
exporting
plvar = '01'
otype = 'S'
objid = ls_data-plans ”组织编码
subty = lv_bzlx "ls_data-zhr_bzlx
infty = '9507'
istat = '1'
begda = ls_data-begda
endda = ls_data-begda
tables
innnn = lt_9507
exceptions
all_infty_with_subty = 1
nothing_found = 2
no_objects = 3
wrong_condition = 4
wrong_parameters = 5
others = 6.
4、定界:RH_CUT_INFTY
这里是借用第三个RH_READ_INFTY函数读取出来的数据进行定界处理的
data:lt_wplog_cut type standard table of wplog,
ls_wplog_cut type wplog.
clear:ls_9507.
read table lt_9507 into ls_9507 index 1.
if sy-subrc = 0.
move-corresponding ls_9507 to ls_p9507.
endif.
lv_cutdate = ls_data-begda - 1.
"先定界再新增
clear ls_wplog_cut.
refresh lt_wplog_cut.
call method cl_hr_pnnnn_type_cast=>pnnnn_to_wplog
exporting
pnnnn = ls_p9507
importing
wplog = ls_wplog_cut.
append ls_wplog_cut to lt_wplog_cut.
call function 'RH_CUT_INFTY'
exporting
gdate = lv_cutdate
histo = 'X'
vtask = 'D'
authy = space
tables
innnn = lt_wplog_cut
exceptions
error_during_cut = 1
no_authorization = 2
gdate_before_begda = 3
cut_of_timco_one = 4
corr_exit = 5
others = 6.
if sy-subrc <> 0.
es_message-msgty = 'E'.
es_message-msgtx = '定界失败'.
return.
else.
call function 'RH_UPDATE_DATABASE'
exporting
vtask = 'D'
exceptions
corr_exit = 1
others = 2.
endif.
5、删除:RH_DELETE_INFTY
data:lt_wplog_del type standard table of wplog,
ls_wplog_del type wplog.
clear ls_wplog_del.
refresh lt_wplog_del.
call method cl_hr_pnnnn_type_cast=>pnnnn_to_wplog
exporting
pnnnn = ls_9507
importing
wplog = ls_wplog_del.
append ls_wplog_del to lt_wplog_del.
call function 'RH_DELETE_INFTY'
exporting
vtask = 'S'
order_flg = 'X'
commit_flg = 'X'
authy = ''
workf_actv = 'X'
tables
innnn = lt_wplog_del
exceptions
error_during_delete = 1
no_authorization = 2
delete_first_record = 3
corr_exit = 4
others = 5.
if sy-subrc <> 0.
es_message-msgty = 'E'.
es_message-msgtx = '删除失败'.
return.
else.
call function 'RH_UPDATE_DATABASE'
exporting
vtask = 'D'
exceptions
corr_exit = 1
others = 2.
endif.