Author |
Message
|
Android 23 |
Posted: Sun Jun 04, 2017 9:31 pm Post subject: how to create Dynamic Filename & each record to each fil |
|
|
Apprentice
Joined: 27 Mar 2017 Posts: 38
|
Hii guys, I have 1 file with 4 records in it.
My Requirement is i need to create 4 files with one record in it. Any file should should be dynamic[/code] |
|
Back to top |
|
 |
smdavies99 |
Posted: Sun Jun 04, 2017 10:42 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
How do you think it should be done?
The answer to your problem is here. The google box on the upper right will help you find it.
We really like people to try to help themselves. Try a few things. If they don't work then tell us what you did and {importantly} what went wrong. Then help will be more forthcoming. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Android 23 |
Posted: Sun Jun 04, 2017 10:55 pm Post subject: I have implemented this code.Im getting onefile wit 1 record |
|
|
Apprentice
Joined: 27 Mar 2017 Posts: 38
|
Code: |
DECLARE H INTEGER 1;
DECLARE count INTEGER;
SET count= CARDINALITY(InputRoot.XMLNSC.PersonDetails."Fname"[])
SET count = CARDINALITY(InputRoot.XMLNSC.PersonDetails."Fname"[])
CREATE LASTCHILD OF OutputRoot DOMAIN 'JSON';
-- WHILE H <= count DO
--CALL CopyMessageHeaders();
SET OutputRoot.JSON.Data.PersonDetails=InputRoot.XMLNSC.PersonDetails[i];
CREATE LASTCHILD OF OutputRoot DOMAIN 'JSON';
SET OutputRoot.JSON.Data.PersonDetails=InputRoot.XMLNSC.PersonDetails;
CREATE LASTCHILD OF OutputRoot DOMAIN 'JSON';
SET OutputRoot.JSON.Data.PersonDetails=InputRoot.XMLNSC.PersonDetails;
PROPAGATE TO TERMINAL 'out';
SET OutputRoot.JSON.Data.PersonDetails=InputRoot.XMLNSC.PersonDetails;
PROPAGATE TO TERMINAL 'out1';
SET OutputRoot.JSON.Data.PersonDetails=InputRoot.XMLNSC.PersonDetails;
PROPAGATE TO TERMINAL 'out2';
SET OutputRoot.JSON.Data.PersonDetails=InputRoot.XMLNSC.PersonDetails;
PROPAGATE TO TERMINAL 'out3';
DECLARE H INTEGER 1;
DECLARE count INTEGER;
SET OutputLocalEnvironment.Destination.File.Directory='D://Task//output';
SET OutputLocalEnvironment.Destination.File.Name='PersonDetails.json';
SET OutputLocalEnvironment.Destination.File.Action='Create';
SET OutputRoot.JSON.Data.PersonDetails=ER.JSON.Data.Fname.Lname[c];
SET count= CARDINALITY(InputRoot.XMLNSC.PersonDetails."Fname"[])
SET count = CARDINALITY(InputRoot.XMLNSC.PersonDetails."Fname"[])
WHILE (H <= count) DO
CALL CopyMessageHeaders();
SET OutputRoot.JSON.Data.PersonDetails=InputRoot.XMLNSC.PersonDetails[i];
PROPAGATE;
SET H= H+1;
END WHILE;
RETURN FALSE; |
thanks for reply. |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Jun 05, 2017 12:18 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
So how will this
Code: |
SET OutputLocalEnvironment.Destination.File.Name='PersonDetails.json';
|
make a different file?
Windows and Unix/Linux files systems do not support versioning of files unlike say VMS.
Please use the appropriate tags when posting (above the edit window). It makes reading your replied easier.
Also, using CARDINALITY is not the way to do looping effiiciently. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Android 23 |
Posted: Mon Jun 05, 2017 3:41 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2017 Posts: 38
|
Thanks for the reply,
Code: |
SET OutputLocalEnvironment.Destination.File.Name = InputRoot.XMLNSC.PersonDetails.Fname||'.txt'; |
I have used this code. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 05, 2017 3:45 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Android 23 wrote: |
Code: |
SET OutputLocalEnvironment.Destination.File.Name = InputRoot.XMLNSC.PersonDetails.Fname||'.txt'; |
|
Will the Fname field have spaces in it? Will it have / or \ in it? Will it have extended unicode character that your operating system will not accept as part of an allowed file or path name?
Is there a different field in your record that will not have those issues - and does not represent privacy sensitive data? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Android 23 |
Posted: Mon Jun 05, 2017 5:07 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2017 Posts: 38
|
Code: |
SET OutputRoot = InputRoot;
SET OutputLocalEnvironment.Destination.File.Directory='D://Task//output';
SET OutputLocalEnvironment.Destination.File.Name = InputRoot.XMLNSC.PersonDetails.Fname||'.txt';
|
I didn't mention any encode values.
" || " is concatation of file with extension of txt document to it.
Regards,
Android23 |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jun 05, 2017 6:18 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Android 23 wrote: |
I didn't mention any encode values. |
I don't think I did either...
If the field Fname is a field that holds a full name, it could very likely have a wide variety of characters that are illegal to be in paths or file names, or simply point to places you don't expect.
For example, on unix, if Fname = "bob smith", and you try to write a file named 'bob smith.txt", then that will try to write two files.
Even on windows, which you seem to be using, you may have to do additional things to make "d://Task/output/bob smith.txt" work properly, so again it doesn't try to write two files...
And, again, consider a full name that contains a unicode character, that happens to be represented in CCSID 437 as a "~", or something like a CR etc. etc. etc.
Android 23 wrote: |
" || " is concatation of file with extension of txt document to it.
|
I believe I know that. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Android 23 |
Posted: Mon Jun 05, 2017 8:27 pm Post subject: |
|
|
Apprentice
Joined: 27 Mar 2017 Posts: 38
|
Quote: |
If the field Fname is a field that holds a full name |
Fname defines firstname & it changes for every value.
Quote: |
Even on windows, which you seem to be using, you may have to do additional things to make "d://Task/output/bob smith.txt" work properly, so again it doesn't try to write two files... |
I agree with you, If there is a changed in fname(firstname), then it creates a file again with new name & places it in "d://Task/output/".
And it works with fileInputnode with RecordDetection is "Delimited".
Regards,
Android 23 |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jun 05, 2017 9:44 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
smdavies99 wrote: |
So how will this
Code: |
SET OutputLocalEnvironment.Destination.File.Name='PersonDetails.json';
|
make a different file?
Windows and Unix/Linux files systems do not support versioning of files unlike say VMS.
|
So you did not set the value of the file name in the WHILE loop and you do not vary the file name for each iteration of the WHILE loop, nor do you close the File by propagating to the file close terminal from within the WHILE loop.
So how does that make multiple files???  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Android 23 |
Posted: Mon Jun 05, 2017 10:42 pm Post subject: |
|
|
Apprentice
Joined: 27 Mar 2017 Posts: 38
|
Quote: |
So you did not set the value of the file name in the WHILE loop and you do not vary the file name for each iteration of the WHILE loop, nor do you close the File by propagating to the file close terminal from within the WHILE loop. |
I didnot mention any While loop in it.
Code: |
SET OutputRoot = InputRoot;
SET OutputLocalEnvironment.Destination.File.Directory='D://Task//output';
SET OutputLocalEnvironment.Destination.File.Name = InputRoot.XMLNSC.PersonDetails.Fname||'.txt'; |
If my Fname changes , then it creates new file with fname & data which is present in that Fname.
It's not neccessary to use while loop in FileInputnode.Just mention Record Detection as "Delimited".
"While loop (or) For loop " is required when we declare it with MQInputnode.
Regards,
Android 23 |
|
Back to top |
|
 |
|