View previous topic :: View next topic
|
Author |
Message |
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
Hi,
I have a requirement where in I need to update sequence number field at variable position. File is variable length and maximum length is 1014 . Input data will be in below format
<Name>ABC</Name><Address>Address1</Address><City>US</City><DateOfBirth>1983-03-03</DateOfBirth><LocaleCode>VFC</LocaleCode><NameLine>AYUSH</NameLine> <SequenceNum>00000018</SequenceNum><StatusCode>I</StatusCode><Status>Married</Status> <MailID>abc</MailID><Age>23</Age><Telephone>123456</Telephone><SequenceNum>00000021</SequenceNum><Occupation>Student</Occupation><Name>ABC</Name><Add>Address1</Add><SequenceNum>00000021</SequenceNum> <City>US</City><DateOfBirth>1983-03-03</DateOfBirth>
Output will be like this
<Name>ABC</Name><Address>Address1</Address><City>US</City><DateOfBirth>1983-03-03</DateOfBirth><LocaleCode>VFC</LocaleCode><NameLine>AYUSH </NameLine> <SequenceNum>00000001</SequenceNum><StatusCode>I</StatusCode><Status>Married</Status> <MailID>abc</MailID><Age>23</Age><Telephone>123456</Telephone><SequenceNum>00000002</SequenceNum><Occupation>Student</Occupation><Name>ABC</Name><Add>Address1</Add><SequenceNum>00000003</SequenceNum> <City>US</City><DateOfBirth>1983-03-03</DateOfBirth>
How can we achieve this using DFSORT?
Thanks,
Indrajit |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Can you split it into individual elements, like your last question? The sequence is then in a fixed position. |
|
Back to top |
|
|
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
I thought of that option first, but now the requirement has changed and they want the input data to be kept as is and just to update the SequenceNum in the same place it is present in the input file. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
Back to top |
|
|
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
I have tried that solution, reason I m posting this again because of following input change :-
1. One line can have multiple sequence number field.
2. File length is 1014.
3. After modification of previous sort as per new requirement, I m getting output as follow
<Name>ABC</Name><Address>Address1</Address><City>US</City><DateOfBirth>1983-03-03</DateOfBirth><LocaleCode>VFC</LocaleCode><NameLine>AYUSH</NameLine> <SequenceNum>StatusCode>I</StatusCode><Status>Married</Status> <MailID>abc</MailID><Age>23</Age><Telephone>123456</Telephone>00000001</SequenceNum><SequenceNum>Occupation>Student</Occupation><Name>ABC</Name><Add>Address1</Add><SequenceNum> 0000002</SequenceNum><<City>US</City><DateOfBirth>1983-03-03</DateOfBirth>
Modified sort card is
OPTION COPY
INREC IFOUTLEN=1014,
IFTHEN=(WHEN=(1,1014,SS,EQ,C'<SequenceNum>'),
BUILD=(C'"',1,1014),HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,EQ,C'"'),
FINDREP=(SHIFT=NO,IN=C'<SequenceNum>',
OUT=C'<SequenceNum>" '),HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,EQ,C'"'),
OVERLAY=(1016:SEQNUM,8,FS,C'</SequenceNum>',
1:1,1038,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,EQ,C'"'),
FINDREP=(IN=C'"',OUT=C'')) |
|
Back to top |
|
|
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
Please ignore the above output.
What I am getting now is that the sequence number and the ending tag is always coming at the end of the record and not following the start of the sequence number tag. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Indrajit_57,
DFSORT does NOT have any feature to handle multiple occurrences of the <SequenceNum> tags and update them. A simple COBOL program should be able to do this easily. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Indrajit_57,
Are you OK with this now?
You have the rexx example enrico posted on a previous question. I can get to the following with Cobol, if you have need of more than the sequence number. If you just need the sequence, even simpler:
Code: |
0019ENTRIES
FOR NUMBER =0001= ENTRY
XML IS =<NAME>ABC</NAME>=
TAG IS =<NAME>=
DATA IS =ABC=
FOR NUMBER =0002= ENTRY
XML IS =<ADDRESS>ADDRESS1</ADDRESS>=
TAG IS =<ADDRESS>=
DATA IS =ADDRESS1=
FOR NUMBER =0003= ENTRY
XML IS =<CITY>US</CITY>=
TAG IS =<CITY>=
DATA IS =US=
FOR NUMBER =0004= ENTRY
XML IS =<DATEOFBIRTH>1983-03-03</DATEOFBIRTH>=
TAG IS =<DATEOFBIRTH>=
DATA IS =1983-03-03=
FOR NUMBER =0005= ENTRY
XML IS =<LOCALECODE>VFC</LOCALECODE>=
TAG IS =<LOCALECODE>=
DATA IS =VFC=
FOR NUMBER =0006= ENTRY
XML IS =<NAMELINE>AYUSH</NAMELINE>=
TAG IS =<NAMELINE>=
DATA IS =AYUSH=
FOR NUMBER =0007= ENTRY
XML IS =<SEQUENCENUM>00000018</SEQUENCENUM>=
TAG IS =<SEQUENCENUM>=
DATA IS =00000018=
FOR NUMBER =0008= ENTRY
XML IS =<STATUSCODE>I</STATUSCODE>=
TAG IS =<STATUSCODE>=
DATA IS =I=
FOR NUMBER =0009= ENTRY
XML IS =<STATUS>MARRIED</STATUS>=
TAG IS =<STATUS>=
DATA IS =MARRIED=
FOR NUMBER =0010= ENTRY
XML IS =<MAILID>ABC</MAILID>=
TAG IS =<MAILID>=
DATA IS =ABC=
FOR NUMBER =0011= ENTRY
XML IS =<AGE>23</AGE>=
TAG IS =<AGE>=
DATA IS =23=
FOR NUMBER =0012= ENTRY
XML IS =<TELEPHONE>123456</TELEPHONE>=
TAG IS =<TELEPHONE>=
DATA IS =123456=
FOR NUMBER =0013= ENTRY
XML IS =<SEQUENCENUM>00000021</SEQUENCENUM>=
TAG IS =<SEQUENCENUM>=
DATA IS =00000021=
FOR NUMBER =0014= ENTRY
XML IS =<OCCUPATION>STUDENT</OCCUPATION>=
TAG IS =<OCCUPATION>=
DATA IS =STUDENT=
FOR NUMBER =0015= ENTRY
XML IS =<NAME>ABC</NAME>=
TAG IS =<NAME>=
DATA IS =ABC=
FOR NUMBER =0016= ENTRY
XML IS =<ADD>ADDRESS1</ADD>=
TAG IS =<ADD>=
DATA IS =ADDRESS1=
FOR NUMBER =0017= ENTRY
XML IS =<SEQUENCENUM>00000021</SEQUENCENUM>=
TAG IS =<SEQUENCENUM>=
DATA IS =00000021=
FOR NUMBER =0018= ENTRY
XML IS =<CITY>US</CITY>=
DATA IS =US=
FOR NUMBER =0019= ENTRY
XML IS =<DATEOFBIRTH>1983-03-03</DATEOFBIRTH>=
TAG IS =<DATEOFBIRTH>=
DATA IS =1983-03-03= |
|
|
Back to top |
|
|
|