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

Selection-Screen Query??

Former Member
0 Likes
1,391

Hi..

I want two things

1) The date field on my selectionn screen should be sy-datum minus 30 days..

please tell me the command name.

2) Also I want to give an err message IF to-date minus from-date > 30

Please tell me the command in this case also.

15 REPLIES 15
Read only

Former Member
0 Likes
1,341

Hi,

First decalre a variable v_date type sy-datum.

v_date = sy-datum-30.

parameters:p_date type sy-datum default v_date.

For displaying the error message,

let us say,

REPORT  Z11  message-id smsg                                   .

select-options : s_date for sy-datum.

data: v_date1 type sy-datum,
      v_date2 type sy-datum,
      v_date3 type i.

v_date1 = s_date-low.
v_date2 = s_date-high.
v_date3 = v_date2 - v_date1.

if v_date3 > 30.
message e000 with 'improper date'.
endif.

Regards,

Aswin

Read only

0 Likes
1,341

Thanks

But is there any event which we can use to fill the Selction-option Date fields..I mean like start-of-selection event, where shall we calculate v_date = sy-datum-30.

And also under which event we shall give an err message for the date field?

Thanks

Read only

0 Likes
1,341

Hi again,

1. But is there any event which we can use to fill the Selction-option

INITIALIZATION

2.

But is there any event which we can use to fill the Selction-option

START-OF-SELECTION.

Then on error we can give,

LEAVE LIST-PROCESSING.

3. Please see my previous reply.

(it contains the full code)

regards,

amit m.

Read only

0 Likes
1,341

Hi Subash,

put that code in <b>AT SELECTION SCREEN</b> event

Regards,

Santosh

Read only

0 Likes
1,341

Hi,

Use the Initialization event to initialize the date parameter.

You can give the error message in AT Selection-screen.

Regards,

Message was edited by: Amit Mishra

Read only

Former Member
0 Likes
1,341

Hi Soni,

Use the function module CCM_GO_BACK_MONTHS to go back one month.

Refer the code below.

CALL FUNCTION 'CCM_GO_BACK_MONTHS'

EXPORTING

currdate = sy-datum

backmonths = '001'

IMPORTING

newdate = lv_newdate.

<b>Reward points if it helps.</b>

Message was edited by: Amit Mishra

Read only

0 Likes
1,341

hi Soni,

Use FM <b>CCM_GO_BACK_MONTHS</b>

DATA L_DATE TYPE SY-DATUM.

CALL FUNCTION <b>'CCM_GO_BACK_MONTHS'</b>

EXPORTING

CURRDATE = SY-DATUM

BACKMONTHS ='001'

IMPORTING

NEWDATE = L_DATE.

MOVE : L_DATE TO S_FKDAT-LOW ,

SY-DATUM TO S_FKDAT-HIGH.

APPEND S_FKDAT.

Read only

Former Member
0 Likes
1,341

Hi,

i very simple

<b>1) Condition</b>

simly minus 30 from the sy-datum.

lv_date type dats.

lv_date = sy-datum - 30.

<b>2) Condition</b>

lv_days type i.

lv_days = to_date - form_date.

.if lv_days > 30.

message e100(meddage_id).

endif.

Mark Helpfull Answers

Message was edited by: Manoj Gupta

Read only

Former Member
0 Likes
1,341

Hi subhash,

1. both cases

a) default date

b) difference checking

2. just copy paste in new program.

3.

report abc.

DATA : DIFF TYPE I.

*----


parameters : fdate type sy-datum.

parameters : todate type sy-datum.

*----


INITIALIZATION.

FDATE = SY-DATUM - 30.

*----


START-OF-SELECTION.

DIFF = TODATE - FDATE.

IF DIFF > 30.

MESSAGE 'DATE IMPROPER' TYPE 'S'.

LEAVE LIST-PROCESSING.

ENDIF.

regards,

amit m.

Read only

Former Member
0 Likes
1,341

You can also use Function Module MONTH_PLUS_DETERMINE

with the date and -1 for MONTHS parameter.

Cheers,

Thomas.

Read only

abdul_hakim
Active Contributor
0 Likes
1,341

use the below code as an example..

tables mara.

data res_dat like sy-datum.

select-option s_1 for mara-erdat.

initialization.

s_1-low = sy-datum - 30.

at selection-screen.

res_dat = s_1-low - s_high.

if res_dat > 30.

<give ur error message here>

endif.

Cheers,

Abdul Hakim

Mark all useful answers

Read only

Former Member
0 Likes
1,341

initialization.

s_date-low = sy-datum - 31.

s_date-high = sy-datum.

s_date-sign = 'I'.

s_date-option = 'EQ'.

append s_date.

clear s_date.

at selection-screen.

read s_date index 1.

if s_date-high - s_date-low > 30.

message e000(ZZ) with 'Invalid Date range'.

endif.

REgards,

Ravi

Read only

Former Member
0 Likes
1,341

Hi,

put the variable sy-datum-30 in the <b>initialization</b> event and the message in the <b>start-of-selection</b> event.

Regards,

Aswin

Read only

Former Member
0 Likes
1,341

hi subhash,

under the event.

<b>Initialization</b>

s_date-low = sy-datum - 30.

s_date-high = sy-datum.

s_date-sign = 'I'.

s_date-option = 'EQ'.

append s_date.

at selection-screen.

if s_date-high - s_date-low > 30.

message e001(ZZ1).

endif.

hope this helps,

priya.

Read only

Former Member
0 Likes
1,341

hi subhash,

under the event.

<b>Initialization</b>

s_date-low = sy-datum - 30.

s_date-high = sy-datum.

s_date-sign = 'I'.

s_date-option = 'EQ'.

append s_date.

at selection-screen.

if s_date-high - s_date-low > 30.

message e001(ZZ1).

endif.

hope this helps,

priya.