Function Test_Daniel(@Service, @Params)
#pragma precomp SRP_PreCompiler

$Insert SERVICE_SETUP
$Insert REVDOTNETEQUATES
$Insert LOGICAL
$Insert REACT_RUN_EQUATES
$Insert RUN_STAGE_WFR_EQUATES
$Insert SRP_IO_EQUATES
$Insert WO_MAT_EQUATES
$Insert PRS_STAGE_EQUATES
$Insert OIPRINT_EQUATES
$Insert PRINTSETUP_EQUATES
$Insert RLIST_EQUATES
$Insert ROTR_EQUATES
$Insert WO_WFR_EQUATES
$Insert RDS_EQUATES
$Insert PROD_SPEC_EQUATES
$Insert WO_MAT_QA_EQUATES
$Insert SCHED_DET_NG_EQUATES
$Insert MSG_EQUATES
$Insert WM_OUT_EQUATES
$Insert MAKEUP_WAFERS_EQUATES
$Insert CLEAN_INSP_EQUATES

EQU PI$LEFT		TO 1	;* OIPI page parameters
EQU PI$TOP		TO 2
EQU PI$RIGHT	TO 3
EQU PI$BOTTOM	TO 4
EQU PI$WIDTH	TO 5
EQU PI$HEIGHT	TO 6
EQU PI$SIZE		TO 7

Declare function    SRPExampleDLL2, Database_Services, obj_WO_Mat, obj_Shipment, DateTime, SRP_Array, Gan_Services
Declare function    Signature_Services, Memberof, Security_Services, SRPWinAPI_CreateFile, SRP_IO, Engineering_Services
Declare function    Excel_Services, File_Services, QA_Services, Excel_Services_Dev, obj_Location, GetCommandLine
Declare function    PrintSetup, Set_Printer, SRPWinAPI_CopyFile, Math_Services, obj_RDS, obj_React_Run, Reactor_Services
Declare subroutine  Error_Services, Set_Status, Database_Services, Excel_Services, SRP_IO, File_Services, Set_Property
Declare subroutine  SRPWinAPI_CloseHandle, ErrMsg, GetTempPath, GetTempFileName, Btree.Extract, Excel_Services_Dev
Declare subroutine  Send_Message.Net, Engineering_Services, Qa_Services, Gan_Services, RList, Delete_Table, Sleepery
Declare subroutine  SRP_Stopwatch, Dialog_Box, Schedule_Services, Set_IDXSvr, Set_Bgnd_IX_Time, Signature_Services
Declare subroutine  Mona_Services, Msg, Work_Order_Services, Copy_Record_To_SQL, Material_Services, Sql_Services
Declare subroutine  SQL_Services_RevDotNet, Memory_Services, Replication_Services, Write_OI_To_Sql, Attach_Table
Declare subroutine  Detach_Table
Declare function    Repository, Get_Status, Get_Repos_Entities, obj_NCR, RTI_CreateGUID
Declare function    Epi_Part_Services, SRP_Math, obj_WM_Out, Error_Services, Signature_Services, obj_WO_Mat_QA
Declare function    GetTickCount, Schedule_Services, Msg, SRP_Stopwatch, IConv, OConv, SRP_Get_FileVersion
Declare function    GetVersionEx, RTI_Lock_Owner, Sql_Services, SQL_Services_RevDotNet, Replication_Services
Declare function    Printer_Select

