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
Routine help needed
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
After GoSub RunNTCmd there is nothing to prevent your code falling through the RunNTCmd code again.
You need to branch away. Perhaps a GoTo NormalExit or RETURN immediately following the GoSub statement.
You need to branch away. Perhaps a GoTo NormalExit or RETURN immediately following the GoSub statement.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: