Image not found Collapse All | Expand All | Show Default


KgdStopSeq
DataStage Routine Report
Generated 2004-07-11 09:47:08pm


 - Routine Information  

Property Value
SubType Transform Function 
Category KimD 
Author Kim Duke 
Arg Count
Version 2.0.0 
Routine Type
Short Description This will stop all jobs in a sequence 
Long Description Routine: KgdStopSeq
=================================================================
Description:
This will stop all jobs in a sequence.
=================================================================
Arguments:
1. SeqName
=================================================================
Modification History
=================================================================
Developer Date Modification description
======== ========= ==============================================
kduke 2004-05-01 created
======== ========= ==============================================
 


 - Arguments  

Argument Description
SeqName Job sequence name


 - Source Code  

LineNo Source Code
1 FUNCTION KgdStopSeq(SeqName)
2 * ------------------------------------------------------------
3 * KgdStopSeq(SeqName)
4 * Decription: This routine will stop all jobs in a sequence
5 * Written by: Kim Duke
6 * ------------------------------------------------------------
7 $INCLUDE DSINCLUDE JOBCONTROL.H
8 * ------------------------------------------------------------
9        Ans = ""
10        open 'DS_JOBS' to DsJobs else
11           ErrMsg = "Error: Unable to open DS_JOBS"
12           goto ErrRtn
13        end
14 * ------------------------------------------------------------
15 * Get JobNo
16 * ------------------------------------------------------------
17        read JobRec from DsJobs, SeqName else
18           ErrMsg = 'Error: ':SeqName:' not a valid Job'
19           goto ErrRtn
20        end
21        JobNo = JobRec<5>
22        open 'DS_JOBOBJECTS' to DsJobObjects else
23           ErrMsg = "Error: Unable to open DS_JOBOBJECTS"
24           goto ErrRtn
25        end
26        ObjId = 'J\':JobNo:'\ROOT'
27        read ObjRec from DsJobObjects, ObjId then
28           JobType = ObjRec<40>
29           if JobType <> '2' then
30              ErrMsg = 'Error: ':SeqName:' not a Job Sequence'
31              goto ErrRtn
32           end
33           Cnt = 0
34 * ------------------------------------------------------------
35 * loop thru dependent job names
36 * ------------------------------------------------------------
37           NoJobs = dcount(ObjRec<31>, @VM)
38           for i = 1 to NoJobs
39              DependJob = ObjRec<31,i>
40              DependType = ObjRec<32,i>
41              if DependType = '0' then
42                 Cnt += 1
43 * ------------------------------------------------------------
44 * attach, get status, stop job
45 * ------------------------------------------------------------
46                 RunHandle = DSAttachJob(JobName, DSJ.ERRNONE)
47                 JStat = DSGetJobInfo(RunHandle, DSJ.JOBSTATUS)
48 * ------------------------------------------------------------
49                 ContinueFlag = @true
50                 begin case
51                    case JStat = 0
52                       JobStatus = 'Running'
53                       JStat = DSStopJob(RunHandle)
54                    case JStat = 1
55                       JobStatus = 'Finished'
56                    case JStat = 2 ; * Finished with warnings
57                       JobStatus = 'Finished (see log)'
58                    case JStat = 3
59                       ContinueFlag = @false
60                       JobStatus = 'Aborted'
61                    case JStat = 11 or JStat = 7
62                       JobStatus = 'Validated OK'
63                    case JStat = 12 ; * Validated with warnings
64                       JobStatus = 'Validated (see log)'
65                    case JStat = 13 or JStat = 8
66                       ContinueFlag = @false
67                       JobStatus = 'Failed validation'
68                    case JStat = 21 or JStat = 9
69                       JobStatus = 'Has been reset'
70                    case JStat = 96
71                       ContinueFlag = @false
72                       JobStatus = 'Aborted'
73                    case JStat = 97
74                       * ContinueFlag = @false
75                       JobStatus = 'Stopped'
76                    case JStat = 98
77                       JobStatus = 'Finished'
78                    case JStat = 99
79                       JobStatus = 'Compiled'
80                    case @true
81                       ContinueFlag = @false
82                       JobStatus = 'Not Compiled'
83                 end case
84                 if ContinueFlag then
85                    JStat = DSStopJob(RunHandle)
86                 end
87                 JStat = DSDetachJob(RunHandle)
88              end
89           next i
90        end else
91           ErrMsg = 'Error: ':SeqName:' not a valid Job'
92           goto ErrRtn
93        end
94        Ans = JobStatus
95        goto TheEnd
96 * ------------------------------------------------------------
97 ErrRtn:
98        Ans = ErrMsg
99 * ------------------------------------------------------------
100 TheEnd:
101  
102  
103 RETURN(Ans)






Ascential and DataStage are trademarks of Ascential Software Corporation or its affiliates and may be registered in the United States or other jurisdictions.
Not for resale. For questions or comments regarding KgdGenHtml, contact kim_g_duke@hotmail.com.