IanCockcroft
IS-IT--Management
Guys, I am new to DS and I need a solution.
We have txt files coming through on a daily, weeklu and monthly basis. Diffrent jobs run different files. eg. we have Dim_LEAD.TXT file run daily by the dimLead job. FCT_LEAD.TXT file run weekly by the fctLead job.
When the files come through, they have a date as well.
DIM_LEAD20061101.TXT
DIM_LEAD20061102.TXT
DIM_LEAD20061103.TXT
FCT_LEAD20061101.TXT
FCT_LEAD20061108.TXT
FCT_LEAD20061115.TXT
I am trying to do the following.
pass in the file name without the date as a parameter.
Pick up the latest date from the filenames in the folder.
Check if that file has been run
if not, return that file name, with the date part.
else return 'no'file.
this is what I have so far, but its copied from other routines and really, I have no idea.
*****Functional Arguments
Ans = "No File"
SeqFileName = SRCPATH:"Direct_Channel\Fct_Lead_LRD.txt"
openseq SeqFileName to SeqFile1
On Error
Call DSLogWarn("Cannot Open " : SeqFileName ,"JobControl")
GoTo TheEnd
End
Then
****2. Get the last rundate
ReadSeq FileLine from SeqFile1
On Error
Call DSLogWarn("Error readng SeqFile1","JobControl")
Goto TheEnd
End
Then
****3. Set the LastRunDate to the file line, and calculate the NextRunDate
** LastRunDate = Trim(Oconv(Iconv(FileLine[17,6],"DDMY[2,2,2]"),"DDMY[2,2,2]"),' ',"A")
LastRunDate = Iconv(FileLine[9,8],"DDMY[2,2,2]")
Ans = LastRunDate
NextRunDate = Trim(Oconv(Iconv(FileLine[17,6],"DDMY[2,2,2]")+1,"DDMY[2,2,2]"),' ',"A")
****4. Set the RundateFile as the source path, the FileName, the nextrundate, the file extension as an initial variable
RunDateFile = SRCPATH:"Direct_Channel\Fct_Lead":NextRunDate:".txt"
****5. Calculate the difference in days between the current date and the next rundate.
****This is done to restrict the loop to run only until today's date has been achieved
DiffDates = @date - Iconv(FileLine[17,6],"DDMY[2,2,2]")+1
****6. Loop till today's date, and check if a file exists.
For LoopRunDate = 1 to DiffDates
OpenSeq RunDateFile To CheckExist Locked
End Then
Ans = NextRunDate
End Else
FilePresent = @False
NextRunDate = Trim(Oconv(Iconv(FileLine[17,6],"DDMY[2,2,2]")+LoopRunDate ,"DDMY[2,2,2]"),' ',"A")
RunDateFile = SRCPATH:"MATS\MI_MOBILE_ACT_T_":NextRunDate:".txt"
End
Next LoopDate
CloseSeq SeqFile1
End
End
TheEnd:
Can anyone help or have a similoar solution?
thanks alot
Ian
We have txt files coming through on a daily, weeklu and monthly basis. Diffrent jobs run different files. eg. we have Dim_LEAD.TXT file run daily by the dimLead job. FCT_LEAD.TXT file run weekly by the fctLead job.
When the files come through, they have a date as well.
DIM_LEAD20061101.TXT
DIM_LEAD20061102.TXT
DIM_LEAD20061103.TXT
FCT_LEAD20061101.TXT
FCT_LEAD20061108.TXT
FCT_LEAD20061115.TXT
I am trying to do the following.
pass in the file name without the date as a parameter.
Pick up the latest date from the filenames in the folder.
Check if that file has been run
if not, return that file name, with the date part.
else return 'no'file.
this is what I have so far, but its copied from other routines and really, I have no idea.
*****Functional Arguments
Ans = "No File"
SeqFileName = SRCPATH:"Direct_Channel\Fct_Lead_LRD.txt"
openseq SeqFileName to SeqFile1
On Error
Call DSLogWarn("Cannot Open " : SeqFileName ,"JobControl")
GoTo TheEnd
End
Then
****2. Get the last rundate
ReadSeq FileLine from SeqFile1
On Error
Call DSLogWarn("Error readng SeqFile1","JobControl")
Goto TheEnd
End
Then
****3. Set the LastRunDate to the file line, and calculate the NextRunDate
** LastRunDate = Trim(Oconv(Iconv(FileLine[17,6],"DDMY[2,2,2]"),"DDMY[2,2,2]"),' ',"A")
LastRunDate = Iconv(FileLine[9,8],"DDMY[2,2,2]")
Ans = LastRunDate
NextRunDate = Trim(Oconv(Iconv(FileLine[17,6],"DDMY[2,2,2]")+1,"DDMY[2,2,2]"),' ',"A")
****4. Set the RundateFile as the source path, the FileName, the nextrundate, the file extension as an initial variable
RunDateFile = SRCPATH:"Direct_Channel\Fct_Lead":NextRunDate:".txt"
****5. Calculate the difference in days between the current date and the next rundate.
****This is done to restrict the loop to run only until today's date has been achieved
DiffDates = @date - Iconv(FileLine[17,6],"DDMY[2,2,2]")+1
****6. Loop till today's date, and check if a file exists.
For LoopRunDate = 1 to DiffDates
OpenSeq RunDateFile To CheckExist Locked
End Then
Ans = NextRunDate
End Else
FilePresent = @False
NextRunDate = Trim(Oconv(Iconv(FileLine[17,6],"DDMY[2,2,2]")+LoopRunDate ,"DDMY[2,2,2]"),' ',"A")
RunDateFile = SRCPATH:"MATS\MI_MOBILE_ACT_T_":NextRunDate:".txt"
End
Next LoopDate
CloseSeq SeqFile1
End
End
TheEnd:
Can anyone help or have a similoar solution?
thanks alot
Ian