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: 

HOW TO PASS DATE FIELD IN FM

Former Member
0 Kudos

Hi Abappers,

I am getting error when i am passing date field in function module Date_get_week i want to pass the date which i have given in select-options: s_budat for bsad-budat.

Regards,

simba.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

use as following

tables:bsad.

select-options: s_date for bsad-budat.

data: week type KWEEK.

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

date = s_date-low " or s_date-high

IMPORTING

WEEK = WEEK

EXCEPTIONS

DATE_INVALID = 1.

Regards,

Raju.

4 REPLIES 4

Former Member
0 Kudos

HEllo,

Try this sample code:

data:  l_t_deldat type table of edatu,
        l_f_date like scal-date.
data: l_f_deldatwk like scal-week.
    call function 'DATE_GET_WEEK'
      exporting
        date               = l_f_date
     importing
       week               =  l_f_deldatwk.
    concatenate l_f_deldatwk+4(2) '.' l_f_deldatwk+0(4)
       into l_f_deldat.

write: l_F_deldate

Cheers,

Vasanth

Former Member
0 Kudos

Hi,

I gave just like this 'YYYYMMDD'.

It works.

Try this.

Anyway get into 'SU01' and check your default date format and give that formatted date as inout.

Regards,

R.Nagarajan.

Former Member
0 Kudos

Hi,

use as following

tables:bsad.

select-options: s_date for bsad-budat.

data: week type KWEEK.

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

date = s_date-low " or s_date-high

IMPORTING

WEEK = WEEK

EXCEPTIONS

DATE_INVALID = 1.

Regards,

Raju.

former_member387317
Active Contributor
0 Kudos

Hi simba ravi,

U are getting error or dump because might be passing select-option date which stores the data in internal table...

either u should use PARAMETERS here

Or u can do in below way... use HIGH and LOW options of select-options here...

SELECT-OPTIONS : DATE1 FOR SY-DATUM.

DATA: WEEK1 LIKE SCAL-WEEK.


CALL FUNCTION 'DATE_GET_WEEK'
  EXPORTING
    DATE         = DATE1-LOW
  IMPORTING
    WEEK         = WEEK1
  EXCEPTIONS
    DATE_INVALID = 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.

WRITE 😕 'Week Number' , WEEK1+4(2).

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7