‎2009 Jan 13 5:37 AM
Hi all,
in the below code i am converting the ITAB data to Xstring by using Fm : SCMS_TEXT_TO_XSTRING.
here in ITAB i am taking 2 records, but in the generted Xstring is the same for both the records.
how do i get different Xstring for different rows of ITAB.?
where i am doing wrong in the code ?
types: BEGIN OF t_mara,
matnr type mara-matnr,
END OF t_mara.
data: itab TYPE TABLE OF t_mara,
wa TYPE t_mara.
select matnr FROM mara INTO TABLE itab UP TO 3 ROWS.
DATA: i_xstr TYPE XSTRING.
delete itab WHERE matnr is INITIAL.
LOOP AT itab INTO wa .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa-matnr
IMPORTING
OUTPUT = wa-matnr
.
WRITE:/ wa-matnr.
at new matnr.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
EXPORTING
FIRST_LINE = 0
LAST_LINE = 0
MIMETYPE = ' '
IMPORTING
BUFFER = i_xstr
TABLES
text_tab = itab
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ i_xstr.
endat.
clear i_xstr.
thanks
KR.
‎2009 Jan 13 5:43 AM
hi,
Write the FM call outside the Loop.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
EXPORTING
FIRST_LINE = 0
LAST_LINE = 0
MIMETYPE = ' '
IMPORTING
BUFFER = i_xstr
TABLES
text_tab = itab
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
‎2009 Jan 13 5:43 AM
hi,
Write the FM call outside the Loop.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
EXPORTING
FIRST_LINE = 0
LAST_LINE = 0
MIMETYPE = ' '
IMPORTING
BUFFER = i_xstr
TABLES
text_tab = itab
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
‎2009 Jan 13 5:46 AM
HI,
I am getting different string values if I code like this....
DATA: itab LIKE tstc OCCURS 0 WITH HEADER LINE.
DATA: buffer TYPE xstring.
SELECT * FROM tstc INTO TABLE itab UP TO 2 ROWS.
LOOP AT itab.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
EXPORTING
first_line = sy-tabix
last_line = sy-tabix
MIMETYPE = ' '
IMPORTING
buffer = buffer
TABLES
text_tab = itab
EXCEPTIONS
failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ buffer.
ENDLOOP.
I never used this FM, but i am trying to use this FM.
Regards,
Venkatesh
‎2009 Jan 13 6:13 AM
Hi venkatesh,
thanks for reply.
replace the TSTC with MARA and check the output. i am getting same XSTRING output for all records.
why ia m getting like that ?
any idea ..?
Thanks
Kr
‎2009 Jan 13 5:50 AM
You have looped itab into wa and passed itab to the FM.
either pass wa and try to move the generated Xstrings to anothertable or handle it outside of teh loop.
‎2009 Jan 13 6:17 AM
Hi,
Try this
data: begin of itab occurs 0,
matnr type mara-matnr,
ersda type mara-ersda,
end of itab.
DATA: buffer TYPE xstring.
SELECT matnr ersda FROM mara INTO TABLE itab UP TO 2 ROWS.
LOOP AT itab.
CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
EXPORTING
first_line = sy-tabix
last_line = sy-tabix
MIMETYPE = ' '
IMPORTING
buffer = buffer
TABLES
text_tab = itab
EXCEPTIONS
failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ buffer.
ENDLOOP.
Output
3030303030303030303030303030303034330D0A
3030303030303030303030303030303035380D0A
Here when i have declared my itab like mara then the output it similar,
but when i declared like above fashion , the output differs.
Regards,
Venkatesh