04-13-2012 5:28 AM
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]
04-13-2012 7:48 AM
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.
04-13-2012 6:02 AM
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
04-13-2012 7:37 AM
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.
04-13-2012 7:38 AM
Further the above code needs to be executed for each line item in loop. At the end of process of i_tline clear it.
04-13-2012 7:48 AM
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.
04-13-2012 8:41 AM
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.