100% found this document useful (1 vote)
881 views9 pages

Datastage Functions and Routines

$Define Defines identifiers that control program compilation or supplies replacement text for an identifier. $Include Inserts source code contained in a separate file and compiles it along with the main program.

Uploaded by

sreehare
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
881 views9 pages

Datastage Functions and Routines

$Define Defines identifiers that control program compilation or supplies replacement text for an identifier. $Include Inserts source code contained in a separate file and compiles it along with the main program.

Uploaded by

sreehare
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

Datastage functions and routines

$Define Defines identifiers that control program compilation or supplies replacement text for an identifier. $IfDef Tests an identifier to see if it is defined or not defined. $IfNDef Tests an identifier to see if it is defined or not defined. $Include Inserts source code contained in a separate file and compiles it along with the main program. $Undefine Removes an identifier that was set using the $Define statement. If no identifier is set, $Undefine has no effect. Abs Returns the absolute (unsigned) value of a number. ACos returns the arc-cosine of number in degrees. ACos is the inverse of Cos. Alpha Checks if a string is alphabetic. If NLS is enabled, the result of this function is dependent on the current locale setting of the Ctype convention. Ascii Converts the values of characters in a string from EBCDIC to ASCII. ASin returns the arc-sine of number in degrees. ASin is the inverse of Sin. ATan returns the arc-tangent of number in degrees. ATan is the inverse of Tan. BitAnd compares two integers bit by bit. For each bit, it returns bit 1 if both bits are 1; otherwise it returns bit 0. BitNot inverts the bits in an integer, that is, changes bit 1 to bit 0, and vice versa. If bit.number is specified, that bit is inverted; otherwise all bits are inverted. BitOr compares two integers bit by bit. For each bit, it returns bit 1, if either or both bits is 1; otherwise it returns bit 0. BitReset resets the specified bit to 0. If it is already 0, it is not changed. BitSet sets the specified bit to 1. If it is already 1, it is not changed. BitTest tests if the specified bit is set. It returns 1 if the bit is set; 0 if it is not. BitXOr

compares two integers bit by bit. For each bit, it returns bit 1 if only one of the two bits is 1; otherwise it returns bit 0. Byte Lets you build a string byte by byte. ByteLen Returns the length of a string in bytes ByteType Determines the internal function of a particular byte. ByteVal Determines the value of a particular byte in a string. Call Calls a subroutine. Case Alters the sequence of execution in the program according to the value of an expression. Cats Concatenates two strings. Change Replaces one or more instances of a substring. Char Generates an ASCII character from its numeric code value. Checksum Returns a checksum value for a string. CloseSeq Closes a file after sequential processing. Col1 Returns the character position preceding the substring specified in the most recently executed Field function. Col2 Returns the character position following the substring specified in the most recently executed Field function. Common Defines a common storage area for variables. Compare Compares two strings. If NLS is enabled, the result of this function depends on the current locale setting of the Collate convention. Convert Replaces every instance of specified characters in a string with substitute characters. Cos returns the cosine of an angle. number is the number of degrees in the angle. Cos is the inverse of ACos. CosH returns the hyperbolic cosine of an angle. number is the number of degrees in the angle. Count Counts the number of times a substring occurs in a string. CRC Returns a 32-bit cyclic redundancy check value for a string.

