Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Add Text

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

karol_seman
Active Participant
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

Read data from STXH. if no record then use SAVE_TEXT.

Regards

M

0 Kudos

Hi Muthappan,

Do you mean to say if there exists an entry in STXH then only use READ_TEXT?

Regards,

ALAM.

Former Member
0 Kudos

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.

0 Kudos

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.

karol_seman
Active Participant
0 Kudos

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

Former Member
0 Kudos

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