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

Logic

Former Member
0 Likes
1,029

Hello all,

In my selection screen,i should have a start date as input parameter.i should check the start date entered by the user should be only a monday.if it is not monday then it should give a message.

End date should be a seventh day from the date entered.

ie.. Sunday

How can i do it ?

Regards,

Johnn.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
935

Hi John,

DATA:v_date TYPE scal-date,

v_day LIKE scal-indicator.

parameters: p_bdate type begda,p_edate type begda.

AT SELECTION-SCREEN.

v_date = p_bdate.

CALL FUNCTION 'DATE_COMPUTE_DAY'

EXPORTING

date = v_date

IMPORTING

day = v_day.

IF v_day = '1'.

p_edate = v_date + 6.

ELSE.

MESSAGE e001(zrep) WITH 'enter date is not monday'..

ENDIF.

Tahnks

Eswar

7 REPLIES 7
Read only

Former Member
0 Likes
935

Hello John,

U can use the FM <b>DATE_TO_DAY</b>

I think u can use the AT SELECTION-SCREEN on field event.

If useful reward.

Vasanth

Read only

anversha_s
Active Contributor
0 Likes
935

hi,

<b>at selection-screen.</b>

if p_date-low is not initial.

use the FM - > <b>DATE_TO_DAY</b>.

it will export - <b>WEEKDAY</b>

if it is not monday.

show ur error.

endif.

endif.

if p_date-high is not initial.

use the FM - > <b>DATE_TO_DAY</b>.

it will export - <b>WEEKDAY</b>

if it is not sunday.

show ur error.

endif.

endif.

rgds

anver

pls mark if hlped

Message was edited by: Anversha s

Read only

Former Member
0 Likes
935

Call function 'DAY_IN_WEEK'

exporting

datum = startdate

importing

wotnr = lday.

If lday ne 1.

message it is not monday.

else.

enddate = startdate + 6.

endif.

Read only

Former Member
0 Likes
935
Hi John,

 try this code

REPORT YCHATEST.

PARAMETERS : P_DATE LIKE SY-DATUM DEFAULT SY-DATUM.
DATA : V_DAY TYPE P DECIMALS 2.

CALL FUNCTION 'DAY_IN_WEEK'
  EXPORTING
    DATUM = P_DATE
  IMPORTING
    WOTNR = V_DAY.

IF V_DAY NE 1.
  WRITE :  'Not a monday'.
ELSE..
  WRITE : 'Monday'.
ENDIF.
Read only

Former Member
0 Likes
935

Hi,

use FM DATE_TO_DAY

data var1 like DTRESR-WEEKDAY.

at selection-screen.

CALL FUNCTION 'DATE_TO_DAY'

EXPORTING

DATE = p_date

IMPORTING

WEEKDAY = var1

.

if not var1 is initial.

if var1 <> 'MONDAY'.

message e000 with 'End date should be a seventh day from the date entered'.

endif.

Regards

amole

Read only

Former Member
0 Likes
935

Hi john

you can make use of the FM, DATE_COMPUTE_DAY as follows

Let the code be like this.

Parameters: start_dt type sy-datum,

end_dte type sy-datum,

wrk_day type i.

CALL FUNCTION 'DATE_COMPUTE_DAY'

EXPORTING

DATE = start_dt

IMPORTING

DAY = wrk_day

.

if wrk_day ne 1. " wrk_day = 1 means monday,,,,,

message.

endif.

now add the logic for end date, I think it will solve your problem.

Thanks and Regards

Antony Thomas

Read only

Former Member
0 Likes
936

Hi John,

DATA:v_date TYPE scal-date,

v_day LIKE scal-indicator.

parameters: p_bdate type begda,p_edate type begda.

AT SELECTION-SCREEN.

v_date = p_bdate.

CALL FUNCTION 'DATE_COMPUTE_DAY'

EXPORTING

date = v_date

IMPORTING

day = v_day.

IF v_day = '1'.

p_edate = v_date + 6.

ELSE.

MESSAGE e001(zrep) WITH 'enter date is not monday'..

ENDIF.

Tahnks

Eswar