f_init_sys_plan.srf 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. $PBExportHeader$f_init_sys_plan.srf
  2. global type f_init_sys_plan from function_object
  3. end type
  4. forward prototypes
  5. global subroutine f_init_sys_plan ()
  6. end prototypes
  7. global subroutine f_init_sys_plan ();datastore ds_funcpwr
  8. ds_funcpwr = CREATE datastore
  9. ds_funcpwr.DataObject = 'ds_sys_funcpwr'
  10. ds_funcpwr.SetTransObject(sqlca)
  11. Long maxFuncId,maxFuncIdRow
  12. SELECT sys_pwrstr,sys_optionstr,if_development
  13. INTO :sys_pwrstr,:sys_optionstr,:sys_development
  14. FROM sys_DB_version;
  15. IF sqlca.SQLCode <> 0 THEN
  16. //sys_pwrstr = Fill('1',5000)
  17. //sys_optionstr = Fill('1',1000)
  18. END IF
  19. IF sys_optionstr = '' THEN
  20. sys_optionstr = Fill('1',1000)
  21. END IF
  22. IF sys_pwrstr = '' THEN
  23. //sys_pwrstr = Fill('1',5000)
  24. maxFuncId = ds_funcpwr.Object.funcid[ds_funcpwr.RowCount()]
  25. maxFuncIdRow = ds_funcpwr.Find("funcid > " + String(maxFuncId), 1, ds_funcpwr.RowCount())
  26. DO WHILE maxFuncIdRow > 0
  27. maxFuncId = ds_funcpwr.Object.funcid[maxFuncIdRow]
  28. maxFuncIdRow = ds_funcpwr.Find("funcid > " + String(maxFuncId), 1, ds_funcpwr.RowCount())
  29. LOOP
  30. IF maxFuncId <= 0 THEN
  31. maxFuncId = 5000
  32. END IF
  33. sys_pwrstr = Fill('1',maxFuncId)
  34. END IF
  35. Int modulesCount
  36. modulesCount = UpperBound(sys_enabledModules)
  37. IF modulesCount <= 0 THEN RETURN
  38. String moduleidStr = '('
  39. Int i
  40. modulesCount = modulesCount
  41. FOR i = 1 TO UpperBound(sys_enabledModules)
  42. moduleidStr += String(sys_enabledModules[i])
  43. IF i < modulesCount THEN
  44. moduleidStr += ','
  45. END IF
  46. NEXT
  47. moduleidStr += ')'
  48. Long curFuncid
  49. FOR curFuncid = 1 TO Len(sys_pwrstr)
  50. IF Mid(sys_pwrstr,curFuncid,1) = '0' THEN CONTINUE
  51. IF ds_funcpwr.Find("funcid = " + String(curFuncid) + " AND moduleid IN " + moduleidStr, 1, ds_funcpwr.RowCount()) <= 0 THEN
  52. sys_pwrstr = Replace(sys_pwrstr,curFuncid,1,"0")
  53. END IF
  54. NEXT
  55. end subroutine