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

Former Member
0 Likes
592

Hi Friends,

In my selection screen i want :-

period (range)-mandatory as YYYYMM to YYYYMM.

note:--- the given field is vbak-audat..

but audat is of 8 in length. so how can i validate it..

Thus when i enter the period from -


to -


and after calling the function modules

'FIRST_DAY_IN_PERIOD_GET' and 'LAST_DAY_IN_PERIOD_GET'.

I should get the first and last date of the given period.

so how can i code this..

the below code works but i havent used the period as range.

***********************************************************

parameter: period(6) type c.

Data: date1 like sy-datum.

data: date2 like sy-datum.

DATA: YEAr type T009B-BDATJ.

data: per(2) type c .

data : fp like T009B-periv.

data: perod type T009B-POPER.

year = period+0(4).

per = period+4(2).

concatenate '0' per into perod.

select PERIV from T009B into fp where poper = perod.

endselect.

CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

EXPORTING

i_gjahr = year

  • I_MONMIT = 00

i_periv = fp

i_poper = perod

IMPORTING

E_DATE = date1

  • EXCEPTIONS

  • INPUT_FALSE = 1

  • T009_NOTFOUND = 2

  • T009B_NOTFOUND = 3

  • OTHERS = 4

.

IF sy-subrc 0.

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

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

ENDIF.

write:/ date1.

reward points if useful.

CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'

EXPORTING

i_gjahr = year

  • I_MONMIT = 00

i_periv = fp

i_poper = perod

IMPORTING

E_DATE = date2

  • EXCEPTIONS

  • INPUT_FALSE = 1

  • T009_NOTFOUND = 2

  • T009B_NOTFOUND = 3

  • OTHERS = 4

.

IF sy-subrc 0.

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

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

ENDIF.

write:/ date2.

4 REPLIES 4
Read only

Former Member
0 Likes
566

Hi Daniel,

you will need to declare a select-options for period range say... s_period

then if you want to retrieve the first day in the period and last day of period you can use the code you posted but follow this...

your lowest period values are in s_period-low - this has YYYYMM

retrieve the year and use funtion first_day_in_perido

your highest perid is in s_period-high - again retrieve year and use last_day_in_period function

you can get these two dates in to variables and then proceed with those dates for futher logic.

Read only

0 Likes
566

actually in my selection screen in need

vbak-audat as select-option and in format yyyymm to yyyymm.

but audat is of 8 in length.

and after that i need to call 2 fm 'first_date_dispaly' and last_date.....

to get the first and last date...

cld u plz write down how to step this....

Read only

0 Likes
566

So why use VBAK-AUDAT? What you need is a range of type SCAL-WEEK (yyyymm) and forget about VBAK-AUDAT.

Read only

Sm1tje
Active Contributor
0 Likes
566

from FM's you get a date back which is also of length 8 (date type). To compare the date use

if vbak-audat between lv_date1 and lv_date2.

  • REMARK: LV_DATE1 AND LV_DATE2 ARE WITHIN THE SELECTION. So audat is not really BETWEEN but, start and enddate are part of the range.

else.

endif.