Application Development and Automation 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: 
Read only

error in FM read text/save text

Former Member
0 Likes
2,186

Hi All!

I am using FM read text and save text respectively to read the already existing value in text element and concatenate with new text and then save the text using save text FM and this method is perfectly working fine in this scenario.

If when there is no text to be read while using read text I am getting an error and hence could not able to save my new text and the program is terminating.How to handle this.

This is with reference to text elements on text tab in the header section of transaction VL02N.

Regrads

pavan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,715

Try catching the errors in the exceptions parameter of the function module, using if sy-subrc <> 0.

10 REPLIES 10
Read only

Former Member
0 Likes
1,715

Hi Pavan,

Remove the <b>exception handling</b> after the <b>READ_TEXT</b> think this is the problem. It wont cause any problem. After that you know the text, id and object and save with the new text using <b>SAVE_TEXT</b>. It will work.

Reward if helpful.

Regards,

Tushar

Read only

0 Likes
1,715

Tushar!

Indeed I removed the exception handling part and tested but my code is getting struck at the read text FM giving an error "Text 80006463 ID ZHIS Language EN not found".

Please advise.

Regards

Pavan

Read only

0 Likes
1,715

Hi pavan,

first find the Correct parameters TDID,TDNAME ,TDOBJ from STXH table and then proceed.can i see your code, so that it is easy to tell what is wrong.

TDNAME should be padded with zeroes.

say sales order.(VBELN)if you give 12345 then it will give error.

<b>0000012345</b> you should pass with padded zeroes. it if item then it should be <b>0000012345000010</b>.

try that.

Regards

vijay

Read only

Former Member
0 Likes
1,716

Try catching the errors in the exceptions parameter of the function module, using if sy-subrc <> 0.

Read only

Former Member
0 Likes
1,715

Hi,

comment the execptions in READ_TEXT FM.

OR

comment the MESSAGE statement after SY_SUBRC check

after calling READ_TEXT.

Regards,

Shashank

Read only

Former Member
0 Likes
1,715

Hi,

you can also use INIT_TEXT when creating a new text.

Cheers,

Stefan.

Read only

Former Member
0 Likes
1,715

Hai Pavan Kumar

Check the following Code for F.M READ_TEXT & SAVE_TEXT

DATA: BEGIN OF XTHEAD.

INCLUDE STRUCTURE THEAD.

DATA: END OF XTHEAD.

DATA: BEGIN OF ZZTLINE OCCURS 10.

INCLUDE STRUCTURE TLINE.

DATA: END OF ZZTLINE.

XTHEAD-TDID = 'ZPPM'. "TEXT-ID

XTHEAD-TDSPRAS = SY-LANGU. "Language

XTHEAD-TDNAME = 'ZTKF'. "identification

CONCATENATE SY-TCODE(5) ITAB0300POS-AUFNR

INTO XTHEAD-TDNAME.

XTHEAD-TDOBJECT = 'TEXT'. "Object type top/position

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = XTHEAD-TDID

LANGUAGE = XTHEAD-TDSPRAS

NAME = XTHEAD-TDNAME

OBJECT = XTHEAD-TDOBJECT

IMPORTING

HEADER = XTHEAD

TABLES

LINES = ZZTLINE

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.

REFRESH ZZTLINE.

ZZTLINE-TDLINE = ITAB0300POS-BEM.

APPEND ZZTLINE.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

HEADER = XTHEAD

IMPORTING

FUNCTION = ZFUNCTION

NEWHEADER = XTHEAD

TABLES

LINES = ZZTLINE

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4

OTHERS = 5.

ELSE.

XTHEAD-TDID = 'ZPPM'. "TEXT-ID

XTHEAD-TDSPRAS = SY-LANGU. "Language

XTHEAD-TDNAME = 'ZTKF'. "identification

CONCATENATE SY-TCODE(5) ITAB0300POS-AUFNR

INTO XTHEAD-TDNAME.

XTHEAD-TDOBJECT = 'TEXT'. "Object type top/position

REFRESH ZZTLINE.

ZZTLINE-TDLINE = ITAB0300POS-BEM.

APPEND ZZTLINE.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

FID = XTHEAD-TDID

FLANGUAGE = XTHEAD-TDSPRAS

FNAME = XTHEAD-TDNAME

FOBJECT = XTHEAD-TDOBJECT

TABLES

FLINES = ZZTLINE

EXCEPTIONS

NO_INIT = 01

NO_SAVE = 02.

ENDIF.

Thanks & regards

Sreenivasulu P

Read only

Former Member
0 Likes
1,715

HI,

see the below code

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = 'FKK0'

language = sy-langu

name = w_text

object = 'FKKKO'

TABLES

lines = it_read_line

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.

<b>

    LOOP AT it_read_line.
      MOVE: it_read_line-tdline TO it_fline-tdline.
      APPEND it_fline.
    ENDLOOP.  " LOOP AT notes

</b>

    • Creating the TEXT

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

fid = 'FKK0'

flanguage = sy-langu

fname = w_text

fobject = 'FKKKO'

save_direct = 'X'

TABLES

flines = it_fline

EXCEPTIONS

NO_INIT = 1

NO_SAVE = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR w_text.

ENDLOOP.

here, just get the text using FM 'READ_TEXT' then move to another Internal table adding the new text to that internal table then call the FM 'CREATE_TEXT',

so if you have the new text then it will add to the existing one, if there is no new text then it will create the old one itself..

hope you got my point

Thanks

Sudheer

Read only

Former Member
0 Likes
1,715

Hi Pavan,

Remove the sy-subrc check after the READ_TEXT funciton module. to the internal table where u pass to the SAVE_TEXT append the new text you want to save and do the save part. Hope this works.

Regards,

Tushar

Read only

Former Member
0 Likes
1,715

Hi Pavan,

Remove the sy-subrc check after the READ_TEXT funciton module. to the internal table where u pass to the SAVE_TEXT append the new text you want to save and do the save part. Hope this works.

Regards,

Tushar