Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Describe length of a generic table line at runtime?

Former Member
0 Kudos

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?

6 REPLIES 6

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

Stanley,

In the max's reply he also mentioned


LEN_1 = STRLEN( TEXT ). -----> it'll be 3 

Have you tried this?

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

.

Edited by: Stanley Marsh on Oct 17, 2008 7:19 PM