Joined: 22 Nov 2016 Posts: 6 Topics: 1 Location: Chennai
Posted: Fri Dec 16, 2016 9:21 am Post subject: Removing opening and closing bracket '[' & ']' using sor
Hi All,
I have a requirement to strip opening and closing bracket of a field whose length is variable. Required field starts at position 5.
Sample Input (LRECL - 80)
Code:
1236 HI HI HI
1236 OP QRS TREND
4997 T UVW
4997 HI HOW ARE YOU
1111 I'M FINE
4991 COME[ON ] ]
4998 [COME[ON ] ]
4999 [AAB CCDD [EEFF] GGG IIIAREWAY]
4955 [AAB CCDD [EEFF GGG IIIAREWAY]
4955 [AAB CCDD EEFF] GGG IIIAREWAY]
4955 [AAB CCDD EEFF GGG IIIAREWAY]
Output: (LRECL - 80)
Code:
1236 HI HI HI
1236 OP QRS TREND
4997 T UVW
4997 HI HOW ARE YOU
1111 I'M FINE
4991 COME[ON ] ]
4998 COME[ON ]
4999 AAB CCDD [EEFF] GGG IIIAREWAY
4955 AAB CCDD [EEFF GGG IIIAREWAY
4955 AAB CCDD EEFF] GGG IIIAREWAY
4955 AAB CCDD EEFF GGG IIIAREWAY
For which, I am trying to generate control card as below.
Query 1:
Hi Koulsu, I have referred your solution in other topics and trying to code according to my requirement. I have not yet coded to write complete sort card. I'm adding ITHEN statement one by one so that I can find where the problem is.
Now, Last two IFTHEN statements to overlay 1st 8 bytes to OUTFIL for first line and space for other lines are not working. Could you please suggest any idea whether the last 2 statements are ignored or coded wrongly
Later I'm planning to add missing sort card lines like "OPTION COPY" using HEADER statement
Query 2:
In next step, I need to sort the output control card based on position (85,3) so that IFTHEN and OVERLAY statements come as a pair. Please give me any hint if I can achieve in first step itself.
Joined: 26 Nov 2002 Posts: 12358 Topics: 75 Location: San Jose
Posted: Fri Dec 16, 2016 10:41 am Post subject:
srihemz,
There are some inconsistencies in your output. You say you need to remove the leading and trailing [ and ] , but this record
Code:
4991 COME[ON ] ]
should have been
Code:
4991 COMEON ]
But you wanted
Code:
4991 COME[ON ] ]
which does not fit the requirement.
Assuming that the above record is a typo here is a JCL which will remove the leading and trailing brackets in one go
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1236 HI HI HI
1236 OP QRS TREND
4997 T UVW
4997 HI HOW ARE YOU
1111 I'M FINE
4991 COME[ON ] ]
4998 [COME[ON ] ]
4999 [AAB CCDD [EEFF] GGG IIIAREWAY]
4955 [AAB CCDD [EEFF GGG IIIAREWAY]
4955 [AAB CCDD EEFF] GGG IIIAREWAY]
4955 [AAB CCDD EEFF GGG IIIAREWAY]
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,FINDREP=(DO=1,INOUT=(C'[',C''))),
IFTHEN=(WHEN=INIT,BUILD=(1,80,JFY=(SHIFT=RIGHT))),
IFTHEN=(WHEN=INIT,
OVERLAY=(80:80,1,CHANGE=(1,C']',C' '),NOMATCH=(80,1),
01:01,80,JFY=(SHIFT=LEFT)))
//*
The output from this is
Code:
1236 HI HI HI
1236 OP QRS TREND
4997 T UVW
4997 HI HOW ARE YOU
1111 I'M FINE
4991 COMEON ]
4998 COME[ON ]
4999 AAB CCDD [EEFF] GGG IIIAREWAY
4955 AAB CCDD [EEFF GGG IIIAREWAY
4955 AAB CCDD EEFF] GGG IIIAREWAY
4955 AAB CCDD EEFF GGG IIIAREWAY
_________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 22 Nov 2016 Posts: 6 Topics: 1 Location: Chennai
Posted: Fri Dec 16, 2016 1:00 pm Post subject:
Thanks a lot for your response kolusu. Sorry that my requirement was not mentioned clearly. Code you provided will perfectly suit my requirement. But in the very least cases input file may not come with both leading and trailing brackets. Sometimes few records will have onlyleading or only trailing. To say in detail, opening bracket that is present only at position 5 (start of the field) should be removed when its corresponding closing bracket appears only at the end of field or even when its corresponding closing bracket not present at all but should not be removed if it has closing bracket before the end of the field. Closing bracket that is present at end of field should be removed when its corresponding opening bracket removed at the start of the field or no opening bracket at all. Words in between the field can have the brackets which neednot be removed. It is not necessary for every open brackets to have closing bracket and viceversa. Please let me know if i confused more. When i go to office on monday i will try to incorporate your code and alter according to my requirement if i could
Joined: 22 Nov 2016 Posts: 6 Topics: 1 Location: Chennai
Posted: Mon Dec 19, 2016 6:45 am Post subject:
Hi Kolusu & William,
At my work place, I was asked to change the requirement to remove '[' and ']' present anywhere. So my work became quite simple. I used Kolusu's logic given above and modified slightly as per the changed requirement. Thanks a lot for both of your response and help
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