Using wildcards when reading a file

Hi,

I need to read an xml file from a location on a daily basis.

File Format: Location_YYYYMMDDHHMISS_UniqueID

Ihave assigned a global variable pointing to this file and based on previous variables it can read ‘Location’ and the ‘Unique ID’ part of the XML file.

I can handle the YYYYMMDD datetime part of it and want to use wildcard characters for the HHMISS part of the datetime in the file as the time when the file is generated and the execution of the DI job is different.I am getting an error most likely because of the syntax.

Here is the global variable i am using,

$g_File_Name=‘C\dOCUMENTS\Location_[to_char(sysdate(),‘YYYYMMDD’)]%%%%%%_{$g_XML_Unique_ID}.xml’;

The variable is taking the % sign but not reading it as a wildcard.

Any help on this is greatly appreciated. Thank you


kountay (BOB member since 2008-08-13)

Do we have a widlcard character for a single char? The “*” is for 0…n chars, what about the “_”? Is that the single char placeholder??

https://boc.sdn.sap.com/node/5230 might help as well…


Werner Daehn :de: (BOB member since 2004-12-17)

Hello Werner ,

I tried using the * but it still does not take it as a wildcard entry. This is probably becoz of single quotations i have at the beginning and at the end of the value assigned to the variable.

Is there anyway i can bypass the HHMISS part of the file ?? :hb:


kountay (BOB member since 2008-08-13)

We’ve done similar, and the trick was to use a directory function to generate a list of files - that should definitely take the wildcards. You then just need to step thru the list of file names returned by that call - that will give you all the filenames, something that you can use to open each file.

Not sure what you’d want to plug in, but in VB I think it’s an ADir call.

B.


bdouglas :switzerland: (BOB member since 2002-08-29)

Hi bdouglas,

Can you give me your answer in more detail or possibly a snippet of the code you used in ur script or a pseudo code of the steps involved ?

I also have an option of pulling *_uniqueid.xml but DI does not recognize that i am using a wild character !

Thanks for your help


kountay (BOB member since 2008-08-13)

see your point, you are using the wildcard inside a global variable, not specifying it as parameter.

One version of the code bdouglas is talking about is in the link I mentioned above: https://boc.sdn.sap.com/node/5239
This document uses wit_for_file() function to fetch on filename after the other instead of an exec(‘cmd.exe’, ‘dir’, 8 );.


Werner Daehn :de: (BOB member since 2004-12-17)

Here’s an example of something I did a LONG time ago, may be useful as pseudocode

' set up an array and populate it with file names (directories)

declare vars(1)
ok=adir('vars',path+'*.*','D')
badval=.f.
	
' for each item in the array, do some action

for x=1 to alen(vars,1)
    variableX= ars(x,1)
    ' etc, etc, etc
next x

The syntax may need a lot of work, but there are versions of this in most languages - use your wildcards when you populate the array of file names, then step thru those names to do your work.

Good luck!
Brent


bdouglas :switzerland: (BOB member since 2002-08-29)

Werner,

Thank you for posting those links they were really helpful ! It did solve one of my problems.

Thank you for the support bdouglas.

Cheers


kountay (BOB member since 2008-08-13)