PROGRAM UPDATE_ROUTINE.
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* Rutina para validar Dias Habiles
*TYPES: BEGIN OF ti_estruc,
* /bic/zfecfin LIKE /bic/cs8z_ss_0025-/bic/zfecfin,
* /bic/zfecini LIKE /bic/cs8z_ss_0025-/bic/zfecini,
* /bic/zfecterm LIKE /bic/cs8z_ss_0025-/bic/zfecterm,
* /bic/zrecmots LIKE /bic/cs8z_ss_0025-/bic/zrecmots,
* /bic/zrecresul LIKE /bic/cs8z_ss_0025-/bic/zrecresul,
* /bic/zrectpo LIKE /bic/cs8z_ss_0025-/bic/zrectpo,
* /bic/zrutemp LIKE /bic/cs8z_ss_0025-/bic/zrutemp,
* /bic/zlocalid LIKE /bic/cs8z_ss_0025-/bic/zlocalid.
*TYPES:
*recno LIKE sy-tabix,
*conta(04) TYPE n,
*END OF ti_estruc.
*
*DATA: ti_entradas TYPE STANDARD TABLE OF ti_estruc WITH HEADER LINE
* WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
*
*TYPES:
* BEGIN OF data_package_copy.
* INCLUDE STRUCTURE /bic/cs8z_ss_0025.
*TYPES:
* recno LIKE sy-tabix,
* END OF data_package_copy.
*DATA:
* data_package_copy TYPE STANDARD TABLE OF data_package_copy
* WITH HEADER LINE
* WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
DATA: lc_dias TYPE i, " Numero de dias entre fechas
lc_diash TYPE i, " Numero de dias habiles
lc_fecha LIKE sy-datum, " Fecha para funcion
lc_indic LIKE scal-indicator, " Indicador de dia habil
lc_tabix LIKE sy-tabix.
*$*$ end of global - insert your declaration only before this line *-*
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS8Z_SS_0025
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BIC/VZSSI_CO04T-/BIC/ZDIAS_HAB
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
*
*$*$ begin of routine - insert your code only below this line *-*
* fill the internal table "MONITOR", to make monitor entries
*++++++++++++++++ Inicio de Rutina
* LOOP AT DATA_PACKAGE.
CLEAR: lc_dias, lc_diash.
* lc_tabix = sy-tabix.
* Restar fechas
lc_dias = COMM_STRUCTURE-/bic/zfecfin - COMM_STRUCTURE-/bic/zfecini.
ADD 1 TO lc_dias.
* Asignar fecha inicial a variable local
lc_fecha = COMM_STRUCTURE-/bic/zfecini.
* Ciclo de búsqueda de Días Habiles dentro del periodo
DO lc_dias TIMES.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
correct_option = '+'
date = lc_fecha
factory_calendar_id = 'CL'
IMPORTING
workingday_indicator = lc_indic
EXCEPTIONS
calendar_buffer_not_loadable = 1
correct_option_invalid = 2
date_after_range = 3
date_before_range = 4
date_invalid = 5
factory_calendar_not_found = 6
OTHERS = 7.
* Comparación de Día Habil
IF lc_indic IS INITIAL.
ADD 1 TO lc_diash.
ENDIF.
* Incrementar fecha
ADD 1 TO lc_fecha.
ENDDO.
RESULT = lc_diash.
* MODIFY DATA_PACKAGE.
* ENDLOOP.
* result value of the routine
* RESULT = .
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.
*$*$ end of routine - insert your code only before this line *-*
*
El calendario se parametriza en SPRO de BW: