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

Interpret argument as number

Former Member
0 Likes
1,761

Hello,

in my startroutine I'd like to interpret an argument as number. Problem is, that the name of the argument should be created during runtime. During dataload I got the error message, that argument can not interpreted as number.

Here is the code:

DATA:

          lv_time           TYPE N LENGTH 3,

          lv_validfrom      TYPE N LENGTH 2,

          lv_month          TYPE C LENGTH 30.

DO 3 TIMES.



     CONCATENATE 'wa_source_package-month' lv_time INTO lv_month.

      wa_source_package-amount = lv_month.

       COLLECT wa_source_package INTO SOURCE_PACKAGE.


       lv_time = lv_time + 1.

ENDDO.

Many thanks for your help.

Ella

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,733

Use a field-symbol :

FIELD-SYMBOLS: <value> TYPE wa_source_package-amount. " Adapt

CONCATENATE 'MONTH' lv_time INTO lv_month.
ASSIGN COMPONENT lv_month OF STRUCTURE wa_source_package TO <value>.
wa_source_package-amount = <value>.

Alternative : use a DO VARYING (beware :  obsolete form of statement)

DO 3 TIMES VARYING lv_month FROM wa_source_package-month1 NEXT wa_source_package-month2.
   wa_source_package-amount = lv_month.
   COLLECT wa_source_package INTO source_package.
ENDDO.

Regards,

Raymond

10 REPLIES 10
Read only

Former Member
0 Likes
1,733

lv_time           TYPE N LENGTH 3,

this would have leading zeroes, pls check in debug once, better to have type i

Read only

0 Likes
1,733

Hello Kartik,

I checked that and get the same error message.

Kind regards

Ella

Read only

0 Likes
1,733

Hi Ella Rose,

After this Line.

CONCATENATE 'wa_source_package-month' lv_time INTO lv_month


You can check with Condense with NO-GAPS.


Condense lv_month NO-GAPS.


wa_source_package = lv_month.


COLLECT wa_source_package INTO SOURCE_PACKAGE.


Check with the tabel type also .




I hope this will be helpful.



Thanks & Regards,

Raghunadh Kodali.




Read only

0 Likes
1,733

can u paste the values as you see in debug.

Read only

0 Likes
1,733

I get the an error message again.

In debug I see following values:

lv_time -> 1

lv_month -> wa_source_package-month1

In lv_month I need the value of wa_source_package-month1 (in this example it would be 1000,00) and not the argument.

Read only

0 Likes
1,733

I mean that system should interpret wa_source_package-month1.

Read only

0 Likes
1,733

ohh ofcourse.

Remove the quotes from 'wa_source_package-month' in the concatenate.


Raymond's code makes sense, I missed pay attention to the o/p u were trying to achieve

Message was edited by: Kartik Tarla

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,734

Use a field-symbol :

FIELD-SYMBOLS: <value> TYPE wa_source_package-amount. " Adapt

CONCATENATE 'MONTH' lv_time INTO lv_month.
ASSIGN COMPONENT lv_month OF STRUCTURE wa_source_package TO <value>.
wa_source_package-amount = <value>.

Alternative : use a DO VARYING (beware :  obsolete form of statement)

DO 3 TIMES VARYING lv_month FROM wa_source_package-month1 NEXT wa_source_package-month2.
   wa_source_package-amount = lv_month.
   COLLECT wa_source_package INTO source_package.
ENDDO.

Regards,

Raymond

Read only

0 Likes
1,733

Hello Raymond,

with field symbols it works. There is a little misstake in your code.

DO 3 TIMES VARYING lv_month FROM wa_source_package-month1 NEXT wa_source_package-month2.

          wa_source_package-amount = lv_month.

          COLLECT wa_source_package INTO source_package.

ENDDO.

I get an error message but with following code it works fine.

DO 3 TIMES VARYING <value> FROM wa_source_package-month1 NEXT wa_source_package-month2.

          wa_source_package-amount = <value>.

          COLLECT wa_source_package INTO source_package.

ENDDO.

Many thanks for your answer.

Read only

0 Likes
1,733

I forgot to add the DATA or FIELD-SYMBOLS statement to define the dynamic field for the second option