cancel
Showing results for 
Search instead for 
Did you mean: 

Text Include / Read_TEXT in Smartforms

Former Member
0 Kudos

Hi,

i can't use text include in smartforms, so i use read_text.

But i have a problem when no text exists.

In text include for that they are a case for no error if no text exists.

How can do when i use read_text for not have error if no text exists please?


DATA: BEGIN OF it_lines occurs 0,
        tdformat TYPE tline-tdformat,
        tdline TYPE tline-tdline,
      END OF it_lines.

DATA : str_lines like tline.
DATA : Z0001_ADVTEXTE1 type TDLINE.
DATA : Z0001_ADVTEXTE2 type TDLINE.
DATA : Z010_LIB1 type TDLINE.
DATA : Z010_LIB2 type TDLINE.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
    id                            = '0001'
    language                      = SY-LANGU
    name                          = '0050000027000010'
    object                        = 'VBBP'
  tables
    lines                         = it_lines.
 .

READ TABLE it_lines into str_lines index 3.
Z0001_ADVTEXTE1 = str_lines-tdline+0(132).
READ TABLE it_lines into str_lines index 4.
Z0001_ADVTEXTE2 = str_lines-tdline+0(132).

Concatenate Z0001_ADVTEXTE1 Z0001_ADVTEXTE2 into Z0001_ADVTEXTE separated by ''.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

For your code add the following code, just before calling the read_text write the select query like this,

And if sy-subrc is initial then call the Function module

Along with that code uncomment the exceptions also of the Function Module

DATA: BEGIN OF it_lines occurs 0,

tdformat TYPE tline-tdformat,

tdline TYPE tline-tdline,

END OF it_lines.

DATA : str_lines like tline.

DATA : Z0001_ADVTEXTE1 type TDLINE.

DATA : Z0001_ADVTEXTE2 type TDLINE.

DATA : Z010_LIB1 type TDLINE.

DATA : Z010_LIB2 type TDLINE.

DATA : it_stxh type table of stxh.

select * from stxh

into table it_stxh

where TDOBJECT = 'VBBP'

TDNAME = '0050000027000010'

TDID = '0001'

TDSPRAS = 'EN'.

if sy-subrc is initial.

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = '0001'

language = SY-LANGU

name = '0050000027000010'

object = 'VBBP'

tables

lines = it_lines.

.

endif.

READ TABLE it_lines into str_lines index 3.

Z0001_ADVTEXTE1 = str_lines-tdline+0(132).

READ TABLE it_lines into str_lines index 4.

Z0001_ADVTEXTE2 = str_lines-tdline+0(132).

Concatenate Z0001_ADVTEXTE1 Z0001_ADVTEXTE2 into Z0001_ADVTEXTE separated by ''.

Hope this solve your problem,

reward if it is helpfull,

Regards,

KP

Edited by: krishna prasad on Jul 25, 2008 6:08 AM

Edited by: krishna prasad on Jul 25, 2008 6:21 AM

Answers (2)

Answers (2)

Former Member
0 Kudos

Yep, it's what i have use and that's work thanks RP.

And thanks Bruno too.

BGarcia
Active Contributor
0 Kudos

Hello Spawn,

If I didn't misunderstood the question, you can use the exceptions provided in READ_TEXT function, to catch the errors.

Try something like this:


CALL FUNCTION 'READ_TEXT'
  EXPORTING
    id                            = '0001'
    language                      = SY-LANGU
    name                          = '0050000027000010'
    object                        = 'VBBP'
  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 NE 0.
* ERROR - do something?
ENDIF.

Then, you can check the error by consulting sy-subrc variable.

Kind regards,

Bruno