‎2010 May 06 5:33 PM
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
‎2010 May 06 6:11 PM
‎2010 May 06 6:26 PM
BREAKPOINT,
It didn't work. I put the clear inside the loop after MOVE. Still same result. Pl. help.
‎2010 May 06 6:49 PM
‎2010 May 06 7:03 PM
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
‎2010 May 06 7:07 PM
Don't put the refresh inside the loop, put it just after the endloop.
‎2010 May 06 7:09 PM
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
‎2010 May 06 7:22 PM
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.
‎2010 May 06 7:30 PM
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
‎2010 May 06 7:37 PM
>
> 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
‎2010 May 07 9:18 AM
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.
‎2010 May 07 7:52 AM
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
‎2010 May 07 9:26 AM
Hi Dhimbak, It should work now with the solution sent by Ana Luisa. If not then send me complete code for a quick response.
‎2010 May 24 7:04 PM
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.