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

SQ02 READ_TEXT ABAP Codings

Former Member
0 Likes
2,498

I've written this ABAP coding at SQ02 Infosets. It is to extract the Long Text from SD Outbound Delivery long text.

[code]

v_name = LIPS-VBELN.

CALL FUNCTION 'READ_TEXT'

  EXPORTING

    "client   = '120'

    client   = sy-mandt

    id       = 'Z014'

    language = 'E'

    name     = v_name    "'5300000001'

    object   = 'VBBK'

  TABLES

    lines    = i_tline

  EXCEPTIONS

    ID = 1

    LANGUAGE = 2

    NAME = 3

    NOT_FOUND = 4

    OBJECT = 5

    REFERENCE_CHECK = 6

    WRONG_ACCESS_TO_ARCHIVE = 7

    OTHERS = 8.

LOOP AT i_tline INTO k_tline.

  READ TABLE i_tline INDEX 1.

  "IF sy-subrc = 0.

    REMARKS_LN1 = k_tline-tdline.

  "ENDIF.

ENDLOOP.

[/code]

Lets say i have 5 Delivery Order and the remarks long text are as follow

[code]

DO #   | Long Text

---------------

DO# 01 | Text 01

DO# 02 | <none>

DO# 03 | <none>

DO# 04 | Text 04

DO# 05 | <none>

[/code]

After i run my query, i gotten such results

[code]

DO #   | Long Text

---------------

DO# 01 | Text 01

DO# 02 | Text 01

DO# 03 | Text 01

DO# 04 | Text 04

DO# 05 | Text 04

[/code]

By right DO# 02, DO# 03 and DO# 05 should be empty. But it is populated from values from the previous DO

[b]

What codings should i insert to rectify this problem?[/b]

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,279

Hi Chin,

You need to clear the variable before assign the value. That is why it is taking previous value, if the text is blank for next DO.

LOOP AT i_tline INTO k_tline.

  READ TABLE i_tline INDEX 1.

  "IF sy-subrc = 0.

     CLEAR REMARKS_LN1.

    REMARKS_LN1 = k_tline-tdline.

  "ENDIF.

ENDLOOP.

I've written this ABAP coding at SQ02 Infosets. It is to extract the Long Text from SD Outbound Delivery long text.

[code]

v_name = LIPS-VBELN.

CALL FUNCTION 'READ_TEXT'

  EXPORTING

    "client   = '120'

    client   = sy-mandt

    id       = 'Z014'

    language = 'E'

    name     = v_name    "'5300000001'

    object   = 'VBBK'

  TABLES

    lines    = i_tline

  EXCEPTIONS

    ID = 1

    LANGUAGE = 2

    NAME = 3

    NOT_FOUND = 4

    OBJECT = 5

    REFERENCE_CHECK = 6

    WRONG_ACCESS_TO_ARCHIVE = 7

    OTHERS = 8.

LOOP AT i_tline INTO k_tline.

  READ TABLE i_tline INDEX 1.

  "IF sy-subrc = 0.

    REMARKS_LN1 = k_tline-tdline.

  "ENDIF.

ENDLOOP.

[/code]

Lets say i have 5 Delivery Order and the remarks long text are as follow

[code]

DO #   | Long Text

---------------

DO# 01 | Text 01

DO# 02 | <none>

DO# 03 | <none>

DO# 04 | Text 04

DO# 05 | <none>

[/code]

After i run my query, i gotten such results

[code]

DO #   | Long Text

---------------

DO# 01 | Text 01

DO# 02 | Text 01

DO# 03 | Text 01

DO# 04 | Text 04

DO# 05 | Text 04

[/code]

By right DO# 02, DO# 03 and DO# 05 should be empty. But it is populated from values from the previous DO

[b]

What codings should i insert to rectify this problem?[/b]

5 REPLIES 5
Read only

Former Member
0 Likes
1,279

Which internal table results you have mentioned here 'i_tline' from read_text?

If not

Loop statement doesn't look good. Please check it once.

Raja Sekhar

Read only

Private_Member_49934
Product and Topic Expert
Product and Topic Expert
0 Likes
1,279

Dear Chin

what it appears from you query is you are trying to read the line item text and not the header text. Am I correct?

if it is so that you may like to use the following

CONCATENATE LIPS-VBELN LIPS-VBELP INTO v_name.

CALL FUNCTION 'READ_TEXT'

  EXPORTING

    "client   = '120'

    client   = sy-mandt

    id       = 'Z014'  "?? cHECK OUT WHAT iD IS MAINTAINED FOR iTEM TEXT

    language = 'E'

    name     = v_name    "'5300000001000010'

    object   = 'VBBP'

  TABLES

    lines    = i_tline

  EXCEPTIONS

    ID = 1

    LANGUAGE = 2

    NAME = 3

    NOT_FOUND = 4

    OBJECT = 5

    REFERENCE_CHECK = 6

    WRONG_ACCESS_TO_ARCHIVE = 7

    OTHERS = 8.

Read only

0 Likes
1,279

Further the above code needs to be executed for each line item in loop. At the end of process of i_tline clear it.

Read only

Former Member
0 Likes
1,280

Hi Chin,

You need to clear the variable before assign the value. That is why it is taking previous value, if the text is blank for next DO.

LOOP AT i_tline INTO k_tline.

  READ TABLE i_tline INDEX 1.

  "IF sy-subrc = 0.

     CLEAR REMARKS_LN1.

    REMARKS_LN1 = k_tline-tdline.

  "ENDIF.

ENDLOOP.

Read only

0 Likes
1,279

Dear All,

I've tried a lot of places for the CLEAR statement but it didnt work. I put it before the Function, between the Loop...

But i've managed to get it worked. Upon getting advice from another forum, he advice using REFRESH

REFRESH i_tline.

CLEAR REMARKS_LN1.

v_name = LIPS-VBELN.

CALL FUNCTION 'READ_TEXT'

   EXPORTING    "client = '120'

     client                  = sy-mandt

     id                      = 'Z014'

     language                = 'E'

     name                    = v_name    "'5300000001'

     object                  = 'VBBK'

   TABLES

     lines                   = i_tline

   EXCEPTIONS

     ID                      = 1

     LANGUAGE                = 2

     NAME                    = 3

     NOT_FOUND               = 4

     OBJECT                  = 5

     REFERENCE_CHECK         = 6

     WRONG_ACCESS_TO_ARCHIVE = 7

     OTHERS                  = 8.

LOOP AT i_tline INTO k_tline.

   READ TABLE i_tline INDEX 1.

   IF sy-subrc = 0.

     REMARKS_LN1 = i_tline-tdline.

   ENDIF.

ENDLOOP.