02-24-2010 6:28 AM
Hi all,
After using the FM READ_TEXT I have data with length = 132.
Now I want to display the result but with 200 chars per line.
Please suggest me any FM to do that.
Thanks,
Khanh
02-24-2010 6:38 AM
Hello,
You can use the FM: SX_TABLE_LINE_WIDTH_CHANGE to change the line width from 132 to 200
BR,
SUhas
02-24-2010 6:42 AM
Hi Suhas,
I did try this function module but the result is not as my expectation
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
* LINE_WIDTH_SRC = 132
LINE_WIDTH_DST = 200
* TRANSFER_BIN = ' '
TABLES
CONTENT_IN = t1
CONTENT_OUT = t2
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4
.
Thanks,
Khanh
02-24-2010 6:39 AM
Just declare a char variable of length 200 and pass the TDLINE value to it in the sy-subrc of the FM READ_TEXT. Is this not sufficient?
Vikranth
02-24-2010 6:42 AM
Hi,
I am not completely sure about you requirement, but you can try this:
TYPES: BEGIN OF ts_line200,
tdformat TYPE tdformat,
tdline(200) TYPE c,
END OF ts_line200.
DATA: lt_lines TYPE STANDARD TABLE OF tline,
ls_line TYPE tline,
lt_lines200 TYPE STANDARD TABLE OF ts_line200,
ls_line200 TYPE ts_line200.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = lv_id
language = sy-langu
name = lv_name
object = lv_object
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = lt_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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR lt_lines200.
LOOP AT lt_lines INTO ls_line.
ls_line200-tdformat = ls_line-tdformat.
ls_line200-tdline = ls_line-tdline.
ENDLOOP.
Regards,
Adrian
02-24-2010 6:46 AM
Hi Adrian,
When do you append the table 200?
If doing like this, the new table is similar to the old table except the length of the new table.
Thanks,
Khanh
02-24-2010 6:50 AM
Hi,
sorry, APPEND statement is missing in my code. It should be before ENDLOOP statement. But probably I do not understand your requirement.
>
> If doing like this, the new table is similar to the old table except the length of the new table.
I thought this is your requirement.
Adrian
02-24-2010 6:54 AM
Hi Adrian,
Sorry for my unclear explanation.
My requirement is as following:
In TLine table I have 5 rows for example which each line contains less or equal 132 chars.
If I use this table to display data, each line will contain maximum of 132 chars.
The requirement is to display each line with maximum of 200 chars (so it may be less than 5 rows).
I would like to ask whether we have a FM to do that or we need to create a custom as my specific requirement.
Thanks all,
Khanh
02-24-2010 7:04 AM
Hi Knah,
so now I understand your requirement.
Try to do it like this:
LOOP AT lt_lines INTO ls_line.
CONCATENATE lv_string ls_line-tdline INTO lv_string.
ENDLOOP.
DO.
ls_line200-tdline = lv_string.
APPEND ls_line200 TO lt_lines200.
SHIFT lv_string BY 200 PLACES LEFT.
IF STRLEN( lv_string ) EQ 0.
EXIT.
ENDIF.
ENDDO.
I am afraid that there is no standard FM for this, but maybe I am wrong.
Regards,
Adrian
02-24-2010 7:05 AM
Hello,
Does this fit the bill ?
DATA: it_line TYPE STANDARD TABLE OF tline,
wa_line TYPE tline,
it_200 TYPE STANDARD TABLE OF char200,
wa_200 TYPE char200,
v_string(5000) TYPE c.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'ST'
language = 'E'
name = 'ZTEST01335'
object = 'TEXT'
TABLES
lines = it_line
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 = 0.
LOOP AT it_line INTO wa_line.
CONCATENATE v_string wa_line-tdline INTO v_string
SEPARATED BY space.
WRITE / wa_line-tdline.
ENDLOOP.
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = v_string
outputlen = 200
TABLES
out_lines = it_200
EXCEPTIONS
outputlen_too_large = 1
OTHERS = 2.
IF sy-subrc = 0.
LOOP AT it_200 INTO wa_200.
WRITE / wa_200.
ENDLOOP.
ENDIF.
ENDIF.
BR,
Suhas
02-24-2010 7:08 AM
The function module mentioned 'SX_TABLE_LINE_WIDTH_CHANGE' does work for your requirement.....
Try using that..
Regards,
Lalit Mohan Gupta.
02-24-2010 7:14 AM
hi you can try like this,
Hello,
Does this fit the bill ?
<blatant_copy&paste_removed_by_moderator>
ENDIF.
Edited by: Julius Bussche on Feb 24, 2010 12:04 PM
If you do this again then there will be BIG trouble coming your way!
02-24-2010 7:18 AM
02-24-2010 7:37 AM
Hi Susha,
Thanks for your great support.
I still have a concern, how will I handle a break line?
Because by using command concatenate, all the text become one string.
@All: Thanks for your time and support.
Thanks,
Khanh
02-24-2010 7:49 AM
Hi,
your requirement is becoming probably very specific to be able to do it by standard function modules. But you can probably do it like this:
LOOP AT lt_lines INTO ls_line.
IF ls_line-tdformat NE gc_line_separator.
CONCATENATE lv_string ls_line-tdline INTO lv_string.
ELSE.
DO.
ls_line200-tdline = lv_string.
APPEND ls_line200 TO lt_lines200.
SHIFT lv_string BY 200 PLACES LEFT.
IF STRLEN( lv_string ) EQ 0.
EXIT.
ENDIF.
ENDDO.
lv_string = ls_line-tdline.
ENDIF.
ENDLOOP.
IF STRLEN( lv_string ) GT 0.
DO.
ls_line200-tdline = lv_string.
APPEND ls_line200 TO lt_lines200.
SHIFT lv_string BY 2 PLACES LEFT.
IF STRLEN( lv_string ) EQ 0.
EXIT.
ENDIF.
ENDDO.
ENDIF.
Adrian
02-24-2010 8:10 AM
Hi,
Thanks all for your support.
@Adrian: Using SHIFT LEFT is not a good move because it will cause the data broken (lost meaning).
It is better using FM 'RKD_WORD_WRAP' given by Susha.
Anyway, thanks for your ideas.
Thanks,
Khanh
02-24-2010 11:09 AM