Routine help needed
Posted: Wed Sep 03, 2008 8:55 pm
Hi,
I am far from good in writing routines and was hopeful somebody could tell me why is it that the I get my file twice written to?
2 arguments passed to a routine are: InputArg and ErrorCode
InputArg = "echo 'test line' >> target file"
The routine's code is as follows:
___________________________________________________________
Deffun DSRMessage(A1, A2, A3) Calling "*DataStage*DSR_MESSAGE"
Equate RoutineName To "ExecDOS"
* If InputArg is empty, log a Warning-type message and return
If Trim(InputArg) = "" Then
Message = DSRMessage("DSTAGE_TRX_E_0011", "No command to execute.", "")
GoTo ErrorExit
End
vCmd = InputArg
GoSub RunNTCmd
* Sub routine
*==============================================
RunNTCmd:
vMessage = "RunNTCmd: " : vCmd
*Call DSLogInfo(vMessage, "JobControl")
Call DSExecute("NT", vCmd, vOut, vRet)
vMessage = "NT Cmd = " : vCmd : @FM : "Return Code = " : vRet : @FM : "Output = " : vOut
If vRet = 0 then
vMessage = "NT Command Successful ":@FM:vMessage
*Call DSLogInfo(vMessage,"JobControl")
End Else
vMessage = "NT Command Failed " : Dquote(vRet) : @FM : vMessage
*Call DSLogWarn(vMessage, "JobControl")
End
* Exit with no error.
ErrorCode = 0
GoTo NormalExit
* Exit with error, logging warning message first.
ErrorExit:
Call DSLogWarn(Message, RoutineName)
ErrorCode = 1
NormalExit:
After I run this my file will contain :
test line
test line
Regards,
Novak
I am far from good in writing routines and was hopeful somebody could tell me why is it that the I get my file twice written to?
2 arguments passed to a routine are: InputArg and ErrorCode
InputArg = "echo 'test line' >> target file"
The routine's code is as follows:
___________________________________________________________
Deffun DSRMessage(A1, A2, A3) Calling "*DataStage*DSR_MESSAGE"
Equate RoutineName To "ExecDOS"
* If InputArg is empty, log a Warning-type message and return
If Trim(InputArg) = "" Then
Message = DSRMessage("DSTAGE_TRX_E_0011", "No command to execute.", "")
GoTo ErrorExit
End
vCmd = InputArg
GoSub RunNTCmd
* Sub routine
*==============================================
RunNTCmd:
vMessage = "RunNTCmd: " : vCmd
*Call DSLogInfo(vMessage, "JobControl")
Call DSExecute("NT", vCmd, vOut, vRet)
vMessage = "NT Cmd = " : vCmd : @FM : "Return Code = " : vRet : @FM : "Output = " : vOut
If vRet = 0 then
vMessage = "NT Command Successful ":@FM:vMessage
*Call DSLogInfo(vMessage,"JobControl")
End Else
vMessage = "NT Command Failed " : Dquote(vRet) : @FM : vMessage
*Call DSLogWarn(vMessage, "JobControl")
End
* Exit with no error.
ErrorCode = 0
GoTo NormalExit
* Exit with error, logging warning message first.
ErrorExit:
Call DSLogWarn(Message, RoutineName)
ErrorCode = 1
NormalExit:
After I run this my file will contain :
test line
test line
Regards,
Novak