2007 Nov 19 2:31 PM
Hi SAPpers I have a code
DATA: dayattr TYPE casdayattr OCCURS 0 WITH HEADER LINE.
DATA: hcal LIKE scal-hcalid, fcal LIKE scal-fcalid.
fcal = 'CZ'.
hcal = 'CS'.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = fcal
holiday_calendar = hcal
date_from = '20071025'
language = sy-langu
TABLES
day_attributes = dayattr.
WRITE: / dayattr-weekday.I need to get weekday-number, but no matter which date I give to the function (date_from) it returns '1'. 20071025 is thursday, so I assume that dayattr-weekday should be '4' (or '5' if sunday is the first day). What am I doing wrong? Greetings
2007 Nov 19 2:38 PM
hi Piotr,
try to fill the date_to parameters of the FM as well.
ec
Hi SAPpers I have a code
DATA: dayattr TYPE casdayattr OCCURS 0 WITH HEADER LINE.
DATA: hcal LIKE scal-hcalid, fcal LIKE scal-fcalid.
fcal = 'CZ'.
hcal = 'CS'.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = fcal
holiday_calendar = hcal
date_from = '20071025'
language = sy-langu
TABLES
day_attributes = dayattr.
WRITE: / dayattr-weekday.I need to get weekday-number, but no matter which date I give to the function (date_from) it returns '1'. 20071025 is thursday, so I assume that dayattr-weekday should be '4' (or '5' if sunday is the first day). What am I doing wrong? Greetings
2007 Nov 19 2:36 PM
2007 Nov 19 2:38 PM
Piotr,
The FM raises an exception if you dont give a "<b>date_to</b>". Instead try this.
DATA: dayattr TYPE casdayattr OCCURS 0 WITH HEADER LINE.
DATA: hcal LIKE scal-hcalid, fcal LIKE scal-fcalid.
fcal = 'CZ'.
hcal = 'CS'.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = fcal
holiday_calendar = hcal
date_from = '20071025'
date_to ='20071025'
language = sy-langu
TABLES
day_attributes = dayattr.
if sy-subrc = 0.
loop at dayattr.
WRITE: / dayattr-weekday.
endloop.
endif.Regards
Aneesh.
2007 Nov 19 2:38 PM
hi Piotr,
try to fill the date_to parameters of the FM as well.
ec
2007 Nov 19 2:40 PM
hi,
try like this....
LOOP AT dayattr WHERE date EQ '20071025'.
WRITE: / dayattr-weekday.
ENDLOOP.
2007 Nov 19 2:41 PM
It is required to pass the EXPORTING parameter DATE_TO even if there isn't any range of dates.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = fcal
holiday_calendar = hcal
date_from = '20071025'
date_to = '20071025' " <<<
language = sy-langu
TABLES
day_attributes = dayattr.Regards,
Naimesh Patel
2007 Nov 19 3:05 PM
Hi Piotr,
I am not sure based on what requirement you are using it but i just tested the FM 'DAY_ATTRIBUTES_GET' in SE37 to get proper output i.e to get the day num' for the same i did some small changes as follows:
<b>1.</b> <b>date_from</b> - here don't pass SAP format date instead give as <b>mm/dd/yyyy</b> format. Inorder to convert the SAP date format to mm/dd/yyyy use CONVERSION_EXIT_PDATE_OUTPUT FM i.e.
CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
EXPORTING
input = <b>lv_date</b> " say this has your date 20071025
IMPORTING
output = <b>lv_cdate</b>. " This wud have 10/25/2007
<b>2. Also pass date_to value in the FM</b> with same date value
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = 'CZ'
holiday_calendar = 'CS'
date_from = <b>lv_cdate</b>
<b>date_to = lv_cdate</b>
language = sy-langu
TABLES
day_attributes = dayattr.
WRITE: / dayattr-weekday. " I had value as 4 here
If this answers your query inform me.
Regards,
Bharathy.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |