f_get_dft_pf.srf 947 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $PBExportHeader$f_get_dft_pf.srf
  2. global type f_get_dft_pf from function_object
  3. end type
  4. forward prototypes
  5. global function string f_get_dft_pf (long arg_mtrlid)
  6. end prototypes
  7. global function string f_get_dft_pf (long arg_mtrlid);String rst_pfcode
  8. Long cnt
  9. Long ll_dftwrkgrpid
  10. Select count(*)
  11. Into :cnt
  12. From u_mtrl_pf
  13. Where mtrlid = :arg_mtrlid
  14. And ifdft = 1;
  15. If sqlca.SQLCode <> 0 Then cnt = 0
  16. If cnt = 1 Then
  17. Select pfcode Into :rst_pfcode
  18. From u_mtrl_pf
  19. Where mtrlid = :arg_mtrlid
  20. And ifdft = 1;
  21. Else
  22. Select dftwrkgrpid
  23. Into :ll_dftwrkgrpid
  24. From u_mtrldef
  25. Where mtrlid = :arg_mtrlid;
  26. If sqlca.SQLCode <> 0 Then ll_dftwrkgrpid = 0
  27. Select top 1 u_mtrl_pf.pfcode Into :rst_pfcode
  28. From u_mtrl_pf
  29. Where u_mtrl_pf.mtrlid = :arg_mtrlid
  30. And u_mtrl_pf.ifdft = 1
  31. And (u_mtrl_pf.wrkid = :ll_dftwrkgrpid or :ll_dftwrkgrpid = 0 );
  32. End If
  33. If sqlca.SQLCode <> 0 Then rst_pfcode = ''
  34. Return rst_pfcode
  35. end function