CRC32 Returns a 32-bit cyclic redundancy check value for a string. Date Returns a date in its internal system format. DCount Counts delimited fields in a string. Deffun Defines a user-written function. Dimension Defines the dimensions of one or more arrays. Div Divides one number by another. DownCase Converts uppercase letters in a string to lowercase. If NLS is enabled, the result of this function depends on the current locale setting of the Ctype convention. DQuote Encloses a string in double quotation marks. DSAttachJob Attaches to a job in order to run it in job control sequence. A handle is returned which is used for addressing the job. There can only be one handle open for a particular job at any one time. DSCheckRoutine Checks if a BASIC routine is cataloged, either in the VOC as a callable item, or in the global catalog space. DSDetachJob This routine is used to give back a JobHandle acqu DSExecute Executes a DOS or DataStage Engine command from a before/after subroutine. DSGetJobInfo Provides a method of obtaining information about a job, which can be used generally as well as for job control. It can refer to the current job or a controlled job, depending on the value of JobHandle. DSGetLinkInfo Provides a method of obtaining information about a link on an active stage, which can be used generally as well as for job control. This routine may reference either a controlled job or the current job, depending on the value of JobHandle. DSGetLogEntry This function is used to read the full event details given in EventId. DSGetLogSummary Returns a list of short log event details. The details returned are determined by the setting of some filters. (Care should be taken with the setting of the filters, otherwise a large amount of information can be returned.) DSGetNewestLogId This function is used to get the ID of the most recent log event in a particular category, or in any category. DSGetParamInfo

This function provides a method of obtaining information about a parameter, which can be used generally as well as for job control. This routine may reference either a controlled job or the current job, depending on the value of JobHandle. DSGetProjectInfo Provides a method of obtaining information about the current project. DSGetStageInfo Provides a method of obtaining information about a stage, which can be used generally as well as for job control. It can refer to the current job, or a controlled job, depending on the value of JobHandle. DSGetStageLinks Returns a field mark delimited list containing the names of all of the input/output links of the specified stage. DSLogEvent This function is used to log an event message to a job other than the current one. (Use DSLogInfo, DSLogFatal, or DSLogWarn to log an event to the current job.) DSLogFatal Logs a fatal error message in a job's log file and aborts the job. DSLogInfo Logs an information message in a job's log file. DSLogToController This routine may be used to put an info message in the log file of the job controlling this job, if any. If there isn't one, the call is just ignored. DSLogWarn Logs a warning message in a job's log file. DSMakeJobReport Generates a string describing the complete status of a valid attached job. DSMakeMsg Insert arguments into a message template. Optionally, it will look up a template ID in the standard DataStage messages file, and use any returned message template instead of that given to the routine. DSPrepareJob Used to ensure that a compiled job is in the correct state to be run or validated. DSRunJob Used to start a job running. Note that this call is asynchronous; the request is passed to the run-time engine, but you are not informed of its progress. DSSendMail This DSSetGenerateOpMetaData Use this to specify whether the job generates operational meta data or not. This overrides the default setting for the project. In order to generate operational meta data the Process MetaBroker must be installed on your DataStage machine. DSSetJobLimit By default a controlled job inherits any row or warning limits from the controlling job. These can, however, be overridden using the DSSetJobLimit function. DSSetParam

Used to specify job parameter values prior to running a job. Any parameter not set will be defaulted. DSSetUserStatus This routine applies only to the current job, and does not take a JobHandle parameter. It can be used by any job in either a JobControl or After routine to set a termination code for interrogation by another job. In fact, the code may be set at any poin DSStopJob This routine should only be used after a DSRunJob has been issued. It immediately sends a Stop request to the run-time engine. DSTransformError Logs a warning message to a job log file. Called from transforms only. DSTranslateCode Converts a job control status or error code into an explanatory text message. DSWaitForFile Suspend a job until a named file either exists or does not exist. DSWaitForJob This function is only valid if the current job has issued a DSRunJob on the given JobHandle. It returns if that job has started since the last DSRunJobwas issued on it and si Dtx Converts a decimal integer to hexadecimal. Ebcdic Converts the values of characters in a string from ASCII to EBCDIC format. Else Define several blocks of statements and the conditions that determine which block is executed. You can use a single line syntax or multiple lines in a block. End Indicates the end of a program, a subroutine, or a block of statements. Equate Equates a value to a symbol or a literal string during compilation. Ereplace Replaces one or more instances of a substring. Exchange Replaces a character in a string. Exit Define a program loop. Exp Returns the value of "e" raised to the specified power. Field Returns delimited substrings in a string. FieldStore Modifies character strings by inserting, deleting, or replacing fields separated by specified delimiters. Fix

