f_find_mtrl_dftprice.srf 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. $PBExportHeader$f_find_mtrl_dftprice.srf
  2. global type f_find_mtrl_dftprice from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_find_mtrl_dftprice (long arg_mtrlid, ref decimal arg_price, ref decimal arg_rebate)
  6. end prototypes
  7. global function integer f_find_mtrl_dftprice (long arg_mtrlid, ref decimal arg_price, ref decimal arg_rebate);Int rslt = 1
  8. long ll_moneyid
  9. SELECT moneyid
  10. INTO :ll_moneyid
  11. FROM cw_currency
  12. Where native = 1;
  13. IF sqlca.SQLCode <> 0 THEN
  14. arg_price = 0
  15. arg_rebate = 1
  16. rslt = 0
  17. GOTO ext
  18. end if
  19. SELECT u_sale_price_mx.price,
  20. u_sale_price_mx.rebate
  21. INTO :arg_price,
  22. :arg_rebate
  23. FROM u_sale_price_list,u_sale_price_mx
  24. WHERE u_sale_price_list.pricelistid = u_sale_price_mx.pricelistid
  25. AND u_sale_price_list.dftflag = 1
  26. AND u_sale_price_mx.mtrlid = :arg_mtrlid and u_sale_price_list.moneyid = :ll_moneyid;
  27. IF sqlca.SQLCode <> 0 THEN
  28. arg_price = 0
  29. arg_rebate = 1
  30. rslt = 0
  31. GOTO ext
  32. ELSEIF sqlca.SQLNRows = 0 THEN
  33. SELECT u_mtrldef.lmsaleprice
  34. INTO :arg_price
  35. FROM u_mtrldef
  36. Where u_mtrldef.mtrlid = :arg_mtrlid;
  37. IF sqlca.SQLCode <> 0 THEN
  38. arg_price = 0
  39. arg_rebate = 1
  40. rslt = 0
  41. GOTO ext
  42. END IF
  43. END IF
  44. ext:
  45. RETURN rslt
  46. end function