我们知道在做会计凭证时,借贷不平是保存不了的,但是预制凭证时借贷不平是可以保存的。现在用户要求在预制时借贷就要做不平的检查,实现方法:
1,在用户ID的参数里加下面的参数:
FO2 X X X X XX
2,通过OB28写校验,在写完全凭证里。
代码如下:
FORM u002 USING bool_data TYPE gb002_015
CHANGING b_result.
DATA : lv_wrbtr_s TYPE wrbtr,
lv_wrbtr_h TYPE wrbtr,
lv_dmbtr_s TYPE dmbtr,
lv_dmbtr_h TYPE dmbtr.
DATA : ls_bseg TYPE bseg.
IF sy-tcode EQ 'FBV1'." F-65
LOOP AT bool_data-bseg INTO ls_bseg.
IF ls_bseg-shkzg EQ 'S'.
lv_wrbtr_s = lv_wrbtr_s + ls_bseg-wrbtr.
lv_dmbtr_s = lv_dmbtr_s + ls_bseg-wrbtr.
ELSE.
lv_wrbtr_h = lv_wrbtr_h + ls_bseg-wrbtr.
lv_dmbtr_h = lv_dmbtr_h + ls_bseg-wrbtr.
ENDIF.
b_result = b_true.
ENDLOOP.
IF abs( lv_wrbtr_s ) NE abs( lv_wrbtr_h ).
b_result = b_false.
MESSAGE '借贷凭证金额不一致!' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
IF abs( lv_dmbtr_s ) NE abs( lv_dmbtr_h ).
b_result = b_false.
MESSAGE '借贷本位币金额不一致!' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
IF b_result NE b_false.
b_result = b_true.
ENDIF.
ENDIF.
ENDFORM.
|