start_agent_info
AgentName = "AU_PREV_CORR_COORDINATOR"
AgentDescr = "Preventive and Corrective Actions Coordinator"
AgentLanguage = ""
__timer_interval = 0 {....define
(in seconds
) the timer interval
for the wake up}
__delete_on_termination = 0 {....1=the agent frees itself
when terminates its task}
end_agent_info
start_bpm_activity "Peventive and Corrective Action"
start_bpm_subactivity "Form"
rec = __params[1]
form = __params[2]
expr = strcat
(rec
,"=AU_PREV_CORR"
)
call OpenFormTop
("ptEdit"
,form
,"WORK.AU_PREV_CORR"
,1
,expr
)
end_bpm_subactivity
start_bpm_validation
result = 1
cnt = SelectFrom
("
SELECT COUNT
(AU_PREV_CORR_EXE
) FROM AU_PREV_CORR_EXE
WHERE (AU_PREV_CORR="
,__params[1]
,"
)"
)
cnt = val
(cnt
)
if (cnt = 0
) then
call message
("You must define at least one assosiate
for the correction!"
)
result = 0
endif
end_bpm_validation
end_bpm_activity
start_bpm_activity "Approvals
for the Correcive Actions"
start_bpm_subactivity "Form"
rec = __params[1]
form = __params[2]
expr = strcat
(rec
,"=AU_PREV_CORR"
)
call OpenFormTop
("ptEdit"
,form
,"WORK.AU_PREV_CORR"
,1
,expr
)
end_bpm_subactivity
start_bpm_validation
result = 1
cnt = SelectFrom
("
SELECT COUNT
(AU_PREV_CORR_APPR
) FROM AU_PREV_CORR_APPR
WHERE (AU_PREV_CORR="
,__params[1]
,"
)"
)
cnt = val
(cnt
)
if (cnt = 0
) then
call message
("You must define at least one assosiate
to approve the correction!"
)
result = 0
endif
end_bpm_validation
end_bpm_activity
start_bpm_activity "Approval/Rejection of Corrective Actions"
start_bpm_subactivity "Form"
rec = __params[1]
form = __params[3]
expr = strcat
(rec
,"=AU_PREV_CORR"
)
call OpenFormTop
("ptEdit"
,form
,"WORK.AU_PREV_CORR"
,1
,expr
)
end_bpm_subactivity
start_bpm_subactivity "Approve"
flag = message_yes_no
("Attention! You will give your approval!"
)
if (flag = 1
) then
call UpdateField
("AU_PREV_CORR_APPR"
,__params[2]
,"YES_FLAG"
,"1"
)
endif
end_bpm_subactivity
start_bpm_subactivity "Reject"
flag = message_yes_no
("Attention! You will reject the!"
)
if (flag = 1
) then
call UpdateField
("AU_PREV_CORR_APPR"
,__params[2]
,"NO_FLAG"
,"1"
)
endif
end_bpm_subactivity
start_bpm_validation
result = 1
yes = LookUpId
("AU_PREV_CORR_APPR"
,__params[2]
,"YES_FLAG"
)
no = LookUpId
("AU_PREV_CORR_APPR"
,__params[2]
,"NO_FLAG"
)
flag = yes+no
if (flag <> 1
) then
call message
("You must approve or reject"
)
result = 0
endif
end_bpm_validation
end_bpm_activity
start_bpm_activity "Corrective Action"
start_bpm_subactivity "Form"
rec = __params[1]
form = __params[3]
expr = strcat
(rec
,"=AU_PREV_CORR"
)
call OpenFormTop
("ptEdit"
,form
,"WORK.AU_PREV_CORR"
,1
,expr
)
end_bpm_subactivity
start_bpm_subactivity "Comments
for Correction"
rec = __params[2]
expr = strcat
(rec
,"=AU_PREV_CORR_EXE"
)
call OpenFormTop
("ptEdit"
,"
AU_PREV_CORR_EXE_E.FM"
,"WORK.AU_PREV_CORR_EXE"
,1
,expr
)
end_bpm_subactivity
end_bpm_activity
start_action
id = __params[1]
form = __params[2]
call bpm_setprocedureowner
(__activation_user
) {.....set the procedure owner}
num = SelectFrom
("
SELECT MAX
(PNUM
) FROM AU_PREV_CORR"
)
num = num + 1
call UpdateField
("AU_PREV_CORR"
,id
,"PNUM"
,num
,"PDATE"
,crDate
)
comm = LookUpId
("AU_PREV_CORR"
,id
,"PSUBJECT"
)
call bpm_setprocedurecomment
(comm
) {.....set the process comment}
{.....fill in the form from the activating assosiate..............................}
call bpm_openatonce
()
callwait bpm_assign_job
("Peventive and Corrective Action"
,__activation_user
,""
, 0
, id
, form
)
{.....catalog of approving assosiates....................}
callwait bpm_assign_job
("Approvals
for the Correcive Actions"
,""
,"QUALITY ASSURANCE MANAGER"
, 0
, id
, form
)
{...........get the group of approving associates.....................}
start_sql "*" "KOSMOS"
SELECT *
FROM AU_PREV_CORR_APPR
WHERE (AU_PREV_CORR = :A
)
end_sql
q = QueryByName
()
call TSetParam
(q
,"A"
,id
)
call TExecute
(q
)
appr_count = TRecordCount
(q
)
call TFirst
(q
)
for i = 1
to appr_count
appr_name[i] = TGetFld
(q
,"AU_USER"
)
appr_name[i] = LookUpId
("AU_USER"
,appr_name[i]
,"UNAME"
)
appr_id[i] = TGetFld
(q
,"AU_PREV_CORR_APPR"
)
call TNext
(q
)
next
call FreeEmbSQL
(q
)
{...........sent tasks
for approving
(parallel execution
)......................}
split_
for i = 1
to appr_count
callwait bpm_assign_job
("Approval/Rejection of Corrective Actions"
, appr_name[i]
, ""
, 0
, id
, appr_id[i]
, form
)
appr_flag[i] = LookUpId
("AU_PREV_CORR_APPR"
,appr_id[i]
,"YES_FLAG"
)
next_branch
{.....does everybody has approved?.....}
flag = 1
for i = 1
to appr_count
appr_flag[i] = val
(appr_flag[i]
)
if (appr_flag[i] = 0
) then
flag = 0
endif
next
{.......get group of correcion associates..................................}
start_sql "*" "KOSMOS"
SELECT *
FROM AU_PREV_CORR_EXE
WHERE (AU_PREV_CORR = :A
)
end_sql
q = QueryByName
()
call TSetParam
(q
,"A"
,id
)
call TExecute
(q
)
corr_count = TRecordCount
(q
)
call TFirst
(q
)
for i = 1
to corr_count
corr_name[i] = TGetFld
(q
,"AU_USER"
)
corr_name[i] = LookUpId
("AU_USER"
,corr_name[i]
,"UNAME"
)
corr_id[i] = TGetFld
(q
,"AU_PREV_CORR_EXE"
)
call TNext
(q
)
next
call FreeEmbSQL
(q
)
{.....
if everybody has approved s
end the tasks
to correction assosiates......}
if (flag = 1
) then
{...............correction in parallel split......................}
split_
for i = 1
to corr_count
callwait bpm_assign_job
("Corrective Action"
, corr_name[i]
, ""
, 0
, id
, corr_id[i]
, form
)
corr_flag[i] = LookUpId
("AU_PREV_CORR_EXE"
,corr_id[i]
,"YES_FLAG"
)
next_branch
endif
end_action