Image not found Collapse All | Expand All | Show Default


KgdSortMetadata
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 kduke 2004-05-01 created  
Long Description Routine: KgdSortMetadata
=================================================================
Description:
This will sort metadata by column name in DS_METADATA.
=================================================================
Arguments:
1. DsMetadataId
=================================================================
Modification History
=================================================================
Developer Date Modification description
======== ========= ==============================================
kduke 2004-05-01 created
======== ========= ==============================================
 


 - Arguments  

Argument Description
DsMetadataId Id to DS_METADATA like 'AdSalesDWH\MSDV\DAY_DIM' or 'PlugIn\ORAOCI8\DAY_DIM'


 - Source Code  

LineNo Source Code
1 FUNCTION KgdSortMetadata(DsMetadataId)
2 * ------------------------------------------------------------
3 * KgdSortMetadata(DsMetadataId)
4 * Decription: This will sort metadata by column name in DS_METADATA
5 * Written by: Kim Duke
6 * ------------------------------------------------------------
7 $INCLUDE DSINCLUDE JOBCONTROL.H
8 * ------------------------------------------------------------
9        Ans = ""
10        open 'DS_METADATA' to DsMetadata else
11           ErrMsg = "Error: Unable to open DS_METADATA"
12           goto ErrRtn
13        end
14 * ------------------------------------------------------------
15 * Get JobNo
16 * ------------------------------------------------------------
17        read DsMetadataRec from DsMetadata, DsMetadataId else
18           ErrMsg = 'Error: ':DsMetadataId:' not a valid DS_METADATA ID'
19           goto ErrRtn
20        end
21        NewId = 'Sorted\' : field(DsMetadataId, '\',2,99)
22        NewRec = DsMetadataRec
23        NoOfFields = dcount(DsMetadataRec, @FM)
24        NoOfColumns = dcount(DsMetadataRec<12>, @VM)
25        for j=12 to NoOfFields
26           if dcount(DsMetadataRec<j>, @VM)>1 then
27              NewRec<j> = DsMetadataRec<j, 1>
28           end
29        next j
30        for i=2 to NoOfColumns
31           ColumnName = DsMetadataRec<12, i>
32           locate ColumnName in NewRec<12> by 'AL' setting MvNo else
33              ins ColumnName before NewRec<12, MvNo>
34              for j=13 to NoOfFields
35                 if dcount(DsMetadataRec<j>, @VM)>1 then
36                    ins '1' before NewRec<j, MvNo>
37                    NewRec<j, MvNo> = DsMetadataRec<j, i>
38                 end
39              next j
40           end
41        next i
42        write NewRec on DsMetadata, NewId else
43           ErrMsg = "Error: Unable to write new rec: ":NewId
44           goto ErrRtn
45        end
46        Ans = NewId:" written to DS_METADATA"
47        goto TheEnd
48 * ------------------------------------------------------------
49 ErrRtn:
50        Ans = ErrMsg
51 * ------------------------------------------------------------
52 TheEnd:
53        print Ans
54  
55 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.