|
View previous topic :: View next topic
|
| Author |
Message |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
Could you please help on this one along with the above requirement:
For the Same Input file (or records), I want to write only the 'V' records with the three key fields of Header & one field from V record itself,into a separate output file.
Input Record :
=========
| Code: |
000164319079.010.H.0000XXYYYY.00001.MM/DD/YYYY.MM/DD/YYYY HH:MM:SS. .001000ZZZZ.
000164319079.010.L.00001.000.00000.009. .000000000000.0000000
000164319079.010.M.00001.0000.01.00000000000000.00000000000000.0000000000000.000
000164319079.010.T.00001.001.00001.001.TX001.
000164319079.010.L.00002.006.00600.028. .000000000000.0000000
000164319083.010.H.0000XXYYYY.00001.MM/DD/YYYY.MM/DD/YYYY HH:MM:SS. .001000ZZZZ.
000164319083.010.L.00000.0000000000000000000000000000 .000000000000.0000000
000164319083.010.V.00001.00001.0010000022.1.09999
000164319080.010.H.0000XXYYYY.00001.MM/DD/YYYY.MM/DD/YYYY HH:MM:SS. .001000ZZZZ.
000164319080.010.L.00001.014.02409.038. .000000000000.0000000
000164319080.010.L.00002.006.00600.246. .000000005996.0000000 |
Output Record :
==========
| Code: |
| XXYYYYMM/DD/YYYY0022000164319083.010.V.00001.00001.0010000022.1.09999 |
Here 0022 is taken from the V record itself (from position 37 to 40). |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please do not "piggy-back" multiple questions onto an existing topic. You need to start a new topic for a new question.
Your topic will be split, but in the future you may notice the tha add-on is simply deleted with no feedback. |
|
| Back to top |
|
 |
Naish
New User

Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
dinfeo,
Suggest you try it and come back if you are stuck and also post the JCL and the error messages. We all will then collectively help you and resolve issues. Believe me you can do this. |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
Hi Naish,
I have written a COBOL program to do this function (Not sure how to write it in SORT).
I tried using JCL SORT, but do know how to take the key fields from Header and write it to another record. I will try to do some more and will get back to you.
Thank You. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10899 Location: italy
|
|
|
|
here for syncsort and in the DFSORT section
there are zillions of examples to achieve what you ask for ...
search for the IFTHEN,PUSH,SELECT,BUILD constructs
and You will find something that' s usable with little modifications |
|
| Back to top |
|
 |
Naish
New User

Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
Hello dinfeo,
There is no need for a COBOL program (at least for what you want here). You just have to tweak the SORT that I gave you in your previous topic.
As enrico had already mentioned please do a search and I am sure you can do it?
A small hint is to add one more IFTHEN and an OMIT COND (if not 'V' - since you don't want other records).
Get back if you are stuck. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
dinfeo came to the forum for a custom built solution.
you did not give it to him; you actually said 'try to work it out yourself'.
so, he goes to COBOL, which apparently he can use successfully
to accomplish this very complex task.
dinfeo will be back, but not with this thread
= unless of course you provide him with his custom solution =
he will open another thread, with another of these complicated problems,
looking for a custom solution. |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
| Hi Naish, I will try it and get back to you. Thanks for the info. |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
dbzTHEdinosauer,
You are correct. I wanted to write it in sort and make the process simpler than to go with a COBOL. I am not familiar with techniques in SORT, but will surely learn it. |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
Hi,
I am unable to get the data from Header.
INREC IFTHEN=(WHEN=GROUP,BEGIN=(18,1,CH,EQ,C'H'),
PUSH=(473:24,2,475:26,4,479:37,10,489:76,4))
INCLUDE COND=(18,1,CH,EQ,C'V')
SORT FIELDS=COPY
OUTREC FIELDS=(1:24,2,3:26,4,7:37,10,17:38,4,21:1,472)
Output is :
1.000000022.1.090022000164319083.010.V.00001.00001.0010000022.1.09999
It is taking the data only from V record. There seems to be an usage of BUILD option for writing a field from one record to another . But I am not finding the explanation for BUILD syntax. |
|
| Back to top |
|
 |
Naish
New User

Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
dinfeo,
| Quote: |
| It is taking the data only from V record. |
Because of this
| Quote: |
| INCLUDE COND=(18,1,CH,EQ,C'V') |
Why don't you try this?
| Quote: |
| A small hint is to add one more IFTHEN and an OMIT COND (if not 'V' - since you don't want other records). |
and please also READ THIS to get an idea of what BUILD is. |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
INREC IFTHEN=(WHEN=GROUP,BEGIN=(18,1,CH,EQ,C'H'),
PUSH=(473:24,2,475:26,4,479:37,10,489:76,4)),
IFTHEN=(WHEN=INIT,
OVERLAY=(1:24,2,3:26,4,7:37,10,17:76,4,21:1,472))
SORT FIELDS=COPY
OMIT COND=((18,1,CH,EQ,C'H'),OR,
(18,1,CH,EQ,C'L'),OR,
(18,1,CH,EQ,C'T'),OR,
(18,1,CH,EQ,C'A'),OR,
(18,1,CH,EQ,C'M'),OR,
(18,1,CH,EQ,C'D'),OR,
(18,1,CH,EQ,C'N'))
OUTREC FIELDS=(1,492)
But the output is coming as
1.000000022.1.09 1.000000022.1.09 0001.00001.0010000022.1.09999
1.000000026.1.09 1.000000026.1.09 0001.00001.0010000026.1.09999
I tried with different other changes but still couldn't get it. |
|
| Back to top |
|
 |
Naish
New User

Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
dinfeo,
Appreciate that you are trying. But, you should know what GROUP and INIT means and what takes preference when used together. It is detailed in the manual with very good examples.
Try this - (Note that this is just an example)
| Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(18,1,CH,EQ,C'H'),
PUSH=(501:24,2,503:26,4,507:27,10)),
IFTHEN=(WHEN=(18,1,CH,EQ,C'V'),
OVERLAY=(516:37,4))
SORT FIELDS=(501,2,CH,A,503,4,CH,A,507,10,CH,A)
OUTFIL BUILD=(1:501,2,3:503,4,7:507,10,17:516,4),
OMIT=(18,1,CH,NE,C'V') |
Experts will guide us if there is an efficient way. |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
Hi Naish,
Thank You. I didn't try with OUTFIL BUILD.
When initially i tried with the virtual sort position field I got spaces in the first 16 positions.
But now I am able to get that. Thank You once again.
SORTCARD:
=======
INREC IFTHEN=(WHEN=GROUP,BEGIN=(18,1,CH,EQ,C'H'),
PUSH=(473:24,2,475:26,4,479:37,10,489:76,4)),
IFTHEN=(WHEN=(18,1,CH,EQ,C'V'),
OVERLAY=(489:38,4))
SORT FIELDS=(473,2,CH,A,475,4,CH,A,479,10,CH,A,489,4,CH,A)
OUTFIL BUILD=(1:473,2,3:475,4,7:479,10,17:489,4,21:1,472),
OMIT=(18,1,CH,NE,C'V')
Output:
=====
07615503/28/20120022000164319083.010.V.00001.00001.0010000022.1.09999
07615503/28/20120026000164319083.010.V.00001.00001.0010000026.1.09999
Thank You once again Naish, Bill & dbzTHEdinosauer. |
|
| Back to top |
|
 |
Naish
New User

Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
| Glad that you got it working. Thanks for letting us know. And could you try and use the code tags next time when you post JCL, etc? |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
| Ok Sure. |
|
| Back to top |
|
 |
dinfeo
New User
Joined: 07 Jun 2012 Posts: 20 Location: India
|
|
|
|
Hi Naish,
Made the two requirements under one sort card:
1) To Sort the entire file and write into one file.
2) To Write only required V record on required format. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please do not post "screenshots" - they take more space and are somewhat cluttered in appearance.
The Code tag will preserve alignment and improve readability. Code'd text appears green on black (like many terminals). There is a Preview function so you can see your post as it will appear to the forum. When you have it looking as you want, Submit. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|