09-29-2008 7:35 PM
Hi,
The requirement I'm working with requires to add text to the existing text object. I used READ_TEXT to read the existing text and SAVE_TEXT to append the additional text. There is a scenario where there might be no text in the text object. In this case the FM READ_TEXT fails and the program stops at that point. Is there any way we can check if there is already some text in a text object so that only in that case we can use FM READ_TEXT else we just use SAVE_TEXT to append new text.
Any help will be appreciated.
Thanks,
ALAM.
09-29-2008 7:54 PM
Hi Alam,
to check if the text exists just use FM READ_TEXT. If there is no text, the FM will raise exception NOT_FOUND which you catch via subrc code.
So it is just enough to use case of subrc after call of the FM.
If subrc is 0 then text exists, then just edit table with text and use SAVE_TEXT.
If text doesn't exitst - I don't know which value of subrc is it now (you will get it when you use pattern button) then first call INIT_TEXT and then SAVE_TEXT (or you can use CREATE_TEXT - but this is not working properly in some cases because of COMMIT inside the body).
Regards,
Karol
Edited by: Karol Seman on Sep 29, 2008 8:55 PM
09-29-2008 7:49 PM
09-29-2008 7:56 PM
Hi Muthappan,
Do you mean to say if there exists an entry in STXH then only use READ_TEXT?
Regards,
ALAM.
09-29-2008 7:50 PM
Hi,
> In this case the FM READ_TEXT fails and the program stops at that point.
>
Do you mean if there is no text the READ_TEXT FM goes for a Short dump??
To check if there is a text exist, you have to use READ_TEXT.
You can jus go without checking sy-subrc or your itab is initial after the READ_TEXT stmt, let the code pass through both the FM all the time you run.
09-29-2008 7:54 PM
Hello Senthil,
Do you mean if there is no text the READ_TEXT FM goes for a Short dump?? - It does not dump but it stops at an error message inside the READ_TEXT FM.
Thanks,
ALAM.
09-29-2008 7:54 PM
Hi Alam,
to check if the text exists just use FM READ_TEXT. If there is no text, the FM will raise exception NOT_FOUND which you catch via subrc code.
So it is just enough to use case of subrc after call of the FM.
If subrc is 0 then text exists, then just edit table with text and use SAVE_TEXT.
If text doesn't exitst - I don't know which value of subrc is it now (you will get it when you use pattern button) then first call INIT_TEXT and then SAVE_TEXT (or you can use CREATE_TEXT - but this is not working properly in some cases because of COMMIT inside the body).
Regards,
Karol
Edited by: Karol Seman on Sep 29, 2008 8:55 PM
09-29-2008 8:13 PM
You have to include the exception NOT_FOUND in your call to FM READ_TEXT. Then you will be able to check sy-subrc.
Rob