06-15-2015 9:23 AM
if there are three records in a loop, it's always fetching long text for last 2 records.
below is the model code:
PARAMETERS: p_ordid TYPE afru-aufnr.
SELECT * FROM afru INTO TABLE it_afru
WHERE aufnr = p_ordid AND
ltxa1 <> '0'.
LOOP AT it_afru INTO ws_afru.
CONCATENATE ws_afru-mandt ws_afru-rueck ws_afru-rmzhl INTO var_name.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* client = sy-mandt
id = 'RMEL'
language = sy-langu
name = var_name
object = 'AUFK'
TABLES
lines = tbl_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 EQ 0.
LOOP AT tbl_lines.
CONCATENATE tbl_lines-tdline tbl_com-tdline INTO tbl_com-tdline.
APPEND tbl_comm.
ENDIF.
ENDLOOP.
Here in the loop. first time tbl_lines being fetched 3rd line long text of it_afru and then 2nd line long text and when it come for 3 record again it's fetchin last one.
please suggest me on this, i'm missing anything in exporting.
thanks.
ram
06-15-2015 9:35 AM
06-15-2015 9:42 AM
06-15-2015 9:52 AM
Hi Ram,
How about refresh tbl_lines itab before read_text?
Or the long text of 2nd just same as the 3rd one`s ?
regards,
Archer
06-15-2015 10:01 AM
Hi Zhang,
thanks for the reply, clearing variable is taken care.
it's like, 1st text: aaaaaaaaaaaaaaaaaaaaaaaa1111111111111111111111
2nd text : bbbbbbbbbbbbbbbbbbbbbbbbbbbbb222222222222222222222222222
3rd text : ccccccccccccccccccccccccccccccc333333333333333333333333333
by using FM, the output we are getting :
ccccccccccccccccccccccccccccccc333333333333333333333333333
bbbbbbbbbbbbbbbbbbbbbbbbbbbbb222222222222222222222222222
ccccccccccccccccccccccccccccccc333333333333333333333333333
atlimately the 1st text is missing.
06-15-2015 10:06 AM
HI Ram,
I guess it is not missing but it is being over written. Can u tell me the screen shot of the data that is there.
In the debug try to check after the first loop what is the result and then try doing it.
First try to store the single lines in the Comments and then try debugging. Later as a second step if you are able to c the correct results for one line then try adding another line and debug to further analyse the issue.
Thanks and Regards,
Chanakya
06-15-2015 10:00 AM
Hey HI Ram,
That FM will never fetch wrong results. It's the standard. SO we need to make it used correctly.
Since that is in a loop, below are the things that should be concentrated,
1) we need to refresh the TBL_LINES after the endloop of the main loop.
2) the declaration for the variable should be similar to that of the parameters that are being used in the FM
3) If the value is existing then definitely it would be captured into the internal table.
Kindly check and update. Kindly reply if your still facing any issues.
Thanks and Regards,
Chanakya
06-15-2015 10:22 AM
Hi Chanakya,
Thanks for the response.
please see the below code and suggest me if mistakes:
DATA: it_afru TYPE TABLE OF afru,
ws_afru TYPE afru,
var_name LIKE thead-tdname,
tbl_lines LIKE tline OCCURS 0 WITH HEADER LINE,
tbl_comm LIKE tline OCCURS 0 WITH HEADER LINE.
PARAMETERS: p_ordid TYPE afru-aufnr.
SELECT * FROM afru INTO TABLE it_afru
WHERE aufnr = p_ordid AND
ltxa1 <> '0'.
CLEAR ws_afru.
LOOP AT it_afru INTO ws_afru.
CLEAR var_name.
CONCATENATE ws_afru-mandt ws_afru-rueck ws_afru-rmzhl INTO var_name.
CLEAR tbl_lines.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* client = sy-mandt
id = 'RMEL'
language = 'F'"sy-langu
name = var_name
object = 'AUFK'
TABLES
lines = tbl_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 EQ 0.
CLEAR: tbl_lines.
LOOP AT tbl_lines.
CLEAR tbl_comm.
CONCATENATE tbl_lines-tdline tbl_comm-tdline INTO tbl_comm-tdline.
APPEND tbl_comm.
ENDLOOP.
ENDIF.
ENDLOOP.
CLEAR tbl_comm.
LOOP AT tbl_comm.
WRITE :/ tbl_comm.
ENDLOOP.
Result:
*/*/*/*/*/**/-/-*/*/*//*-/*-/*-///*-/*-/*-/*-/*/-/-*//*-/-*/
143284972357852379062769237592739572590723757213572309572359
*/*/*/*/*/**/-/-*/*/*//*-/*-/*-///*-/*-/*-/*-/*/-/-*//*-/-*/
06-15-2015 10:38 AM
Hi Ram,
Thanks for your detailed code.
The clear statement is used usually for clearing the Work Area and not for the internal table.
Here in the above logic use Refresh TBL_lines. Instead of clear TBL_COMM use even Refresh TBL_COMM also. Please use this statement before Endloop. and after the APPEND TBL_COMM.
Because the values from the READ_TEXT is returned into TBL_LINES and after storing the data to the internal table TBL_COMM before the second loop the TBL_LINES should be refreshed.
So that next loop will not get the fresh values of the resultant and that would be again stored in the TBL_COMM.
As an alternative if your still unsuccessful. Could you please let me know the field in the transaction for which you are trying to fetch the data.
So that even I would try from my end. Thanks.
Regards,
Chanakya
06-15-2015 11:41 AM
Hi Chanakya,
still same problem, please find the below details with screen-shot. Thanks for your support.
T.CODE : IW43
FIELD Name: LTXA1(structure-AFRUD)
DB Table - AFRU
06-15-2015 11:59 AM
I have tried another way without calling the FM directly, of course the logic may same for both but i wrote a small program to check out. i'm posting the code here, which is also giving the same result.
please suggest me if i miss something logically.
TYPES: BEGIN OF ty_stxl,
tdname TYPE stxl-tdname,
clustr TYPE stxl-clustr,
clustd TYPE stxl-clustd,
END OF ty_stxl.
DATA: t_stxl TYPE STANDARD TABLE OF ty_stxl.
FIELD-SYMBOLS: <stxl> TYPE ty_stxl.
*Compressed text data without text name
TYPES: BEGIN OF ty_stxl_raw,
clustr TYPE stxl-clustr,
clustd TYPE stxl-clustd,
END OF ty_stxl_raw.
DATA: t_stxl_raw TYPE STANDARD TABLE OF ty_stxl_raw.
DATA: w_stxl_raw TYPE ty_stxl_raw.
*Decompressed text
DATA: t_tline TYPE STANDARD TABLE OF tline.
FIELD-SYMBOLS: <tline> TYPE tline.
DATA: t_stxh TYPE STANDARD TABLE OF stxh,
w_stxh TYPE stxh.
SELECT * FROM afru INTO TABLE it_afru
WHERE aufnr = p_ordid AND
ltxa1 <> '0'.
REFRESH : t_stxh, t_stxl, t_tline.
LOOP AT it_afru INTO ws_afru.
CONCATENATE ws_afru-mandt ws_afru-rueck ws_afru-rmzhl INTO var_name.
SELECT tdname tdobject tdid
FROM stxh
INTO CORRESPONDING FIELDS OF TABLE t_stxh
WHERE tdobject = 'AUFK' AND
tdname = var_name AND
tdid = 'RMEL'.
*and then select compressed text lines in blocks of 3000 (adjustable)
SELECT tdname clustr clustd
INTO TABLE t_stxl
FROM stxl
PACKAGE SIZE 3000
FOR ALL ENTRIES IN t_stxh
WHERE relid = 'TX'
AND tdobject = t_stxh-tdobject
AND tdname = t_stxh-tdname
AND tdid = t_stxh-tdid
AND tdspras = sy-langu.
LOOP AT t_stxl ASSIGNING <stxl>.
*Decompress text
CLEAR: t_stxl_raw[], t_tline[].
w_stxl_raw-clustr = <stxl>-clustr.
w_stxl_raw-clustd = <stxl>-clustd.
APPEND w_stxl_raw TO t_stxl_raw.
IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.
*Access text lines for further processing
LOOP AT t_tline ASSIGNING <tline>.
WRITE: / <tline>-tdline.
ENDLOOP.
ENDLOOP.
FREE t_stxl.
ENDSELECT.
ENDLOOP.
-Regards,
Ram
06-16-2015 5:13 AM
Hi,
Can anybody suggest me on this READ_TEXT FM or is there any alternate solution.
regards,
Ram
06-16-2015 5:23 AM
Hi Ram ,
The confirmation text is stored in LTXA1 field for AFRU table. Please check this filed and let me know if you are looking for this text additional with long text.
Thanks
-Learner
06-16-2015 5:29 AM
06-16-2015 3:56 PM
Hi Ram,
Can you paste the screenshot of the long text from the system..
And screenshot of internal table tbl_lines data in debug..
Regards,
Raju