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

default values for parameter

Former Member
0 Likes
1,392

hi i have a parameter month,

the user wants it default to the month before 10 days..

so sy-datum - 10 and then the month of new date..

i hve tried to calculate this in intialization but doesnt work, can you help please.

thanks,

AJ

16 REPLIES 16
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,359

Hello,

Try this code:


PARAMETERS: P_MONTH TYPE NUMC2.

INITILIZATION.
V_DATE = SY-DATUM - 10.

V_MONTH = V_DATE+4(2).

P_MONTH = V_MONTH.

Suhas

Read only

former_member156446
Active Contributor
0 Likes
1,359
PARAMETER: p_mon(2) TYPE n.

INITIALIZATION.
  DATA: lv_date TYPE d.
  lv_date = sy-datum - 10.

  p_mon = lv_date+4(2).
Read only

0 Likes
1,359

guys thanks for your help, but as stupid as it may sound, i already have that code in place.

begin of screen 100

parameter definition.

end of screen 100.

initialization.

code to get the date.

any bright ideas ??

Read only

0 Likes
1,359

hi,

Can you please paste the code.

Read only

0 Likes
1,359

selection-screen begin of screen 100 as subscreen.

selection-screen begin of block rep_perio with frame title text-bl2.

Selection-screen begin of line .

SELECTION-SCREEN COMMENT 1(31) TEXT-018.

parameters: p_perio type co_perio default lv_default_date+4(2) obligatory.

SELECTION-SCREEN COMMENT 37(30) TEXT-019.

Selection-screen end of line.

selection-screen end of block rep_perio.

selection-screen end of screen 100.

initialization.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = sy-datum

DAYS = '7'

MONTHS = '00'

SIGNUM = '-'

YEARS = '00'

IMPORTING

CALC_DATE = lv_default_date.

at selection-screen on p_bukrs.

-


lv_default_date is defined in another include

Read only

0 Likes
1,359

hi,

Try this way

selection-screen begin of screen 100 as subscreen.
selection-screen begin of block rep_perio with frame title text-bl2.
Selection-screen begin of line .
SELECTION-SCREEN COMMENT 1(31) TEXT-018.

parameters: p_perio type co_perio .          " Remove the default statement
SELECTION-SCREEN COMMENT 37(30) TEXT-019.

Selection-screen end of line.
selection-screen end of block rep_perio.
selection-screen end of screen 100.

initialization.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = sy-datum
DAYS = '7'
MONTHS = '00'
SIGNUM = '-'
YEARS = '00'
IMPORTING
CALC_DATE = lv_default_date.

lp_perio  = v_default_date+4(2).          " Try this way..

at selection-screen on p_bukrs.

Read only

0 Likes
1,359

Since this is a sub screen, put the provided code from others in your PBO routine for the subscreen.

Read only

0 Likes
1,359

No luck Avi

Read only

0 Likes
1,359

More of an issue may be that you are asking to back up 7 days.. not 10


CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
     EXPORTING
          date      = sy-datum
          days      = '7'            "<==  I would think needs to be 10
          months    = '00'
          signum    = '-'
          years     = '00'
     IMPORTING
          calc_date = lv_default_date.

Read only

0 Likes
1,359

This worked


DATA: lv_default_date      TYPE d.


*SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.

SELECTION-SCREEN BEGIN OF BLOCK rep_perio WITH FRAME TITLE text-bl2.

SELECTION-SCREEN BEGIN OF LINE .

SELECTION-SCREEN COMMENT 1(31) text-018.

PARAMETERS: p_perio TYPE co_perio.             " This was changed
* DEFAULT lv_default_date+4(2) OBLIGATORY.   " This was changed

SELECTION-SCREEN COMMENT 37(30) text-019.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK rep_perio.

*SELECTION-SCREEN END OF SCREEN 100.

INITIALIZATION.

  CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
       EXPORTING
            date      = sy-datum
            days      = '7'
            months    = '00'
            signum    = '-'
            years     = '00'
       IMPORTING
            calc_date = lv_default_date.
  p_perio = lv_default_date+4(2).    "  This was added

Read only

0 Likes
1,359

Paul, Avi

Still not working, however i am not able to debug it all , which leads me to believe that may be this code is not being executed at all.

Read only

0 Likes
1,359

hi,

You creating the screen as subscreen you are you calling this some where in your program.

before calling this screen you set the value of p_perio.

selection-screen begin of screen 100 as subscreen.
selection-screen begin of block rep_perio with frame title text-bl2.
Selection-screen begin of line .
SELECTION-SCREEN COMMENT 1(31) TEXT-018.
 
parameters: p_perio type co_perio .          
SELECTION-SCREEN COMMENT 37(30) TEXT-019.
 
Selection-screen end of line.
selection-screen end of block rep_perio.
selection-screen end of screen 100.
 
initialization.
 
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = sy-datum
DAYS = '7'
MONTHS = '00'
SIGNUM = '-'
YEARS = '00'
IMPORTING
CALC_DATE = lv_default_date.
 
p_perio  = lv_default_date+4(2).          " Pass the month to p_perio field 

Read only

0 Likes
1,359

Hi

U need to fill the parameter in INITIALIZATION event and not by DEFAULT option at selection-screen level:

selection-screen begin of screen 100 as subscreen.

selection-screen begin of block rep_perio with frame title text-bl2.

Selection-screen begin of line .

SELECTION-SCREEN COMMENT 1(31) TEXT-018.
*parameters: p_perio type co_perio default lv_default_date+4(2) obligatory.
parameters: p_perio type co_perio obligatory.

SELECTION-SCREEN COMMENT 37(30) TEXT-019.

Selection-screen end of line.

selection-screen end of block rep_perio.

selection-screen end of screen 100.

initialization.

  CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
      DATE      = sy-datum
      DAYS      = '7'
      MONTHS    = '00'
      SIGNUM    = '-'
      YEARS     = '00'
    IMPORTING
      CALC_DATE = lv_default_date.

  move lv_default_date+4(2) to p_perio.

Max

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,359

Hello,

You must not declare a default for the paramter & then call initialization as advised by Max.

[Select-Option: Default|;

Hope this helps.

BR,

Suhas

Read only

tushar_shukla
Active Participant
0 Likes
1,359

PARAMETERS : p_date TYPE sy-datum .

INITIALIZATION .
p_date = sy-datum - 10 .

check above code.

Tushar

Read only

Former Member
0 Likes
1,359

As also said by others do it this way:

Parameters:
  p_date(2) type c.

Initialization.
Data:
  w_date like sy-datum.
  w_date = sy-datum - 10.
  p_date = w_date+4(2).

or if you want the month in words than do it this way:

Parameters:
  p_monam type t015m-monam.

Initialization.
Data:
  w_date like sy-datum,
  w_monum type t015m-monam.

  w_date = sy-datum - 10.
  w_monum = w_date+4(2).

select single monam
  from t015m
  into p_monam
 where spras eq 'E'
   and monum eq w_monum.

With luck,

Pritam.