Deletion of output file
Moderators: chulett, rschirm, roy
DSguru2B,
I need some information on COMMON variables for the same issue. Let me know whether following works or not:
Data for the target sequential file stages is passed through the Transformer stage. In the constraints section of the file stage, I called the following routine. If the routine returned value is 1, then that record will be inserted in the file else, rejected.
Routine name: mstat
IF Len(EndDate)=0 THEN
Ans = 0
END ELSE
IF (Iconv(Field(CurrentDate," ",1),"D-DMY[2,2,4]") - Iconv(Field(EndDate," ",1),"D-YMD[4,2,2]")) < 0 THEN
Ans = 0
END ELSE
Ans = 1
End
END
So, I know when the record is going to be inserted in the file. So can I use a counter in this routine, whenever the returned value is 1 (Ans=1), counter will be incremented by 1.
For deleting the empty file, I can have a after-job routine. In this, if I can get access to this counter (final) value, I can check whether this = 0 or not. If it's zero, I can delete the file by creating the following routine (with COMMON Variables):
COMMON ..................
If Counter = 0 Then
Command = 'Erase "':MoutDir:'\':WarnFileName:'.':dttm:'.war.csv"'
Call DSExecute("NT", Command, Output, SystemReturnCode)
End
End
Please advise me on this.
Also let me know status function, which Ray had created earlier.
I need some information on COMMON variables for the same issue. Let me know whether following works or not:
Data for the target sequential file stages is passed through the Transformer stage. In the constraints section of the file stage, I called the following routine. If the routine returned value is 1, then that record will be inserted in the file else, rejected.
Routine name: mstat
IF Len(EndDate)=0 THEN
Ans = 0
END ELSE
IF (Iconv(Field(CurrentDate," ",1),"D-DMY[2,2,4]") - Iconv(Field(EndDate," ",1),"D-YMD[4,2,2]")) < 0 THEN
Ans = 0
END ELSE
Ans = 1
End
END
So, I know when the record is going to be inserted in the file. So can I use a counter in this routine, whenever the returned value is 1 (Ans=1), counter will be incremented by 1.
For deleting the empty file, I can have a after-job routine. In this, if I can get access to this counter (final) value, I can check whether this = 0 or not. If it's zero, I can delete the file by creating the following routine (with COMMON Variables):
COMMON ..................
If Counter = 0 Then
Command = 'Erase "':MoutDir:'\':WarnFileName:'.':dttm:'.war.csv"'
Call DSExecute("NT", Command, Output, SystemReturnCode)
End
End
Please advise me on this.
Also let me know status function, which Ray had created earlier.
dsx
In that case, skip the whole 'check the file size' way and check link counts instead.Latha1919 wrote:I need to have the column names in the file.
An after job routine can be used to query the job using DSGetLinkInfo to determine the count of rows that went down any given link. Check for a zero count there and then delete the file associated with that link. Lather, rinse, repeat.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Never seen that kind of message before?
It means you need to include the header file with the function declaration for DSGetLinkInfo... JOBCONTROL.H off the top of my head. Search the forum for the proper syntax, something like:
This needs to be at the top of your routine.
It means you need to include the header file with the function declaration for DSGetLinkInfo... JOBCONTROL.H off the top of my head. Search the forum for the proper syntax, something like:
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 included the below mentioned files in the routine and so I am not getting any error while compiling the routine.
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
CountRows = DSGetLinkInfo(DSJ.ME,"WarningOut","ToWarningOut", DSJ.LINKROWCOUNT)
However, as I said earlier, File will have the first row as column names. Do I need to condier the CountRows as 1, if I have to delete the empty file (having only the column names).
Is the row of column names is also considered in the rowcount or not?
Please advise.
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
CountRows = DSGetLinkInfo(DSJ.ME,"WarningOut","ToWarningOut", DSJ.LINKROWCOUNT)
However, as I said earlier, File will have the first row as column names. Do I need to condier the CountRows as 1, if I have to delete the empty file (having only the column names).
Is the row of column names is also considered in the rowcount or not?
Please advise.
dsx
No. I wouldn't suggest something like that specifically to counter the issue of column headings if it wouldn't work as suggested. Trust me.Latha1919 wrote:Is the row of column names is also considered in the rowcount or not?
As noted, you are checking the link that is sending data to the Sequential file, counting the records being sent to the stage - not counting the total number of records in the file. Almost the same thing but not quite in this case.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
I created a before/after job routine as below for deleting the empty file (after the job run), but its not working out, please advise me whats wrong with code: (This job will be recursively called for processing the data in different directories.)
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
ErrorCode = 0 ;* set this to non-zero to stop the stage/job
MoutDir= Field(InputArg,"~",1)
WarnFileName= Field(InputArg,"~",2)
dttm = Field(InputArg,"~",3)
WarnRows = DSGetLinkInfo(DSJ.ME,"WarningOutbox","ToWarningOutbox", DSJ.LINKROWCOUNT)
If WarnRows = 0 Then
Command = 'Erase "':MoutDir:'\':WarnFileName:'.':dttm:'.war.csv"'
End
Call DSExecute("NT", Command, Output, SystemReturnCode)
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
ErrorCode = 0 ;* set this to non-zero to stop the stage/job
MoutDir= Field(InputArg,"~",1)
WarnFileName= Field(InputArg,"~",2)
dttm = Field(InputArg,"~",3)
WarnRows = DSGetLinkInfo(DSJ.ME,"WarningOutbox","ToWarningOutbox", DSJ.LINKROWCOUNT)
If WarnRows = 0 Then
Command = 'Erase "':MoutDir:'\':WarnFileName:'.':dttm:'.war.csv"'
End
Call DSExecute("NT", Command, Output, SystemReturnCode)
dsx
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Please expand on "its not working out".
As I read your code, the Input Values field should provide a string of the form directorypath~filename~datetime and issues an ERASE command for the fileif the link row count is zero.
Add some diagnostic capability. For example:
Replace $DEFINE with $UNDEFINE when debugging is no longer required. You only need one $DEFINE declaration in the subroutine.
As I read your code, the Input Values field should provide a string of the form directorypath~filename~datetime and issues an ERASE command for the file
Code: Select all
directorypath\filename.datetime.war.csv
Add some diagnostic capability. For example:
Code: Select all
$DEFINE DEBUGGING
$IFDEF DEBUGGING
Message = "Parse results: "
Message<-1> = "MoutDir = " : Quote(MoutDir)
Message<-1> = "WarnFileName = " : Quote(WarnFileName)
Message<-1> = "dttm = " : Quote(dttm)
Call DSLogInfo(Message, "Debugging")
$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.
Ray,
I can see only this much of you reply, but not complete one:
Please expand on "its not working out". As I read your code, the Input Values field should provide a string of the form directorypath~filename~datetime and issues an ERASE command for the file ...
Please advise. Also, let me know the code I have written in "Command = " is correct or not.
Thanks
I can see only this much of you reply, but not complete one:
Please expand on "its not working out". As I read your code, the Input Values field should provide a string of the form directorypath~filename~datetime and issues an ERASE command for the file ...
Please advise. Also, let me know the code I have written in "Command = " is correct or not.
Thanks
dsx
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
For less than $1 per week you CAN read all of the premium posts. This money goes only part way towards funding this site. Without funding, it will cease to exist. Do you want that?
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.
You could read the part where he asked you to expand on your "It's not working out" comment, how about taking a stab at that? There's nothing obviously wrong with what you've posted that I can see, but without specific examples of your problem - what error you are getting, what it is doing wrong or not doing, something - we can't really be of much help.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
When the job processes the .csv input file, it wil create 2 to 3 files based on the number of written to output file or rejected rows. I am observing that after job is routine is deleting all the files from the output folder, where the out files are written. Also deleting the other input files that are to be processed.
Please advise.
Please advise.
dsx
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Following is the code, I have used in the before/after job routine. I am not finding any wild card characters here.
WarnRows = DSGetLinkInfo(DSJ.ME,"WarningOutbox","ToWarningOutbox", DSJ.LINKROWCOUNT)
If WarnRows = 0 Then
Command = 'Erase "':MoutDir:'\':WarnFileName:'.':dttm:'.war.csv"'
End
Call DSExecute("NT", Command, Output, SystemReturnCode)
WarnRows = DSGetLinkInfo(DSJ.ME,"WarningOutbox","ToWarningOutbox", DSJ.LINKROWCOUNT)
If WarnRows = 0 Then
Command = 'Erase "':MoutDir:'\':WarnFileName:'.':dttm:'.war.csv"'
End
Call DSExecute("NT", Command, Output, SystemReturnCode)
dsx