Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading files using a DS basic routine

Status
Not open for further replies.

IanCockcroft

IS-IT--Management
Mar 16, 2004
7
0
0
ZA
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
 
It uses stage "Folder" you read all the DIM_LEAD*.txt archives there and that
list of archives you leave of exit in a field of a file sequential.txt it
with another field in which you make counter that to counter is going to serve
to you so that you use stage of loop of DS and would be the times that would
be executed for the total of archives.

As long as he is fixed name (DIM_LEAD) and (FCT_LEAD).

The same procedure happens for archives FCT_LEAD*.TXT.

After you have all the names of the archives in a field of sequential.txt you can
do substring so that you obtain the week or month that this loading itself so that
you use it in where is necessary.

Greetings!
 
My Solution:


openseq SeqFileName to SeqFile1
On Error
Call DSLogWarn("Cannot Open " : SeqFileName ,"JobControl")
GoTo TheEnd
End
Then

***************************************************
*********** LOOP TILL NEXT FILE FOUND *************
***************************************************

ReadSeq FileLine from SeqFile1
On Error
Call DSLogWarn("Error readng SeqFile1","JobControl")
End
Then

Check = @False
Counter = 1
Loop

Add1Day = Trim(Oconv(Iconv(FileLine,"DYMD[4,2,2]")+ Counter,"DYMD[4,2,2]"),' ',"A")
RunDateFile = SRCPATH:"DIRECT_CHANNEL\":File_Name:Add1Day:".txt"
OpenSeq RunDateFile To CheckExist Locked
* FilePresent = @True
End Then
Check = @True
Ans = File_Name:Add1Day:".txt"


End
Counter += 1
Until (Check or Counter = 40)Repeat
end
CloseSeq SeqFile1
End




TheEnd:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top