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: 

Can I declare paremeters with calculated value as default?

Former Member
0 Kudos

Hi all,

I have to put as a parameter the date (the last day of month before). For example:

- today is 06.07.2006

- required value is 30.06.2006 but the user should be able to change it.

I thing the best solution is declare the parameter.

I know how to calculate the right date but when I declare a parameter with this value the field is empty.

For example - simple ABAP program:

REPORT Z_TEST8_AB.

DATA: value1(10).

value1 = '01.07.2006'.

  • it's only for test. I calculate the right date in this place

PARAMETERS par1(10) DEFAULT '01.07.2006'.

PARAMETERS par2(10) DEFAULT value1.

When I run this program the field for par1 is with value but the field for par2 is empty.

Could anybody help me? Is it possible to do or not?

Best regards,

Arek

1 ACCEPTED SOLUTION

Former Member

remove the default statement and give it in initialization event.

Initialization.

P_date = value1.

regards

8 REPLIES 8

former_member181962
Active Contributor
0 Kudos

Do the calculation in initializationj part.

PARAMETERS par1(10) DEFAULT '01.07.2006'.

PARAMETERS par2(10) DEFAULT value1.

initialization.

par2 = par1 -1.

Former Member
0 Kudos

hi,

try this

initialization

par2 = value1.

regards,

Manohar.

Former Member
0 Kudos

Hi Arkadiusz,

You can assign a value to parameter in INITIALIZATION event.

Try with this code.

INITIALIZATION.

CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'

EXPORTING

day_in = SY-DATUM

IMPORTING

LAST_DAY_OF_MONTH = PAR2

EXCEPTIONS

DAY_IN_NOT_VALID = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Thanks,

Vinay

Former Member

remove the default statement and give it in initialization event.

Initialization.

P_date = value1.

regards

Former Member
0 Kudos

Write the value of date in event 'Initialize'. It will work.

Regards,

Subhasish

Former Member
0 Kudos

Hi,

You need t0 calculate the value for the default date in the INITIALIZATION event. Then the selection screen will come up with these default values.

refer to code below.

REPORT Z_TEST8_AB.

DATA: value1(10).

PARAMETERS par1(10) DEFAULT '01.07.2006'.

PARAMETERS par2(10) DEFAULT value1.

INITIALIZATION.

value1 = '01.07.2006'.

former_member188685
Active Contributor
0 Kudos

Try this way...

REPORT  ZZTEST        .

PARAMETERS par1(10) DEFAULT '01.07.2006'.
PARAMETERS par2(10).

initialization.
par2 = '01.07.2006'.

Regards

vijay

0 Kudos

It works with initialization event.

Very important is to remove the default statement

Thx a lot.