GoToService else
    Error_Services('Set', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
end

Return Response else ''


Service NCRCount()
    
    Debug
    NumNCR = Xlate('RDS', 582818, 'TOT_REJ', 'X')
    
    
    
    
end service


Service NewScript()
    

    KeyList    = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
    For each WOMatKey in KeyList using @FM setting fPos then
        WONo = Field(WOMatKey, '*', 1)
        MUBox = False$
        ReactType = Xlate('WO_MAT', WOMatKey, 'REACTOR_TYPE', 'X')
        If ReactType EQ 'EPP' then
            
            WMOKey = Xlate('WO_MAT', WOMatKey, 'WMO_KEY', 'X')
            MUBox = Xlate('WM_OUT', WMOKey, 'MAKEUP_BOX', 'X')
            
            If MUBox then
                CurrWaferCount  = obj_WO_Mat('CurrWaferCnt', WOMatKey)
                If CurrWaferCount GT 0 then
                    // Populate MAKEUP_WAFERS table
                    // Add/update cassette data to the MAKEUP_WAFERS table
                    Database_Services('ActivateRecord', 'WM_OUT', WMOKey)
                    WOMatKey                                    = {WO_MAT_KEY}
                    MUWfrRec                                    = ''
                    MUWfrRec<MAKEUP_WAFERS.SAP_BATCH_NO$>       = {SAP_BATCH_NO}
                    MUWfrRec<MAKEUP_WAFERS.PS_NO$>              = {PS_NO}
                    MUWfrRec<MAKEUP_WAFERS.CUST_NO$>            = Xlate('WO_LOG', WONo, 'CUST_NO', 'X')
                    MUWfrRec<MAKEUP_WAFERS.PROD_ORD_NO$>        = Xlate('WO_LOG', WONo, 'PROD_ORD_NO', 'X')
                    MUWfrRec<MAKEUP_WAFERS.WAFER_SIZE$>         = Xlate('WO_MAT', WOMatKey, 'WAFER_SIZE', 'X')
                    MUWfrRec<MAKEUP_WAFERS.EPI_PART_NO$>        = {PART_NO}
                    MUWfrRec<MAKEUP_WAFERS.RDS_NO$>             = {RDS}
                    MUWfrRec<MAKEUP_WAFERS.WM_OUT_NO$>          = WMOKey
                    MUWfrRec<MAKEUP_WAFERS.PROD_VER_NO$>        = Xlate('WO_MAT', WOMatKey, 'PROD_VER_NO', 'X')
                    MUWfrRec<MAKEUP_WAFERS.CUST_PART_NO$>       = Xlate('WO_MAT', WOMatKey, 'CUST_PART_NO', 'X')
                    MUWfrRec<MAKEUP_WAFERS.REACT_TYPE$>         = Xlate('WO_LOG', WONo, 'REACT_TYPE', 'X')
                    MUWfrRec<MAKEUP_WAFERS.CURR_STATUS_STATIC$> = {CURR_STATUS_STATIC}
                    RDSNos                                      = {RDS}
                    RDSNos                                      = SRP_Array('Clean', RDSNos, 'TrimAndMakeUnique', @VM)
                    UnloadDTMs                                  = ''
                    For each RDSNo in RDSNos using @VM
                        DateOut           = Xlate('RDS', RDSNo, 'DATE_OUT', 'X')
                        TimeOut           = Xlate('RDS', RDSNo, 'TIME_OUT', 'X') / 86400
                        TimeOut[1, 2]     = ''
                        TimeOut           = TimeOut[1, 5]
                        UnloadDTMs<0, -1> = DateOut:'.':TimeOut
                    Next RDSNo
                    UnloadDTMs                                  = SRP_Array('Clean', UnloadDTMs, 'TrimAndMakeUnique', @VM)
                    UnloadDTMs                                  = SRP_Array('SortSimpleList', UnloadDTMs, 'AscendingNumbers', @VM)
                    MUWfrRec<MAKEUP_WAFERS.UNLOAD_DTM$>         = UnloadDTMs<0, 1>
                    Database_Services('WriteDataRow', 'MAKEUP_WAFERS', WOMatKey, MUWfrRec, True$, False$, True$)
                end else
                    // Remove cassette data from MAKEUP_WAFERS table if it is present
                    If RowExists('MAKEUP_WAFERS', WOMatKey) then
                        Database_Services('DeleteDataRow', 'MAKEUP_WAFERS', WOMatKey, True$, False$)
                    end
                end
            end
        end else
            MUBox = Xlate('WO_MAT', WOMatKey, 'MAKEUP_BOX', 'X')
            If MUBox then
                CurrWaferCount  = obj_WO_Mat('CurrWaferCnt', WOMatKey)
                If CurrWaferCount GT 0 then
                    Database_Services('ActivateRecord', 'WO_MAT', WOMatKey)
                    // Populate MAKEUP_WAFERS table
                    // Add/update cassette data to the MAKEUP_WAFERS table
                    MUWfrRec                                    = ''
                    MUWfrRec<MAKEUP_WAFERS.SAP_BATCH_NO$>       = {SAP_BATCH_NO}
                    MUWfrRec<MAKEUP_WAFERS.PS_NO$>              = Xlate('WO_LOG', WONo, 'PS_NO', 'X')
                    MUWfrRec<MAKEUP_WAFERS.CUST_NO$>            = {CUST_NO}
                    MUWfrRec<MAKEUP_WAFERS.PROD_ORD_NO$>        = {PROD_ORD_NO}
                    MUWfrRec<MAKEUP_WAFERS.WAFER_SIZE$>         = {WAFER_SIZE}
                    MUWfrRec<MAKEUP_WAFERS.EPI_PART_NO$>        = {EPI_PART_NO}
                    MUWfrRec<MAKEUP_WAFERS.RDS_NO$>             = {RDS_NO}
                    MUWfrRec<MAKEUP_WAFERS.WM_OUT_NO$>          = ''            ; // Only applies to EPP
                    MUWfrRec<MAKEUP_WAFERS.PROD_VER_NO$>        = {PROD_VER_NO}
                    MUWfrRec<MAKEUP_WAFERS.CUST_PART_NO$>       = {CUST_PART_NO}
                    MUWfrRec<MAKEUP_WAFERS.REACT_TYPE$>         = {REACTOR_TYPE}
                    MUWfrRec<MAKEUP_WAFERS.CURR_STATUS_STATIC$> = {CURR_STATUS_STATIC}
                    DateOut                                     = Xlate('RDS', {RDS_NO}, 'DATE_OUT', 'X')
                    TimeOut                                     = Xlate('RDS', {RDS_NO}, 'TIME_OUT', 'X') / 86400
                    TimeOut[1, 2]                               = ''
                    TimeOut                                     = TimeOut[1, 5]
                    UnloadDTM                                   = DateOut:'.':TimeOut
                    MUWfrRec<MAKEUP_WAFERS.UNLOAD_DTM$>         = UnloadDTM
                    Database_Services('WriteDataRow', 'MAKEUP_WAFERS', WOMatKey, MUWfrRec, True$, False$, True$)
                end else
                    // Remove cassette data from MAKEUP_WAFERS table if it is present
                    If RowExists('MAKEUP_WAFERS', WOMatKeyID) then
                        Database_Services('DeleteDataRow', 'MAKEUP_WAFERS', WOMatKey, True$, False$)
                    end
                end
            end
        end
*        If MUBox then
*            CurrWaferCount  = obj_WO_Mat('CurrWaferCnt', WOMatKey)
*            If CurrWaferCount GT 0 then NewKeyList<-1> = WOMatKey 
*        end
        
    Next Key
    
*    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL3', NewKeyList)
    
end service

*    Open 'DICT.MAKEUP_WAFERS' to @Dict  then
*        Open 'MAKEUP_WAFERS' to hMUWfrs then
*            Done = False$
*            Select hMUWfrs
*            Loop
*                ReadNext @ID, hMUWfrs else Done = True$
*                Until Done
*                If {REACT_TYPE} EQ 'EPP' then
*                    debug
*                    WMOKey = Field(@ID, '*', 1):'*1*':Field(@ID, '*', 2)
*                    WMORec = Database_Services('ReadDataRow', 'WM_OUT', WMOKey)
*                    Database_Services('WriteDataRow', 'WM_OUT', WMOKey, WMORec)
*                end else
*                    WOMatRec = Database_Services('ReadDataRow', 'WO_MAT', @ID)
*                    Database_Services('WriteDataRow', 'WO_MAT', @ID, WOMatRec)
*                end
*            Repeat
*        end
*    end
    
*    List = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
*    For each @ID in List using @FM setting fPos
*        UnloadDTM = ''
*        MUWfrRec  = Database_Services('ReadDataRow', 'MAKEUP_WAFERS', @ID)
*        ReactType = Xlate('WO_MAT', @ID, 'REACTOR_TYPE', 'X')
*        If ReactType EQ 'EPP' then
*            WMOKey = Field(@ID, '*', 1):'*1*':Field(@ID, '*', 2)
*            RDSNos = Xlate('WM_OUT', WMOKey, 'RDS', 'X')
*            RDSNos = SRP_Array('Clean', RDSNos, 'TrimAndMakeUnique', @VM)
*            RDSNos = SRP_Array('Clean', RDSNos, 'TrimAndMakeUnique', @SVM)
*            RDSNos = SRP_Array('Clean', RDSNos, 'TrimAndMakeUnique', @TM)
*            RDSNos = SRP_Array('Clean', RDSNos, 'TrimAndMakeUnique', @STM)
*            If RDSNos NE '' then
*                UnloadDTMs = ''
*                For each RDSNo in RDSNos using @VM
*                    DateOut           = Xlate('RDS', RDSNo, 'DATE_OUT', 'X')
*                    TimeOut           = Xlate('RDS', RDSNo, 'TIME_OUT', 'X') / 86400
*                    TimeOut[1, 2]     = ''
*                    TimeOut           = TimeOut[1, 5]
*                    UnloadDTMs<0, -1> = DateOut:'.':TimeOut
*                Next RDSNo
*                UnloadDTMs = SRP_Array('Clean', UnloadDTMs, 'TrimAndMakeUnique', @VM)
*                UnloadDTMs = SRP_Array('SortSimpleList', UnloadDTMs, 'AscendingNumbers', @VM)
*                UnloadDTM  = UnloadDTMs<0, 1>
*            end else
*                // Inspect the signature profile
*                SigProf = Xlate('WO_MAT', @ID, 'SIG_PROFILE', 'X')
*                SigDTMs = Xlate('WO_MAT', @ID, 'SIG_DTM', 'X')
*                Locate '1MO_QA' in SigProf using @VM setting vPos then
*                    UnloadDTM = SigDTMs<0, vPos>
*                end
*            end
*        end else
*            RDSNo = Xlate('WO_MAT', @ID, 'RDS_NO', 'X')
*            RDSNo = SRP_Array('Clean', RDSNo, 'TrimAndMakeUnique', @VM)
*            RDSNo = SRP_Array('Clean', RDSNo, 'TrimAndMakeUnique', @SVM)
*            RDSNo = SRP_Array('Clean', RDSNo, 'TrimAndMakeUnique', @TM)
*            RDSNo = SRP_Array('Clean', RDSNo, 'TrimAndMakeUnique', @STM)
*            If RDSNo NE '' then
*                DateOut       = Xlate('RDS', RDSNo, 'DATE_OUT', 'X')
*                TimeOut       = Xlate('RDS', RDSNo, 'TIME_OUT', 'X')
*                If DateOut NE '' and TimeOut NE '' and TimeOut GT 0 then
*                    TimeOut       = TimeOut / 86400
*                    TimeOut[1, 2] = ''
*                    TimeOut       = TimeOut[1, 5]
*                    UnloadDTM     = DateOut:'.':TimeOut
*                end
*            end else
*                // Inspect the signature profile
*                SigProf = Xlate('WO_MAT', @ID, 'SIG_PROFILE', 'X')
*                SigDTMs = Xlate('WO_MAT', @ID, 'SIG_DTM', 'X')
*                Locate '1UNLOAD' in SigProf using @VM setting vPos then
*                    UnloadDTM = SigDTMs<0, vPos>
*                end
*            end
*        end
*        If UnloadDTM NE '' then
*            MUWfrRec<MAKEUP_WAFERS.UNLOAD_DTM$> = UnloadDTM
*            Database_Services('WriteDataRow', 'MAKEUP_WAFERS', @ID, MUWfrRec, True$, False$, True$)
*        end
*    Next @ID
    

Service CleanRepMan()
    debug
    ErrorList   = ''
    Application = 'LSL'
    Table       = 'REPLICATION_QUEUE_WO_WFR'
    hQueueTable = Replication_Services('GetReplicationQueueTableHandle', Application, Table)
    If hQueueTable then

        Select hQueueTable
        Done = False$
        Loop
            Readnext Key else Done = True$
            If Index(Key, '*', 1) then
                Delete hQueueTable, Key else
                    ErrorList<-1> = Key
                end
            end
        Repeat
        Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL', ErrorList)
    end
    
end service


Service PopulateMUWafers()
*    debug
    // Non EpiPro
    
*    NonEppList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
*    
    Def              = ""
    Def<MCAPTION$>   = "Populating Non EpiPro Makeup Wafers..."
    Def<MTYPE$>      = "GC"
    Def<MEXTENT$>    = Dcount(NonEppList, @FM)
    Def<MTEXTWIDTH$> = 600
    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
*    
*    For each WOMatKey in NonEppList setting fPos
*        Database_Services('ActivateRecord', 'WO_MAT', WOMatKey)
*        If {MAKEUP_BOX} then
*            WONo           = Field(WOMatKey, '*', 1, 1)
*            CurrWaferCount = obj_WO_Mat('CurrWaferCnt', WOMatKey)
*            If CurrWaferCount GT 0 then
*                // Populate MAKEUP_WAFERS table
*                // Add/update cassette data to the MAKEUP_WAFERS table
*                MUWfrRec = ''
*                MUWfrRec<MAKEUP_WAFERS.SAP_BATCH_NO$>       = {SAP_BATCH_NO}
*                MUWfrRec<MAKEUP_WAFERS.PS_NO$>              = Xlate('WO_LOG', WONo, 'PS_NO', 'X')
*                MUWfrRec<MAKEUP_WAFERS.CUST_NO$>            = {CUST_NO}
*                MUWfrRec<MAKEUP_WAFERS.PROD_ORD_NO$>        = {PROD_ORD_NO}
*                MUWfrRec<MAKEUP_WAFERS.WAFER_SIZE$>         = {WAFER_SIZE}
*                MUWfrRec<MAKEUP_WAFERS.EPI_PART_NO$>        = {EPI_PART_NO}
*                MUWfrRec<MAKEUP_WAFERS.RDS_NO$>             = {RDS_NO}
*                MUWfrRec<MAKEUP_WAFERS.WM_OUT_NO$>          = ''            ; // Only applies to EPP
*                MUWfrRec<MAKEUP_WAFERS.PROD_VER_NO$>        = {PROD_VER_NO}
*                MUWfrRec<MAKEUP_WAFERS.CUST_PART_NO$>       = {CUST_PART_NO}
*                MUWfrRec<MAKEUP_WAFERS.REACT_TYPE$>         = {REACTOR_TYPE}
*                MUWfrRec<MAKEUP_WAFERS.CURR_STATUS_STATIC$> = {CURR_STATUS}
*                Database_Services('WriteDataRow', 'MAKEUP_WAFERS', WOMatKey, MUWfrRec, True$, False$, True$)
*            end
*        end
*    Running = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
*    Next WOMatKey
*    Msg(@WINDOW,MsgUp)      ;* Take message down
    
    // EpiPro
    
    EppList    = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL2')
    
    Def              = ""
    Def<MCAPTION$>   = "Populating EpiPro Makeup Wafers..."
    Def<MTYPE$>      = "GC"
    Def<MEXTENT$>    = Dcount(EppList, @FM)
    Def<MTEXTWIDTH$> = 600
    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
    
    For each WMOKey in EppList setting fPos
        Database_Services('ActivateRecord', 'WM_OUT', WMOKey)
        If {MAKEUP_BOX} then
            WOMatKey       = {WO_MAT_KEY}
            WONo           = Field(WOMatKey, '*', 1, 1)
            CurrWaferCount = obj_WO_Mat('CurrWaferCnt', WOMatKey)
            If CurrWaferCount GT 0 then
                // Populate MAKEUP_WAFERS table
                // Add/update cassette data to the MAKEUP_WAFERS table
                WOMatKey                                    = {WO_MAT_KEY}
                MUWfrRec                                    = ''
                MUWfrRec<MAKEUP_WAFERS.SAP_BATCH_NO$>       = {SAP_BATCH_NO}
                MUWfrRec<MAKEUP_WAFERS.PS_NO$>              = {PS_NO}
                MUWfrRec<MAKEUP_WAFERS.CUST_NO$>            = Xlate('WO_LOG', WONo, 'CUST_NO', 'X')
                MUWfrRec<MAKEUP_WAFERS.PROD_ORD_NO$>        = Xlate('WO_LOG', WONo, 'PROD_ORD_NO', 'X')
                MUWfrRec<MAKEUP_WAFERS.WAFER_SIZE$>         = Xlate('WO_MAT', WOMatKey, 'WAFER_SIZE', 'X')
                MUWfrRec<MAKEUP_WAFERS.EPI_PART_NO$>        = {PART_NO}
                MUWfrRec<MAKEUP_WAFERS.RDS_NO$>             = {RDS}
                MUWfrRec<MAKEUP_WAFERS.WM_OUT_NO$>          = WMOKey
                MUWfrRec<MAKEUP_WAFERS.PROD_VER_NO$>        = Xlate('WO_MAT', WOMatKey, 'PROD_VER_NO', 'X')
                MUWfrRec<MAKEUP_WAFERS.CUST_PART_NO$>       = Xlate('WO_MAT', WOMatKey, 'CUST_PART_NO', 'X')
                MUWfrRec<MAKEUP_WAFERS.REACT_TYPE$>         = Xlate('WO_LOG', WONo, 'REACT_TYPE', 'X')
                MUWfrRec<MAKEUP_WAFERS.CURR_STATUS_STATIC$> = {CURR_STATUS}
                Database_Services('WriteDataRow', 'MAKEUP_WAFERS', WOMatKey, MUWfrRec, True$, False$, True$)
            end
        end
        Running = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
    Next WMOKey
    
    Msg(@WINDOW,MsgUp)      ;* Take message down
    
end service


Service GetEPP()
    
    EPPRTUMUList = ''
    RTUMUList    = Database_Services('ReadDataRow', 'SYSLISTS', 'RTU_MU')
    
    For each WONo in RTUMUList using @FM
        
        RType = Xlate('WO_LOG', WONo, 'REACT_TYPE', 'X')
        If RType EQ 'EPP' then 
            EPPRTUMUList<-1> = WONo
        end
        
    Next WONo
    Database_Services('WriteDataRow', 'SYSLISTS', 'EPP_RTU_MU', EPPRTUMUList)
    
end service


Service GetMergeClause()
    debug
    JoinClause  = 'RDS_NO = 460155 AND CASS_NO = 2'
    Swap ' AND ' with @FM in JoinClause
    MergeClause = ''
    For each Clause in JoinClause using @FM
        MergeClause := Clause : ' = src.':Clause
    Next Clause
    
    
    
end service



Service AddTrans()
    
    debug
*    File = '2021-07-02 SQL Services Log.csv'
    Path = 'D:\apps\LogFiles\SQL_Services\'
*    FileList = File
    InitDir Path:'*'
    FileList = DirList()
    NumFiles = DCount(FileList, @FM)
    
    For each File in FileList using @FM setting fPos
        
        OSRead FileData from Path:File then
            
            Def              = ""
            Def<MCAPTION$>   = "Replicating data in file ":File:"..."
            Def<MTYPE$>      = "GC"
            Def<MEXTENT$>    = Dcount(FileData, CRLF$)
            Def<MTEXTWIDTH$> = 600
            MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
            
            For each Line in FileData using CRLF$ setting fPos
                TableName = Field(Line, ',', 2, 1)
                KeyID     = Field(Line, ',', 3, 1)

                If TableName NE '' and KeyID NE '' then
                    TransID = ''
                    TransID<1> = 'WRITE'
                    TransID<2> = 'LSL2'
                    TransID<3> = 'LSL'
                    TransID<4> = TableName
                    TransID<5> = KeyID
                    Write_OI_To_Sql(TransID)
                end
                
                Running = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
            Next Line
        end
        Running = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
    Next File
        
    Msg(@WINDOW,MsgUp)      ;* Take message down
    
end service


Service GetDup()
    
    Export  = ''
    DupList = ''
    DupCnt  = 0
    Queue = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
        For each Key in Queue using @FM setting fPos
            QueueRec = Database_Services('ReadDataRow', 'REPLICATION_QUEUE_LSL2_WO_MAT', Key)
            QueueAction = QueueRec<1>
            QueueTable  = QueueRec<4>
            QueueKey    = QueueRec<5>
            ExportRow   = QueueAction:',':QueueTable:',':QueueKey:CRLF$
            Export     := ExportRow
            LookupKeyID = QueueAction:'*':QueueTable:'*':QueueKey
            If LookupKeyID NE '' then
                Locate LookupKeyID in DupList using @FM setting fPos then
                    DupCnt += 1
                    Database_Services('DeleteDataRow', 'REPLICATION_QUEUE_LSL2_WO_MAT', Key, True$, False$)
                end else
                    DupList<-1> = LookupKeyID
                end
            end
        Next Key
        OSWrite Export To 'D:\temp\DupList.csv'
        Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL2', DupList)
    
end service


Service TestReactState()
    debug
    WONo = 170033
    For CassNo = 1 to 96
        Key = WONo:'*1*':CassNo
        Rec = Database_Services('ReadDataRow', 'WM_OUT', Key)
        FlatFinderDTM = Rec<WM_OUT_FLATFINDER_DTM$>
        Rec<WM_OUT_FLATFINDER_DTM$> = ''
        Database_Services('WriteDataRow', 'WM_OUT', Key, Rec, True$, False$, False$)
        Rec<WM_OUT_FLATFINDER_DTM$> = FlatFinderDTM
        Database_Services('WriteDataRow', 'WM_OUT', Key, Rec, True$, False$, False$)
    Next CassNo
    
end service


Service TestRepMan()
    
    
    *    Memory_Services('SetValue', 'SQL_SERVICES*GetConnectionObject*messv01ec.ec.local\PROD1,53959*objConnection', '')
    *    Free_Class.NET()
    Server = 'messv01ec.ec.local\PROD1,53959'
    TableData = SQL_Services('GetTables', '', Server, '', '', False$, True$, True$, True$)
    *    objConn = Sql_Services('GetConnectionObject', 'messv01ec.ec.local\PROD1,53959')
    
    *    ConnString = SQL_Services('GetConnectionString', 'messv01ec.ec.local\PROD1,53959')
    *    objConn = SQL_Services('GetConnectionObject', 'messv01ec.ec.local\PROD1,53959')
    *    If objConn then SQL_Services('DestroyConnectionObject', objConn)
    
    *    RDSNo = 457493
    *    RDSRec = Database_Services('ReadDataRow', 'RDS', RDSNo)
    *    Sql_Services('WriteDataRowToSQL', 'RDS', RDSNo, RDSRec)
    
    *    Table = 'WO_MAT'
    *    WONo  = '170178'
    *    Key = '170213*34'
    *    For CassNo = 54 to 67
    *        Key   = WONo:'*':CassNo
    *        Rec   = Database_Services('ReadDataRow', Table, Key)
    *        Sql_Services('WriteDataRowToSQL', Table, Key, Rec)
    *        If Error_Services('HasError') then
    *            debug
    *        end
    *    Next CassNo
    
    
end service


Service TestRevDotNet()
    debug
    objConn = SQL_Services('GetConnectionObject', 'IQSDMS1')
    QueryStatement = "select [Probe_Key] from [G4Wafers_01].[dbo].[Probe3]"
    ProbeKey = SQL_Services('ExecuteQuery', objConn, QueryStatement, True$)
    NewProbeKey = ProbeKey + 1
    QueryStatements = ''
    QueryStatements<1> = 'update [G4Wafers_01].[dbo].[Probe3] set [Probe_Key] = ':NewProbeKey:' where [Probe_Key] = ':ProbeKey
    ProbeKey = NewProbeKey
    NewProbeKey = ProbeKey + 1
    QueryStatements<2> = 'update [G4Wafers_01].[dbo].[Probe3] set [Probe_Key] = ':NewProbeKey:' where [Probe_Key] = ':ProbeKey
    SQL_Services('ExecuteQueries', objConn, QueryStatements, True$)
    
    
    If objConn then SQL_Services('DestroyConnectionObject', objConn)
    
end service


Service Test7()
    
    WOMatList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_WO_MAT_BAD')
    For each WOMatKey in WOMatList using @FM setting fPos
        Material_Services('PostWOMatUpdateRequest', WOMatKey)
    Next WOMatKey
    
end service


Service Test6()
    
    BadList = ''
    WOMatList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_WO_MAT')
    NumWOMat         = DCount(WOMatList, @FM)
    Def              = ""
    Def<MCAPTION$>   = "Verifying WO_MAT CURR_STATUS_STATIC..."
    Def<MTYPE$>      = "GC"
    Def<MEXTENT$>    = NumWOMat
    Def<MTEXTWIDTH$> = 600
    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
    
    For each WOMatKey in WOMatList using @FM setting fPos
        StaticCurrStatus = Xlate('WO_MAT', WOMatKey, 'CURR_STATUS_STATIC', 'X')
        CalcCurrStatus = obj_WO_Mat('CurrStatus', WOMatKey)
        If StaticCurrStatus NE CalcCurrStatus then
            BadList<-1> = WOMatKey
        end
        Running = Msg(@WINDOW, MsgUp, fPos, MSGINSTUPDATE$) ;* Update message
    Next WOMatKey
    
    Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_WO_MAT_BAD', BadList)
    
    Msg(@WINDOW,MsgUp)      ;* Take message down
    
end service


Service Test5()
    
    WOMatKeyList     = Xlate('SYSLISTS', 'WO_MAT_100000', '', 'X')
    NumWOMat         = DCount(WOMatKeyList, @FM)
    Def              = ""
    Def<MCAPTION$>   = "Updating WO_MAT CURR_STATUS_STATIC..."
    Def<MTYPE$>      = "GC"
    Def<MEXTENT$>    = NumWOMat
    Def<MTEXTWIDTH$> = 600
    MsgUp            = Msg(@WINDOW, Def) ;* Start gas guage message
    
    WOMatKeyListIndex = 1
    NewWOMatKeyList   = WOMatKeyList
    
    Loop
        
        WOMatKey         = WOMatKeyList<WOMatKeyListIndex>
        WOMatRec         = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
        CurrStatus       = Xlate('WO_MAT', WOMatKey, 'CURR_STATUS', 'X')
        StaticCurrStatus = WOMatRec<WO_MAT_CURR_STATUS_STATIC$>
        If CurrStatus NE StaticCurrStatus then
            WOMatRec<WO_MAT_CURR_STATUS_STATIC$> = CurrStatus
            Database_Services('WriteDataRow', 'WO_MAT', WOMatKey, WOMatRec, True$, True$, True$)
            If Error_Services('HasError') then
                ErrorList    = Database_Services('ReadDataRow', 'SYSLISTS', 'WO_MAT_ERROR')
                ErrorList<-1> = WOMatKey
                Database_Services('WriteDataRow', 'SYSLISTS', 'WO_MAT_ERROR', ErrorList)
            end
        end
        If Error_Services('NoError') then
            NewWOMatKeyList = Delete(NewWOMatKeyList, 1, 0, 0)
            WOMatKeyListIndex += 1
            Database_Services('WriteDataRow', 'SYSLISTS', 'WO_MAT_100000', NewWOMatKeyList)
        end
        
        Running = Msg(@WINDOW, MsgUp, WOMatKeyListIndex, MSGINSTUPDATE$) ;* Update message
        
    Until WOMatKeyListIndex GE NumWOMat
    Repeat 
    
    Msg(@WINDOW,MsgUp)      ;* Take message down
    
end service


Service FabtimePush()
    
    debug
    WOMatKeyList = Database_Services('ReadDataRow', 'SYSLISTS', 'WO_MAT_PUSH')
    NumWOMatKeys = DCount(WOMatKeyList, @FM)
    
    Def               = ""
    Def<MCAPTION$>    = "Updating WO_MAT..."
    Def<MTYPE$>       = "GC"
    Def<MEXTENT$>     = NumWOMatKeys
    Def<MTEXTWIDTH$>  = 600
    MsgUp             = Msg(@WINDOW, Def) ;* Start gas guage message
    Table             = 'WO_MAT'
    WOMatKeyListIndex = 1
    NewWOMatKeyList   = WOMatKeyList
    Loop
        ID                 = WOMatKeyList<WOMatKeyListIndex>
        Copy_Record_To_SQL(Table, ID, 1)
        NewWOMatKeyList    = Delete(NewWOMatKeyList, 1, 0, 0)
        WOMatKeyListIndex += 1
        Database_Services('WriteDataRow', 'SYSLISTS', 'WO_MAT_PUSH', NewWOMatKeyList)
        Running            = Msg(@WINDOW, MsgUp, WOMatKeyListIndex, MSGINSTUPDATE$) ;* Update message
    Until WOMatKeyListIndex GE NumWOMatKeys
    Repeat
    
    Msg(@WINDOW,MsgUp)      ;* Take message down
    
end service


Service Test2()
    debug
    WOLogKeyList      = Xlate('SYSLISTS', 'TEST_DANIEL', '', 'X')
    NumWOLog          = DCount(WOLogKeyList, @FM)
    Def               = ""
    Def<MCAPTION$>    = "Updating WO_MAT..."
    Def<MTYPE$>       = "GC"
    Def<MEXTENT$>     = NumWOLog
    Def<MTEXTWIDTH$>  = 600
    MsgUp = Msg(@WINDOW, Def) ;* Start gas guage message
    
    WOLogKeyListIndex = 1
    NewWOLogKeyList   = WOLogKeyList
    
    Loop
        GoSub ClearCursors
        Query = 'COUNT WO_STEP_QUEUE'
        Rlist(Query, Target_ActiveList$, '', '', '')
        
        If @RecCount LT 25 then
            // Don't overwhelm the SQL queue
            WONo = WOLogKeyList<WOLogKeyListIndex>
            Work_Order_Services('PostWOStepUpdateRequest', WONo)
            NewWOLogKeyList = Delete(NewWOLogKeyList, 1, 0, 0)
            WOLogKeyListIndex += 1
            Database_Services('WriteDataRow', 'SYSLISTS', 'TEST_DANIEL', NewWOLogKeyList)
        end else
            // Give the queue time to crunch
            Sleepery(30000)
        end
        GoSub ClearCursors
        
        Running = Msg(@WINDOW, MsgUp, WOLogKeyListIndex, MSGINSTUPDATE$) ;* Update message
        
    Until WOLogKeyListIndex GE NumWOLog
    Repeat 
    
    Msg(@WINDOW,MsgUp)      ;* Take message down
    
end service


Service Script()
    
    debug
    WOMatKeyList      = Xlate('SYSLISTS', 'SIG_PROF_PUSH', '', 'X')
    NumWOMat          = DCount(WOMatKeyList, @FM)
    Def               = ""
    Def<MCAPTION$>    = "Updating WO_MAT..."
    Def<MTYPE$>       = "GC"
    Def<MEXTENT$>     = NumWOMat
    Def<MTEXTWIDTH$>  = 600
    MsgUp = Msg(@WINDOW, Def) ;* Start gas guage message
    
    WOMatKeyListIndex = 1
    NewWOMatKeyList   = WOMatKeyList
    
    Loop
        GoSub ClearCursors
        Query = 'COUNT SQL_BACKLOG_WO_MAT'
        Rlist(Query, Target_ActiveList$, '', '', '')
        
        If @RecCount LT 25 then
            // Don't overwhelm the SQL queue
            WOMatKey     = WOMatKeyList<WOMatKeyListIndex>
            SigProf      = Signature_Services('GetSigProfile', WOMatKey)
            Stages       = SigProf<1>
            Sigs         = SigProf<2>
            SigDTMs      = SigProf<3>
            WOMatRec     = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
            WOMatSigProf = WOMatRec<WO_MAT_SIG_PROFILE$>
            For each Stage in Stages using @VM setting sPos
                WOMatStage                        = '1':Stage
                Locate WOMatStage in WOMatSigProf using @VM setting vPos then
                    WOMatRec<WO_MAT_SIGNATURE$, vPos> = Sigs<0, sPos>
                    WOMatRec<WO_MAT_SIG_DTM$, vPos>   = IConv(SigDTMS<0, sPos>, 'DT')
                end
            Next Stage
            Error_Services('Clear')
            Database_Services('WriteDataRow', 'WO_MAT', WOMatKey, WOMatRec, True$, False$, True$)
            If Error_Services('NoError') then
                NewWOMatKeyList = Delete(NewWOMatKeyList, 1, 0, 0)
                WOMatKeyListIndex += 1
                Database_Services('WriteDataRow', 'SYSLISTS', 'SIG_PROF_PUSH', NewWOMatKeyList)
            end
        end else
            // Give the queue time to crunch
            Sleepery(30000)
        end
        GoSub ClearCursors
        
        Running = Msg(@WINDOW, MsgUp, WOMatKeyListIndex, MSGINSTUPDATE$) ;* Update message
        
    Until WOMatKeyListIndex GE NumWOMat
    Repeat 
    
    Msg(@WINDOW,MsgUp)      ;* Take message down
    
end service


Service Test()
    
    SRP_Stopwatch('Reset')
    SRP_Stopwatch('Start', 'Release')
    Sleepery(1000)
    SRP_Stopwatch('Stop', 'Release')
    SRP_Stopwatch('Start', 'Refresh')
    Sleepery(1000)
    SRP_Stopwatch('Stop', 'Refresh')
    SRP_Stopwatch('Start', 'Refresh')
    Sleepery(1000)
    SRP_Stopwatch('Stop', 'Refresh')
    debug
    Data = SRP_Stopwatch('GetAll')
end service


Service RDSFix1()
    debug
    SuccessList = ''
    ErrorList   = ''
    *    RDSList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
    
    NextRDSNo  = Xlate('DICT.RDS', '%SK%', '', 'X')
    LastRDSNo  = NextRDSNo - 1
    FirstRDSNo = LastRDSNo - 1000
    
    For RDSNo = FirstRDSNo to LastRDSNo Step 1
        RDSRec = Database_Services('ReadDataRow', 'RDS', RDSNo)
        If Error_Services('NoError') then
            Database_Services('DeleteDataRow', 'RDS', RDSNo, True$, True$)
            If Error_Services('NoError') then
                Database_Services('WriteDataRow', 'RDS', RDSNo, RDSRec, True$, True$, True$)
                If Error_Services('NoError') then
                    SuccessList<-1> = RDSNo
                end else
                    ErrorMsg      = Error_Services('GetMessage')
                    ErrorList<-1> = RDSNo : ' ' :ErrorMsg
                end
            end else
                ErrorMsg      = Error_Services('GetMessage')
                ErrorList<-1> = RDSNo : ' ' :ErrorMsg
            end
        end else
            ErrorMsg      = Error_Services('GetMessage')
            ErrorList<-1> = RDSNo : ' ' :ErrorMsg
        end
    Next RDSNo
    
    Database_Services('WriteDataRow', 'SYSLISTS', 'RDS_SUCCESS', SuccessList)
    Database_Services('WriteDataRow', 'SYSLISTS', 'RDS_ERROR', ErrorList)
    
end service


Service RDSFix2()
    
    debug
    SuccessList = ''
    ErrorList   = ''
    *    RDSList     = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL3')
    RDSList = 441972
    *    NumRDS  = DCount(RDSList, @FM)
    *    
    *    Def              = ""
    *    Def<MCAPTION$>   = "Updating RDS Indexes..."
    *    Def<MTYPE$>      = "GC"
    *    Def<MEXTENT$>    = NumRDS
    *    Def<MTEXTWIDTH$> = 600
    *    MsgUp = Msg(@WINDOW, Def) ;* Start gas guage message
    For each RDSNo in RDSList using @FM setting vPos
        RDSRec = Database_Services('ReadDataRow', 'RDS', RDSNo)
        If Error_Services('NoError') then
            Database_Services('DeleteDataRow', 'RDS', RDSNo, True$, True$)
            If Error_Services('NoError') then
                Database_Services('WriteDataRow', 'RDS', RDSNo, RDSRec, True$, True$, True$)
                If Error_Services('NoError') then
                    SuccessList<-1> = RDSNo
                end else
                    ErrorMsg      = Error_Services('GetMessage')
                    ErrorList<-1> = RDSNo : ' ' :ErrorMsg
                end
            end else
                ErrorMsg      = Error_Services('GetMessage')
                ErrorList<-1> = RDSNo : ' ' :ErrorMsg
            end
        end else
            ErrorMsg      = Error_Services('GetMessage')
            ErrorList<-1> = RDSNo : ' ' :ErrorMsg
        end
        *        Running = Msg(@WINDOW, MsgUp, vPos, MSGINSTUPDATE$) ;* Update message
    Next RDSNo
    
    Database_Services('WriteDataRow', 'SYSLISTS', 'RDS_SUCCESS', SuccessList)
    Database_Services('WriteDataRow', 'SYSLISTS', 'RDS_ERROR', ErrorList)
    
    *    Msg(@WINDOW,MsgUp)      ;* Take message down
end service





If @USER4 EQ 'DANIEL_ST' then
    debug
    OrigQty   = 2400
    NewQty    = 2000
    ModifyQty = NewQty - OrigQty
    WONo      = 169909
    Begin Case
        Case ModifyQty GT 0
            // Search schedule for most recent event and increase that event quantity by the difference.
            Query  = 'SELECT SCHED_DET_NG WITH WO_NO EQ ':WONo:' BY-DSND STOP_DTM'                  
            GoSub ClearCursors
            Set_Status(0)
            RList(Query, TARGET_ACTIVELIST$, '', '', False$)
            errCode       = ''
            If Get_Status(errCode) then
                ErrorMsg = 'Error retrieving event list in WO_LOG_Actions. Error code ':errCode:'.'
                Error_Services('Add', ErrorMsg)       
            end else
                EOF = False$
                ReadNext SchedDetNGKey else EOF = True$
                If SchedDetNGKey NE '' then
                    EventRec    = Database_Services('ReadDataRow', 'SCHED_DET_NG', SchedDetNGKey)
                    ReactNo     = EventRec<SCHED_DET_NG.REACT_NO$>
                    WONo        = EventRec<SCHED_DET_NG.WO_NO$>
                    StartDTM    = EventRec<SCHED_DET_NG.START_DTM$>
                    StopDTM     = EventRec<SCHED_DET_NG.STOP_DTM$>
                    Desc        = EventRec<SCHED_DET_NG.DESC$>
                    EventQty    = EventRec<SCHED_DET_NG.EVENT_TOTAL_WFRS$>
                    NewEventQty = EventQty + ModifyQty
                    Schedule_Services('ModifySchedEvent', SchedDetNGKey, ReactNo, WONo, StartDTM, StopDTM, Desc, NewEventQty)
                end
            end
            GoSub ClearCursors
            Schedule_Services('AdjustScheduleEvents')
        Case ModifyQty LT 0
            // Search schedule for most recent events and decrease/delete those events as needed.
            Query  = 'SELECT SCHED_DET_NG WITH WO_NO EQ ':WONo:' BY-DSND STOP_DTM'                  
            GoSub ClearCursors
            Set_Status(0)
            RList(Query, TARGET_ACTIVELIST$, '', '', False$)
            errCode       = ''
            If Get_Status(errCode) then
                ErrorMsg = 'Error retrieving event list in WO_LOG_Actions. Error code ':errCode:'.'
                Error_Services('Add', ErrorMsg)       
            end else
                EOF  = False$
                Done = False$
                Loop
                    ReadNext SchedDetNGKey else EOF = True$
                Until EOF EQ True$
                    If SchedDetNGKey NE '' then
                        EventRec    = Database_Services('ReadDataRow', 'SCHED_DET_NG', SchedDetNGKey)
                        ReactNo     = EventRec<SCHED_DET_NG.REACT_NO$>
                        WONo        = EventRec<SCHED_DET_NG.WO_NO$>
                        StartDTM    = EventRec<SCHED_DET_NG.START_DTM$>
                        StopDTM     = EventRec<SCHED_DET_NG.STOP_DTM$>
                        Desc        = EventRec<SCHED_DET_NG.DESC$>
                        EventQty    = EventRec<SCHED_DET_NG.EVENT_TOTAL_WFRS$>
                        If EventQty GT Abs(ModifyQty) then
                            // This event has enough wafers, so just reduce the quantity.
                            Done        = True$
                            NewEventQty = EventQty + ModifyQty
                            Schedule_Services('ModifySchedEvent', SchedDetNGKey, ReactNo, WONo, StartDTM, StopDTM, Desc, NewEventQty)
                        end else
                            // This event has fewer wafers than are being removed. Delete this event and continue
                            // onto the next event.
                            Schedule_Services('CancelScheduleEvent', SchedDetNGKey, True$)
                            ModifyQty += EventQty
                        end
                    end
                Until Done EQ True$
                Repeat
                Schedule_Services('AdjustScheduleEvents')
            end
            GoSub ClearCursors
            
        Case Otherwise$
            Null
    End Case
end

return

ClearCursors:
    For counter = 0 to 8
        ClearSelect counter
    Next counter
return

*    EOF              = False$
*    ReactProbCatData = ''
*    Filepath         = 'D:\FITemp\ReactProbCatList.txt'
*    Open 'REACT_PROB_CAT' to RPCTable then
*        Select RPCTable 
*        Loop
*            ReadNext @ID else EOF = True$
*        Until EOF EQ True$
*            Read @Record from RPCTable, @ID then
*                Desc = @Record<1>
*                Category = Xlate('REACT_PROB_CAT', @ID, 'REACTOR_PROBLEM_CATEGORY_XREF', 'X')
*                ReactProbCatData := @ID:',':Desc:',':Category:CRLF$
*            end
*        Repeat
*    end
*    OSWrite ReactProbCatData on Filepath

*    EOF              = False$
*    ReactServCatData = ''
*    Filepath         = 'D:\FITemp\ReactServCatList.txt'
*    Open 'REACT_SERV_CAT' to RSCTable then
*        Select RSCTable 
*        Loop
*            ReadNext @ID else EOF = True$
*        Until EOF EQ True$
*            Read @Record from RSCTable, @ID then
*                Desc = @Record<1>
*                ReactServCatData := @ID:',':Desc:CRLF$
*            end
*        Repeat
*    end
*    OSWrite ReactServCatData on Filepath

return

*    debug
*    Query      = 'SELECT SQL_BACKLOG'
*    Rlist(Query, Target_ActiveList$, '', '', '')
*    QueueCount = @RecCount
*    GoSub ClearCursors
*    Mona_Services('SendMetric', 'SQL_BACKLOG', 'Test', QueueCount)
*    
*    Query      = 'SELECT SQL_BACKLOG_WO_LOG'
*    Rlist(Query, Target_ActiveList$, '', '', '')
*    QueueCount = @RecCount
*    GoSub ClearCursors
*    Mona_Services('SendMetric', 'SQL_BACKLOG', 'Test', QueueCount)
*    
*    Query      = 'SELECT SQL_BACKLOG_WO_MAT'
*    Rlist(Query, Target_ActiveList$, '', '', '')
*    QueueCount = @RecCount
*    GoSub ClearCursors
*    Mona_Services('SendMetric', 'SQL_BACKLOG', 'Test', QueueCount)

* return
* 
* 
* ClearCursors:
*    For counter = 0 to 8
*        ClearSelect counter
*    Next counter
* return

*    debug
*    02:30:30PM

*    List1   = 10:@VM:11:@VM:12:@VM:13
*    For Index = 1 to 4
*        List1<0, Index> = List1<0, Index> -  3
*    Next Index
*    ThickTest = Xlate('RDS', 425385, 'UNLOAD_THICK_TEST', 'X')
*    Database_Services('ActivateRecord', 'RDS', 425385)
*        
*    UnloadThickTest  = False$
*    Parms            = {WO_MAT_KEY}:@RM
*    Parms           := '':@RM
*    Parms           := FIELD(@RECORD<256>,'*',2):@RM              ;* WOStep
*    Parms           := 'UNLOAD':@RM
*    Parms           := WO_MAT_QA_PROFILE$
*    QAMetArray       = obj_WO_Mat_QA('GetQAMet', Parms)
*    For each Row in QAMetArray using @FM setting fPos
*        Locate 'THICK_ONLY' in Row using @VM setting vPos then
*            UnloadThickTest = True$
*        end
*    Until UnloadThickTest EQ True$
*    Next Row
*    ActionFlow = UnloadThickTest

return

ProdSpecKeys = Database_Services('ReadDataRow', 'APP_INFO', 'SS_MODIFY_SET')
For each ProdSpecKey in ProdSpecKeys using @FM
    PRSKey  = ProdSpecKey:'*LWI'
    PRSRec  = Database_Services('ReadDataRow', 'PRS_STAGE', PRSKey)
    SSQtys  = PRSRec<PRS_STAGE_SS_SAMP_QTY$>
    SSSODs  = PRSRec<PRS_STAGE_SURF_DEFECTS$>
    SSHazes = PRSRec<PRS_STAGE_SURF_HAZE$>
    Locate 6 in SSQtys using @VM setting vPos then
        SOD  = SSSODs<0, vPos>
        Haze = SSHazes<0, vPos>
        Locate 25 in SSQtys using @VM setting sPos then
            SSSODs<0, sPos>                 = SOD
            SSHazes<0, sPos>                = Haze
            PRSRec<PRS_STAGE_SURF_DEFECTS$> = SSSODs
            PRSRec<PRS_STAGE_SURF_HAZE$>    = SSHazes
            Database_Services('WriteDataRow', 'PRS_STAGE', PRSKey, PRSRec, True$, False$, True$)
        end
    end
Next ProdSpecKey
return


*    ErrorList    = ''
*    ProdSpecKeys = Database_Services('ReadDataRow', 'APP_INFO', 'SS_MODIFY_SET')
*    For each ProdSpecKey in ProdSpecKeys using @FM
*        LWIPRSKey = ProdSpecKey:'*LWI'
*        LWIPRSRec = Database_Services('ReadDataRow', 'PRS_STAGE', LWIPRSKey)
*        If Error_Services('NoError') then
*            SSRecipes = LWIPRSRec<PRS_STAGE_SURFSCAN_RECIPE$>
*            SSQtys    = LWIPRSRec<PRS_STAGE_SS_SAMP_QTY$>
*            ASFlag    = False$
*            IFXFlag   = False$
*            Locate 'AS_IFX_ROTR' in SSRecipes using @VM setting vPos then
*                ASFlag = True$
*            end else
*                Locate 'AS_IFX100_ROTR' in SSRecipes using @VM setting vPos then
*                    ASFlag = True$
*                end else
*                    Locate '8IN_IFX_ROTR' in SSRecipes using @VM setting vPos then
*                        IFXFlag = True$
*                    end else
*                        Locate 'IFX100_ROTR' in SSRecipes using @VM setting vPos then
*                            IFXFlag = True$
*                        end
*                    end
*                end
*            end
*            Begin Case
*                Case ASFlag EQ True$
*                    SSRecipes<0, -1> = 'AS_IFX25_ROTR'
*                    SSQtys<0, -1>    = 25
*                Case IFXFlag EQ True$
*                    SSRecipes<0, -1> = 'IFX25_ROTR'
*                    SSQtys<0, -1>    = 25
*                Case Otherwise$
*                    ErrorList<-1> = LWIPRSKey
*                    Error_Services('Add', 'Error finding recipe')
*            End Case
* 
*            If Error_Services('NoError') then
*                LWIPRSRec<PRS_STAGE_SURFSCAN_RECIPE$> = SSRecipes
*                LWIPRSRec<PRS_STAGE_SS_SAMP_QTY$>     = SSQtys
*                Database_Services('WriteDataRow', 'PRS_STAGE', LWIPRSKey, LWIPRSRec, True$, False$, True$)
*                If Error_Services('HasError') then
*                    ErrorList<-1> = LWIPRSKey
*                end
*            end
*        end else
*            ErrorList<-1> = LWIPRSKey
*        end
*    Next ProdSpecKey
*    Database_Services('WriteDataRow', 'APP_INFO', 'SS_ERROR_SET', ErrorList)

return


*    * turn off dedicated indexing
*    Set_IDXSvr(0)
*    * reset background indexing delay to zero (no indexing)
*    Set_Bgnd_IX_Time(0)
* 
*    * update indexes every 10 seconds
*    Set_Bgnd_IX_Time(10)
*    * turn on dedicated indexing
*    Set_IDXSvr(1)

* return

PSNList   = Database_Services('ReadDataRow', 'APP_INFO', 'PCRB_4_TO_8')
ThickList = Database_Services('ReadDataRow', 'APP_INFO', 'PCRB_4_TO_8_THICK')
RESList   = Database_Services('ReadDataRow', 'APP_INFO', 'PCRB_4_TO_8_RES')
For each PSNo in PSNList using @FM setting fPos
    PSRec = Database_Services('ReadDataRow', 'PROD_SPEC', PSNo)
    If Error_Services('NoError') then
        SpecEpi                    = PSRec<PROD_SPEC_SPEC_EPI$>
        ThickData                  = SpecEpi<0, 13>
        ResData                    = SpecEpi<0, 14>
        Swap '~' with @SVM in ThickData
        Swap '~' with @SVM in ResData
        OrigThickQty               = ThickData<0, 0, 4>
        OrigResQty                 = ResData<0, 0, 4>
        NewThickQty                = ThickList<fPos>
        NewResQty                  = ResList<fPos>
        ThickData<0, 0, 4>         = NewThickQty
        ResData<0, 0, 4>           = NewResQty
        Swap @SVM with '~' in ThickData
        Swap @SVM with '~' in ResData
        SpecEpi<0, 13>             = ThickData
        SpecEpi<0, 14>             = ResData
        PSRec<PROD_SPEC_SPEC_EPI$> = SpecEpi
        Database_Services('WriteDataRow', 'PROD_SPEC', PSNo, PSRec, True$, False$, True$)
    end
Next PSNo

// Extract new values to verify data
NewThickList = ''
NewResList   = ''
For each PSNo in PSNList using @FM setting fPos
    PSRec = Database_Services('ReadDataRow', 'PROD_SPEC', PSNo)
    If Error_Services('NoError') then
        SpecEpi            = PSRec<PROD_SPEC_SPEC_EPI$>
        ThickData          = SpecEpi<0, 13>
        ResData            = SpecEpi<0, 14>
        Swap '~' with @SVM in ThickData
        Swap '~' with @SVM in ResData
        CurrThickQty       = ThickData<0, 0, 4>
        CurrResQty         = ResData<0, 0, 4>
        NewThickList<fPos> = CurrThickQty
        NewResList<fPos>   = CurrResQty
    end
Next PSNo
Database_Services('WriteDataRow', 'APP_INFO', 'PCRB_4_TO_8_THICK_VERIFY', NewThickList)
Database_Services('WriteDataRow', 'APP_INFO', 'PCRB_4_TO_8_RES_VERIFY', NewResList)

return

* 
*    SigStage = 'LWIS'
*    WOMatKey = '169821*5'
*    Signature_Services('CheckSigOrder', WOMatKey, SigStage)
*    If Error_Services('HasError') then
*        ErrMsg(Error_Services('GetMessage'))
*        return
*    end 
*    
* return
* 
*    InspReqList = ''
*    RDSNos      = Xlate('WO_STEP', '169803*1', 'RDS_KEY', 'X')
*    For each RDSNo in RDSNos using @VM
*        LWICINo = Xlate('RDS', RDSNo, 'LWI_CI_NO', 'X')
*        InspReq = Xlate('CLEAN_INSP', LWICINo, 'INSP_REQ', 'X')
*        If InspReq then
*            InspReqList<-1> = Xlate('RDS', RDSNo, 'RUN_ORDER_NUM', 'X')
*        end
*    Next RDSNo
*    
*    Database_Services('WriteDataRow', 'APP_INFO', 'INSP_INTERVAL_VERIFY', InspReqList)
*    
*    
* return

*    CIKey = 2380297
*    InspReq = Xlate('CLEAN_INSP', 2380297, 'INSP_REQ', 'X')
* 
*    Database_Services('ActivateRecord', 'CLEAN_INSP', CIKey)
*    RDSNo        = {RDS_NO}
*    RunNo        = Xlate('RDS', RDSNo, 'RUN_ORDER_NUM', 'X')
*    InspInterval = Xlate('PRS_STAGE', {PS_STAGE_KEY}, 'INSP_INTERVAL', 'X')
*    InspReq      = (Mod((RunNo + 1), InspInterval) EQ 0)
*    ActionFlow   = InspReq


*    InspReq = Xlate('CLEAN_INSP', 2380298, 'INSP_REQ', 'X')
*    Database_Services('ReleaseKeyIDLock', 'PROD_SPEC', 5192)
*    If Error_Services('HasError') then
*        ErrorMessage = Error_Services('GetMessage')
*    end
*    SoftBlock = Xlate('SCHED_DET_NG', 'C362B3694D7841F1B7FBE689422C80D1', 'HARD_BLOCK', 'X')

* return

*    CSVOutput    = 'EpiPart,Reactor Type,Reactor Utilization,MPW,WPD,WPDA'
*    EpiPartNos   = Xlate('SYSLISTS', 'TEST_DANIEL', '', 'X')
*    EpiPartNos   = Delete(EpiPartNos, 1, 0, 0)
*    ReactorTypes = 'ASM,ASM+,HTR,EpiPro,GaN'
*    For each EpiPartNo in EpiPartNos using @FM setting EPIndex
*        MPWArray = Xlate('EPI_PART', EpiPartNo, 'MINUTES_PER_WAFER_SCHEDULER', 'X')
*        For each ReactorType in ReactorTypes using ',' setting RTIndex
*            ReactorUtil            = Epi_Part_Services('GetReactorUtilization', ReactorType)
*            RowIndex               = ((EPIndex - 1) * 5) + RTIndex
*            MPW                    = OConv(MPWArray<0, RTIndex>, 'MD3')
*            WPD                    = Epi_Part_Services('GetIdealWafersPerDayScheduler', EpiPartNo, ReactorType, MPW)
*            WPDA                   = Epi_Part_Services('GetAdjustedWafersPerDayScheduler', EpiPartNo, ReactorType, MPW)
*            CSVOutput<RowIndex, 1> = EpiPartNo
*            CSVOutput<RowIndex, 2> = ReactorUtil
*            CSVOutput<RowIndex, 3> = ReactorType
*            CSVOutput<RowIndex, 4> = MPW
*            CSVOutput<RowIndex, 5> = WPD
*            CSVOutput<RowIndex, 6> = WPDA
*        Next ReactorType
*    Next EpiPartNo
*    
*    Swap @VM with ',' in CSVOutput
*    Swap @FM with CRLF$ in CSVOutput
*    CSVFile = 'C:\Users\StieberD\Desktop\MPW.csv'
*    OSWrite CSVOutput to CSVFile

* return



*    SchedDetNGRec = Database_Services('ReadDataRow', 'SCHED_DET_NG', '4DCEC176F0774A478CD6A3C06BEBA3A8')

PRSKeys  = Database_Services('ReadDataRow', 'APP_INFO', 'SS_REDUCTION_SET')
For each PRSKey in PRSKeys using @FM
    PRSRec    = Database_Services('ReadDataRow', 'PRS_STAGE', PRSKey)
    SSQtys  = PRSRec<PRS_STAGE_SS_SAMP_QTY$>
    SSSODs  = PRSRec<PRS_STAGE_SURF_DEFECTS$>
    SSHazes = PRSRec<PRS_STAGE_SURF_HAZE$>
    Locate 6 in SSQtys using @VM setting vPos then
        SOD  = SSSODs<0, vPos>
        Haze = SSHazes<0, vPos>
        Locate 25 in SSQtys using @VM setting sPos then
            SSSODs<0, sPos>                 = SOD
            SSHazes<0, sPos>                = Haze
            PRSRec<PRS_STAGE_SURF_DEFECTS$> = SSSODs
            PRSRec<PRS_STAGE_SURF_HAZE$>    = SSHazes
            Database_Services('WriteDataRow', 'PRS_STAGE', PRSKey, PRSRec, True$, False$, True$)
        end
    end
Next PRSKey

* return

*    WOStepKey = '169717*1'
*    RDSNos    = Xlate('WO_STEP', WOStepKey, 'RDS_KEY', 'X')
*    For each RDSNo in RDSNos using @VM setting vPos
*        RDSRec                = Database_Services('ReadDataRow', 'RDS', RDSNo)
*        DateOut               = RDSRec<RDS_DATE_OUT$>
*        TimeOut               = RDSRec<RDS_TIME_OUT$>
*        RDSRec<RDS_DATE_OUT$> = ''
*        RDSRec<RDS_TIME_OUT$> = ''
*        Database_Services('WriteDataRow', 'RDS', RDSNo, RDSRec)
*        RDSRec<RDS_DATE_OUT$> = DateOut
*        RDSRec<RDS_TIME_OUT$> = TimeOut
*        Database_Services('WriteDataRow', 'RDS', RDSNo, RDSRec)
*    Next RDSNo
* 
* return



*    RDSNo   = 424161
*    WOWfrID = '169697*1*4'
*    GaN_Services('CreateRunStageWfr', RDSNo, 'XRD', WOWfrID)
*    GaN_Services('CreateRunStageWfr', RDSNo, 'PR', WOWfrID)
*    Database_Services('ActivateRecord', 'REACT_RUN', RDSNo)
*    ActionFlow = 0
*    InWfrIDs   = {IN_WFR_ID}
*    For each WfrID in InWfrIDs using @VM setting vPos
*        ActionFlow += ( Xlate('WO_WFR', WfrID, 'CRITICAL_FAILURE', 'X') EQ True$ ) 
*    Next WfrID
*    Testing = Xlate('REACT_RUN', RDSNo, 'NUM_ANKO_CRITICAL_FAIL_WFRS', 'X')


*    LayerKeys        = ''
*    LayerKeys<0, -1> = '422908*L1'
*    LayerKeys<0, -1> = '422908*L2'
*    LayerKeys<0, -1> = '422908*2'
*    MetEntered = XLATE('RDS_LAYER',LayerKeys,'TEST_MET_ENTERED','X')
*    Schedule_Services('AddSchedEvent', 22, 169702, 19397, 19404, 'Test', 600)

*    For RDSTestKeyID = 400000 to 1 Step -1
*        
*        If RowExists('RDS_TEST', RDSTestKeyID) then
*            Database_Services('DeleteDataRow', 'RDS_TEST', RDSTestKeyID, True$)
*        end
*        
*    Next RDSTestKeyID
* 	
* 
* return


*    StartKey = Xlate('DICT.RDS', '%SK%', '', 'X')
*    For RDSKey = StartKey to 500000
*        If RowExists('RDS', RDSKey) then 
*            Database_Services('DeleteDataRow', 'RDS', RDSKey, True$, True$)
*        end
*    Next RDSKey
*    
* 

*    CheckID = '168246.1.20'
*    NumDec  = Count(CheckID, '.')

*    ReactorType = Xlate('WO_MAT', '168246*20', 'REACTOR_TYPE', 'X')
*    CassIDSAP   = Xlate('WO_MAT', '168246*20', 'CASS_ID_SAP', 'X')
* return

CurrCassNo = ''
DateIn     = ''
RDSKeys    = Xlate('WO_STEP', '169583*1', 'RDS_KEY', 'X')
NumKeys    = DCount(RDSKeys, @VM)
For KeyIndex = NumKeys to 1 Step -1
    RDSKey = RDSKeys<0, KeyIndex>
    DateIn = Xlate('RDS', RDSKey, 'DATE_IN', 'X')
Until DateIn NE ''
Next KeyIndex
If DateIn NE '' then CurrCassNo = Xlate('RDS', RDSKey, 'CASS_NO', 'X')

return CurrCassNo 

*    GUID = RTI_CreateGUID()
table = "SCHED_DET_NG"
Open "DICT ":table To @DICT Else
    RetVal = Set_FSError()
    Return
End
Column          = "WO_NO"
QueryParam      = 169254
search_criteria = Column:@VM:QueryParam:@FM
keylist         = ""
option          = ""
flag            = ""
Btree.Extract(search_criteria, table, @DICT, keylist, option, flag)

ScheduledQty = 0

For each KeyID in keylist using @VM
    ScheduledQty += Xlate('SCHED_DET_NG', KeyID, 'EVENT_TOTAL_WFRS', 'X')        
Next KeyID


return ScheduledQty


RejWfrIDs         = ''
RejWfrIDs<0, -1>  = '168246*23*1'
RejWfrIDs<0, -1>  = '168246*23*2'
RejWfrIDs<0, -1>  = '168246*23*10'
RejWfrIDs<0, -1>  = '168246*23*11'
Debug
WONo              = 168246
CassNo            = 23
ncrParms          = WONo:@RM
ncrParms         := '1':@RM
ncrParms         := CassNo:@RM		;* Place holder for WO_MAT_CASS_NO
ncrParms         := '':@RM		    ;* Single RDS field 
ncrParms         := '':@RM		    ;* Reactor No
ncrParms         := '':@RM			;* Loss Stage
ncrParms         := RejWfrIDs:@RM	;* WfrIDs			;* CarrWafer IDs
ncrParms         := '':@RM	        ;* CarrSlotIDs		;* GaN PostEpi Carrier Slot ID	-> GaN non-characterization wafers
ncrParms         := '':@RM			;* CassSlotIDs		;* WOMat Cassette Slot ID		-> Rej from cassette
ncrParms         := ''				;* RunPocketZone	;* RPZ							-> Rej from susceptor

Set_Status(0)
NCRNo   = obj_NCR('CreateWfr',ncrParms)		;* Create new NCR for this wafer/group of wafers
errCode = ''
IF Get_Status(errCode) THEN
    ErrMsg(errCode)
end else
    Dialog_Box('NCR', @Window, NCRNo)
    // Add NCRNo to the rejected wafer ID records (WO_WFR table)
    For each WfrID in RejWfrIDs using @VM
        WOWfrRec                     = Database_Services('ReadDataRow', 'WO_WFR', WfrID)
        WOWfrRec<WO_WFR_WMO_NCR_NO$> = NCRNo
        Database_Services('WriteDataRow', 'WO_WFR', WfrID, WOWfrRec, True$, False$, True$)
    Next WfrID
end

return









// Requirements for makeup wafer to be considered 'Available'
// 1. Cassette has to be marked as a makeup box.
// 2. RDS has to have FQA signature.
// 3. PSN must be 'Active' (i.e. 'A')
// 4. RDS cannot have a current status of 'MT, VOID, SHIP, REJ, or HOLD'.

*    debug
*    RDSKeyID = 406141
*    LWICINo  = Xlate('RDS', RDSKeyID, 'LWI_CI_NO', 'X')
*    

WOMatKeyID = '169433*19'
WOMatRec   = Database_Services('ReadDataRow', 'WO_MAT', WOMatKeyID)
WfrData    = obj_WO_Mat('SlotWaferIDs', WOMatKeyID:@RM:WOMatRec)
debug

*    SRP_Stopwatch('Reset')
*    SRP_Stopwatch('Start', 'Routine')
*    CurrStatus = obj_WO_Mat('CurrStatus', WOMatKeyID)
*    SRP_Stopwatch('Stop', 'Routine')
*    SRP_Stopwatch('Start', 'Index')
*    CurrStatus = Xlate('WO_MAT', WOMatKeyID, 'CURR_STATUS', 'X')
*    SRP_Stopwatch('Stop', 'Index')
*    SRP_Stopwatch('ShowAll')
*    CurrWaferCount = obj_WO_Mat('CurrWaferCnt', WOMatKeyID)
return

AppID                   = @APPID<1>  ;* current application
TypeID                  = "OIWIN"    ;* OpenInsight Forms
ClassID                 = ""         ;* Not Applicable
recompile_if_unchanged  = 1
cleanup_orphan_entities = ''
creserve_linemarks      = ''

entlistt = Get_Repos_Entities(appID, typeID, classID)

For each EntID in entlistt using @FM
    Set_Status(0)
    result = Repository("COMPILE", entid, recompile_if_unchanged, cleanup_orphan_entities, preserve_linemarks)
    If Get_Status(ErrCode) then
        call msg(@window, 'Error Message returned: ' : ErrCode)
    end
    
Next EntID    

return

LastCIKey = 2361946

For CIKey = 2000000 to LastCIKey Step 1
    
    ROTRReactorStatus = Xlate('CLEAN_INSP', CIKey, 'ROTR_REACTOR_STATUS', 'X')
    If ROTRReactorStatus NE '' then
        ROTRRec                                       = ''
        ROTRRec<ROTR.REACTOR_STATUS$>                 = ROTRReactorStatus
        ROTRRec<ROTR.REACTOR_STATUS_REASON$>          = Xlate('CLEAN_INSP', CIKey, 'ROTR_REACTOR_STATUS_REASON', 'X')
        ROTRRec<ROTR.REACTOR_NCR_COUNT$>              = Xlate('CLEAN_INSP', CIKey, 'ROTR_REACTOR_NCR_COUNT', 'X')
        ROTRRec<ROTR.REACTOR_ZERO_NCR_RUN_COUNT$>     = Xlate('CLEAN_INSP', CIKey, 'ROTR_REACTOR_ZERO_NCR_RUN_COUNT', 'X')
        ROTRRec<ROTR.REACTOR_UCL_EXCEEDED_RUN_COUNT$> = Xlate('CLEAN_INSP', CIKey, 'ROTR_REACTOR_UCL_EXCEEDED_RUN_COUNT', 'X')
        Database_Services('WriteDataRow', 'ROTR', CIKey, ROTRRec, True$, False$, True$)
    end
Next CIKey

return

TempList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
// Chomp info line
TempList = Delete(TempList, 1, 0, 0)
For each KeyID in TempList using @FM
    Record = Database_Services('ReadDataRow', 'RUN_STAGE_WFR', KeyID)
    Database_Services('WriteDataRow', 'RUN_STAGE_WFR', KeyID, Record, True$, False$, True$)
Next KeyID


return



Sentence = 'SELECT EA_REQUESTS'
Set_Status(0)
RList(Sentence, TARGET_ACTIVELIST$, '', '', '')
EOF      = False$
RDSList  = ''
Loop
    ReadNext RequestKeyID else EOF = True$
    If RequestKeyID NE '' then
        RDSNo        = Field(RequestKeyID, '*', 1)
        RDSList<-1>  = RDSNo
    end
Until EOF EQ True$
Repeat
RDSList = SRP_Array('Clean', RDSList, 'TrimAndMakeUnique', @FM)

For each RDSNo in RDSList using @FM
    ClosedFlag = Xlate('REACT_RUN', RDSNo, 'DISP_COMPLETE', 'X')
    If ClosedFlag EQ True$ then
        Engineering_Services('ClearEARequests', RDSNo)
    end
Next RDSNo

return 

Stages = 'BV'
Tools  = 'BVS01'
For each Stage in Stages using ',' setting sPos
    ToolID = Field(Tools, ',', sPos, 1)
    RDSNo  = 403583
    WfrID  = '168521*10*7'
    GaN_Services('StartWaferStage', RDSNo, WfrID, Stage, ToolID)
    GaN_Services('StopWaferStage', RDSNo, WfrID, Stage)
    GaN_Services('CompleteWaferStage', RDSNo, WfrID, Stage)
    
Next Stage

*    
*    WfrID = '168521*9*25'
*    Gan_Services('CharacterizeWafer', RDSNo, WfrID)
*    
*    For SlotNo = 1 to 6
*        WfrID = '168521*10*':SlotNo
*        Gan_Services('DispositionWfr', RDSNo, WfrID)
*    Next SlotNo
*    
*    WfrID = '168521*10*7'
*    Gan_Services('CharacterizeWafer', RDSNo, WfrID)


return

*    If CAN_PST exists or WET_CLEAN comp then
*        CAN_PST
*    end else
*        If WET_CLEAN comp then
*            CAN_PST
*        end else
*            CAN_PRE
*        end
*        
*    end

* Initialize Common Printer parms
*    debug
*    SourceFilepath = 'C:\Users\ecStieberD\Desktop\Notes\SRP\SRPUtil.ocx':\00\
*    DestFilepath   = 'C:\Users\ecStieberD\Desktop\SRPUtil.ocx':\00\
*    rv             = SRPWinAPI_CopyFile(GetPointer(SourceFilepath), GetPointer(DestFilepath), 0)
*    
*    SourceFilePath = 'C:\Users\ecStieberD\Desktop\Notes\SRP\SRPUtil.ocx'
*    DestFilepath   = 'C:\Users\ecStieberD\Desktop\SRPUtil.ocx'
*    rv             = File_Services('CopyFile', SourceFilepath, DestFilepath)

return 
For I = 1 to 100
    PageInfo			= ''
    PageInfo<PI$LEFT>	= 0.5		;* Margins
    PageInfo<PI$TOP>	= 1.35
    PageInfo<PI$RIGHT>	= 0.5
    PageInfo<PI$BOTTOM>	= 0.25
    
    PageSetup   	= '0' 				;* Portrait
    Models          = ''
    Printers        = ''
    Default         = ''
    PrinterCount    = PrintSetup(PRN_GET$, Models, Printers, Default)
    
    
    FileNameParms = 'Printing PDF Document':@FM: '' :@FM:'':@FM: ''
    TitleParms    = 'Shipping Documents'
    
    PrintSetup	= ''
    PrintSetup<1,1>	= '2'	;* Preview Normal
    PrintSetup<1,2> = '5'	;* Display Print and PDF buttons
    PrintSetup<1,3>	= '0'	;* Display Printing Window
    PrintSetup<1,4> = '0'	;* Normal Start Mode
    
    PrinterParm       = ''
    PrinterParm<1, 1> = 'Microsoft XPS Document Writer'
    PrinterParm<1, 2> = False$  ; // Do not set Windows default printer to this printer
    PrinterParm<2>    = 'Ne00:' ; // Printer port
    PrinterParm<3>    = 100     ; // Scale
    PrinterParm<4>    = ''      ; // Bin Number
    
    stat = Set_Printer('INIT', FileNameParms, 'Shipping Documents', PageInfo, PageSetup, PrintSetup, PrinterParm)
    
    If Stat LT 0 then
        ErrMsg('Failed to initialize printer! Error code: ':Stat)
    end
    
    stat = Set_Printer("TERM")    
Next I


return

*    PSNList = Database_Services('ReadDataRow', 'SYSLISTS', 'TEST_DANIEL')
*    PSNList = Delete(PSNList, 1, 0, 0)
*    PSNList = Delete(PSNList, 1, 0, 0)
*    For each PSNo in PSNList using @FM
*        UVRec = Database_Services('ReadDataRow', 'PRS_STAGE', PSNo:'*UV')
*        If Error_Services('NoError') then
*            UVRec<PRS_STAGE_PROC_TOOL_CLASS$> = 'G_UV_PRE'
*            Database_Services('WriteDataRow', 'PRS_STAGE', PSNo:'*UV_PRE', UVRec)
*            Database_Services('DeleteDataRow', 'PRS_STAGE', PSNo:'*UV')
*        end
*    Next PSNo
*    
*    
* return

*    Test    = 25 ** 0.5
*    CmdLine = GetCommandLine()

debug
// Run IDs to post again once we add in CAN average
RunIDs       = ''
RunIDs<0,-1> = '7104399mvfet'
RunIDs<0,-1> = '7104401mvfet'
RunIDs<0,-1> = '7104403mvfet'
RunIDs<0,-1> = '7104405mvfet'
RunIDs<0,-1> = '7104407mvfet'
RunIDs<0,-1> = '7104409mvfet'
RunIDs<0,-1> = '7104411mvfet'
RunIDs<0,-1> = '7104413mvfet'
RunIDs<0,-1> = '7104415mvfet'
RunIDs<0,-1> = '7104417mvfet'
RunIDs<0,-1> = '7104419mvfet'
RunIDs<0,-1> = '7104421mvfet'

Table = 'REACT_RUN'
Open 'DICT.REACT_RUN' to dReactRun then
    For each RunID in RunIDs using @VM
        Column = "GAN_RUN_ID"
        Query  = Column:@VM:RunID:@FM
        RDSNo  = ""
        Option = ""
        Flag   = ""
        Btree.Extract(Query, Table, dReactRun, RDSNo, Option, Flag)
        If ( (Flag EQ 0) and (RDSNo NE '') ) then
            Engineering_Services('PostEARequest', RDSNo, 'UV_PRE')
        end   
    Next RunID       
end

return 

RunIDs       = ''
RunIDs<0,-1> = '6905517hvfet'
RunIDs<0,-1> = '6905519hvfet'
RunIDs<0,-1> = '6905522hvfet'
RunIDs<0,-1> = '6905525hvfet'
RunIDs<0,-1> = '6905527hvfet'
RunIDs<0,-1> = '6905530hvfet'
RunIDs<0,-1> = '6905534hvfet'
RunIDs<0,-1> = '6905537hvfet'
RunIDs<0,-1> = '6905540hvfet'
RunIDs<0,-1> = '6905543hvfet'
RunIDs<0,-1> = '6905545hvfet'
RunIDs<0,-1> = '6905548hvfet'
RunIDs<0,-1> = '6905550hvfet'
RunIDs<0,-1> = '6905552hvfet'
RunIDs<0,-1> = '6905555hvfet'
RunIDs<0,-1> = '6905557hvfet'
RunIDs<0,-1> = '6905560hvfet'
RunIDs<0,-1> = '6905562hvfet'
RunIDs<0,-1> = '6905564hvfet'
RunIDs<0,-1> = '6905566hvfet'
RunIDs<0,-1> = '6905569hvfet'
RunIDs<0,-1> = '6905571hvfet'
RunIDs<0,-1> = '6905573hvfet'
RunIDs<0,-1> = '6905575hvfet'
RunIDs<0,-1> = '6905577hvfet'
RunIDs<0,-1> = '6905579hvfet'
RunIDs<0,-1> = '6905582hvfet'
RunIDs<0,-1> = '6905585hvfet'
RunIDs<0,-1> = '6905588hvfet'
RunIDs<0,-1> = '6905590hvfet'
RunIDs<0,-1> = '6905593hvfet'
RunIDs<0,-1> = '6905596hvfet'
RunIDs<0,-1> = '6905598hvfet'
RunIDs<0,-1> = '6905601hvfet'
RunIDs<0,-1> = '6905603hvfet'
RunIDs<0,-1> = '6905606hvfet'
RunIDs<0,-1> = '6905609hvfet'
RunIDs<0,-1> = '6905612hvfet'
RunIDs<0,-1> = '6905615hvfet'
RunIDs<0,-1> = '6905618hvfet'
RunIDs<0,-1> = '6905621hvfet'
RunIDs<0,-1> = '6905624hvfet'

Table = 'REACT_RUN'
Open 'DICT.REACT_RUN' to dReactRun then
    For each RunID in RunIDs using @VM
        Column = "GAN_RUN_ID"
        Query  = Column:@VM:RunID:@FM
        RDSNo  = ""
        Option = ""
        Flag   = ""
        Btree.Extract(Query, Table, dReactRun, RDSNo, Option, Flag)
        If ( (Flag EQ 0) and (RDSNo NE '') ) then
            Engineering_Services('PostEARequest', RDSNo, 'PR')    
        end   
    Next RunID       
end

return


SpreadsheetName = '8-inch New HV Epi Development.xlsx'
WorksheetName   = '8inch HELENS'
Password        = 'IRMN2714'
Directory       = '\\messv02ecc1.ec.local\EC_GaN_Development\R69 EPI DEVELOPMENT\DAILY RUN RECORD\'
Offset          = 18
EndCol          = 'CC'

DocPath        = Directory:'\':SpreadsheetName
DocObj         = Excel_Services('GetDocumentObject', DocPath, 'IRMN2714')
CellRangeBegin = 'A16644'
CellRangeEnd   = 'CC16661'
CopyToCell     = 'A16662'
Excel_Services('CopyCellRange', DocObj, WorksheetName, CellRangeBegin, CellRangeEnd, CopyToCell)
Excel_Services('SaveDocument', DocObj, DocPath, 'IRMN2714')
Excel_Services('CloseDocument', DocObj)

return
*    S.WONo  = 169154
*    KitData = obj_Location('KitLocations',S.WONo)
* 
*    SWAP CRLF$ WITH @VM IN KitData
* 
*    S.KitLocation	= KitData<1>
*    I.KitLocation	= S.KitLocation
* 
*    S.KitQty		= OCONV(SUM(KitData<2>) * 25,'MD0,Z')
*    I.KitQty		= S.KitQty
*    
*    
*    
* 
*    Open 'DICT.WO_MAT' to DictVar then
*        LocVar        = 'SR*KTR]'
*        WONo          = S.WONo
*        SearchString  = 'WO_NO':@VM:WONo:@FM
*        SearchString := 'CURR_LOCATION':@VM:LocVar:@FM
*        Flag          = ''
*        WOMatKeys     = ''
*        Btree.Extract(SearchString, 'WO_MAT', DictVar, WOMatKeys, '', Flag)    
*    end
* 
* return
* 
*    If @USER4 EQ 'DANIEL_ST' then debug
*    WOMatKey                   = '169136*22'
*    WOMatRec                   = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
*    SlotNCRs                   = WOMatRec<WO_MAT_SLOT_NCR$>
*    SlotNCRs<0, 22>            = 168779
*    SlotNCRs<0, 23>            = 168779
*    WOMatRec<WO_MAT_SLOT_NCR$> = SlotNCRs
*    Database_Services('WriteDataRow', 'WO_MAT', WOMatKey, WOMatRec, True$, False$, True$)
*    
* return
*    
*    
*    RDSList        = ''
*    RDSList<0, -1> = 397404
*    RDSList<0, -1> = 397200
*    RDSList<0, -1> = 397181
*    RDSList<0, -1> = 396893
*    RDSList<0, -1> = 396216
*    RDSList<0, -1> = 396143
*    RDSList<0, -1> = 396015
*    RDSList<0, -1> = 397166
*    RDSList<0, -1> = 396468
*    RDSList<0, -1> = 397037
*    RDSList<0, -1> = 397270
*    RDSList<0, -1> = 397310
*    RDSList<0, -1> = 397317
*    RDSList<0, -1> = 397429
*    RDSList<0, -1> = 397526
*    RDSList<0, -1> = 397526
*    RDSList<0, -1> = 397578
*    RDSList<0, -1> = 397695
*    RDSList<0, -1> = 397764
*    RDSList<0, -1> = 397777
*    RDSList<0, -1> = 397792
*    RDSList<0, -1> = 397808
*    RDSList<0, -1> = 397821
*    RDSList<0, -1> = 397821
*    RDSList<0, -1> = 397906
*    RDSList<0, -1> = 397972
*    RDSList<0, -1> = 398063
*    RDSList<0, -1> = 398101
*    RDSList<0, -1> = 398137
*    
*    For each RDSNo in RDSList using @VM
*        Engineering_Services('PostEARequest', RDSNo, 'XRD')
*    Next RDSNo
*    
*    
*    
* return
* 
*    CIList         = ''
*    CIList <0, -1> = 1075260
*    CIList <0, -1> = 1075263
*    CIList <0, -1> = 1075284
*    CIList <0, -1> = 1075287
*    CIList <0, -1> = 1075296
*    CIList <0, -1> = 1075350
*    CIList <0, -1> = 1075359
*    CIList <0, -1> = 1075374
*    CIList <0, -1> = 1075380
*    CIList <0, -1> = 1075395
*    CIList <0, -1> = 1075404
*    CIList <0, -1> = 1075416
*    CIList <0, -1> = 1075425
*    CIList <0, -1> = 1075428
*    CIList <0, -1> = 1075431
*    CIList <0, -1> = 1075455
*    CIList <0, -1> = 1075458
*    CIList <0, -1> = 1075488
*    CIList <0, -1> = 1075512
*    CIList <0, -1> = 1075521
*    CIList <0, -1> = 1075533
*    CIList <0, -1> = 1075539
*    CIList <0, -1> = 1075548
*    CIList <0, -1> = 1075572
*    CIList <0, -1> = 1075584
*    CIList <0, -1> = 1075587
*    CIList <0, -1> = 1075596
*    CIList <0, -1> = 1075599
*    CIList <0, -1> = 1075602
*    CIList <0, -1> = 1075611
*    CIList <0, -1> = 1075617
*    CIList <0, -1> = 1075632
*    CIList <0, -1> = 1075635
*    CIList <0, -1> = 1075644
*    CIList <0, -1> = 1075656
*    CIList <0, -1> = 1075659
*    CIList <0, -1> = 1075662
*    CIList <0, -1> = 1075665
*    CIList <0, -1> = 1075668
*    CIList <0, -1> = 1075677
*    CIList <0, -1> = 1075683
*    CIList <0, -1> = 1075686
*    CIList <0, -1> = 1075689
*    CIList <0, -1> = 1075695
*    CIList <0, -1> = 1075758
*    CIList <0, -1> = 1075776
*    CIList <0, -1> = 1075803
*    CIList <0, -1> = 1075806
*    CIList <0, -1> = 1075818
*    CIList <0, -1> = 1075821
*    CIList <0, -1> = 1075836
*    CIList <0, -1> = 1075842
*    CIList <0, -1> = 1075857
*    CIList <0, -1> = 1075863
*    CIList <0, -1> = 1075866
*    CIList <0, -1> = 1075881
*    CIList <0, -1> = 1075896
*    CIList <0, -1> = 1075905
*    CIList <0, -1> = 1075908
*    CIList <0, -1> = 1075914
*    CIList <0, -1> = 1075923
*    CIList <0, -1> = 1075947
*    CIList <0, -1> = 1075953
*    CIList <0, -1> = 1075962
*    CIList <0, -1> = 1075968
*    CIList <0, -1> = 1075971
*    CIList <0, -1> = 1075974
*    CIList <0, -1> = 1075980
*    CIList <0, -1> = 1075989
*    CIList <0, -1> = 1076004
*    CIList <0, -1> = 1076010
*    CIList <0, -1> = 1076028
*    CIList <0, -1> = 1076031
*    CIList <0, -1> = 1076034
*    CIList <0, -1> = 1076046
*    CIList <0, -1> = 1076049
*    CIList <0, -1> = 1076068
*    CIList <0, -1> = 1076074
*    CIList <0, -1> = 1076077
*    CIList <0, -1> = 1076080
*    CIList <0, -1> = 1076086
*    CIList <0, -1> = 1076092
*    CIList <0, -1> = 1076095
*    CIList <0, -1> = 1076098
*    CIList <0, -1> = 1076104
*    CIList <0, -1> = 1076107
*    CIList <0, -1> = 1076122
*    CIList <0, -1> = 1076128
*    CIList <0, -1> = 1076131
*    CIList <0, -1> = 1076140
*    CIList <0, -1> = 1076146
*    CIList <0, -1> = 1076153
*    CIList <0, -1> = 1076159
*    CIList <0, -1> = 1076162
*    CIList <0, -1> = 1076168
*    CIList <0, -1> = 1076183
*    CIList <0, -1> = 1076189
*    CIList <0, -1> = 1076192
*    CIList <0, -1> = 1076195
*    CIList <0, -1> = 1076201
*    CIList <0, -1> = 1076207
*    CIList <0, -1> = 1076210
*    CIList <0, -1> = 1076219
*    CIList <0, -1> = 1076225
*    CIList <0, -1> = 1076231
*    CIList <0, -1> = 1076313
*    CIList <0, -1> = 1076322
*    CIList <0, -1> = 1076358
*    CIList <0, -1> = 1076361
*    CIList <0, -1> = 2346304
* 
*    For each CINo in CIList using @VM
*        CIRec    = Database_Services('ReadDataRow', 'CLEAN_INSP', CINo)
*        DummyKey = 'CLEAN_INSP*':CINo
*        Database_Services('WriteDataRow', 'DUMMY', DummyKey, CIRec)
*        Database_Services('DeleteDataRow', 'CLEAN_INSP', CINo)
*    Next CINo
*   
* return
* 
*    
*    RunIDList        = ''
*    RunIDList<0, -1> = '6905525hvfet'
*    RunIDList<0, -1> = '6905527hvfet'
*    RunIDList<0, -1> = '6905530hvfet'
*    RunIDList<0, -1> = '6905534hvfet'
*    RunIDList<0, -1> = '6905537hvfet'
*    RunIDList<0, -1> = '6905540hvfet'
*    RunIDList<0, -1> = '6905543hvfet'
*    RunIDList<0, -1> = '6905545hvfet'
*    RunIDList<0, -1> = '6905548hvfet'
*    RunIDList<0, -1> = '6905550hvfet'
*    RunIDList<0, -1> = '6905552hvfet'
*    RunIDList<0, -1> = '6905555hvfet'
*    RunIDList<0, -1> = '6905557hvfet'
*    RunIDList<0, -1> = '6905560hvfet'
*    RunIDList<0, -1> = '6905562hvfet'
*    RunIDList<0, -1> = '7103949hvfet'
*    RunIDList<0, -1> = '7103959hvfet'
*    RunIDList<0, -1> = '7103968hvfet'
*    RunIDList<0, -1> = '7103973hvfet'
*    RunIDList<0, -1> = '7103993hvfet'
*    RunIDList<0, -1> = '7104044hvfet'
*    RunIDList<0, -1> = '7104214hvfet'
*    RunIDList<0, -1> = '7104221hvfet'
*    RunIDList<0, -1> = '7104235hvfet'
*    RunIDList<0, -1> = '7104240hvfet'
*    RunIDList<0, -1> = '7104243hvfet'
*    RunIDList<0, -1> = '7104248hvfet'
*    RunIDList<0, -1> = '7104253hvfet'
*    RunIDList<0, -1> = '7104257mvfet'
*    RunIDList<0, -1> = '7104263mvfet'
*    RunIDList<0, -1> = '7104267mvfet'
*    RunIDList<0, -1> = '7104269mvfet'
*    RunIDList<0, -1> = '7104271mvfet'
*    RunIDList<0, -1> = '7104275mvfet'
*    RunIDList<0, -1> = '7104277mvfet'
*    RunIDList<0, -1> = '7104279mvfet'
*    RunIDList<0, -1> = '7104281mvfet'
*    RunIDList<0, -1> = '7104283mvfet'
*    RunIDList<0, -1> = '7104285mvfet'
*    RunIDList<0, -1> = '7104287mvfet'
*    RunIDList<0, -1> = '7104289mvfet'
*    RunIDList<0, -1> = '7104291mvfet'
*    RunIDList<0, -1> = '7104293mvfet'
*    RunIDList<0, -1> = '7103937hvfet'
*    RunIDList<0, -1> = '7104261hvfet'
*    
*    Open 'DICT.REACT_RUN' to hDict then
*        For each RunID in RunIDList using @VM setting vPos
*            Query  = 'GAN_RUN_ID' : @VM : RunID : @FM
*            RDSNo  = ''
*            Option = ''
*            Flag   = ''
*            Btree.Extract(Query, 'REACT_RUN', hDict, RDSNo, Option, Flag)
*            If RDSNo NE '' then
*                Engineering_Services('PostEARequest', RDSNo, 'CHAR')
*            end
*        Next RunID
*    end
*    
* return
* 
* 
*    DocumentPath  = '\\messv02ecc1.ec.local\EC_GaN_Development\R69 EPI DEVELOPMENT\DAILY RUN RECORD\FITesting.xlsx'
*    DocumentPW    = 'IRMN2714'   
*    FileHandle    = File_Services('LockFile', DocumentPath, GENERIC_WRITE$, FILE_SHARE_READ$, OPEN_EXISTING$)
*    If FileHandle NE FILE_ERROR$ then
*        DocObj        = Excel_Services('OpenDocument', DocumentPath, DocumentPW)
*        WorksheetName = '8inch HELENS'
*        CellRangeObj  = Excel_Services('GetCellRangeObject', DocObj, WorksheetName, 'A16068', 'CC16085')
*        If Error_Services('NoError') then
*            rv = Send_Message.Net(CellRangeObj, 'CopyTo', 'A16104', 'System.String', 0)
*            If Get_Status(StatusCode) then
*                Null
*            end else
*                Excel_Services('SaveDocument', DocObj, DocumentPath, DocumentPW)
*                If Error_Services('HasError') then
*                    ErrorMessage = Error_Services('GetMessage')
*                end
*            end
*        end else
*            ErrorMessage = Error_Services("GetMessage")
*        end
*    end
*    If FileHandle NE FILE_ERROR$ then File_Services('UnlockFile', FileHandle)
*    Excel_Services('CloseDocument', DocObj)
* 
* return
*    hDict      = Database_Services('GetTableHandle', 'DICT.EA_REQUESTS')
*    If Error_Services('NoError') then
*        RequestKeyID = ''
*        RDSNo        = 394235
*        Stage        = 'HALL'
*        Query        = 'RDS_NO' : @VM : RDSNo : @FM : 'STAGE' : @VM : Stage : @FM
*        Option       = ''
*        Flag         = ''
*        Btree.Extract(Query, 'EA_REQUESTS', hDict, RequestKeyID, Option, Flag)
*        If RequestKeyID EQ '' then
*            // This is a new request
*            Log = 'EA request posted'
*        end else
*            Log = 'Duplicate EA request found, request ignored.'
*        end
*    end
*    
*    
*    
* return
* 
*    Done         = False$
*    TempFilepath = '\\messv02ecc1.ec.local\EC_GaN_Development\R71 EPI DEVELOPMENT\Daily Run Record\TempBackup.xlsx'
*    Filepath     = '\\messv02ecc1.ec.local\EC_GaN_Development\R71 EPI DEVELOPMENT\Daily Run Record\Francois.xlsx'
*    TempPath     = Str(\00\, 1024)
*    GetTempPath(Len(TempPath), TempPath)
*    Convert \00\ to '' in TempPath
*    TempFilename = Str(\00\, 1024)
*    GetTempFileName(TempPath, \00\, 0, TempFilename)
*    
*    
*    FileHandle = File_Services('LockFile', Filepath, GENERIC_READ$, FILE_SHARE_READ$, OPEN_EXISTING$)
*    If FileHandle NE FILE_ERROR$ then
*        
*        
*        File_Services('CopyFile', Filepath, TempFilepath)
*        FileSize = File_Services('GetFileSize', FileHandle)                
*        DocObj   = Excel_Services('OpenDocument', Filepath, 'IRMN2714')
*        If Error_Services('NoError') then
*            SRP_IO('UnlockFile', FileHandle)                          
*            Excel_Services('SaveDocument', DocObj, Filepath, 'IRMN2714')
*            If Error_Services('HasError') then
*                ErrMsg(Error_Services('GetMessage'))
*            end
*        end
*        File_Services('UnlockFile', FileHandle)
*        OSDelete TempFilepath
*    end
* 
* return
* 
*    RDSNo = 393710
*    RDSCombStatus = Xlate('RDS', RDSNo, 'COMB_STATUS', 'X')
*    RDSCurrStatus = Xlate('RDS', RDSNo, 'CURR_STATUS', 'X')
* 
*    Database_Services('ActivateRecord', 'RDS', RDSNo)
*    WOMatRepStatus = XLATE('WO_MAT',{WO_MAT_KEY},'REP_STATUS','X')
*    RunStatus = XLATE('REACT_RUN',@ID,'RUN_STATUS','X')
* 
*    RunStatus = OCONV(RunStatus,'[RUN_STATUS_CONV]')
* 
*    BEGIN CASE
*         CASE WOMatRepStatus NE '' AND RunStatus NE ''
*              Ans = WOMatRepStatus
*             
*          CASE WOMatRepStatus = '' AND RunStatus NE ''
*              Ans = RunStatus
*             
*          CASE WOMatRepStatus NE '' AND RunStatus = ''
*               Ans = WOMatRepStatus
*               
*           CASE 1
*                Ans = ''
*    END CASE
*    
*    WOMatKey  = '169056*1'
*    SigProfile = Signature_Services('GetSigProfile', WOMatKey)
*    WOMatRec  = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey)
*    RepStatus = obj_WO_Mat('ReportStatus', WOMatKey:@RM:WOMatRec)
* 
* return
* 
*    TestDir      = '\\messv02ecc1.ec.local\EC_GaN_Development\R69 EPI DEVELOPMENT\DAILY RUN RECORD\'
*    TestFilename = 'Test.xlsx'
*    TestFilepath = TestDir:TestFileName   
*    FileHandle   = SRP_IO('LockFile', TestFilepath, GENERIC_READ$, FILE_SHARE_READ$, OPEN_EXISTING$)
*    If FileHandle NE FILE_ERROR$ then
*        DocObj = Excel_Services('OpenDocument', TestFilepath, 'IRMN2714')
*        Excel_Services('SetCellValue', DocObj, '8inch HELENS', 'A', 15779, 'This is a test')
*        SRP_IO('UnlockFile', FileHandle)
*        Excel_Services('SaveDocument', DocObj, TestFilepath, 'IRMN2714')
*    end else
*        ErrCode = SRP_IO('GetLastError')
*    end
* 
*    TestDir               = 'D:\FITemp\'
*    TestFilename          = '8-inch New HV Epi Development.xlsx': \00\
*    TestFilepath          = TestDir:TestFileName   
*    lpFileName            = TestFilepath            ; // File to open
*    dwDesiredAccess       = GENERIC_WRITE$          ; // File access requested
*    dwShareMode           = 0                       ; // Do not allow file sharing (i.e. block all other access until file handle is closed)
*    lpSecurityAttributes  = 0                       ; // Pointer to security structure - not needed
*    dwCreationDisposition = OPEN_EXISTING$          ; // Open the file only if it exists already, otherwise throw an error
*    dwFlagsAndAttributes  = FILE_ATTRIBUTE_NORMAL$  ; // 
*    hTemplateFile         = 0                       ; // When opening an existing file, CreateFile ignores this parameter.
*    FileHandle            = SRPWinAPI_CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)
*    If Assigned(FileHandle) then SRPWinAPI_CloseHandle(FileHandle)
*  
* return
* 
*    ADUser         = 'kirkland'
*    LSLUser        = Security_Services('GetLSLUser', ADUser)
*    Member         = MemberOf(LSLUser, 'ENGINEERING')
*    Testing        = '123'
*    TestingTesting = ''    
*    
* return
*    GaNWIPList = Database_Services('ReadDataRow', 'APP_INFO', 'GAN_WIP')
*    GaNWIPList = Delete(GaNWIPList, 1, 0, 0)
*    GaNWIPList = SRP_Array('Rotate', GaNWIPList, @FM, @VM)
*    RDSList    = GaNWIPList<2>
*    RDSList    = SRP_Array('Clean', RDSList, 'TrimAndMakeUnique', @VM)
*    
*    For each RDSNo in RDSList using @VM
*        ReactRunRec = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
*        WfrIDs      = ReactRunRec<REACT_RUN_IN_WFR_ID$>
*        WfrStages   = ReactRunRec<REACT_RUN_WFR_STAGE$>
*        For each WfrID in WfrIDs using @VM
*            Convert '*' to '.' in WfrID
*            For each WfrStage in WfrStages using @VM
*                ToolClasses     = Gan_Services('GetToolClassIDs', WfrStage)
*                If ToolClasses NE '' then
*                    InvActions      = Gan_Services('GetInvActions', WfrStage)
*                    RunStageWfrKey  = RDSNo:'*':WfrStage:'*':WfrID
*                    If RowExists('RUN_STAGE_WFR', RunStageWfrKey) then
*                        RunStageWfrRec     = Database_Services('ReadDataRow', 'RUN_STAGE_WFR', RunStageWfrKey)
*                        OrigRunStageWfrRec = RunStageWfrRec
*                        If Error_Services('NoError') then
*                            CurrToolClasses = RunStageWfrRec<RUN_STAGE_WFR_SPEC_TOOL_CLASS$>
*                            CurrInvActions  = RunStageWfrRec<RUN_STAGE_WFR_SPEC_INV_ACTION$>
*                            If CurrToolClasses NE ToolClasses then
*                                RunStageWfrRec<RUN_STAGE_WFR_SPEC_TOOL_CLASS$> = ToolClasses
*                            end
*                            If CurrInvActions NE InvActions then
*                                RunStageWfrRec<RUN_STAGE_WFR_SPEC_INV_ACTION$> = InvActions
*                            end
*                            If RunStageWfrRec NE OrigRunStageWfrRec then
*                                Database_Services('WriteDataRow', 'RUN_STAGE_WFR', RunStageWfrKey, RunStageWfrRec, True$, False$, True$)
*                            end
*                        end
*                    end
*                end
*            Next WfrStage
*        Next WfrID          
*    Next RDSNo
* 
* return
* 
*    
*    ShipNo = 155379 
*    COCRec = Database_Services('ReadDataRow', 'COC', ShipNo)
*    Set_Status(0)
*    Database_Services('WriteDataRow', 'COC', ShipNo, COCRec)
*    If Get_Status(errCode) then
*        Null
*    end
*    
* return
* 
*    WONos = 168781; ShipNos = 155376 
*    WONos<-1> = 168801; ShipNos<-1> = 155377
*    WONos<-1> = 168802; ShipNos<-1> = 155379
*    WONos<-1> = 168685; ShipNos<-1> = 155381
*    WONos<-1> = 168829; ShipNos<-1> = 155382
*    WONos<-1> = 168684; ShipNos<-1> = 155383
*    WONos<-1> = 168852; ShipNos<-1> = 155390
*    WONos<-1> = 168817; ShipNos<-1> = 155407
*    WONos<-1> = 168756; ShipNos<-1> = 155414
*    WONos<-1> = 168854; ShipNos<-1> = 155415
*    WONos<-1> = 168803; ShipNos<-1> = 155416
*    WONos<-1> = 168701; ShipNos<-1> = 155417
*    WONos<-1> = 168665; ShipNos<-1> = 155418
*    WONos<-1> = 168671; ShipNos<-1> = 155422
*    WONos<-1> = 168720; ShipNos<-1> = 155423
*    WONos<-1> = 168490; ShipNos<-1> = 155430
*    WONos<-1> = 168837; ShipNos<-1> = 155431
*    WONos<-1> = 168691; ShipNos<-1> = 155432
*    WONos<-1> = 168651; ShipNos<-1> = 155441
*    WONos<-1> = 168760; ShipNos<-1> = 155442
*    WONos<-1> = 168827; ShipNos<-1> = 155444
*    WONos<-1> = 168780; ShipNos<-1> = 155445
*    
*    FilePath = 'D:\FITemp\TSV\'
*    For each WONo in WONos using @FM setting fPos
*        ShipNo          = ShipNos<fPos>
*        PickDTM         = Xlate('COC', ShipNo, 'PICK_DTM', 'X')
*        PickDT          = OConv(Field(PickDTM, '.', 1, 1), 'D4-')
*        Year            = Field(PickDT, '-', 3, 1)
*        Month           = Field(PickDT, '-', 1, 1)
*        Day             = Field(PickDT, '-', 2, 1)
*        PickTM          = Fmt(Field(PickDTM, '.', 2, 1), 'L#6')
*        Swap ':' with '-' in PickDTM
*        TSVFile         = ''
*        SAPDeliveryNo   = Xlate('COC', ShipNo, 'SAP_DEL_NO', 'X')
*        ProdOrdNo       = Xlate('WO_LOG', WONo, 'PROD_ORD_NO', 'X')        
*        CassNos         = Xlate('COC', ShipNo, 'CASS_NO', 'X')
*        For each CassNo in CassNos using @VM setting vPos
*            WOMatKey   = WONo:'*':CassNo
*            SAPBatchNo = Xlate('WO_MAT', WOMatKey, 'SAP_BATCH_NO', 'X')
*            TSVFile   := SAPDeliveryNo : TAB$ : ProdOrdNo : TAB$ : SAPBatchNo : CRLF$
*        Next CassNo
*        Counter = Fmt(fPos, 'R(0)#3')
*        TSVFileName = 'Delivery_':Year:Month:Day:'-':PickTM:'-':Counter:'.tsv'
*        OSWrite TSVFile on FilePath:TSVFileName
*    Next WONo
* 
* return
* 
*    Set_Status(0)
*    TableKey<-1> = 155430
*    Open 'COC' to TableVar then
*        rv<-1> = Get_Status(errCode)
*        Set_Status(0)
*        READ TableRec FROM TableVar;TableKey THEN
*            rv<-1> = Get_Status(errCode)
*            Set_Status(0)
*            WRITE TableRec ON TableVar;TableKey THEN
*                
*                rv<-1> = Get_Status(errCode)
*            END ELSE
*                ErrorMsg<-1> = 'Unable to write ':QUOTE(TableKey):' on ':QUOTE(TableName):' table.'
*            end
*        end
*    end
* 
*    
* return 
*    InboundPath	= 'C:\Users\StieberD\Desktop\FTP_IN_TESTING\'
* 
*    InitDir InboundPath:'*.tsv'
*    FileList<-1> = DirList()
* 
*    FileNames<-1> = ''
*    LOOP
*        FileName<-1> = FileList[1;@FM]
*        FileList[1;Col2()]<-1> = ""
*        
*        LOCATE FileName IN FileNames BY 'AR' USING @FM SETTING Pos ELSE
*            FileNames<-1> = INSERT(FileNames;Pos;0;0;FileName)
*        END
*        
*    UNTIL FileList<-1> = ""
*    REPEAT
*    
*    IF FileNames[-1;1]<-1> = @FM THEN FileNames[-1;1]<-1> = ''
*    Test<-1> = ''
*    FileCnt<-1> = COUNT(FileNames;@FM) + (FileNames NE '')
* 
*    FOR N<-1> = 1 TO FileCnt
* 
*        FileName<-1> = FileNames<N>
*        StartTime<-1> = Time()
*        OSREAD FileIn FROM InboundPath:FileName THEN
* 
*            SWAP TAB$ WITH @VM IN FileIn
*            SWAP CRCRLF$ WITH @FM IN FileIn
*            SWAP CRLF$ WITH @FM IN FileIn
*            
*            LOOP
*                LastChar<-1> = FileIn[-1;1]
*            UNTIL LastChar NE @FM
*                FileIn[-1;1]<-1> = ''
*            REPEAT
*            
*            Error_Services('Clear')
*            RetVal<-1> = obj_Shipment('SAPCreate';FileIn)
*            
*            // If RetVal<-1> = 1 then succesful
*        END
*    NEXT N
* 
* return
* 
* 
* 
* 
* 
* 
*    WOMatKey<-1> = '168809*1'
*    WOMatRec<-1> = Database_Services('ReadDataRow'; 'WO_MAT'; WOMatKey)
*    GRProps<-1> = obj_WO_Mat('GetGRProps'; WOMatKey:@RM:WOMatRec)
*    GRWfrQty<-1> = GRProps<1>
*    ScrapQty<-1> = GRProps<2>
*    ProdTWQty<-1> = GRProps<3>
*    AvailMUWfrQty<-1> = GRProps<4>
*    MUCassIDs<-1> = GRProps<5>
*    MUCassQtys<-1> = GRProps<6>
*    String<-1> = SRPExampleDLL2()
*    DotNetHandle<-1> = StartDotNet(""; "4.0")
*    rv          <-1> = Set_Property.NET(DotNetHandle; "AssemblyName"; "ActiveDirectory.dll")
*    ADApiHandle <-1> = Create_Class.NET(DotNetHandle; "ActiveDirectory.ActiveDirectory"; 0)
*            
*    Username<-1> = "StieberD"
*    Domain  <-1> = "Infineon"
*    Groups  <-1> = Send_Message.NET(ADApiHandle; "GetADGroups"; Username:@FM:Domain; "System.String":@FM:"System.String")
*    Convert \0A\ to @FM in Groups
* 



