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: 

put a variable inside another variable in sapscript form

Former Member
0 Kudos

Hi,

I assume that the question is a little bit confusing, but what I want to do is very simple, suppose that I list an internal table (t_int) into a form. To show the fields I write things like this:

&t_int-kunnr&

and if I need to determine the width of the column, a way of doing this is:

&t_int-kunnr(10)&

but, what if I need a variable width that it is determined in the control program with a variable, suppose something like:

&t_int-kunnr(&width&)&

but this doesn't work, so my question is, how can I put a variable inside another variable in a sapscript form?

thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

There is no way of not hardcoding in sapscript.

You can use like t_int-numc to pass the length of the output .

In SAPSCRIPT you can use

/: CASE &t_int_numc&

/: WHEN 10

  • &t_int-kunnr(10)&

/: WHEN 8

  • &T_INT-KUNNR(8)&

/: ENDCASE.

Or you can achieve by creating different text elements and calling these elements conditionally.

/E TEXT10

  • &t_int-kunnr(10)&

/E TEXT8

  • &T_INT-KUNNR(8)&

However there is no way you can define the output length of a field dynamically.

Cheers.

6 REPLIES 6

Former Member
0 Kudos

hi,

try this

&t_int-kunnr&+0(&width&)

i'm not sure.

sasi

0 Kudos

thanks it solves perfectly the problem,

but I have a problem when I try to give you the points of the forum,

thanks again,

0 Kudos

I'm sorry but I think I've spoken too quick, it seems that the solution of sasikumar doesn't work properly.

any other ideas?, thanks again

Former Member
0 Kudos

Why do you want to put one variable into another in the sapscript. Make all your changes in program in one variable i.e. to be used in SAPSCRIPT. Say

wa_kunnr = t_int-kunnr.

clear t_int-kunnr.

t_int-kunnr = wa_kunnr(8) .

<Shift left right etc>

Later in SAPSCRIPT simply use &t_int-kunnr(10)&

Hope this helps. If not give exact scenario.

Cheers

0 Kudos

that's a good idea, but what I'm looking for is a way of set the width of the columns from the control program instead of <i>hardcoding</i> it in the form.

Former Member
0 Kudos

There is no way of not hardcoding in sapscript.

You can use like t_int-numc to pass the length of the output .

In SAPSCRIPT you can use

/: CASE &t_int_numc&

/: WHEN 10

  • &t_int-kunnr(10)&

/: WHEN 8

  • &T_INT-KUNNR(8)&

/: ENDCASE.

Or you can achieve by creating different text elements and calling these elements conditionally.

/E TEXT10

  • &t_int-kunnr(10)&

/E TEXT8

  • &T_INT-KUNNR(8)&

However there is no way you can define the output length of a field dynamically.

Cheers.