Author |
Message
|
Radhikab |
Posted: Wed Nov 16, 2011 9:50 pm Post subject: How can I ignore 1st record in a file |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
Hi,
We will be receiving a standard format from each source in the form of semi-colon delimited CSV files and we have to convert it to XML message by taking each single record ina file.
Each record on the file contains 10 fields. The first 10 fields of data will always contain a header that describes each field, so this first line should be ignored and no trade created from it.
Iam using while loop
DECLARE IN_I INTEGER 2;
SET IN_RECORD_COUNT = CARDINALITY ( "InputBody"."Record"[] ) ;
WHILE ( IN_I <= IN_RECORD_COUNT ) DO
SET A= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."A"));
SET B= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."B"));
SET C= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."C"));
SET D= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."D"));
SET E= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."E"));
SET F= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."F"));
SET G= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."G"));
SET H= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."H"));
SET I= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."I"));
SET J= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."J"));
CALL INBOUND();
set IN_I = IN_I+1;
END WHILE;
Can anyone of you let me know how to ignore 1st record?
Thanks in advance |
|
Back to top |
|
 |
saurabh867 |
Posted: Wed Nov 16, 2011 11:54 pm Post subject: |
|
|
Voyager
Joined: 13 Jun 2010 Posts: 78
|
Hi,
Is not working with your solution ?
Another way could be to handle this in your message set. Specify one more complex type (e.g. Header with occurrence set to 1) before your Record complex type.
Now you can always look at only the Record and need not bother about Header but if you want to refer, you can use that in future.
Regards,
Saurabh |
|
Back to top |
|
 |
zpat |
Posted: Thu Nov 17, 2011 12:19 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Why not process the file record by record in the file input node, setting the record delimiter to ";"?
Then just ignore the first record, by setting a flag in the environment data to check.
Always remember, files equate to queues, records equate to messages.
Processing a whole file at once will create file size restrictions, and may result in too many uncommitted MQ messages and so on. Avoid. |
|
Back to top |
|
 |
Radhikab |
Posted: Thu Nov 17, 2011 12:50 am Post subject: |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
Hi Saurabh,
Thanks for the response
no, my code is not working..
Also,I tried creating one more complextype as header with min and max occurs as '1' and declared all 10 fields in it. Still it is processing message for 1st row.
don't knw where I did a mistake. |
|
Back to top |
|
 |
Radhikab |
Posted: Thu Nov 17, 2011 12:57 am Post subject: |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
Hi,
I was instructed to use mqinput node instead of fileinput node. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 17, 2011 1:12 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Another way could be to handle this in your message set. Specify one more complex type (e.g. Header with occurrence set to 1) before your Record complex type. |
This is the easiest solution. If it is not working, put a Trace node after the input node so that you can see the message tree. Then take a debug-level user trace, so that you can see exactly what the parser did.
Quote: |
don't knw where I did a mistake. |
Tell us what happened. We may be able to suggest something.
<plug>In WMB v8 this scenario it will be much easier to create and debug CSV scenarios using the DFDL parser.</plug> |
|
Back to top |
|
 |
Radhikab |
Posted: Thu Nov 17, 2011 1:32 am Post subject: |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
Created message set with header and record. min occurs and max occurs is 1 for header and for records it is 0 to -1.
and in my esql code am using the code which was posted in my question.
message flow:
mqinputnode--->computenode---> computenode---> mqoutputnode |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 17, 2011 1:38 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Good. But what is the problem? What is happening that should not? |
|
Back to top |
|
 |
Radhikab |
Posted: Thu Nov 17, 2011 1:42 am Post subject: |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
as per the requirement it has to ignore 1st record. but it is creating message for header also.
We don't have debugger to trace the message. we are using wmb 6.1 |
|
Back to top |
|
 |
ajit1981 |
Posted: Thu Nov 17, 2011 1:52 am Post subject: |
|
|
Apprentice
Joined: 09 Apr 2010 Posts: 41 Location: Bangalore, Inida
|
I rembered once we got this requirement. Since our 1st records was fixed message . So we put If statment to check that fixed message and ignored that records. _________________ Regards,
Ajit |
|
Back to top |
|
 |
Radhikab |
Posted: Thu Nov 17, 2011 2:01 am Post subject: |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
Hi Ajit,
I tried like this
IF IN_I > 1 then
CALL INBOUND();
end if;
set IN_I = IN_I+1;
Then also it is creating message for 1st record |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 17, 2011 2:12 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Then also it is creating message for 1st record |
User trace. |
|
Back to top |
|
 |
Radhikab |
Posted: Thu Nov 17, 2011 2:30 am Post subject: |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
Hi Kimbert,
Can you please check my code and let me know whether it is correct?
Last edited by Radhikab on Thu Nov 17, 2011 2:32 am; edited 1 time in total |
|
Back to top |
|
 |
ajit1981 |
Posted: Thu Nov 17, 2011 2:31 am Post subject: |
|
|
Apprentice
Joined: 09 Apr 2010 Posts: 41 Location: Bangalore, Inida
|
If your 1 records is fixed. Example. AccountNo,Name,Amount,Date
and you are using messageset , then write If conditon to remove first records.
IF inputroot.......ACC.NO = 'AccountNo' AND inputroot.......NAME = 'Name' AND inputroot.......AMOUNT = 'Amount' AND inputroot.......DATE = 'Date'
--do nothing
ELSE
write your code here
ENdIF;
Assuming ACC.NO,NAME,AMOUNT,DATE is element name in Messageset. _________________ Regards,
Ajit |
|
Back to top |
|
 |
Radhikab |
Posted: Thu Nov 17, 2011 2:53 am Post subject: |
|
|
Novice
Joined: 16 Nov 2011 Posts: 11
|
Hi Amit,
Thanks for suggestion.. Could you please paste the complete code?
Iam using SET A= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."A"));
SET B= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."B"));
SET C= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."C"));
SET D= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."D"));
SET E= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."E"));
SET F= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."F"));
SET G= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."G"));
SET H= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."H"));
SET I= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."I"));
SET J= TRIM('"' FROM TRIM("InputBody"."Record"[IN_I]."J"));
and in INbound procedure am using A,B,C,D.... for creating xml message..
SET OutputRoot.XML.InboundGTMXML.TradeDetails.Currency= A ; |
|
Back to top |
|
 |
|