f_insert_0_mtrlware_2.srf 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. $PBExportHeader$f_insert_0_mtrlware_2.srf
  2. global type f_insert_0_mtrlware_2 from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_insert_0_mtrlware_2 (ref long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, long arg_sptid, string arg_status, string arg_woodcode, string arg_pcode, string arg_plancode, string arg_mtrlcuscode, string arg_location, decimal arg_cost, ref string arg_msg)
  6. global function integer f_insert_0_mtrlware_2 (ref long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, long arg_sptid, string arg_status, string arg_woodcode, string arg_pcode, string arg_plancode, string arg_mtrlcuscode, string arg_location, decimal arg_cost, ref integer arg_ref_ifadd, ref string arg_msg, boolean arg_ifcommit)
  7. end prototypes
  8. global function integer f_insert_0_mtrlware_2 (ref long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, long arg_sptid, string arg_status, string arg_woodcode, string arg_pcode, string arg_plancode, string arg_mtrlcuscode, string arg_location, decimal arg_cost, ref string arg_msg);Int rslt = 1
  9. Long cnt
  10. Long ls_mtrlwareid,ls_scid
  11. int li_storMtrlprp
  12. SELECT count(*) INTO :cnt FROM u_mtrlware
  13. WHERE mtrlid = :arg_mtrlid
  14. AND storageid = :arg_storageid
  15. AND sptid = :arg_sptid
  16. AND dxflag = 0
  17. AND woodcode = :arg_woodcode
  18. AND pcode = :arg_pcode
  19. AND status = :arg_status
  20. AND plancode = :arg_plancode
  21. AND mtrlcuscode = :arg_mtrlcuscode
  22. AND Location = :arg_location;
  23. IF sqlca.SQLCode <> 0 THEN
  24. arg_msg = '查询物料:'+arg_mtrlcode+'是否有库存失败,请检查'
  25. rslt = 0
  26. GOTO ext
  27. END IF
  28. IF cnt = 1 THEN
  29. SELECT mtrlwareid INTO :ls_mtrlwareid FROM u_mtrlware
  30. WHERE mtrlid = :arg_mtrlid
  31. AND storageid = :arg_storageid
  32. AND sptid = :arg_sptid
  33. AND dxflag = 0
  34. AND woodcode = :arg_woodcode
  35. AND pcode = :arg_pcode
  36. AND status = :arg_status
  37. AND plancode = :arg_plancode
  38. AND mtrlcuscode = :arg_mtrlcuscode
  39. AND Location = :arg_location;
  40. IF sqlca.SQLCode <> 0 THEN
  41. arg_msg = '查询物料:'+arg_mtrlcode+'是否有库存失败,请检查'
  42. rslt = 0
  43. GOTO ext
  44. END IF
  45. arg_mtrlwareid = ls_mtrlwareid
  46. GOTO ext
  47. END IF
  48. SELECT scid,Mtrlprp INTO :ls_scid,:li_storMtrlprp
  49. FROM u_storage
  50. Where storageid = :arg_storageid;
  51. IF sqlca.SQLCode <> 0 THEN
  52. arg_msg = '查询仓库分部失败,请检查'
  53. rslt = 0
  54. GOTO ext
  55. END IF
  56. IF arg_cost = 0 THEN
  57. SELECT planprice INTO :arg_cost
  58. FROM u_mtrldef_planprice
  59. Where mtrlid = :arg_mtrlid
  60. and status = :Arg_status
  61. and woodcode = :arg_woodcode
  62. and pcode = :arg_pcode;
  63. IF sqlca.SQLCode = -1 THEN
  64. arg_msg = '查询计划价失败!!'
  65. rslt = 0
  66. GOTO ext
  67. elseif sqlca.sqlcode = 100 then
  68. arg_cost = 0
  69. END IF
  70. END IF
  71. ls_mtrlwareid = f_sys_scidentity(ls_scid,"u_mtrlware","mtrlwareid",arg_msg,TRUE,id_sqlca)
  72. INSERT INTO u_mtrlware(scid,
  73. mtrlwareid,
  74. mtrlid,
  75. storageid,
  76. noallocqty,
  77. woodcode,
  78. pcode,
  79. plancode,
  80. status,
  81. sptid,
  82. cost,
  83. mtrlcuscode,
  84. location,
  85. storMtrlprp)
  86. VALUES(:ls_scid,
  87. :ls_mtrlwareid,
  88. :arg_mtrlid,
  89. :arg_storageid,
  90. 0,
  91. :arg_woodcode,
  92. :arg_pcode,
  93. :arg_plancode,
  94. :arg_status,
  95. :arg_sptid,
  96. :arg_cost,
  97. :arg_mtrlcuscode,
  98. :arg_location,
  99. :li_storMtrlprp);
  100. IF sqlca.SQLCode <> 0 THEN
  101. arg_msg = '物料:'+arg_mtrlcode+'加0库存失败或物料已经有库存,请检查'+sqlca.SQLErrText
  102. rslt = 0
  103. GOTO ext
  104. END IF
  105. arg_mtrlwareid = ls_mtrlwareid
  106. ext:
  107. IF rslt = 0 THEN
  108. ROLLBACK;
  109. ELSE
  110. COMMIT;
  111. END IF
  112. RETURN rslt
  113. end function
  114. global function integer f_insert_0_mtrlware_2 (ref long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, long arg_sptid, string arg_status, string arg_woodcode, string arg_pcode, string arg_plancode, string arg_mtrlcuscode, string arg_location, decimal arg_cost, ref integer arg_ref_ifadd, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  115. Long cnt
  116. Long ls_mtrlwareid,ls_scid
  117. Int li_storMtrlprp
  118. SELECT count(*) INTO :cnt FROM u_mtrlware
  119. WHERE mtrlid = :arg_mtrlid
  120. AND storageid = :arg_storageid
  121. AND sptid = :arg_sptid
  122. AND dxflag = 0
  123. AND woodcode = :arg_woodcode
  124. AND pcode = :arg_pcode
  125. AND status = :arg_status
  126. AND plancode = :arg_plancode
  127. AND mtrlcuscode = :arg_mtrlcuscode
  128. And Location = :arg_location;
  129. IF sqlca.SQLCode <> 0 THEN
  130. arg_msg = '查询物料:'+arg_mtrlcode+'是否有库存失败,请检查'
  131. rslt = 0
  132. GOTO ext
  133. END IF
  134. IF cnt = 1 THEN
  135. SELECT mtrlwareid INTO :ls_mtrlwareid FROM u_mtrlware
  136. WHERE mtrlid = :arg_mtrlid
  137. AND storageid = :arg_storageid
  138. AND sptid = :arg_sptid
  139. AND dxflag = 0
  140. AND woodcode = :arg_woodcode
  141. AND pcode = :arg_pcode
  142. AND status = :arg_status
  143. AND plancode = :arg_plancode
  144. AND mtrlcuscode = :arg_mtrlcuscode
  145. And Location = :arg_location;
  146. IF sqlca.SQLCode <> 0 THEN
  147. arg_msg = '查询物料:'+arg_mtrlcode+'是否有库存失败,请检查'
  148. rslt = 0
  149. GOTO ext
  150. END IF
  151. arg_mtrlwareid = ls_mtrlwareid
  152. GOTO ext
  153. END IF
  154. SELECT scid,Mtrlprp INTO :ls_scid,:li_storMtrlprp
  155. FROM u_storage
  156. Where storageid = :arg_storageid;
  157. IF sqlca.SQLCode <> 0 THEN
  158. arg_msg = '查询仓库分部失败,请检查'
  159. rslt = 0
  160. GOTO ext
  161. END IF
  162. IF arg_cost = 0 THEN
  163. SELECT planprice INTO :arg_cost
  164. FROM u_mtrldef_planprice
  165. WHERE mtrlid = :arg_mtrlid
  166. AND status = :Arg_status
  167. AND woodcode = :arg_woodcode
  168. And pcode = :arg_pcode;
  169. IF sqlca.SQLCode = -1 THEN
  170. arg_msg = '查询计划价失败!!'
  171. rslt = 0
  172. GOTO ext
  173. ELSEIF sqlca.SQLCode = 100 THEN
  174. arg_cost = 0
  175. END IF
  176. END IF
  177. ls_mtrlwareid = f_sys_scidentity(ls_scid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
  178. INSERT INTO u_mtrlware(scid,
  179. mtrlwareid,
  180. mtrlid,
  181. storageid,
  182. noallocqty,
  183. woodcode,
  184. pcode,
  185. plancode,
  186. status,
  187. sptid,
  188. cost,
  189. mtrlcuscode,
  190. location,
  191. storMtrlprp)
  192. VALUES(:ls_scid,
  193. :ls_mtrlwareid,
  194. :arg_mtrlid,
  195. :arg_storageid,
  196. 0,
  197. :arg_woodcode,
  198. :arg_pcode,
  199. :arg_plancode,
  200. :arg_status,
  201. :arg_sptid,
  202. :arg_cost,
  203. :arg_mtrlcuscode,
  204. :arg_location,
  205. :li_storMtrlprp);
  206. IF sqlca.SQLCode <> 0 THEN
  207. arg_msg = '物料:'+arg_mtrlcode+'加0库存失败或物料已经有库存,请检查'+sqlca.SQLErrText
  208. rslt = 0
  209. GOTO ext
  210. END IF
  211. arg_ref_ifadd = 1
  212. arg_mtrlwareid = ls_mtrlwareid
  213. ext:
  214. IF rslt = 0 THEN
  215. ROLLBACK;
  216. ELSEIF arg_ifcommit THEN
  217. COMMIT;
  218. END IF
  219. RETURN rslt
  220. end function