on 10-21-2008 12:13 AM
Hi all,
i am trying to return how many days of holiday and saturday and sunday there are between two dates.
Thanks for your help !
Karima
Hi
Try this code . For ex for ITALY use
DATA : IT_HOLIDAYS TYPE TABLE OF ISCAL_DAY.
CALL FUNCTION 'HOLIDAY_GET'
EXPORTING
HOLIDAY_CALENDAR = 'IT'
* FACTORY_CALENDAR = ' '
DATE_FROM = '20080101'
DATE_TO = SY-DATUM
* IMPORTING
* YEAR_OF_VALID_FROM =
* YEAR_OF_VALID_TO =
* RETURNCODE =
TABLES
HOLIDAYS = IT_HOLIDAYS
* EXCEPTIONS
* FACTORY_CALENDAR_NOT_FOUND = 1
* HOLIDAY_CALENDAR_NOT_FOUND = 2
* DATE_HAS_INVALID_FORMAT = 3
* DATE_INCONSISTENCY = 4
* OTHERS = 5
.
IF SY-SUBRC EQ 0.
WRITE 'Done'.
ENDIF.
Output will be
01.01.2008 X 006 Nw Yrs Day New Year's Day
06.01.2008 X 007 Epiphany Epiphany
23.03.2008 X 801 Easter Easter Sunday
24.03.2008 X 002 Easter Mon Easter Monday
25.04.2008 X 036 Liberazio. Festa della Liberazione
01.05.2008 X 009 May Day May Day
02.06.2008 X 257
15.08.2008 X 048 Assumption Assumption
Regards
Edited by: Rajvansh Ravi on Oct 21, 2008 6:17 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks , itried this methode between an ODS and a cube but there is a problem in the datapackage 6 which is always in yellow;
The 5 datapackages are in GREEN, but the 6 not, i don't understand why ?
thank you for help !
PROGRAM trans_routine.
*----
*
CLASS routine DEFINITION
*----
*
*
*----
*
CLASS lcl_transform DEFINITION.
PUBLIC SECTION.
Attributs
DATA:
p_check_master_data_exist
TYPE RSODSOCHECKONLY READ-ONLY,
*- Instance for getting request runtime attributs;
Available information: Refer to methods of
interface 'if_rsbk_request_admintab_view'
p_r_request
TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.
PRIVATE SECTION.
TYPE-POOLS: rsd, rstr.
Rule specific types
TYPES:
BEGIN OF tys_TG_1,
InfoObject: 0SOLD_TO Donneur d'ordre.
SOLD_TO TYPE /BI0/OISOLD_TO,
InfoObject: 0SHIP_TO Récept. de marchandises.
SHIP_TO TYPE /BI0/OISHIP_TO,
InfoObject: 0SHIP_DATE Date d'arrivée de la marchandise chez le c
*lient.
SHIP_DATE TYPE /BI0/OISHIP_DATE,
InfoObject: 0CREATEDON Date de création de l'enregistrement.
CREATEDON TYPE /BI0/OICREATEDON,
InfoObject: 0CREA_TIME Heure de saisie.
CREA_TIME TYPE /BI0/OICREA_TIME,
InfoObject: 0MATL_GROUP Groupe de marchandises.
MATL_GROUP TYPE /BI0/OIMATL_GROUP,
InfoObject: 0MATERIAL Article.
MATERIAL TYPE /BI0/OIMATERIAL,
InfoObject: 0QUANT_B Quantité en unité de base.
QUANT_B TYPE /BI0/OIQUANT_B,
InfoObject: 0BASE_UOM Unité de quantité de base.
BASE_UOM TYPE /BI0/OIBASE_UOM,
InfoObject: 0SALES_OFF Agence commerciale.
SALES_OFF TYPE /BI0/OISALES_OFF,
InfoObject: 0SALESORG Organisation commerciale.
SALESORG TYPE /BI0/OISALESORG,
InfoObject: 0REFER_DOC Numéro du document de référence.
REFER_DOC TYPE /BI0/OIREFER_DOC,
InfoObject: 0DELIV_NUMB Livraison.
DELIV_NUMB TYPE /BI0/OIDELIV_NUMB,
InfoObject: 0CALDAY Jour calendaire.
CALDAY TYPE /BI0/OICALDAY,
InfoObject: 0CALMONTH Année civile/mois.
CALMONTH TYPE /BI0/OICALMONTH,
InfoObject: 0GI_DATE Date de sortie de marchandises.
GI_DATE TYPE /BI0/OIGI_DATE,
InfoObject: 0ACT_GI_DTE Date de sortie de marchandises réelle.
ACT_GI_DTE TYPE /BI0/OIACT_GI_DTE,
InfoObject: ZDTDOCREF Date de création du document de ref.
/BIC/ZDTDOCREF TYPE /BIC/OIZDTDOCREF,
InfoObject: 0DELIV_ITEM Poste de livraison.
DELIV_ITEM TYPE /BI0/OIDELIV_ITEM,
InfoObject: 0REFER_ITM Numéro du poste d'activité commerciale de
*référence.
REFER_ITM TYPE /BI0/OIREFER_ITM,
InfoObject: 0PICK_CONF Statut de validation du prélèvement.
PICK_CONF TYPE /BI0/OIPICK_CONF,
InfoObject: 0STS_PICK Statut du prélèvement d'articles.
STS_PICK TYPE /BI0/OISTS_PICK,
InfoObject: 0GOODSMV_ST Statut mvt de march..
GOODSMV_ST TYPE /BI0/OIGOODSMV_ST,
InfoObject: ZNBWDAY Nombre de jours non ouvré sur Int dates.
/BIC/ZNBWDAY TYPE /BIC/OIZNBWDAY,
InfoObject: 0PRICE_DATE Date détermination du prix et cours des d
*evises.
PRICE_DATE TYPE /BI0/OIPRICE_DATE,
Field: RECORD.
RECORD TYPE RSARECORD,
END OF tys_TG_1.
TYPES:
tyt_TG_1 TYPE STANDARD TABLE OF tys_TG_1
WITH NON-UNIQUE DEFAULT KEY.
$$ begin of global - insert your declaration only below this line -
... "insert your code here
DATA: l_tabix TYPE sy-tabix.
DATA : l_nbj_eff type n.
DATA : l_firstday TYPE /BI0/OICREATEDON.
DATA : l_lastday TYPE /BI0/OISHIP_DATE.
DATA : l_cal TYPE SCAL-FCALID.
DATA : l_hcal TYPE SCAL-HCALID.
DATA : l_returncode TYPE SY-SUBRC.
DATA: ws_i_range TYPE i, "Differece between date
ws_working_days TYPE i, "Counter for working days
ws_c_char TYPE c. "'+' or '-' indicator
DATA : date_returned type DATS.
DATA : T_CALENDRIER TYPE TABLE OF CASDAYATTR.
$$ end of global - insert your declaration only before this line -
METHODS
end_routine
IMPORTING
request type rsrequest
datapackid type rsdatapid
EXPORTING
monitor type rstr_ty_t_monitors
CHANGING
RESULT_PACKAGE type tyt_TG_1
RAISING
cx_rsrout_abort.
METHODS
inverse_end_routine
IMPORTING
i_th_fields_outbound TYPE rstran_t_field_inv
i_r_selset_outbound TYPE REF TO cl_rsmds_set
i_is_main_selection TYPE rs_bool
i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
i_r_universe_inbound TYPE REF TO cl_rsmds_universe
CHANGING
c_th_fields_inbound TYPE rstran_t_field_inv
c_r_selset_inbound TYPE REF TO cl_rsmds_set
c_exact TYPE rs_bool.
ENDCLASS. "routine DEFINITION
$$ begin of 2nd part global - insert your code only below this line *
... "insert your code here
TABLES : /BIC/AO11VAITM00 , /BI0/MREFER_DOC .
$$ end of 2nd part global - insert your code only before this line *
*----
*
CLASS routine IMPLEMENTATION
*----
*
*
*----
*
CLASS lcl_transform IMPLEMENTATION.
*----
*
Method end_routine
*----
*
Calculation of result package via end routine
Note: Update of target fields depends on rule assignment in
transformation editor. Only fields that have a rule assigned,
are updated to the data target.
*----
*
<-> result package
*----
*
METHOD end_routine.
*=== Segments ===
FIELD-SYMBOLS:
TYPE tys_TG_1.
DATA:
MONITOR_REC TYPE rstmonitor.
$$ begin of routine - insert your code only below this line -
DATA : TMP_PACKAGE type tys_TG_1.
DATA : L_Calendrier like Line OF t_calendrier.
l_cal = 'FR'.
LOOP AT RESULT_PACKAGE INTO TMP_PACKAGE .
CLEAR : l_tabix , l_firstday, l_lastday, l_nbj_eff, L_Calendrier,
t_calendrier.
l_tabix = sy-tabix.
SELECT SINGLE /BIC/ZDTDOCREF FROM /BI0/MREFER_DOC into
l_firstday
WHERE REFER_DOC = TMP_PACKAGE-REFER_DOC .
il a trouvé =0
if sy-subrc = 0.
l_lastday = TMP_PACKAGE-SHIP_DATE.
IF l_lastday <> l_firstday AND l_firstday < l_lastday AND NOT
l_lastday IS INITIAL AND NOT l_firstday IS INITIAL.
*SHIP_DATE TYPE /BI0/OISHIP_DATE,
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
factory_calendar = l_cal
date_from = l_firstday
date_to = l_lastday
language = sy-langu
IMPORTING
returncode = l_returncode
TABLES
day_attributes = t_calendrier
EXCEPTIONS
factory_calendar_not_found = 1
holiday_calendar_not_found = 2
date_has_invalid_format = 3
date_inconsistency = 4
OTHERS = 5.
IF sy-subrc <> 0.
exit.
else.
CLEAR l_nbj_eff.
LOOP AT t_calendrier INTO L_Calendrier WHERE FREEDAY EQ 'X'
l_nbj_eff = l_nbj_eff + 1.
ENDLOOP.
endif.
ENDIF.
TMP_PACKAGE-/BIC/ZNBWDAY = l_nbj_eff.
TMP_PACKAGE-/BIC/ZDTDOCREF = l_firstday.
ENDIF.
MODIFY RESULT_PACKAGE FROM TMP_PACKAGE INDEX l_tabix.
ENDIF.
ENDLOOP.
... "to cancel the update process
raise exception type CX_RSROUT_ABORT.
$$ end of routine - insert your code only before this line -
ENDMETHOD. "end_routine
*----
*
Method inverse_end_routine
*----
*
*
This subroutine needs to be implemented only for direct access
(for better performance) and for the Report/Report Interface
(drill through).
The inverse routine should transform a projection and
a selection for the target to a projection and a selection
for the source, respectively.
If the implementation remains empty all fields are filled and
all values are selected.
*
*----
*
*
*----
*
METHOD inverse_end_routine.
$$ begin of inverse routine - insert your code only below this line-
... "insert your code here
$$ end of inverse routine - insert your code only before this line -
ENDMETHOD. "inverse_end_routine
ENDCLASS. "routine IMPLEMENTATION
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.