12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- $PBExportHeader$f_find_unitrate.srf
- global type f_find_unitrate from function_object
- end type
- forward prototypes
- global function integer f_find_unitrate (long arg_mtrlid, ref string arg_unit, ref decimal arg_rate)
- end prototypes
- global function integer f_find_unitrate (long arg_mtrlid, ref string arg_unit, ref decimal arg_rate);Int rslt = 1
- String ls_unit,ls_unit_buy,ls_unit_scll,ls_unit_sale
- Decimal lde_rate_buy, lde_rate_scll, lde_rate_sale
- IF arg_mtrlid = 0 AND arg_unit = "" THEN
- arg_rate = 1
- RETURN 0
- ELSEIF arg_mtrlid = 0 THEN
- arg_rate = 1
- RETURN 1
- END IF
- SELECT unit,unit_buy,rate_buy,unit_scll,rate_scll,unit_sale,rate_sale
- INTO :ls_unit,:ls_unit_buy,:lde_rate_buy,:ls_unit_scll,:lde_rate_scll,:ls_unit_sale,:lde_rate_sale
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF arg_unit = "" THEN
- arg_unit = ls_unit
- arg_rate = 1
- GOTO ext
- END IF
- CHOOSE CASE arg_unit
- CASE ls_unit
- arg_rate = 1
- CASE ls_unit_buy
- arg_rate = lde_rate_buy
- CASE ls_unit_scll
- arg_rate = lde_rate_scll
- CASE ls_unit_sale
- arg_rate = lde_rate_sale
- CASE ELSE
- arg_unit = ls_unit
- arg_rate = 1
- END CHOOSE
- ext:
- RETURN rslt
- end function
|