Edditing DS Macros
Moderators: chulett, rschirm, roy
Edditing DS Macros
I have a need to eddit the JOBCONTROL.H file to add a mutated version of the DSJobStartTimestamp to my system so that I can get the Timestamp into an acceptiable formate for a Dos Batch file that has to do a rename of a file.
The problem is that the original DSJobStartTimestamp outputs dd-mm-yyyy hh:mm:ss. File names cant have : in them so the dos batch rename job fails. Im confused as to what code language is needed to do this. This is what I tried
$IfNDef DSJobStartTimestampM
$Define DSJobStartTime DSJobStartTimestamp[1,10]:"_":DSJobStartTimestamp[12,2]:"_":DSJobStartTimestamp[16,2]:"_":DSJobStartTimestamp[20,2]
$EndIf
it looks good to me but when I try to compile the job I get the following error
Compiling: Source = 'RT_BP106/JOB.975878495.DT.1318937215.TRANS1', Object = 'RT_BP106.O/JOB.975878495.DT.1318937215.TRANS1'
*********************************************************************************************************?*****
INCLUDEd file is 'dsinclude/JOBCONTROL.H'
0333.01 $Define DSJobWaveNo DSGetJobInfo(DSJ.ME, DSJ.JOBWAVENO)
^
"DEFNAM" unexpected, Was expecting: Array Name, Variable name,
New variable name, ';', Statement label, "ABORT", "ABORTE", "ABORTM",
"BEGIN", "BREAK", "CALL", "CHAIN", "CLEAR", "CLEARCOM", "CLEARDATA",
"CLEARFILE", "CLEARPROMPTS", "CLEARSELECT", "CLOSE", "CLOSESEQ",
"COM", "COMMON", "CONVERT", "CREATE", "CRT", "DATA", "DEBUG",
"DEL", "DELETE", "DELETEU", "DIMENSION", "ECHO", "ERRMSG", "ENTER",
"EQUATE", "EXECUTE", "EXIT", "FILELOCK", "FILEUNLOCK", "FLUSH",
"FOOTING", "FOR", "GET", "GETX", "GOSUB", "GOTO", "GROUPSTORE",
"HEADING", "HEADINGE", "HEADINGN", "IF", "INPUT", "INPUTDP",
"INPUTCLEAR", "INPUTERR", "INPUTIF", "INPUTNULL", "INPUTTRAP", "INS",
"KEYEDIT", "KEYTRAP", "LET", "LOCATE", "LOCATEP", "LOCK", "LOOP",
"MAT", "MATBUILD", "MATPARSE", "MATREAD", "MATREADU", "MATWRITE",
"MATWRITEU", "NAP", "NOBUF", "NULL", "ON", "OPEN", "OPENDEV",
"OPENPATH", "OPENSEQ", "PAGE", "PERFORM", "PRECISION", "PRINT",
"PRINTER", "PRINTERIO", "PRINTERR", "PRINTERRX", "PROCREAD",
"PROCWRITE", "PROMPT", "RANDOMIZE", "READ", "READBLK", "READNEXT",
"READSEQ", "READT", "READU", "READV", "READVU", "RELEASE", "REMOVE",
"RETURN", "REWIND", "SEEK", "uSEEK", "SELECT", "SELECTN", "SELECTV",
"SELECTE", "SLEEP", "SSELECT", "SSELECTN", "SSELECTV", "STATUS",
"STOP", "STOPE", "STOPM", "STORAGE", "TABSTOP", "TTYCTL", "UNLOCK",
"WEOF", "WEOFSEQ", "WRITE", "WRITEBLK", "WRITESEQ", "WRITET",
"WRITEU", "WRITEV", "WRITEVU", "TPRINT", "INPUTDISP", "KEYEXIT",
"TIMEOUT", "FIND", "FINDSTR", "GETLIST", "DELETELIST", "READLIST",
"WRITELIST", "DECLARE", "TTYGET", "TTYSET", "HUSH", "ASSIGN",
"SELIND", "LOOPEOL", "uINPUT", "uINPUTDP", "CONTINUE", "DEFFUN",
"TRANSACTION", "OPENCHECK", "READL", "BSCAN", "REVREMOVE", "SETREM",
"AUTHORIZATION", "PCDRIVER", "READVL", "MATREADL", "RECORDLOCKL",
"RECORDLOCKU", "WRITESEQF", "WORDSIZE", "RECIO", "SETIT", "SEND",
"UPRINT", "AUXMAP"
**********
1 Errors detected, No Object Code Produced.
(Load456msg.Transformer_1)
I can only guess that it has no idea what I asked it to do in that macro file. so how is that file writen and how can i modify mine to get around my naming problem?
Jim
The problem is that the original DSJobStartTimestamp outputs dd-mm-yyyy hh:mm:ss. File names cant have : in them so the dos batch rename job fails. Im confused as to what code language is needed to do this. This is what I tried
$IfNDef DSJobStartTimestampM
$Define DSJobStartTime DSJobStartTimestamp[1,10]:"_":DSJobStartTimestamp[12,2]:"_":DSJobStartTimestamp[16,2]:"_":DSJobStartTimestamp[20,2]
$EndIf
it looks good to me but when I try to compile the job I get the following error
Compiling: Source = 'RT_BP106/JOB.975878495.DT.1318937215.TRANS1', Object = 'RT_BP106.O/JOB.975878495.DT.1318937215.TRANS1'
*********************************************************************************************************?*****
INCLUDEd file is 'dsinclude/JOBCONTROL.H'
0333.01 $Define DSJobWaveNo DSGetJobInfo(DSJ.ME, DSJ.JOBWAVENO)
^
"DEFNAM" unexpected, Was expecting: Array Name, Variable name,
New variable name, ';', Statement label, "ABORT", "ABORTE", "ABORTM",
"BEGIN", "BREAK", "CALL", "CHAIN", "CLEAR", "CLEARCOM", "CLEARDATA",
"CLEARFILE", "CLEARPROMPTS", "CLEARSELECT", "CLOSE", "CLOSESEQ",
"COM", "COMMON", "CONVERT", "CREATE", "CRT", "DATA", "DEBUG",
"DEL", "DELETE", "DELETEU", "DIMENSION", "ECHO", "ERRMSG", "ENTER",
"EQUATE", "EXECUTE", "EXIT", "FILELOCK", "FILEUNLOCK", "FLUSH",
"FOOTING", "FOR", "GET", "GETX", "GOSUB", "GOTO", "GROUPSTORE",
"HEADING", "HEADINGE", "HEADINGN", "IF", "INPUT", "INPUTDP",
"INPUTCLEAR", "INPUTERR", "INPUTIF", "INPUTNULL", "INPUTTRAP", "INS",
"KEYEDIT", "KEYTRAP", "LET", "LOCATE", "LOCATEP", "LOCK", "LOOP",
"MAT", "MATBUILD", "MATPARSE", "MATREAD", "MATREADU", "MATWRITE",
"MATWRITEU", "NAP", "NOBUF", "NULL", "ON", "OPEN", "OPENDEV",
"OPENPATH", "OPENSEQ", "PAGE", "PERFORM", "PRECISION", "PRINT",
"PRINTER", "PRINTERIO", "PRINTERR", "PRINTERRX", "PROCREAD",
"PROCWRITE", "PROMPT", "RANDOMIZE", "READ", "READBLK", "READNEXT",
"READSEQ", "READT", "READU", "READV", "READVU", "RELEASE", "REMOVE",
"RETURN", "REWIND", "SEEK", "uSEEK", "SELECT", "SELECTN", "SELECTV",
"SELECTE", "SLEEP", "SSELECT", "SSELECTN", "SSELECTV", "STATUS",
"STOP", "STOPE", "STOPM", "STORAGE", "TABSTOP", "TTYCTL", "UNLOCK",
"WEOF", "WEOFSEQ", "WRITE", "WRITEBLK", "WRITESEQ", "WRITET",
"WRITEU", "WRITEV", "WRITEVU", "TPRINT", "INPUTDISP", "KEYEXIT",
"TIMEOUT", "FIND", "FINDSTR", "GETLIST", "DELETELIST", "READLIST",
"WRITELIST", "DECLARE", "TTYGET", "TTYSET", "HUSH", "ASSIGN",
"SELIND", "LOOPEOL", "uINPUT", "uINPUTDP", "CONTINUE", "DEFFUN",
"TRANSACTION", "OPENCHECK", "READL", "BSCAN", "REVREMOVE", "SETREM",
"AUTHORIZATION", "PCDRIVER", "READVL", "MATREADL", "RECORDLOCKL",
"RECORDLOCKU", "WRITESEQF", "WORDSIZE", "RECIO", "SETIT", "SEND",
"UPRINT", "AUXMAP"
**********
1 Errors detected, No Object Code Produced.
(Load456msg.Transformer_1)
I can only guess that it has no idea what I asked it to do in that macro file. so how is that file writen and how can i modify mine to get around my naming problem?
Jim
Sure I need help....But who dosent?
Re: Edditing DS Macros
No, you don't. Not only that, but you shouldn't be doing stuff like that - IMHO, of course.JDionne wrote:I have a need to edit the JOBCONTROL.H
Why not just write a Routine to take the format coming from the DSStartJobTimestamp and manipulate it to get the output format you are looking for? Sounds to me like a simple EREPLACE could be used to change all occurances of ":" to "_" to get what you need.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Re: Edditing DS Macros
Im imputing this in the after job section of the job. Just like thischulett wrote:No, you don't. Not only that, but you shouldn't be doing stuff like that - IMHO, of course.JDionne wrote:I have a need to edit the JOBCONTROL.H
Why not just write a Routine to take the format coming from the DSStartJobTimestamp and manipulate it to get the output format you are looking for? Sounds to me like a simple EREPLACE could be used to change all occurances of ":" to "_" to get what you need.
call \\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat #DSJobStartTimestamp#
how do u put in a routine here?
Jim
Sure I need help....But who dosent?
Re: Edditing DS Macros
Well, there... you can't. If this is a parameter to your job, do you have an opportunity to manipulate it before the point you use it in your after-job? Or is there a way to do the substitution inside your "456Move.bat"? I'm not that familiar with your options under Windows.JDionne wrote:Im imputing this in the after job section of the job. Just like this
call \\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat #DSJobStartTimestamp#
how do u put in a routine here?
You could also write a routine (make sure you select 'Before/After Subroutine') that takes your timestamp in as a parameter, does the EREPLACE and then calls "DSExecute" to run your batch. You would then be able to run the routine in your after job.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Re: Edditing DS Macros
DOS does not allow substrings or any fancy manipulation of variables.chulett wrote:Well, there... you can't. If this is a parameter to your job, do you have an opportunity to manipulate it before the point you use it in your after-job? Or is there a way to do the substitution inside your "456Move.bat"? I'm not that familiar with your options under Windows.JDionne wrote:Im imputing this in the after job section of the job. Just like this
call \\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat #DSJobStartTimestamp#
how do u put in a routine here?
You could also write a routine (make sure you select 'Before/After Subroutine') that takes your timestamp in as a parameter, does the EREPLACE and then calls "DSExecute" to run your batch. You would then be able to run the routine in your after job.
I have writen a "Before/After" job with the following code
ErrorCode = 0 ;* set this to non-zero to stop the stage/job
InputArg = Ereplace(Ereplace(TimeDate(),":","_")," ","_")
Two questions, when i run this as a transform routine to check it it only gives me a 0 when I run it through a test so does that mean that the code is wrong?
and second the DSExecute step...do I need that in the routine? Is that what will call the dos batch file?
Jim
Sure I need help....But who dosent?
FYI, TimeDate() gives you output in a little different format than your original JobStartTimestamp - "09:59:51 03 JUN 1997", to quote from the Help.
I couldn't help with the Transform routine unless I can see the entire routine, including what it passes back as 'Ans'.
And yes, you can add a call to DSExecute to have it run your batch file from inside the routine. That way you could log the results and check for any errors when it runs, if you wanted to.
I couldn't help with the Transform routine unless I can see the entire routine, including what it passes back as 'Ans'.
And yes, you can add a call to DSExecute to have it run your batch file from inside the routine. That way you could log the results and check for any errors when it runs, if you wanted to.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
The propblem with using JobStartTimestamp is that using it like this:chulett wrote:FYI, TimeDate() gives you output in a little different format than your original JobStartTimestamp - "09:59:51 03 JUN 1997", to quote from the Help.
I couldn't help with the Transform routine unless I can see the entire routine, including what it passes back as 'Ans'.
And yes, you can add a call to DSExecute to have it run your batch file from inside the routine. That way you could log the results and check for any errors when it runs, if you wanted to.
ErrorCode = 0 ;* set this to non-zero to stop the stage/job
Ans = InputArg = Ereplace(Ereplace(JobStartTimestamp,":","_")," ","_")
give me the following error when it is compiled:
Compiling: Source = 'DSU_BP/DSU.CorrectedTimeStamp', Object = 'DSU_BP.O/DSU.CorrectedTimeStamp'
WARNING: Variable 'JobStartTimestamp' never assigned a value.
Compilation Complete.
This is probably due to a miss use on my part, but from reading the help file this seems to be the way that it is needed.
Also the code above is all thaT I have for the routine...again im sorta reading the help docs and fumbeling through this. Any direction would be great.
Jim
Sure I need help....But who dosent?
It's DSJobStartTimestamp.
Something quick for you to expand on:
The array "ScreenOutput" will capture whatever the batch file echoes out when it runs. You could also pass CmdReturnCode out as "Ans" if you wanted to check success outside of the routine.
Something quick for you to expand on:
Code: Select all
FileName = Ereplace(Ereplace(DSJobStartTimestamp,":","_")," ","_")
CmdString = "\\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat ":FileName
Call DSExecute("NT",CmdString,ScreenOutput,CmdReturnCode)
If CmdReturnCode <> 0 Then
<something bad happened>
End
Ans = 0
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
I feel stupid but where is the option to run this routine after the job is done. I see plenty of places for on completion run sub routines...but im comfused...as usual.chulett wrote:It's DSJobStartTimestamp.
Something quick for you to expand on:The array "ScreenOutput" will capture whatever the batch file echoes out when it runs. You could also pass CmdReturnCode out as "Ans" if you wanted to check success outside of the routine.Code: Select all
FileName = Ereplace(Ereplace(DSJobStartTimestamp,":","_")," ","_") CmdString = "\\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat ":FileName Call DSExecute("NT",CmdString,ScreenOutput,CmdReturnCode) If CmdReturnCode <> 0 Then <something bad happened> End Ans = 0
Jim
Sure I need help....But who dosent?
this error may be whats going on
Compiling: Source = 'DSU_BP/DSU.CorrectedTimeStamp', Object = 'DSU_BP.O/DSU.CorrectedTimeStamp'
*
WARNING: Variable 'DSJobStartTimestamp' never assigned a value.
Compilation Complete.
this is the code that im tring to compile
ErrorCode = 0 ;* set this to non-zero to stop the stage/job
FileName = Ereplace(Ereplace(DSJobStartTimestamp,":","_")," ","_")
CmdString = "\\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat ":FileName
Call DSExecute("NT",CmdString,ScreenOutput,CmdReturnCode)
If CmdReturnCode <> 0 Then
Ans = "ERROR" : CmdReturnCode
End
Ans = 0
Jim
Compiling: Source = 'DSU_BP/DSU.CorrectedTimeStamp', Object = 'DSU_BP.O/DSU.CorrectedTimeStamp'
*
WARNING: Variable 'DSJobStartTimestamp' never assigned a value.
Compilation Complete.
this is the code that im tring to compile
ErrorCode = 0 ;* set this to non-zero to stop the stage/job
FileName = Ereplace(Ereplace(DSJobStartTimestamp,":","_")," ","_")
CmdString = "\\scrbbususcnc04\ETL_Processes\456msg\Batch_files\456Move.bat ":FileName
Call DSExecute("NT",CmdString,ScreenOutput,CmdReturnCode)
If CmdReturnCode <> 0 Then
Ans = "ERROR" : CmdReturnCode
End
Ans = 0
Jim
Sure I need help....But who dosent?
No worries.JDionne wrote:I feel stupid but where is the option to run this routine after the job is done. I see plenty of places for on completion run sub routines...but im comfused...as usual.
As long as you've declared it a 'Before/After Subroutine' instead of a 'Transform Function' Routine when you created it, it will automatically show up in the drop-down list on the Job Properties page.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Ya i did do that, but i still get that error when I try to compile it, does that error mean that its not fully compiled and thus will not show up in the drop down?chulett wrote:No worries.JDionne wrote:I feel stupid but where is the option to run this routine after the job is done. I see plenty of places for on completion run sub routines...but im comfused...as usual.
As long as you've declared it a 'Before/After Subroutine' instead of a 'Transform Function' Routine when you created it, it will automatically show up in the drop-down list on the Job Properties page.
Jim
Sure I need help....But who dosent?
You need to add this at the top of the routine to get it to compile:
Also note that your error will never get passed out if there's a problem. You need to add an 'else' in there.
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
I took that IF then stuff out just to test....AND IT WORKED!!!!!chulett wrote:You need to add this at the top of the routine to get it to compile:
Also note that your error will never get passed out if there's a problem. You need to add an 'else' in there.Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
Tomorrow ill get the error traping in
thanx for the help
Jim
Sure I need help....But who dosent?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
It's better (more "bullet proof") to guard against redefinition of constants. The token JOBCONTROL.H is defined in the JOBCONTROL.H header file. I always use the following.chulett wrote:You need to add this at the top of the routine to get it to compile:
Also note that your error will never get passed out if there's a problem. You need to add an 'else' in there.Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
Code: Select all
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.