Application Development and Automation 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: 
Read only

string lenghth calculation.

former_member841898
Participant
0 Likes
2,073

hi experts,

i want to pass the data through parameters and return it will give length, for e.g if i

give sapabap in parameters the o/p will be 7 , for this i m using follwing piece of code.

REPORT ycompute NO STANDARD PAGE HEADING .

DATA: n TYPE i,

word1 type string.

parameters: p_word1 like word1.

n = STRLEN( p_word1 ).

WRITE:/ n.

on activation it sends error

the reference field 'WORD1' has an invalid nested data type.

how to proceed?

i m using 4.7 version.

regards

pankaj

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,016

Hi,

Try this...

DATA: n TYPE i.

parameters: p_word1 type string.

n = STRLEN( p_word1 ).

WRITE:/ n.

Regards,

N M Poojari

17 REPLIES 17
Read only

Former Member
0 Likes
2,016

Use Data type C instead of STRING for WORD1

Read only

0 Likes
2,016

hi amit,

if i use data type c and give a data which has bigger length say 150 or more,

for e.g. wwwwwwwwwwwwwwwwwwwwwwwwwwwaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklllllllllllllllllllllllllllll

mmmmmmmmmmmmmmmmmmmmmm in parameter

the o/p always will be 132

regards

pankaj

Read only

0 Likes
2,016

DATA: a TYPE char200 VALUE 'wwwwwwwwwwwwwwwwwwwwwwwwwwwaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaajjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmm'.

DATA: n(3) TYPE n.

n = strlen( a ).

WRITE: n.

Read only

0 Likes
2,016

hi amit ,

this is what which i have already done ok.

i want a parameter on screen in which data whose length to be calculated is to be passed

regards

pankaj

Read only

Former Member
0 Likes
2,016

Hi,

Try using Datatype of Char instead of string.

Hope it solves out.

Thanks & Regards

Read only

Former Member
0 Likes
2,016

Hi,

Try this....

REPORT ycompute NO STANDARD PAGE HEADING .

DATA: n TYPE i,

word1 type string.

parameters: p_word1 type string.

word1 = p_word1.

n = STRLEN( p_word1 ).

WRITE:/ n

Read only

peter_ruiz2
Active Contributor
0 Likes
2,016

hi,

use this instead...

parameters: p_word1 type string.

regards,

Peter

Read only

0 Likes
2,016

hi peter and avinash,

the data type string is not allowed with parameters,

it is giving error of deep data type.

regards

pankaj

Read only

Former Member
0 Likes
2,016

Hi,

Basically the parameter field to be displayed on screen must contain certain defined length.

if you take parameters type string it takes 256 char length.

so

to best of my knowledge

parameters p_word type char40.

data n type i.

n = strleng( P_word ).

try this out.

regards

Ramchander Rao.K

Read only

0 Likes
2,016

hi ramchander ,

here u r fixing the length only upto 40.

what for length greater than 40?

regards

pankaj

Read only

Former Member
0 Likes
2,016

yes, it seems to be a restriction with parameters

Read only

Former Member
0 Likes
2,016

Hi,

As per my knowledge in 4.7c, we cann't declare string in the selection screen. Its the data type which cann't be used for the parameters or select-options.

I think you got to use char with the restricted length.

If wrong please correct me.

In ECC6.0 your declaration is valid and you can directly declare even "TYPE STRING" in the parameters.

Edited by: Krishna Adabala on Nov 24, 2008 11:59 AM

Read only

Former Member
0 Likes
2,016

There is a workaround for this:

Let ZTEST be your program in which parameter is defined.

Open this program in se51 with screen no 1000.

Double click input/output box of parameter in screen layoout.

Change defined from 132 to any value u like.

Note: Donot activate ztest in se38 again

Read only

Former Member
0 Likes
2,017

Hi,

Try this...

DATA: n TYPE i.

parameters: p_word1 type string.

n = STRLEN( p_word1 ).

WRITE:/ n.

Regards,

N M Poojari

Read only

Former Member
0 Likes
2,016

You may try using inline editor on Screen.

This will capture data in lines, you can add up string length of all lines.

Regards,

Mohaiyuddin

Read only

former_member841898
Participant
0 Likes
2,016

hi all,

thnks all for ur valuable inputs...........

as one of the frnds suggested that string declaration is not allowed with parameters in 4.7,,i also think so................

string declaration with parameters may work in ecc 6.0...if any one of frnds finds its solution then please leave a reply ,

this thread for length calculation remains open..

thanks and regards

pankaj

Read only

former_member841898
Participant
0 Likes
2,016

This message was moderated.