‎2013 May 09 9:55 PM
Hello,
I have created a Class/Method and I need to be able to create HR Intotype texts for Infotype 0021. The code below (which I got off SDN a few years back) works great in an ABAP, but it is not support in the OO Context. the line starting with rp-read-infotype is a macro and it is not supported. Also, export to database is an obsolete statement. The function SAVE_TEXT will not work for infotypes. Does anyone know how I can update/create my comments text in an infotype using OO code?
Old CODE that works in an ABAP:
report zp_pa_0019_save_notes .
tables: pernr.
infotypes: 0019.
data: key like pskey.
data: begin of ptext occurs 200.
data: line(72).
data: end of ptext.
selection-screen begin of block abc with frame title text-001.
parameters: p_pernr like pernr-pernr.
selection-screen end of block abc.
ptext-line = 'Test Text1'.
append ptext.
ptext-line = 'Test Text2'.
append ptext.
rp-read-infotype p_pernr 0019 p0019 '18000101' '99991231'.
sort p0019 descending.
read table p0019 index 1.
move-corresponding p0019 to key.
p0019-itxex = 'X'.
update pa0019 set itxex = 'X' where pernr = p_pernr.
export ptext to database pcl1(tx) id key.
commit work.
‎2013 May 10 8:57 AM
Hi Janice,
there are some restrictions with OO coding.
Use of macros is supported, they only have to be defined within the class. Use of TRMAC-macros however will not work within OO.
Instead use FM HR_READ_INFOTYPE - it's even documented
As for your export statement, it's still supported, only the short syntax isn't.
For full detail see F1 help for export.
If in doubt, use the most explicit syntax version - in most cases this will work with OO.
Best regards
Jörg
‎2013 May 10 8:57 AM
Hi Janice,
there are some restrictions with OO coding.
Use of macros is supported, they only have to be defined within the class. Use of TRMAC-macros however will not work within OO.
Instead use FM HR_READ_INFOTYPE - it's even documented
As for your export statement, it's still supported, only the short syntax isn't.
For full detail see F1 help for export.
If in doubt, use the most explicit syntax version - in most cases this will work with OO.
Best regards
Jörg
‎2013 May 10 3:41 PM
thx for your response. I can read the text just fine (sorry should have been clearer). My problem is actually writing it back to the database with some changes to the text that my code makes.
I did find a class CL_HR_PTEXT which has a method update in it. I can read texts and get lots of things to work in this class, but I can't figure out how to get the update to work. Any advice on this one?
Also I went back and looked at the export statement as you suggested. I did get it so it quicks complaining that it is not OO compliant. However now it only "deletes" my exsiting text from the infotype - it does not update it with my new text.
Here is my "new code:
data: ls_pskey type pskey, "structure for
lt_infotype_text type table of hrwpc_s_infotype_text.
ls_pskey-pernr = wa_p0021-pernr.
ls_pskey-infty = '0021'.
ls_pskey-subty = wa_p0021-subty.
ls_pskey-objps = wa_p0021-objps.
ls_pskey-endda = wa_p0021-endda.
ls_pskey-begda = wa_p0021-begda.
export lt_infotype_text from lt_infotype_text to database pcl1(tx) id ls_pskey.
My id (ls_key) is fine as it is actually deleting the text -- it just doesn't update it with the new text in my lt_infotype_text table.
Any suggestions on the class I mentioned earlier or what I am doing wrong with my export statement or anything else?
‎2013 May 10 5:08 PM
Hi
I have submitted a document with loop holes while updating infotype text ..
Below is the thread .
http://scn.sap.com/docs/DOC-40809
This will definitely works ..reward if useful and let me know if not works i had worked on this recently
‎2013 May 10 5:28 PM
Brilliant!! thank-you a million times. It works!! All I needed was your last example code on using the
cl_hrpa_text_cluster class (i.e., call method lr_upd_cluster->update). I knew there had to be some type of class out there. Great document and also your tips re: needing the text flag set (itxex) are going to be invaluable to many.
‎2013 May 11 6:32 AM
Hi Janice
Good that my document is useful to you and created a blog on this .
http://scn.sap.com/community/erp/hcm/blog/2013/04/30/issue-with-long-text-in-infotypes