[英]Write infotype text programmatically
I need to create/write a text in an infotype via ABAP code.我需要通过 ABAP 代码在信息类型中创建/编写文本。 So I'm looking for a function module or some "clean" solution for this.
所以我正在为此寻找一个功能模块或一些“干净”的解决方案。 Right now I only found this post with a "quick&dirty" solution.
现在我只发现这篇文章有一个“quick&dirty”的解决方案。
I'm a bit afraid to change something directly from the cluster so I hope maybe someone can offer me another way to solve this issue.我有点害怕直接从集群更改某些内容,所以我希望有人可以为我提供另一种解决此问题的方法。
Perhapsthis will help you.也许这会对你有所帮助。 It's the most modular and OO possibility I've came across yet.
这是我遇到的最模块化和面向对象的可能性。
Here is a sample code:这是一个示例代码:
DATA: lo_0194 TYPE REF TO cl_hrpa_infotype_0194,
lw_pernr TYPE p_pernr,
fr_msg_handler TYPE REF TO if_hrpa_message_handler,
lr_message_list TYPE REF TO cl_hrpa_message_list,
ls_container TYPE hrpad_infty_container_ref,
lr_contain_0194 TYPE REF TO cl_hrpa_infotype_container,
lr_upd_cluster TYPE REF TO cl_hrpa_text_cluster,
lt_text_194 TYPE hrpad_text_tab.
creating infotype object创建信息类型对象
CREATE OBJECT lr_message_list.
fr_msg_handler = lr_message_list.
TRY.
CREATE OBJECT lo_0194
EXPORTING
tclas = 'A'
infty = '0194'.
CATCH cx_hrpa_violated_assertion INTO DATA(ls_exp).
DATA(lw_message) = ls_exp->get_text( ).
ENDTRY.
IF lw_message IS INITIAL.
"error handling
ENDIF.
modifying data修改数据
APPEND 'TEXT' TO lt_text_194.
TRY.
lr_contain_0194 ?= ls_container.
lr_contain_0194->modify_text_tab( lt_text_194 ).
CATCH cx_hrpa_violated_assertion INTO ls_exp.
lw_message = ls_exp->get_text( ).
ENDTRY.
TRY.
lo_0194->if_hrpa_infty_bl~modify(
EXPORTING
old_container = lr_contain_0194
massn = space
massg = space
update_mode = VALUE hrpad_update_mode( )
no_auth_check = ''
message_handler = fr_msg_handler
IMPORTING
is_ok = DATA(lw_ok)
CHANGING
container = ls_container ).
CATCH cx_hrpa_violated_assertion INTO ls_exp.
lw_message = ls_exp->get_text( ).
ENDTRY.
updating cluster更新集群
CREATE OBJECT lr_upd_cluster.
TRY.
CALL METHOD lr_upd_cluster->update
EXPORTING
tclas = 'A'
pskey = VALUE pskey( )
histo = abap_true
uname = sy-uname
aedtm = sy-datum
pgmid = VALUE old_prog( )
text_tab = lt_text_194
no_auth_check = abap_true.
CATCH cx_hrpa_violated_assertion.
ENDTRY.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.