IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.


#Sterling
#Supplychain
 View Only
  • 1.  Some FileName with Timestamp

    Posted 09/01/10 02:42 AM

    Originally posted by: sonja1987


    Hi,

    How can I make logic condition using IF statement in Datastage TX, if I am only to truncate the filenames having timestamp else don't truncate if files don't have timestamp.I only know how to truncate the filename with timestamp

    If FileName04252010 then
    
    LEFT (RIGHT(GETFILENAME(RcvData), SIZE(GETFILENAME(RcvData)) - SIZE(GETDIRECTORY(RcvData))), SIZE (RIGHT(GETFILENAME(RcvData), SIZE(GETFILENAME(RcvData)) - SIZE(GETDIRECTORY(RcvData)))) - 8)
    

    Else do not truncate

    Answers will be a big help.
    Thanks =)
    sonja
    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 2.  Re: Some FileName with Timestamp

    Posted 09/01/10 05:58 AM

    Originally posted by: TarunB


    That's some rule you have there. If you know that you have a date in the filename, as in FileName04252010, then just use:-

    SUBSTITUTE (RIGHT (SUBSTITUTE (GETFILENAME (input), GETDIRECTORY(input), ""), 8), "")
    To account for the fact that the date is optional, build upon the rule above as follows:-

    IF (ISNUMBER (RIGHT (SUBSTITUTE (GETFILENAME (input), GETDIRECTORY(input), ""), 8) ),
    SUBSTITUTE (RIGHT (SUBSTITUTE (GETFILENAME (input), GETDIRECTORY(input), ""), 8), ""),
    SUBSTITUTE (GETFILENAME (input), GETDIRECTORY(input), "") )

    ISNUMBER is not a check for a date as such, so it's usefulness here depends on the format of your filename. Also due to the recurrent use of SUBSTITUTE (GETFILENAME (input), GETDIRECTORY(input) , you would be advised to put store the result in a previous cell and use it from there, so that it is only calculated once.
    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 3.  Re: Some FileName with Timestamp

    Posted 09/01/10 06:34 AM

    Originally posted by: sonja1987


    Hi TarunB,

    Thank you!=)
    Sort of confused there.
    Some of the files we received have timestamp and some have don't.
    I think substitute is used to replace a character to another character.
    isnumber is used to search for numeric characters,but my filename has an extension of something like .in3 , in2 ,in1 aside from timestamp
    examples of files we received.(with timestamp and some have don't)
    file001name.in106072010
    file003name.in206072010
    file101name.in1
    file002name.in2

    Here's the pseudocode to make it more clear.=)

    If file001name.in106072010 then
    truncate 06072010
    else if filename101name.in1
    no truncate happen because there is no timestamp.

    thanks,
    sonja=)
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 4.  Re: Some FileName with Timestamp

    Posted 09/01/10 09:43 AM

    Originally posted by: TarunB


    The rule will work because your date appears after the extension, i.e. after the .in1.

    The SUBSTITUTE is being used to replace the date with nothing, i.e. it is removing the date.
    The date in your case is all numeric and so you can use ISNUMBER.

    Assuming FNAME = SUBSTITUTE (GETFILENAME (input), GETDIRECTORY(input), "")

    IF (ISNUMBER (RIGHT (FNAME, 8) ), ........ this checks for the numeric date being present
    SUBSTITUTE (RIGHT (FNAME, 8), ""), ........ this replaces the date with nothing, i.e. removes it
    FNAME) ........ ELSE if no date is found leave the filename as it is
    There are many ways to achieve the same result, but the above will work for the case you have described.
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 5.  Re: Some FileName with Timestamp

    Posted 09/01/10 11:49 PM

    Originally posted by: sonja1987


    Hi,

    Thank you!
    Forgot to include, what if my timestamp is in this format (having hours and minutes)
    filename.in106072010.0735

    IS isnumber still applicable for the validation?
    Timestamp includes a "."(dot) after the date and before the hours and minutes(*06072010.0735*)?
    but still I have to truncate all that date/timestamp..

    thanks so much knowledge gain from you here in datastage TX.?
    Just a newbie here..=)

    thanks,=)
    sonja
    #IBM-Websphere-Transformation-Extender
    #DataExchange
    #IBMSterlingTransformationExtender


  • 6.  Re: Some FileName with Timestamp

    Posted 09/08/10 04:30 PM

    Originally posted by: jvanboga


    If the file name uses delimiters like '.' or '_' you can also use the word function

    word(getfilename(), ".", 1)

    transforms 'filename.date.time' to 'filename'. You can then append whatever you want to it......

    word(getfilename(in1), ".", 1)+"."+word(getfilename(in1), ".", -1) = filename.time
    substitute(getfilename(in1),word(getfilename(in1), ".", 2)+".", "") = filename.time

    substitute(getfilename(in1),"."+word(getfilename(in1), ".", -1), "") = filename.date
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender