‎2009 Mar 25 11:26 AM
Hi
Sorry, but I didn't found any helpful answer.
I call the FM READ_TEXT at SAVE in the audit management.
I would like to get the text from the database, but I get the new text from the memory.
So, is there a FM which reads the text from the db?
Thx in advance
‎2009 Mar 25 11:46 AM
Hi,
ABAP READ_TEXT functions to read the SAP Long Text
All the long text can be retrieve using this method.
You have to used the READ_TEXT functions to read the SAP long text. e.g. Sales Order, Purchase Order Item text etc.
To check your long text header, go into the long text. Click Goto -> Header
Example of READ_TEXT functions reading tables PBIM - Independent requirements for material.
Go through this sample code below:
TABLES: PBIM.
* stxh, stxl, stxb - trans tables for text
* ttxit - text on text-ids
* ttxot - Short texts on text objects
* Transaction MD63
SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR,
S_WERKS FOR PBIM-WERKS.
DATA: BEGIN OF HTEXT.
INCLUDE STRUCTURE THEAD.
DATA: END OF HTEXT.
DATA: BEGIN OF LTEXT OCCURS 50.
INCLUDE STRUCTURE TLINE.
DATA: END OF LTEXT.
DATA: BEGIN OF DTEXT OCCURS 50.
DATA: MATNR LIKE PBIM-MATNR.
INCLUDE STRUCTURE TLINE.
DATA: END OF DTEXT.
DATA: TNAME LIKE THEAD-TDNAME.
SELECT * FROM PBIM WHERE WERKS IN S_WERKS.
MOVE PBIM-BDZEI TO TNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
ID = 'PB'
LANGUAGE = 'E'
NAME = TNAME
OBJECT = 'PBPT'
* ARCHIVE_HANDLE = 0
IMPORTING
HEADER = HTEXT
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
LOOP AT LTEXT.
IF LTEXT-TDLINE NE ''.
MOVE LTEXT-TDLINE TO DTEXT-TDLINE.
MOVE PBIM-MATNR TO DTEXT-MATNR.
APPEND DTEXT.
ENDIF.
ENDLOOP.
ENDSELECT.
LOOP AT DTEXT.
WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.
ENDLOOP.
Hope it helps
Regards
Mansi
Edited by: MANSI ASNANI on Mar 25, 2009 12:46 PM
‎2009 Mar 25 11:35 AM
Hi,
pls refer to the link below:
Link:[https://forums.sdn.sap.com/click.jspa?searchID=24020051&messageID=6915079]
thanks
‎2009 Mar 25 11:46 AM
Hi,
ABAP READ_TEXT functions to read the SAP Long Text
All the long text can be retrieve using this method.
You have to used the READ_TEXT functions to read the SAP long text. e.g. Sales Order, Purchase Order Item text etc.
To check your long text header, go into the long text. Click Goto -> Header
Example of READ_TEXT functions reading tables PBIM - Independent requirements for material.
Go through this sample code below:
TABLES: PBIM.
* stxh, stxl, stxb - trans tables for text
* ttxit - text on text-ids
* ttxot - Short texts on text objects
* Transaction MD63
SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR,
S_WERKS FOR PBIM-WERKS.
DATA: BEGIN OF HTEXT.
INCLUDE STRUCTURE THEAD.
DATA: END OF HTEXT.
DATA: BEGIN OF LTEXT OCCURS 50.
INCLUDE STRUCTURE TLINE.
DATA: END OF LTEXT.
DATA: BEGIN OF DTEXT OCCURS 50.
DATA: MATNR LIKE PBIM-MATNR.
INCLUDE STRUCTURE TLINE.
DATA: END OF DTEXT.
DATA: TNAME LIKE THEAD-TDNAME.
SELECT * FROM PBIM WHERE WERKS IN S_WERKS.
MOVE PBIM-BDZEI TO TNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
ID = 'PB'
LANGUAGE = 'E'
NAME = TNAME
OBJECT = 'PBPT'
* ARCHIVE_HANDLE = 0
IMPORTING
HEADER = HTEXT
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
LOOP AT LTEXT.
IF LTEXT-TDLINE NE ''.
MOVE LTEXT-TDLINE TO DTEXT-TDLINE.
MOVE PBIM-MATNR TO DTEXT-MATNR.
APPEND DTEXT.
ENDIF.
ENDLOOP.
ENDSELECT.
LOOP AT DTEXT.
WRITE:/ DTEXT-MATNR, DTEXT-TDLINE.
ENDLOOP.
Hope it helps
Regards
Mansi
Edited by: MANSI ASNANI on Mar 25, 2009 12:46 PM
‎2009 Mar 25 12:00 PM
Thx for your fast answer
BUT!
Have you read my problem?
I don't think so, because what you wrote is how to use the FM READ_TEXT....it runs...but I get the longtext from the MEMORY and not from DATABASE!
So I need a FM which gives me the longtext from the db.
‎2009 Mar 25 12:21 PM
Hi,
You can go through this link below:
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3bde358411d1829f0000e829fbfe/frameset.htm
Hope it helps
Regards
Mansi
‎2009 Mar 25 12:32 PM
Hi
Thank you for your answer. But I need a FM which gives me the text from the db
and not from the memory.
(I allready get the text from the memory, -> this is my problem)
‎2009 Mar 25 1:12 PM
hi...
read_text FM if you can check the source code of the FM , it pulls data from STXH table which is a database table.. to your request to pull from DB is full filled using read_text fm....
if you dont want to do that hit STXH table, if you have all the primary keys of the table... pick data from DB table directly..
‎2009 Mar 25 1:55 PM
The FM READ_TEXT reads the text from the memory, if there is one.
Because, when I'm debugging my program and stop at FM READ_TEXT, I get the new text (which will be saved after the commit) and when I call the same FM via SE37 AT THE SAME TIME, I still get the old text.
So your reply, that the FM just reads from the db is NOT CORRECT.
I hope somebody can suggest another FM....
‎2009 Mar 25 2:25 PM
>
> So your reply, that the FM just reads from the db is NOT CORRECT.
>
your correct I just read the FM documentation:
A text is read from the text file or text memory with this function module.
‎2009 Mar 25 1:07 PM
Hello,
The function module READ_TEXT reads the desired text from the text file, or the text memory.
For that you must specify the the text using the following parameters:
OBJECT
NAME
ID
LANGUAGE
With these option give unique or selective text rather tahn giving generic text as the internal table can hold only one text.
Example :
Ex:
DATA BEGIN OF i_tlines_r OCCURS 0.
INCLUDE STRUCTURE tline.
DATA END OF i_tlines_r.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'Z040'
LANGUAGE = 'E'
NAME = '0000003243' "For ex, Billing document number ,
OBJECT = 'VBBK'
TABLES
LINES = i_tlines_r
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
‎2009 Mar 25 2:21 PM
After you update the text, you also have to call FM COMMIT_TEXT . It's documented.
Rob
‎2009 Mar 25 2:25 PM
COMMIT_TEXT?
This will book and store my text or?
What has this to do with my problem?
‎2009 Mar 25 2:31 PM
>
> What has this to do with my problem?
It solves your problem.
Rob
‎2009 Mar 25 2:43 PM
Really? How?
This will book the text which is in the memory or?
And when I call the FM READ_TEXT at next, I have no chance to get the old text (text before save).
My problem once again:
I need to get the text from the DB at saving to compare it with the new text (which will be saved).
But when I call the FM READ_TEXT I get the text from the memory (new text).
So, when I call the FM COMMIT_TEXT, I'll get THE NEW TEXT from the DB.
So I need a FM which I can call at saving BEFORE the commit and which reads the text from the DB.
‎2009 Mar 25 3:00 PM
I guess some of the confusion is over exactly what you are trying to do. Is it:
1) Modify some text and save it
2) Read the text that has just been saved
3) Do some processing
or
1) Modify some text and save it
2) Read the text that existed before the save
3) Do some processing
or
Something else?
Rob
‎2009 Mar 25 3:03 PM
I do the second one, (reading existing text)
But the FM READ_TEXT reads the new text from the memory
‎2009 Mar 25 3:32 PM
I think you are using this in a sap standard transaction ( audit management) ? then you need to find a userexit that triggering before any change happens to text by user and get the text here and keep in an internal table , then use that internal table compare text during SAVE.
Please check link
Usually, the system reads a text from the text file. However, for texts with storage in the update task thesystem first looks into the text memory to see whether it contains a currently processed version. If so the system reads this version of the text into the work area, otherwise the text version from the text file
http://help.sap.com/saphelp_nw70/helpdata/EN/d6/0db764494511d182b70000e829fbfe/frameset.htm
a®
‎2009 Mar 25 4:00 PM
I'm allready in the correct BADI.
This is the first BADI which is called at save, so this must be the correct position
‎2009 Mar 25 6:04 PM
Maybe I'm missing something. Can you not keep a copy of the original text before it is edited?
Rob
‎2009 Mar 26 7:51 AM
Hi
I solved my problem now on my own.
But this kind of solution is not very nice
Coding:
IMPORT tline TO rt_lines
FROM DATABASE stxl(tx)
CLIENT rt_client
ID stxl_id
ACCEPTING TRUNCATION
IGNORING CONVERSION
ERRORS.
Thank you for your fast replies
‎2009 May 30 12:24 AM
Even I had the same issue. READ_TEXT was reading from memory instead of picking up the value from Database. After debugging I found that if I free memory id, system is forced to look into to Database.
Use the below statement before the READ_TEXT function module, this will solve the issue. This way you can edit the latest data as well.
free memory id 'SAPLSTXD'.
‎2011 Aug 03 6:59 AM
If you need to read the text from DB, you can achive through calling the sequence of these FM.
1) Call the FM READ_TEXT for the object, it will provide the text from memory. Keep this text in internal table.
2) Call the GM FREE_TEXT_MEMORY, it will clear the memory.
3) Call the FM READ_TEXT again, now it will read the text from Database.
4) Call the FM SAVE_TEXT and pass the internal table used in point 1, the purpose of this is to keep the memory state same. Otherwise the text maintained on screen will not be updated in database later on.