Use the FIX function to convert a numeric value to a floatin-point number with a specified precision. FIX lets you control the accuracy of computation by eliminating excess or unreliable data from numeric results. Fmt Formats data for output. FmtDP In NLS mode, formats data in display positions rather than by character length. Fold Folds strings to create substrings. FoldDP In NLS mode, folds strings to create substrings using character display positions. For Create a ForNext program loop. GetLocale In NLS mode, retrieves the current locale setting for a specified category. GoSub Transfers program control to an internal subroutine. GoTo Transfers program control to the specified statement. Iconv Converts a string to an internal storage format. If Execute one or more statements conditionally. You can use a single line syntax or multiple lines in a block. Index Returns the starting position of a substring. InMat Retrieves the dimensions of an array, or determines if a Dim statement failed due to insufficient memory. Int Returns the integer portion of a numeric expression. IsNull Tests if a variable contains a null value. Left Extracts a substring from the start of a string. Len Returns the number of characters in a string. LenDP In NLS mode, returns the length of a string in display positions. Ln Calculates the natural logarithm of the value of an expression, using base "e". Locate Use a LOCATE statement to search dynamic.array for expression and to return a value Loop Define a program loop. Mat

Assigns values to the elements of an array. Match Compares a string with a format pattern. If NLS is enabled, the result of a match operation depends on the current locale setting of the Ctype and Numeric conventions. MatchField Searches a string and returns the part of it that matches a pattern element. Mod Returns the remainder after a division operation. Nap Pauses a program for the specified number of milliseconds. Neg Returns the inverse of a number. Next Create a ForNext program loop. Not Inverts the logical result of an expression. Null Performs no action and generates no object code. Num Determines whether a string is numeric. If NLS is enabled, the result of this function depends on the current locale setting of the Numeric convention. Oconv Converts an expression to an output format. On Transfer program control to an internal subroutine. OpenSeq Opens a file for sequential processing. Pwr Raises the value of a number to the specified power. Quote Encloses a string in double quotation marks. Randomize Generates a repeatable sequence of random numbers in a specified range. ReadSeq Reads a line of data from a file opened for sequential processing. Real Use the REAL function to convert number into a floating-point number without loss of accuracy. If number evaluates to the null value, null is returned. Repeat Define a program loop. Return Ends a subroutine and returns control to the calling program or statement. Right Extracts a substring from the end of a string. Rnd Generates a random number.

Seq Converts an ASCII character to its numeric code value. SetLocale In NLS mode, sets a locale for a specified category. Sin returns the sine of an angle. number is the number of degrees in the angle. Sin is the inverse of ASin. SinH returns the hyperbolic sine of an angle. number is the number of degrees in the angle. Sleep Pauses a program for the specified number of seconds. Soundex Generates codes that can be used to compare character strings based on how they sound. Space Returns a string containing the specified number of blank spaces. Sqrt Returns the square root of a number. SQuote Encloses a string in single quotation marks. Status Returns a code that provides information about how a preceding function was executed. Str Composes a string by repeating the input string the specified number of times. Substring Returns a substring of a string. Substrings Returns a substring of a string. Tan returns the hyperbolic tangent of an angle. number is the number of degrees in the angle. TanH returns the hyperbolic tangent of an angle. number is the number of degrees in the angle. Then Execute one or more statements conditionally. You can use a single line syntax or multiple lines in a block. Time Returns the internal system time. TimeDate Returns the system time and date. If NLS is enabled, the result of this function depends on the current locale setting of the Time convention. Trim Trims unwanted characters from a string. TrimB Trims trailing spaces from a string. TrimF Trims leading spaces and tabs from a string. UniChar

In NLS mode, generates a single character in Unicode format. UniSeq In NLS mode, converts a Unicode character to its equivalent decimal value. Until Define a program loop. UpCase Changes lowercase letters in a string to uppercase. If NLS is enabled, the result of this function depends on the current locale setting of the Ctype convention. WEOFSeq Writes an end-of-file mark in an open sequential file. While Define a program loop. WriteSeq Writes a new line to a file that is open for sequential processing and advances a pointer to the next position in the file. WriteSeqF Writes a new line to a file that is open for sequential processing, advances a pointer to the next position in the file, and saves the file to disk. Xtd Converts a hexadecimal string to decimal. Copyright , Rob Vonk.

