10-16-2008 4:54 PM
Hi experts,
This is a my FM:
*"----
""Local Interface:
*" IMPORTING
*" REFERENCE(I_LINE_WIDTH) TYPE INT2
*" VALUE(I_LONGTEXT) TYPE N2PMDETEXT-CONTENT
*" TABLES
*" T_LONGTEXT
*"----
Hence I call it:
gt_longtext type table of char255.
CALL FUNCTION 'ZFB_S_SF_LONGTEXT_INTO_TABLE'
EXPORTING
i_line_width = 255
i_longtext = lwa_N2PMDETEXT-content
tables
t_longtext = gt_longtext
.
So I asign gt_longtext table to T_LONGTEXT in my FM. At this moment the parameter table T_LONGTEXT should be of the same type as gt_longtext. How do I find the line lenght in characters of a single line of T_LONGTEXT (should be char255) at runtime in my function module?
10-16-2008 5:00 PM
Hi
DATA: TEXT(255) VALUE 'Max',
LEN_1 TYPE I,
LEN_2 TYPE I.
LEN_1 = STRLEN( TEXT ). -
> it'll be 3
DESCRIBE FIELD TEXT LENGTH LEN_2. -
> It'll be 255
Max
10-17-2008 3:00 PM
Doesn't work. See my FM is used to cut a longtext into a text table of fixed length, hence the input parameter LINE_WIDTH. however , I'd like to chuck out that input parameter so the FM cuts the string to the lenght of an input table line without having to specify the length explicitly. It's important to notice that the lenght of an input table line will not be known until runtime.
Second, DESCRIBE FIELD does not work for strings. I tried :
DESCRIBE FIELd t_longtext LENGTH lv_leng in CHARACTER MODE.
it returns the value '*'.
I also tried :
data: lv_string type string value 'Max'.
append lv_string to t_longtext. "because t_longtext is empty at runtime
DESCRIBE FIELd lv_stringLENGTH lv_leng in CHARACTER MODE.
gives a runtime error.
This is code in the function module mind you. I don't know the lenght of the table that's going to be assigned to T_LONGTEXT until runtime.
Edited by: Stanley Marsh on Oct 17, 2008 4:01 PM
Edited by: Stanley Marsh on Oct 17, 2008 4:13 PM
10-17-2008 3:21 PM
Stanley,
In the max's reply he also mentioned
LEN_1 = STRLEN( TEXT ). -----> it'll be 3
Have you tried this?
a®
10-17-2008 6:19 PM
Solved, thanks everyone for trying.
data: lv_test TYPE char20 VALUE 'check'.
APPEND lv_test TO t_longtext.
DESCRIBE FIELD t_longtext LENGTH lv_line_width IN CHARACTER MODE.
10-16-2008 5:06 PM
Write the below code:
DATA: lw_len TYPE i.
Get the first line of t_longtext table into an workarea.
lw_len = strlen( workarea ).
The above statement gives you the length.
Thanks,
Kiran
10-17-2008 6:19 PM