cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the text element length dynamically?

Former Member
0 Kudos

Hi,

I need to find the length of a text element in script form. Can anyone tell me how we can find it out?

Since the string length will be changed dynamically during the runtime, i need to split the content based on the stringlength. But i need to do the change in my script itself and not in the driver program

Thanks and Regards,

Vimala P

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I think you dont have to find the length of string option in script itslef. But you can do it this way without touching your driver program using PERFORM in script command.

Pass the text element to PERFORM in USING statement and write the code in sub routine pool or new program there you calculate lenght of the string.

Hope this gives you some idea.

Thanks.

Former Member
0 Kudos

Hi,

I tried with the perform subroutine defined in a Z program. But the problem is still exist. How can we actually pass the Changing parameter values of the subroutine from the program using the out_par structure, since i have two Using parameters and two Changing parameters, am not sure whether how to modify the out_par structure for corresponding parameters. Right now, am just modifying with index values. Its not working for me. Can anyone help me to figure out where may be the problem.

My code is:

In script:

perform get_name_length in program ZNOTICE_PRINT

USING &ITAB-NAME_FIRST&

USING &ITAB-NAME_LAST&

CHANGING &FULLNAME&

CHANGING &LENGHT&

In program ZNOTICE_PRINT:

FORM get_name_length TABLES in_par STRUCTURE itcsy

out_par STRUCTURE itcsy.

DATA: firstname(40),

lastname(40),

final(80),

length(3).

READ TABLE in_par WITH KEY name = 'ITAB-NAME_FIRST'.

IF sy-subrc = 0.

firstname = in_par-value.

ENDIF.

READ TABLE in_par WITH KEY name = 'ITAB-NAME_LAST'.

IF sy-subrc = 0.

lastname = in_par-value.

ENDIF.

CONCATENATE firstname lastname INTO final.

out_par-value = final.

MODIFY out_par INDEX 1.

length = STRLEN( final ).

out_par-value = length.

MODIFY out_par INDEX 2.

ENDFORM. "get_name_length

Thanks in Advance,

Vimala P