Reputation: 429
I need to create/write a text in an infotype via ABAP code. 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.
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.
Upvotes: 2
Views: 1725
Reputation: 399
Perhaps this 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.
Upvotes: 1