open-insight/LSL2/STPROC/RDS_WO_VERIFY_MAINT.txt
Infineon\StieberD 7762b129af pre cutover push
2024-09-04 20:33:41 -07:00

163 lines
5.6 KiB
Plaintext

function rds_wo_verify_maint( WO )
declare function msg, fieldcount, popup, next_key, Dialog_Box
declare subroutine extract_si_keys, make.list
$insert msg_equates
$insert wo_verify_equ
$insert rds_equ
$insert popup_equates
equ CrLf$ to char(13):char(10)
open 'RDS' to RdsTable else
Void = msg( '', 'Unable to open RDS...' )
return 0
end
open 'WO_VERIFY' to WOVerifyTable else
Void = msg( '', 'Unable to open WO_VERIFY...' )
return 0
end
extract_si_keys( 'RDS', 'WO', WO, RdsIds )
if RdsIds then
Rcnt = fieldcount( RdsIds, @vm )
Vids = xlate( 'RDS', RdsIds, rds_wo_verify_id$, 'X' )
PreSelect = ''
PreSelectRDS = ''
for i = 1 to Rcnt
if Vids<1,i> <> '' then
PreSelect<1,-1> = i
PreSelectRDS<1,-1> = RdsIds<1,i>
end
next i
PopRec = xlate( 'SYSREPOSPOPUPS', @appid<1>:'**':'RDS_QUERY', '', 'X' )
PopRec<ptitle$> = 'Choose the RDSs that you wish to have WORK ORDER VERIFICATION.'
if PreSelect <> '' then
PopRec<pinitselect$> = PreSelect
end
convert @vm to @fm in RdsIds
HoldRDSIds = RdsIds
make.list( 0, RdsIds, '', '' )
ChoosenKeys = popup( @window, PopRec )
if ChoosenKeys then
Ccnt = fieldcount( ChoosenKeys, @vm )
* FIRST ADD THE NEW ONES
RDSUpdateMsg = ''
for i = 1 to Ccnt
ThisCRDS = ChoosenKeys<1,i>
locate ThisCRDS in HoldRDSIds using @fm setting Rpos then
locate Rpos in PreSelect using @vm setting Ppos then
* WAS ALREADY SELECTED AND THE RDS WILL BE STAMPED WITH A VERIFICATION
end else
* LOCK RDS OTHERWISE DO NOT CREATE VERIFICATION
lock RDSTable, ThisCRDS then
* CREATE THE VERIFICATION AND STAMP RDS ID
KeyToUse = next_key( 'WO_VERIFY', WOVerifyTable, 'NEXT', '' )
WOVRec = ''
WOVRec<wo_verify_entry_id$> = @user4
WOVRec<wo_verify_entry_date$> = date()
WOVRec<wo_verify_rds_id$> = ThisCRDS
WOVRec<wo_verify_status$> = 'O'
write WOVRec on WOVerifyTable, KeyToUse else
Void = msg( '', 'Unable to write WO_VERIFY ':KeyToUse )
return 0
end
unlock WOVerifyTable, KeyToUse else
Void = msg( '', 'Unable to unlock WO_VERIFY ':KeyToUse )
return 0
end
Void = next_key( 'WO_VERIFY', WOVerifyTable, 'UPDATE', KeyToUse )
* NOW UPDATE THE RDS WITH THE WO_VERIFY ID
writev KeyToUse on RDSTable, ThisCRDS, rds_wo_verify_id$ else
Void = msg( '', 'Unable to write to RDS ':ThisCRDS )
return 0
end
unlock RDSTable, ThisCRDS else
Void = msg( '', 'Unable to unlock RDS ':ThisCRDS )
return 0
end
RDSUpdateMsg := 'RDS# ':ThisCRDS:' Run Order# ':xlate( 'RDS', ThisCRDS, 'RUN_ORDER_NUM', 'X' ):CrLf$
end else
MsgInfo = ''
MsgInfo<micon$> = '!'
MsgInfo<mtext$> = 'RDS ':ThisCRDS:' is in use and no verification can be created...Try at a later point.'
Void = msg( '', MsgInfo )
end
end
end
next i
if RDSUpdateMsg <> '' then
RDSUpdateMsg[-2,2] = ''
* RDSUpdateMsg = 'The Following RDSs were stamped as needing Work Order Verification':CrLf$:RDSUpdateMsg
* MsgInfo = ''
* MsgInfo<micon$> = '!'
* MsgInfo<mtext$> = RDSUpdateMsg
* Void = msg( '', MsgInfo )
Void = Dialog_Box('RDS_WORK_ORDER_MAINTENANCE', @Window, RDSUpdateMsg)
end
* NOW DID THEY REMOVE A VERIFICATION THAT WAS PREVIOUSLY SELECTED IS SO THEN
* PROMPT THE USER TO MAKE SURE
RDSUpdateMsg = ''
Pcnt = fieldcount( PreSelectRds, @vm )
for i = 1 to Pcnt
TPRds = PreSelectRds<1,i>
locate TPRds in ChoosenKeys using @vm setting OKPos else
WOVerifyID = xlate( 'RDS', TPRds, rds_wo_verify_id$, 'X' )
TechSig = xlate( 'WO_VERIFY', WOVerifyID, wo_verify_tech_sig$, 'X' )
if TechSig = '' then
lock RDSTable, TPRds then
lock WOVerifyTable, WOVerifyID then
delete WOVerifyTable, WOVerifyID else
Void = msg( '', 'Unable to delete WO_VERIFY ':WOVerifyID )
end
unlock WOVerifyTable, WOVerifyID else
Void = msg( '', 'Unable to unlock WO_VERIFY ':WOVerifyID )
return 0
end
writev '' on RDSTable, TPRds, rds_wo_verify_id$ else
Void = msg( '', 'Unable to write to RDS ':TPRds )
return 0
end
unlock RDSTable, TPRds else
Void = msg( '', 'Unable to unlock RDS ':TPRds )
return 0
end
RDSUpdateMsg := 'RDS# ':TPRds:' Run Order# ':xlate( 'RDS', TPRds, 'RUN_ORDER_NUM', 'X' ):CrLf$
end else
MsgInfo = ''
MsgInfo<micon$> = '!'
MsgInfo<mtext$> = 'RDS ':TPRds:' and verification records are in use and the verification can not be removed...Try at a later point.'
Void = msg( '', MsgInfo )
end
end else
MsgInfo = ''
MsgInfo<micon$> = '!'
MsgInfo<mtext$> = 'RDS ':TPRds:' is in use and the verification can not be removed...Try at a later point.'
Void = msg( '', MsgInfo )
end
end else
MsgInfo = ''
MsgInfo<micon$> = '!'
MsgInfo<mtext$> = 'RDS ':TPRds:' has already been Work Order Verified by a technician and cannot be removed.'
Void = msg( '', MsgInfo )
end
end
next i
if RDSUpdateMsg <> '' then
RDSUpdateMsg[-2,2] = ''
RDSUpdateMsg = 'The Following RDSs had Work Order Verification removed:':CrLf$:RDSUpdateMsg
MsgInfo = ''
MsgInfo<micon$> = '!'
MsgInfo<mtext$> = RDSUpdateMsg
Void = msg( '', MsgInfo )
end
end; * NO CHOOSEN KEYS
end else
MsgInfo = ''
MsgInfo<mtext$> = 'Error extracting keys...'
MsgInfo<micon$> = 'H'
Void = msg( '', MsgInfo )
return 0
end
return 0