*&---------------------------------------------------------------------*
*& Include RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*
program conversion_routine.
* Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
* Fieldname = FISCPER
* data type = NUMC
* length = 000007
* -------------------------------------------------------------------
form c_FISCPER
tables l_t_range structure rssdlrange
using i_r_request type ref to IF_RSBK_REQUEST_ADMINTAB_VIEW
i_fieldnm type RSFIELDNM
changing p_subrc like sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*
DATA
: ls_tvarvc TYPE tvarvc
.
* Находим период закрытия
SELECT SINGLE * INTO ls_tvarvc
FROM tvarvc
WHERE type = 'S' AND name EQ 'Y_KPS_CLOSE_FISCPER_BE1000'.
IF sy-subrc EQ 0.
IF ls_tvarvc-high+4(3) = '012'.
ls_tvarvc-high(4) = ls_tvarvc-high(4) + 1.
ls_tvarvc-high+4(3) = '000'.
ENDIF.
l_t_range-fieldname = 'FISCPER'.
l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
l_t_range-low = ls_tvarvc-high + 1.
APPEND l_t_range.
ELSE.
p_subrc = sy-subrc.
ENDIF.
*$*$ end of routine - insert your code only before this line *-*
endform.
______________________________________________________________________________
Ещё вкусный вариант с дополнительной проверкой:
*&---------------------------------------------------------------------*
*& Include RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*
PROGRAM conversion_routine.
* Type pools used by conversion program
TYPE-POOLS: rsarc, rsarr, rssm.
TABLES: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
* Fieldname = CALDAY
* data type = DATS
* length = 000008
* -------------------------------------------------------------------
FORM compute_CALDAY
TABLES l_t_range STRUCTURE rssdlrange
CHANGING p_subrc LIKE sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*
DATA: ls_tvarvc TYPE tvarvc.
SELECT SINGLE *
INTO ls_tvarvc
FROM tvarvc
WHERE type = 'S'
AND name EQ 'ZSO_REVERSE_TURNOVER'.
IF sy-subrc EQ 0.
* Защита от дурака, если не поставят "между" или "равно"
IF ls_tvarvc-opti IS INITIAL.
IF ls_tvarvc-high IS NOT INITIAL.
ls_tvarvc-opti = 'BT'.
ELSE.
ls_tvarvc-opti = 'EQ'.
ENDIF.
ENDIF.
* Защита от дурака, если не поставят "включительно"
IF ls_tvarvc-sign IS INITIAL.
ls_tvarvc-sign = 'I'.
ENDIF.
l_t_range-fieldname = 'CALDAY'.
l_t_range-sign = ls_tvarvc-sign.
l_t_range-option = ls_tvarvc-opti.
l_t_range-low = ls_tvarvc-low.
l_t_range-high = ls_tvarvc-high.
APPEND l_t_range.
ELSE.
p_subrc = sy-subrc.
ENDIF.
*$*$ end of routine - insert your code only before this line *-*
ENDFORM. "compute_CALDAY
*& Include RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*
program conversion_routine.
* Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
* Fieldname = FISCPER
* data type = NUMC
* length = 000007
* -------------------------------------------------------------------
form c_FISCPER
tables l_t_range structure rssdlrange
using i_r_request type ref to IF_RSBK_REQUEST_ADMINTAB_VIEW
i_fieldnm type RSFIELDNM
changing p_subrc like sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*
DATA
: ls_tvarvc TYPE tvarvc
.
* Находим период закрытия
SELECT SINGLE * INTO ls_tvarvc
FROM tvarvc
WHERE type = 'S' AND name EQ 'Y_KPS_CLOSE_FISCPER_BE1000'.
IF sy-subrc EQ 0.
IF ls_tvarvc-high+4(3) = '012'.
ls_tvarvc-high(4) = ls_tvarvc-high(4) + 1.
ls_tvarvc-high+4(3) = '000'.
ENDIF.
l_t_range-fieldname = 'FISCPER'.
l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
l_t_range-low = ls_tvarvc-high + 1.
APPEND l_t_range.
ELSE.
p_subrc = sy-subrc.
ENDIF.
*$*$ end of routine - insert your code only before this line *-*
endform.
______________________________________________________________________________
Ещё вкусный вариант с дополнительной проверкой:
*&---------------------------------------------------------------------*
*& Include RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*
PROGRAM conversion_routine.
* Type pools used by conversion program
TYPE-POOLS: rsarc, rsarr, rssm.
TABLES: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
* Fieldname = CALDAY
* data type = DATS
* length = 000008
* -------------------------------------------------------------------
FORM compute_CALDAY
TABLES l_t_range STRUCTURE rssdlrange
CHANGING p_subrc LIKE sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*
DATA: ls_tvarvc TYPE tvarvc.
SELECT SINGLE *
INTO ls_tvarvc
FROM tvarvc
WHERE type = 'S'
AND name EQ 'ZSO_REVERSE_TURNOVER'.
IF sy-subrc EQ 0.
* Защита от дурака, если не поставят "между" или "равно"
IF ls_tvarvc-opti IS INITIAL.
IF ls_tvarvc-high IS NOT INITIAL.
ls_tvarvc-opti = 'BT'.
ELSE.
ls_tvarvc-opti = 'EQ'.
ENDIF.
ENDIF.
* Защита от дурака, если не поставят "включительно"
IF ls_tvarvc-sign IS INITIAL.
ls_tvarvc-sign = 'I'.
ENDIF.
l_t_range-fieldname = 'CALDAY'.
l_t_range-sign = ls_tvarvc-sign.
l_t_range-option = ls_tvarvc-opti.
l_t_range-low = ls_tvarvc-low.
l_t_range-high = ls_tvarvc-high.
APPEND l_t_range.
ELSE.
p_subrc = sy-subrc.
ENDIF.
*$*$ end of routine - insert your code only before this line *-*
ENDFORM. "compute_CALDAY
Комментариев нет:
Отправить комментарий