Wednesday, October 21, 2009

Updating long text in IW32 and IW62

If you change the long texts in IW32 and IW62 using the function module SAVE_TEXT, you will not be able to see the text from the TCodes, even though you can see the text when you use function module READ_TEXT. The problem is because both TCodes relies on values on other tables to determine the language used for the text.

Here is how to update the text for IW32:


form f_update_text
using fu_aufnr fu_vornr fu_ltxa1 fu_avot.

data:
ld_aufpl like afvc-aufpl,
ld_aplzl like afvc-aplzl,
ld_vornr(4) type n,
ld_name like stxh-tdname,
ld_subrc like sy-subrc.

ld_vornr = fu_vornr.
select single aufpl into ld_aufpl from caufv
where aufnr = fu_aufnr.

select single aplzl into ld_aplzl from afvc
where aufpl = ld_aufpl and vornr = ld_vornr.

concatenate sy-mandt ld_aufpl ld_aplzl into ld_name.

perform f_write_text
using ld_name fu_ltxa1 fu_avot
changing ld_subrc.

if ld_subrc is initial.
update afvc set txtsp = sy-langu
where aufpl = ld_aufpl and aplzl = ld_aplzl.
endif.

endform. "f_update_text


form f_write_text
using fu_name fu_shorttext fu_text
changing fc_subrc.

data:
lw_thead type thead,
lt_tline type table of tline with header line.

lw_thead-tdobject = 'AUFK'. "SO Header (table TTXOB)
lw_thead-tdspras = sy-langu.
lw_thead-tdname = fu_name.
lw_thead-tdid = 'AVOT'. "Header note 1 (table TTXID)

lt_tline-tdformat = '*'.
lt_tline-tdline = fu_shorttext.
append lt_tline.
lt_tline-tdformat = '*'.
lt_tline-tdline = fu_text.
append lt_tline.

call function 'SAVE_TEXT'
exporting
header = lw_thead
savemode_direct = 'X'
tables
lines = lt_tline
exceptions
id = 1
language = 2
name = 3
object = 4
others = 5.

if sy-subrc <> 0.
fc_subrc = sy-subrc.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.
clear fc_subrc.
endif.
endform. "f_write_text



And here is the code for IW62:


form f_update_text
using fu_aufnr fu_vornr fu_ltxa1 fu_avot.

data:
ld_aufpl like afvc-aufpl,
ld_aplzl like afvc-aplzl,
ld_vornr(4) type n,
ld_name like stxh-tdname,
ld_subrc like sy-subrc.

ld_vornr = fu_vornr.
select single aufpl aplzl into (ld_aufpl, ld_aplzl) from hivg
where aufnr = fu_aufnr and vornr = ld_vornr.


concatenate sy-mandt ld_aufpl ld_aplzl into ld_name.

perform f_write_text
using ld_name fu_ltxa1 fu_avot
changing ld_subrc.

if ld_subrc is initial.
update hivg set txtsp = sy-langu
where aufpl = ld_aufpl and aplzl = ld_aplzl.
endif.

endform. "f_update_text


form f_write_text
using fu_name fu_shorttext fu_text
changing fc_subrc.

data:
lw_thead type thead,
lt_tline type table of tline with header line.

lw_thead-tdobject = 'AUFK'. "SO Header (table TTXOB)
lw_thead-tdspras = sy-langu.
lw_thead-tdname = fu_name.
lw_thead-tdid = 'AVOT'. "Header note 1 (table TTXID)

lt_tline-tdformat = '*'.
lt_tline-tdline = fu_shorttext.
append lt_tline.
lt_tline-tdformat = '*'.
lt_tline-tdline = fu_text.
append lt_tline.

call function 'SAVE_TEXT'
exporting
header = lw_thead
savemode_direct = 'X'
tables
lines = lt_tline
exceptions
id = 1
language = 2
name = 3
object = 4
others = 5.

if sy-subrc <> 0.
fc_subrc = sy-subrc.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

else.
clear fc_subrc.
endif.
endform. "f_write_text

No comments:

Post a Comment