FORM
ztfi_ruvat_exp_events_01.
**********************************************************************
DATA ls_line TYPE ztfi_ruvat_exp.
DATA lv_subrc TYPE sy-subrc.
DATA lv_index TYPE sy-tabix.
DATA lv_export_conf TYPE ztfi_ruvat_exp-export_conf.
DATA lt_exp TYPE TABLE OF
ztfi_ruvat_exp.
DATA ls_split TYPE ztfi_ruvat_split.
DATA lt_split TYPE TABLE OF
ztfi_ruvat_split.
FIELD-SYMBOLS TYPE ztfi_ruvat_exp.
FIELD-SYMBOLS TYPE ztfi_ruvat_exp.
* Fill
internal table
LOOP AT total.
CHECK EQ neuer_eintrag OR
EQ aendern OR EQ original.
ASSIGN total TO CASTING.
INSERT INTO TABLE lt_exp.
ENDLOOP.
* Check
data
LOOP AT lt_exp ASSIGNING .
" Check key fields
IF -gjahr IS INITIAL OR
-quart IS INITIAL OR -cdate IS INITIAL.
MESSAGE 'Key must be filled' TYPE 'I'.
lv_subrc = 4.
EXIT.
ENDIF.
" Check sum fields
IF ( -total IS NOT INITIAL OR
-export IS NOT INITIAL OR -perc_export IS NOT INITIAL )
AND
( -export_conf IS NOT INITIAL
OR -perc_export_conf IS NOT INITIAL
).
MESSAGE 'You can fill TOTAL block or
CONFIRMED block only' TYPE 'I'.
lv_subrc = 4.
EXIT.
ENDIF.
" Check total for period only one time
IF -total IS NOT INITIAL OR
-export IS NOT INITIAL OR -perc_export IS NOT INITIAL.
LOOP AT lt_exp TRANSPORTING NO FIELDS
WHERE gjahr EQ -gjahr
AND quart EQ -quart
AND cdate NE -cdate
AND ( total IS NOT
INITIAL OR export IS NOT INITIAL OR perc_export IS NOT INITIAL ).
EXIT.
ENDLOOP.
IF sy-subrc EQ 0.
MESSAGE 'TOTAL block can be filled only
one time for period' TYPE 'I'.
lv_subrc = 4.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
IF lv_subrc EQ 0.
* Calc and
update data
LOOP AT total.
CHECK EQ neuer_eintrag OR
EQ aendern OR EQ original.
READ TABLE extract WITH KEY
.
IF
sy-subrc EQ 0.
lv_index = sy-tabix.
ELSE.
CLEAR lv_index.
ENDIF.
ASSIGN total TO CASTING.
" Calc exp to total percent
IF NE original AND
-total IS NOT INITIAL.
" Update
CLEAR ls_split.
ls_split-fromdate(4) = -gjahr.
ls_split-todate(4) = -gjahr.
CASE -quart.
WHEN '1'.
ls_split-fromdate+4(4) = '0101'.
ls_split-todate+4(4) = '0331'.
WHEN '2'.
ls_split-fromdate+4(4) = '0401'.
ls_split-todate+4(4) = '0630'.
WHEN '3'.
ls_split-fromdate+4(4) = '0701'.
ls_split-todate+4(4) = '0930'.
WHEN '4'.
ls_split-fromdate+4(4) = '1001'.
ls_split-todate+4(4) = '1231'.
ENDCASE.
ls_split-zvariant = 'A0'.
ls_split-mwskz = '*'.
ls_split-further_export =
-perc_export.
ls_split-deduct = 100 -
ls_split-further_export.
INSERT ls_split INTO TABLE lt_split.
ENDIF.
" Calc confirmed percent
IF NE original AND
-export_conf IS NOT INITIAL.
lv_export_conf =
-export_conf.
LOOP AT lt_exp ASSIGNING
WHERE gjahr EQ -gjahr
AND
quart EQ -quart
AND
cdate LT -cdate
AND
export_conf NE 0.
SUBTRACT -export_conf FROM
lv_export_conf.
ENDLOOP.
LOOP AT lt_exp ASSIGNING
WHERE gjahr EQ -gjahr
AND quart EQ -quart
AND
cdate LT -cdate
AND
export NE 0.
EXIT.
ENDLOOP.
ENDIF.
MODIFY total.
CHECK lv_index GT 0.
extract = total.
MODIFY extract INDEX lv_index.
ENDLOOP.
ENDIF.
sy-subrc = lv_subrc.
IF lv_subrc EQ 0.
MODIFY ztfi_ruvat_split FROM TABLE
lt_split.
ENDIF.
ENDFORM.
Комментариев нет:
Отправить комментарий