Очень, очень годный FM - MONTH_PLUS_DETERMINE.
Его брат-близнец - SEPA_MANDATE_ADD_MONTH_TO_DATE.
Ну и на всякий случай сам код, если в системе не подняты какие-либо компоненты, а поднимать лень:
Его брат-близнец - SEPA_MANDATE_ADD_MONTH_TO_DATE.
Ну и на всякий случай сам код, если в системе не подняты какие-либо компоненты, а поднимать лень:
function ZNF_PERIOD_ADD_TO.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*" IMPORTING
*" REFERENCE(MONTHS)
*" REFERENCE(OLDDATE) TYPE DATS
*" EXPORTING
*" REFERENCE(NEWDATE) TYPE DATS
*"----------------------------------------------------------------------
data:
begin of dat,
jjjj(4),
mm(2),
tt(2),
end of dat,
begin of hdat,
jjjj(4),
mm(2),
tt(2),
end of hdat,
newmm type p,
diffjjjj type p.
*"----------------------------------------------------------------------
*BREAK-POINT id break.
write: olddate+0(4) to dat-jjjj,
olddate+4(2) to dat-mm,
olddate+6(2) to dat-tt.
diffjjjj = ( dat-mm + months - 1 ) div 12.
newmm = ( dat-mm + months - 1 ) mod 12 + 1.
dat-jjjj = dat-jjjj + diffjjjj.
if newmm < 10.
write '0' to dat-mm+0(1).
write newmm to dat-mm+1(1).
else.
write newmm to dat-mm.
endif.
if dat-tt > '28'.
hdat-tt = '01'.
newmm = ( dat-mm ) mod 12 + 1.
hdat-jjjj = dat-jjjj + ( ( dat-mm ) div 12 ).
if newmm < 10.
write '0' to hdat-mm+0(1).
write newmm to hdat-mm+1(1).
else.
write newmm to hdat-mm.
endif.
if dat-tt = '31'.
newdate = hdat.
newdate = newdate - 1.
else.
if dat-mm = '02'.
newdate = hdat.
newdate = newdate - 1.
else.
newdate = dat.
endif.
endif.
else.
newdate = dat.
endif.
endfunction.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*" IMPORTING
*" REFERENCE(MONTHS)
*" REFERENCE(OLDDATE) TYPE DATS
*" EXPORTING
*" REFERENCE(NEWDATE) TYPE DATS
*"----------------------------------------------------------------------
data:
begin of dat,
jjjj(4),
mm(2),
tt(2),
end of dat,
begin of hdat,
jjjj(4),
mm(2),
tt(2),
end of hdat,
newmm type p,
diffjjjj type p.
*"----------------------------------------------------------------------
*BREAK-POINT id break.
write: olddate+0(4) to dat-jjjj,
olddate+4(2) to dat-mm,
olddate+6(2) to dat-tt.
diffjjjj = ( dat-mm + months - 1 ) div 12.
newmm = ( dat-mm + months - 1 ) mod 12 + 1.
dat-jjjj = dat-jjjj + diffjjjj.
if newmm < 10.
write '0' to dat-mm+0(1).
write newmm to dat-mm+1(1).
else.
write newmm to dat-mm.
endif.
if dat-tt > '28'.
hdat-tt = '01'.
newmm = ( dat-mm ) mod 12 + 1.
hdat-jjjj = dat-jjjj + ( ( dat-mm ) div 12 ).
if newmm < 10.
write '0' to hdat-mm+0(1).
write newmm to hdat-mm+1(1).
else.
write newmm to hdat-mm.
endif.
if dat-tt = '31'.
newdate = hdat.
newdate = newdate - 1.
else.
if dat-mm = '02'.
newdate = hdat.
newdate = newdate - 1.
else.
newdate = dat.
endif.
endif.
else.
newdate = dat.
endif.
endfunction.
А почему не использовать ФМ 'SEPA_MANDATE_ADD_MONTH_TO_DATE'?
ОтветитьУдалитьДа, код тот же, спасибо! Не нашли его сразу.
ОтветитьУдалить