ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » FileInput Node - record count problem

Post new topic  Reply to topic
 FileInput Node - record count problem « View previous topic :: View next topic » 
Author Message
MarkOates
PostPosted: Thu Nov 06, 2008 7:01 am    Post subject: FileInput Node - record count problem Reply with quote

Newbie

Joined: 24 Sep 2007
Posts: 6

We have a requirement to process a text file which has the following structure:

header
data 1
data 2
data 3
..
data n
footer

The problem we have is that the number of data lines in the text file is variable, but is stored in the footer - the footer stores the number of data lines plus a further 2 lines (1 each for the header and footer).

Is there an easy way of using a message set to determine the number of data lines in the file in the message set definition? If not what is the best way to achieve this.

The number of data lines in the message is always a positional field and will never change.

Any help would be much appreciated.

Rgds,
Mark
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 06, 2008 7:19 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Are the header & trailer identified by anything other than their postion? For instance, another poster had a file with "0" in the 1st postion for the header, "9" in the footer and "5" in the data records. Is there anything like that you could use, to remove for the need for the record count.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Thu Nov 06, 2008 8:03 am    Post subject: Re: FileInput Node - record count problem Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi MarkOates,

Is your question related to FileInput node or is mainly about creating a message set for the input fetched ? The topic seems to throw me off.

MarkOates wrote:
Is there an easy way of using a message set to determine the number of data lines in the file in the message set definition? If not what is the best way to achieve this.
Yes you can. The repeat(or a property named like that ) can be set to reference a field within the message defn. and use it's value as the number of occurrences.

You can ofcourse only do the above if the message set can differentiate the header and footer in the first place...either by position as Vitor asked or by some identifier.

But if you are sure that the first and the last row are the header and footer, then you don't really need the occurrence, do you ? You can simply ask all rows except first and last to be considered as 'data'.

Regards.
Back to top
View user's profile Send private message Send e-mail
MarkOates
PostPosted: Thu Nov 06, 2008 8:26 am    Post subject: Re: FileInput Node - record count problem Reply with quote

Newbie

Joined: 24 Sep 2007
Posts: 6

We are reading a file using a fileinput node and then using a message set to read the file, so the question is related to creating the message set.

The input message footer is identifiable by having a 'F' in character position 1, but we aren't sure how to reference this in the message set
Back to top
View user's profile Send private message
MarkOates
PostPosted: Thu Nov 06, 2008 8:45 am    Post subject: Re: FileInput Node - record count problem Reply with quote

Newbie

Joined: 24 Sep 2007
Posts: 6

Something else:

The reason we need to do this is to change part of each data row in the message, and then pass on the remaining content out to an MQ or file output node, including the message header and footer.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Nov 06, 2008 8:47 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

This seems like a basic TDS message, depending on how the header and data records are identified or layed out.
Back to top
View user's profile Send private message
MarkOates
PostPosted: Thu Nov 06, 2008 9:06 am    Post subject: Re: FileInput Node - record count problem Reply with quote

Newbie

Joined: 24 Sep 2007
Posts: 6

How can this be treated as a simple TDS message? I think I must be missing something! n example of the file we are trying to process looks like:

D00011225446469a0198020081031104749003
EIMSTD00002231000062YZ044 001 000000001145X
EIMSTD00002231100062YZ054 001 000000000000X
EIMSTD00002231200062YZ056 001 000000000000X
EIMSTD00002231300062YZ066 001 000000000000X
EIMSTD00002231400062YZ067 001 000000001150X
EIMSTD00002231500062YZ082 001 000000000000X
EIMSTD00002231600062ZGO008 001 000000000000X
EIMSTD00002231700062ZRR005 001 000000000000X
F000000010


As can be seen in the above example, the total number of rows in the message is 10, including the header and the footer. The footer also shows the total number of lines in the message.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 06, 2008 9:12 am    Post subject: Re: FileInput Node - record count problem Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

MarkOates wrote:
How can this be treated as a simple TDS message? I think I must be missing something!


Possibly that the messages are Tagged by the first character, and Delimited by a CR/LF?

Doesn't seem too tricky. What problem do you encounter when modelling it?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Nov 06, 2008 2:57 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Hi Mark,

Your message consists of lines of text, each starting with a single-character tag. Message Broker calls that a 'Tagged Delimited' message with a delimiter of CR/LF ( or whatever you line feed character happens to be ).

You need to
- Create a message set
- Add a TDS physical format
- Create a new message looking like this:
Code:

Message
    Complex Type  Data Element Separation='Tagged Delimited', Delimiter='<CR><LF>', Tag Length=1
        Element Name='Header' Tag='D'
        Element Name='Line' Tag='E'
        Element Name='Footer' Tag='F'
Obviously, the complex types which define Header, Line and Trailer will need a different Data Element Separation ( probably Fixed Length, or possibly All Elements Delimited ) but I cannot advise on that as you have not given any details about the internal structure of these elements.
Don't worry about the 'number of lines' element in the footer. You message flow is not adding or removing lines, so it does not need to change

elvis_gn: Two reasons why Repeat Reference is not the correct answer here. It only works when the counter comes before the repeating item, and it is not automatically populated when a message is written.
Back to top
View user's profile Send private message
Muhammad Haider
PostPosted: Tue Apr 05, 2011 10:11 pm    Post subject: FileInput Node: Code to get File Name and record count Reply with quote

Apprentice

Joined: 14 Mar 2011
Posts: 43

Here are my findings to get file name and reocrd count for FileInput node in broker 7. I used a java compute node at 'End of Data' terminal and used following code:


MbElement localEnv = contact admin.getLocalEnvironment().getRootElement();
String directory = localEnv.getFirstChild().getFirstChild().getValueAsString();
String fileName1 = localEnv.getFirstChild().getFirstChild().getNextSibling().getValueAsString();
logger1.info("File Name :"+fileName1);
String records = localEnv.getFirstChild().getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getValueAsString();
String propertyName = localEnv.getFirstChild().getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getName().toString(); // Record property
logger1.info("property :"+propertyName+" : "+recordNumber);
logger1.info("Record :"+records);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » FileInput Node - record count problem
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.