2008 Jul 11 9:35 AM
how to retrieve long texts from infotypes.
From infotype 0040 I need to retrieve long texts.
Where actually it gets saved.
The Macro RT-IMP-C1-TX can be used for this purpose.
But how to use it.
2008 Jul 11 2:08 PM
How RP-IMP-C1-TX macro is used.
I need to fetch long texts from infotype 0040.
pls explain how this macro is processed.
2008 Jul 11 9:45 AM
Hi charan,
Try this one
REPORT ZHUGE_LONGTEXTS .
TABLES: PCL1,PA0000,T582S.
DATA: TX-KEY LIKE PSKEY.
DATA: BEGIN OF TEXT-VERSION,
NUMMER TYPE X VALUE '02',
END OF TEXT-VERSION.
DATA: BEGIN OF PTEXT OCCURS 200.
DATA: LINE(78).
DATA: END OF PTEXT.
DATA: KEY1 LIKE PCL1-SRTFD.
DATA: KEY2 LIKE PCL1-SRTFD.
DATA: FINAL_KEY LIKE PCL1-SRTFD.
DATA: BLANK(7).
DATA: BLANK1(3).
PARAMETERS: PERNR LIKE PA0000-PERNR,
INFTY LIKE T582S-INFTY,
SUBTY LIKE PA0000-SUBTY,
ENDDA LIKE PA0000-ENDDA,
BEGDA LIKE PA0000-BEGDA.
IF SUBTY IS INITIAL.
CONCATENATE PERNR INFTY INTO KEY1.
CONCATENATE ENDDA BEGDA '000' INTO KEY2.
CONCATENATE KEY1 KEY2 INTO FINAL_KEY SEPARATED BY BLANK.
ELSE.
*-- if with subtypes
CONCATENATE PERNR INFTY SUBTY INTO KEY1.
CONCATENATE ENDDA BEGDA '000' INTO KEY2.
CONCATENATE KEY1 KEY2 INTO FINAL_KEY SEPARATED BY BLANK1.
ENDIF.
MOVE FINAL_KEY TO TX-KEY.
RP-IMP-C1-TX.
LOOP AT PTEXT.
WRITE:/ PTEXT.
ENDLOOP.
Regards
Divya
2008 Jul 11 10:32 AM
Hi Divya,
I have already tried this code earlier.
But I could not find when the PTEXT internal table is getting filled.
After the macro if I check this table, it is initial.
Can u let me know how this table gets populated.
Will it be automatically populated after the Macro statement.
2008 Jul 11 9:48 AM
Hey
try this also
Hi,
Function READ_TEXT is the right one for retrieving the long text of
the material. Try the following :
data: lv_object like stxh-tdobject.
lv_object = mara-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
mandt = sy-mandt
id = 'GRUN' <---- GRUN for Basic Data Text,
IVER for Internal Comment,
PRUE for Inspection text
BEST for Purchase order text
language = sy-langu
name = 'MATERIAL'
object = lv_object
tables
lines = it_lines
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
reward if useful.
regards
Divya
2008 Jul 11 9:48 AM
hi check this example..
A simple code that will insert infotype data and Maintain Text data.
For the sample I use infotype 2002 (Attendances).
Type and Data declaration:
TYPES BEGIN OF text_version.
TYPES nummer TYPE x.
TYPES END OF text_version.
DATA: PERSONALDATAKEY LIKE BAPIPAKEY.
DATA: RETURN LIKE BAPIRETURN1.
DATA: P2002 LIKE P2002.
DATA: PSKEY TYPE PSKEY.
DATA: IT_TEXT TYPE HRPAD_TEXT_TAB .
DATA: LINE TYPE HRPAD_TEXT.
DATA: version TYPE text_version.
DATA: pcl1 TYPE pcl1.
Input Parameters:
PARAMETERS: PERNR LIKE PA2002-PERNR DEFAULT '1004511',
AWART LIKE PA2002-AWART DEFAULT 'LW',
BEGDA LIKE PA2002-BEGDA DEFAULT SY-DATUM,
ENDDA LIKE PA2002-ENDDA DEFAULT SY-DATUM,
BEGUZ LIKE PA2002-BEGUZ,
ENDUZ LIKE PA2002-ENDUZ.
Lock Personnel Number:
START-OF-SELECTION.
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = PERNR
IMPORTING
RETURN = RETURN.
IF RETURN-NUMBER IS NOT INITIAL.
EXIT.
ENDIF.
Insert infotype data:
ADD DATA
CLEAR: P2002.
P2002-PERNR = PERNR.
P2002-SUBTY = AWART.
P2002-ENDDA = BEGDA.
P2002-BEGDA = BEGDA.
P2002-BEGUZ = BEGUZ.
P2002-ENDUZ = ENDUZ.
P2002-AWART = AWART.
P2002-ITXEX = 'X'.
WRITE DATA
CLEAR: RETURN, PERSONALDATAKEY.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '2002'
NUMBER = PERNR
SUBTYPE = AWART
VALIDITYEND = BEGDA
VALIDITYBEGIN = BEGDA
RECORD = P2002
OPERATION = 'INS'
NOCOMMIT = ''
TCLAS = 'A'
IMPORTING
RETURN = RETURN
KEY = PERSONALDATAKEY
EXCEPTIONS
OTHERS = 0.
IF RETURN-NUMBER IS INITIAL.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
EXIT.
ENDIF.
Insert Maintain Text data:
ADD DATA
CLEAR: PSKEY, IT_TEXT[].
pskey-pernr = PERNR.
pskey-infty = '2002'.
pskey-subty = AWART.
pskey-endda = BEGDA.
pskey-begda = ENDDA.
pskey-seqnr = PERSONALDATAKEY-RECORDNR.
version-nummer = '02'.
pcl1-histo = 'X'.
pcl1-uname = SY-UNAME.
pcl1-aedtm = SY-DATUM.
ADD IT_TEXT DATA
CLEAR: LINE.
LINE = 'Sample text:'.
APPEND LINE TO IT_TEXT.
CLEAR: LINE.
LINE = 'Here you can store your information.'.
APPEND LINE TO IT_TEXT.
EXPORT
text-version FROM version
ptext FROM IT_TEXT
TO DATABASE pcl1(TX) ID pskey
FROM pcl1.
Unlock Personnel Number:
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = PERNR
IMPORTING
RETURN = RETURN.
2008 Jul 11 2:08 PM
How RP-IMP-C1-TX macro is used.
I need to fetch long texts from infotype 0040.
pls explain how this macro is processed.
2008 Jul 11 2:11 PM
Please use the method READ of the class CL_HRPA_TEXT_CLUSTER, no need to use any macros.
2008 Jul 14 6:47 AM
Hi Rajesh,
Thanks for valuable time.
Long text can be retrieved using the class CL_HRPA_TEXT_CLUSTER.
Is there any possibility of creating a new record in infotype 0040 along with long texts.
This is an interface requirement.
Any RFC or BAPI available.
2008 Jul 22 10:56 AM
Dear Rajesh,
How to Create long text in infotypes (not through PA30).
for ex: infotypes 0040, 2001.
The class CL_HRPA_TEXT_CLUSTER is working for READ and Updating the text.
When I am creating new record using UPDATE I cannot see the text when I go to infotype screen.
But if I read the text using the READ method of the same class
I am getting the text.
Is there any method to do so. or any other alternate way.
2008 Jul 22 10:59 AM
solution provided is working fine for display and Update, but not working for creating long text (without using pa30).
2008 Jul 22 11:22 AM
Hi Charan
Develop a program on the similar lines as shown below with your own data, it works fine with me
REPORT test.
DATA:
tclas TYPE tclas,
pskey TYPE pskey,
auth_check TYPE boole_d,
text_tab TYPE hrpad_text_tab,
wa_text_tab LIKE LINE OF text_tab.
tclas = 'A'.
pskey-pernr = '87654301'.
pskey-infty = '0001'.
pskey-subty = ''.
pskey-objps = ''.
pskey-begda = '20070401'.
pskey-endda = '99991231'.
*TRY.
CALL METHOD cl_hrpa_text_cluster=>read
EXPORTING
tclas = tclas
pskey = pskey
no_auth_check = 'X'
IMPORTING
* histo =
* uname =
* aedtm =
* pgmid =
text_tab = text_tab
.
* CATCH cx_hrpa_missing_authorization .
* CATCH cx_hrpa_violated_assertion .
*ENDTRY.
LOOP AT text_tab INTO wa_text_tab.
wa_text_tab = 'Testing "UPDATE" Method of the class "cl_hrpa_text_cluster"'.
modify text_tab from wa_text_tab.
ENDLOOP.
*TRY.
CALL METHOD cl_hrpa_text_cluster=>update
EXPORTING
tclas = tclas
pskey = pskey
histo = 'X'
* uname = SY-UNAME
* aedtm = SY-DATUM
pgmid = 'ZYTEST'
text_tab = text_Tab
no_auth_check = 'X'.
* CATCH cx_hrpa_missing_authorization .
* CATCH cx_hrpa_violated_assertion .
*ENDTRY.
LOOP AT text_tab INTO wa_text_tab.
WRITE: wa_text_tab.
ENDLOOP.
2008 Jul 22 11:34 AM
Thanks again for your time Rajesh.
I tried in the exact way you replied.
As I told you I could not find the text in infotype pa30 screen.
But I can read it.
It is not being displayed there.
I am developing an RFC for MSS through which the new record is created.
Pls see the Code:
Lock Employee
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = employeenumber
IMPORTING
return = wa_return1.
IF NOT wa_return1 IS INITIAL.
CONCATENATE wa_return1-message
employeenumber
INTO return_message
SEPARATED BY space.
exit.
ENDIF.
Create New Record
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = c_infty
NUMBER = employeenumber
VALIDITYEND = VALIDITYEND
VALIDITYBEGIN = VALIDITYBEGIN
RECORD = wa_0040
OPERATION = 'INS'
IMPORTING
RETURN = wa_return1
KEY = wa_pakey
EXCEPTIONS
OTHERS = 0.
IF NOT wa_return1 IS INITIAL.
CONCATENATE wa_return1-message
employeenumber
INTO return_message
SEPARATED BY space.
ELSE.
wa_pskey-pernr = wa_pakey-pernr.
wa_pskey-infty = c_infty.
wa_pskey-subty = wa_pakey-subtype.
wa_pskey-objps = wa_pakey-objectid.
wa_pskey-sprps = wa_pakey-lockindic.
wa_pskey-endda = wa_pakey-validend.
wa_pskey-begda = wa_pakey-validbegin.
wa_pskey-seqnr = wa_pakey-recordnr.
TRY.
CALL METHOD CL_HRPA_TEXT_CLUSTER=>READ
EXPORTING
TCLAS = 'A'
PSKEY = wa_pskey
NO_AUTH_CHECK = 'X'
IMPORTING
HISTO = l_histo
UNAME = l_uname
AEDTM = l_aedtm
PGMID = l_pgmid
TEXT_TAB = it_text.
CATCH CX_HRPA_MISSING_AUTHORIZATION .
CATCH CX_HRPA_VIOLATED_ASSERTION .
ENDTRY.
refresh it_text.
append text1 to it_text.
append text2 to it_text.
append text3 to it_text.
TRY.
CALL METHOD CL_HRPA_TEXT_CLUSTER=>UPDATE
EXPORTING
TCLAS = 'A'
PSKEY = wa_pskey
HISTO = l_histo
UNAME = l_uname
AEDTM = l_aedtm
PGMID = l_pgmid
TEXT_TAB = it_text
NO_AUTH_CHECK = 'X'.
CATCH CX_HRPA_MISSING_AUTHORIZATION .
CATCH CX_HRPA_VIOLATED_ASSERTION .
ENDTRY.
2008 Jul 22 12:25 PM
Hi Charan
Kindly check the below part of your code
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = c_infty
NUMBER = employeenumber
VALIDITYEND = VALIDITYEND
VALIDITYBEGIN = VALIDITYBEGIN
RECORD = wa_0040
OPERATION = 'INS'
IMPORTING
RETURN = wa_return1
KEY = wa_pakey
EXCEPTIONS
OTHERS = 0.
IF NOT wa_return1 IS INITIAL.
CONCATENATE wa_return1-message
employeenumber
INTO return_message
SEPARATED BY space.
ELSE.
wa_pskey-pernr = wa_pakey-pernr.
wa_pskey-infty = c_infty.
wa_pskey-subty = wa_pakey-subtype.
wa_pskey-objps = wa_pakey-objectid.
wa_pskey-sprps = wa_pakey-lockindic.
wa_pskey-endda = wa_pakey-validend.
wa_pskey-begda = wa_pakey-validbegin.
The variable wa_return1 will not be initial, even if the operation performed by HR_INFOTYPE_OPERATION is successfull.
So, please place the logic of updating the text cluster in the IF part ( currently this logic is placed in the ELSE part, and handle the error records according to the message type - (S)uccess, (E)rror, ..)
2008 Jul 22 1:00 PM
that's Ok Rajesh.
You have given a new point.
But as of now I am getting the control to this update part.
That's not a problem for me now.
But Can you check that I have created a record thru HR_INFOTYPE_OPERATION.
Since this is a new record for this no information will be available in PCL1.
so even if I read I wont get any data in importing parameters.
then I am trying to update
TRY.
CALL METHOD CL_HRPA_TEXT_CLUSTER=>UPDATE
EXPORTING
TCLAS = 'A'
PSKEY = wa_pskey
HISTO = 'X'
UNAME = sy-uname
AEDTM = sy-datum
PGMID = 'ZOBJECT'
TEXT_TAB = it_text
NO_AUTH_CHECK = ' X'.
CATCH CX_HRPA_MISSING_AUTHORIZATION .
CATCH CX_HRPA_VIOLATED_ASSERTION .
ENDTRY.
after this method subrc is initial.
But I wont be able to watch this text in infotype screen.
(all normal fields are been displayed perfectly)
But I am getting the text when I execute the READ method of the above class.
How come this deviation?
2008 Jul 23 9:50 AM
Dear Rajesh,
My problem is still not solved.
If u can share your contact number it would be great.
pls share your contact number to
+91-9821681056
2008 Aug 05 3:32 PM
The module pool of the infotype framework expects that the field ITXEX (infotype text exists) of the structure PSHD1 to be updated with the value 'X' before displaying the text from the cluster TX(PCL1), so the program is also expected to update the field ITXEX after calling the "UPDATE" method. Hope this helps.
2011 Apr 05 1:10 PM