Common questions

Powered by AI

Control flow functions such as For, While, and If in DataStage provide essential advantages by structuring the program logic into manageable blocks, enabling iterative operations, and making conditional decisions. The For function facilitates iteration with a predefined beginning and end, suitable for loops with a known number of cycles. The While function supports loops that continue based on a given condition, useful for processes that require repeated execution until a condition changes. The If function empowers branching logic, allowing the execution of statements based on conditions. Together, these functions enhance code clarity, efficiency, and adaptability in complex data processing tasks .

In DataStage, National Language Support (NLS) affects the behavior of functions like Alpha and Compare by making their results dependent on the current locale settings. For the Alpha function, which checks if a string is alphabetic, its behavior changes based on the locale settings of the Ctype convention. Similarly, the Compare function's result varies with the Collate convention setting under NLS, affecting how strings are compared based on locale-specific sorting rules. This ensures that functions are compatible with different languages and cultural conventions .

The Abs function in DataStage returns the absolute (unsigned) value of a number. This means that when applied to both positive and negative values, it will return the non-negative version of that value. For instance, Abs(-10) would return 10, and Abs(10) would also return 10, removing any sign from the input number .

The $Define directive in DataStage is used to define identifiers that control program compilation or provide replacement text for an identifier. It essentially acts as a macro preprocessing feature that helps in setting up compilation directives. This directive plays a crucial role in controlling how the code is compiled by allowing conditional compilation and inclusion of specific code snippets or definitions based on the presence or value of these identifiers .

Using DSStopJob immediately after DSRunJob in a DataStage job sequence can be counterproductive unless specifically intended to halt a job shortly after starting it. DSRunJob asynchronously starts the job, passing the execution request to the run-time engine without immediate feedback about its progress. Following it immediately with DSStopJob effectively sends a command to stop the job soon after it begins running. This sequence should typically be used in testing scenarios where job start-stop behavior needs to be verified or in situations where an immediate stop is needed due to preliminary checks or conditions being unmet after the run command .

The $Include directive in DataStage is used to insert source code from a separate file into the main program during compilation. This facilitates modular programming by allowing reusable code blocks to be maintained separately and included as needed. It contributes to better source code management by promoting reusability and reducing redundancy, thereby making the code easier to maintain and understand .

The DSSetParam function is employed in DataStage to specify values for job parameters prior to executing a job. Any parameter not explicitly set by DSSetParam will default to its pre-assigned value. This function is crucial for dynamic job configurations where parameter values need to be adjusted based on current conditions or external inputs, allowing for flexible and adaptable job execution. Using DSSetParam ensures that jobs run with the correct parameters tailored to the specific context of each execution .

The Dim statement in DataStage is used to define the dimensions of one or more arrays, effectively determining the amount of memory allocated for these arrays. By specifying the size and potentially the shape of the arrays, it initializes them for use in the program. Proper use of the Dim statement can optimize memory management by allocating only the necessary space required for the arrays, thus preventing inefficient memory use that could arise from overly large array declarations .

DSLogInfo and DSLogFatal serve different purposes in DataStage logging mechanisms. DSLogInfo is used to log informational messages within a job's log file, typically documenting the progress or status of the job without affecting its execution. On the other hand, DSLogFatal logs a fatal error message and immediately aborts the job, signaling a critical failure that prevents the job from continuing. DSLogInfo should be used for regular logging of job activity, while DSLogFatal is appropriate for conditions that should halt the job due to unexpected, irrecoverable issues .

The DSWaitForFile function is particularly useful in scenarios where a DataStage job depends on the presence or absence of a specific file to proceed. This function suspends the job until the specified file either exists or does not exist, making it crucial for synchronizing job execution with external processes that produce, modify, or delete files. For example, when a job depends on input data files generated by another system, DSWaitForFile can prevent the DataStage job from starting until the required files are available, thus ensuring data consistency and reducing errors in data processing .

You might also like