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

READ_TEXT issue

Former Member
0 Likes
1,938

Hi,

I'm trying to read gl texts into an additional field of sap query called PR. It's working but with some problems. It's populating blank values with the previous value when there is no value. This happens until it finds a new value.

if i have 4 accounts for which i'm extracting text, say 111,222,333,444 where only 111 and 333 have valid texts as text1 and text2. But the script is generating output as

111 - text1

222 - text1

333 - text2

444 - text2

Please let me know what is wrong below.

TABLES: STXL.
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 STXL WHERE TDID ='0001' AND TDSPRAS = 'E' AND TDOBJECT  = 'SKB1'.
  CONCATENATE SKB1-SAKNR SKB1-BUKRS INTO TNAME.
  CALL FUNCTION 'READ_TEXT'
       EXPORTING
*         CLIENT                  = SY-MANDT
          ID                      = '0001'
          LANGUAGE                = 'E'
          NAME                    = TNAME
          OBJECT                  = 'SKB1'
*         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 PR.
    ELSE.
      MOVE TNAME TO PR.
    ENDIF.
  ENDLOOP.
ENDSELECT.

Edited by: Dhimbak on May 6, 2010 6:53 PM

Moderator message - Please use code tags to format your code

Edited by: Rob Burbank on May 6, 2010 1:45 PM

13 REPLIES 13
Read only

Former Member
0 Likes
1,612

insert

Clear LTEXT[].

between accounts.

Read only

0 Likes
1,612

BREAKPOINT,

It didn't work. I put the clear inside the loop after MOVE. Still same result. Pl. help.

Read only

0 Likes
1,612

Try REFRESH instead of CLEAR.

Rob

Read only

0 Likes
1,612

Hi Rob,

Refresh completely erasing the LTEXT. I believe the way LTEXT is getting populated is wrong. Can you see anything wrong in passing values to the READ_TEXT.

Thanks

Read only

0 Likes
1,612

Don't put the refresh inside the loop, put it just after the endloop.

Read only

0 Likes
1,612

You should try it before looking elsewhere.

You're not even testing sy-subrc before you go into the LOOP.

You really should do more debugging before posting a question here.

Rob

Edited by: Rob Burbank on May 6, 2010 2:10 PM

Read only

0 Likes
1,612

Rob,

Thanks. I'm only coming here after trying myself including system variable. I'm relatively new to ABAP. Nobody would like to showcase his problems and ask for help just for the sake of it.

Read only

0 Likes
1,612

Hi Gustavo,

I tried that, but still same result. I have a feeling the internal table itself is populated incorrectly. But i'm not able to find anything wrong in the FM read_text. Thanks

Edited by: Dhimbak on May 6, 2010 8:30 PM

Read only

0 Likes
1,612

>

> Thanks. I'm only coming here after trying myself including system variable. I'm relatively new to ABAP. Nobody would like to showcase his problems and ask for help just for the sake of it.

Lots of people do here and it's hard for moderators to know the difference between someone who is legitimately stumped and someone who can't be bothered to solve his or her own problem. Eventually, though the lazy ones give themselves away by the sheer quantity of lazy questions.

But that doesn't appear to be the case here.

Anyway - your table appears to be filled correctly with the exception of not testing the return code.

But please do as I suggested before posting any more follow ups though.

Rob

Read only

0 Likes
1,612

Hi Dhimbak,

Add the following line before the CALL FUNCTION 'READ_TEXT' :

REFRESH LTEXT.

Or,

Add the following line before the LOOP AT LTEXT:

IF SY-SUBRC = 0.

(ENDIF after the ENDLOOP line)

Regards,

Ana Luisa.

Read only

Former Member
0 Likes
1,612

Hi Dhimbak,

Please debug the FM "TEXT_READ_ARCHIVE_OBJECT" called inside the FM"READ_TEXT", you can sort out the exact problem.

I strogely believe that the problem is with the READ_TEXT fm.

Hope this may help you.

Regards,

Smart Varghese

Read only

Former Member
0 Likes
1,612

Hi Dhimbak, It should work now with the solution sent by Ana Luisa. If not then send me complete code for a quick response.

Read only

0 Likes
1,612

Hi All,

I figured it out myself after i learnt how i can simply use other fields in SAP Query in an additional field. here is the code, hope will be useful for someone in future. Thanks all.

DATA: BEGIN OF HDTEXT.

INCLUDE STRUCTURE THEAD.

DATA: END OF HDTEXT.

DATA: BEGIN OF LNTEXT OCCURS 50.

INCLUDE STRUCTURE TLINE.

DATA: END OF LNTEXT.

DATA: KNAME LIKE THEAD-TDNAME.

CONCATENATE SKB1-SAKNR SKB1-BUKRS INTO KNAME.

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = '0001'

LANGUAGE = 'E'

NAME = KNAME

OBJECT = 'SKB1'

IMPORTING

HEADER = HDTEXT

TABLES

LINES = LNTEXT

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

MOVE '' TO LR.

LOOP AT LNTEXT.

IF LNTEXT-TDLINE NE ''.

MOVE LNTEXT-TDLINE TO LR.

ENDIF.

ENDLOOP.

REFRESH LNTEXT.