View previous topic :: View next topic
Author
Message
justjpr New User Joined: 03 Nov 2022Posts: 33 Location: INDIA
i/p :
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
LINE-AB
LINE-PQ
FULL-NAME
COMPANY-NAME
ADDRESS:
OFFICE 201, BENT TREE COMPLEX
4065, GUS ECKERT RD
CITY-ABCD
LINE-AB2
LINE-PQ2
FULL-NAME2
COMPANY-NAME2
ADDRESS:
ADDRESS-LINE1
ADDRESS-LINE2
ADDRESS-LINE2
CITY-2
o/p:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
LINE-AB
LINE-PQ
FULL-NAME FN
COMPANY-NAME BN
ADDRESS:
OFFICE 201, BENT TREE COMPLEX A1
4065, GUS ECKERT RD A2
CITY-ABCD
LINE-AB2
LINE-PQ2
FULL-NAME2 FN
COMPANY-NAME2 BN
ADDRESS:
ADDRESS-LINE1 A1
ADDRESS-LINE2 A2
CITY-2
I can mark the line with 'MM' in position 55 when 'ADDRESS:' occurs , using SORT-WHEN. However I am unable to mark previous 2 lines and the next two lines. I am aware that it can be done using WHEN=GROUP, but i don't know how to do it.
The sort card which I used to mark 'ADDRESS:' :
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(12,8,CH,EQ,C'ADDRESS:'),
OVERLAY=(055:C'MM'))
/*
Output with this sort card:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
LINE-AB
LINE-PQ
FULL-NAME
COMPANY-NAME
ADDRESS: MM
OFFICE 201, BENT TREE COMPLEX
4065, GUS ECKERT RD
CITY-ABCD
LINE-AB2
LINE-PQ2
FULL-NAME2
COMPANY-NAME2
ADDRESS: MM
ADDRESS-LINE1
ADDRESS-LINE2
CITY-2
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2141 Location: USA
With the code you presented letters ‘MM’ cannot be inserted into the line next to ‘ADDRESS’ as shown in your sample.
Your explanation is extremely unclear: what is varying data, what is constant, what is same line, what is next line? Etc. etc. etc.
Back to top
justjpr New User Joined: 03 Nov 2022Posts: 33 Location: INDIA
sergeyken wrote:
With the code you presented letters ‘MM’ cannot be inserted into the line next to ‘ADDRESS’ as shown in your sample.
Your explanation is extremely unclear: what is varying data, what is constant, what is same line, what is next line? Etc. etc. etc.
Please ignore 'MM', that is not needed. I just wanted to say I can apply OVERLAY in that line, and I don't know how to apply OVERLAY in next/previous lines.
If 'ADDRESS:' string is present in column 12 of a line, then
OVERLAY=(055:C'A1') in the next line
OVERLAY=(055:C'A2') in the next to next line
OVERLAY=(055:C'BN') in the previous line
OVERLAY=(055:C'FN') in the previous to previous line.
This input file is a report file that has letters to many customers/vendors. Requirement is to mask Customer name/Company name/address line 1 & line2. We use delphix tool for masking. Delphix needs record type
to apply appropriate masking algorithm. Here A1,A2,BN & FN are the record types.
We can mark (A,B,C,D) instedad of (FN,BN,A1,A2), that is also fine. I can update record type in delphix accordingly.
Hope this clarifies you. Let me know if you have any questions. Thanks.
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2141 Location: USA
Two pass processing is required. Not possible to guess "previous one or two lines" before reaching the ADDRESS line!
Pass 1:
- renumber all input lines;
- create "marker file": detect "ADDRESS" line numbers (LN), create output file with 5 lines from each "ADDRESS" line, with numbers and corresponding markers:
Code:
LN MM
LN-2 FN
LN-1 BN
LN+1 A1
LN+2 A2
. . . etc, for each ADDRESS line . . . .
In your sample:
Code:
000005 MM
000003 FN
000004 BN
000006 A1
000007 A2
000013 MM
000011 FN
000012 BN
000014 A1
000015 A2
Pass 2:
- join renumbered input file, and created "marker file" using calculated line numbers as joining keys,
- insert markers code from matching lines into positions 55 of corresponding original records.
Back to top
justjpr New User Joined: 03 Nov 2022Posts: 33 Location: INDIA
I simplified my requirement: we need A1,A2 in the 2 lines following the line where 'ADDRESS:' occurs.
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
LINE-AB
LINE-PQ
<many lines>
FULL-NAME
COMPANY-NAME
ADDRESS:
OFFICE 201, BENT TREE COMPLEX A1
4065, GUS ECKERT RD A2
CITY-ABCD
LINE-AB2
LINE-PQ2
<many lines>
FULL-NAME2
COMPANY-NAME2
ADDRESS:
ADDRESS-LINE1 A1
ADDRESS-LINE2 A2
CITY-2
I don't know how to use many features such as PASS, GROUP, PUSH. I know basics like INREC, OUTREC, WHEN, OVERLAY.
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1335 Location: Bamberg, Germany
If you only need a marker, try this:
Code:
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(12,8,CH,EQ,C'ADDRESS:'),PUSH=(55:12,1,SEQ=1),RECORDS=3)
END
When you are flexible with the tags, see as follows:
Code:
LINE-AB
LINE-PQ
<many lines>
FULL-NAME
COMPANY-NAME
ADDRESS: A1
OFFICE 201, BENT TREE COMPLEX A2
4065, GUS ECKERT RD A3
CITY-ABCD
LINE-AB2
LINE-PQ2
<many lines>
FULL-NAME2
COMPANY-NAME2
ADDRESS: A1
ADDRESS-LINE1 A2
ADDRESS-LINE2 A3
CITY-2
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2141 Location: USA
justjpr wrote:
I simplified my requirement: we need A1,A2 in the 2 lines following the line where 'ADDRESS:' occurs.
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
LINE-AB
LINE-PQ
<many lines>
FULL-NAME
COMPANY-NAME
ADDRESS:
OFFICE 201, BENT TREE COMPLEX A1
4065, GUS ECKERT RD A2
CITY-ABCD
LINE-AB2
LINE-PQ2
<many lines>
FULL-NAME2
COMPANY-NAME2
ADDRESS:
ADDRESS-LINE1 A1
ADDRESS-LINE2 A2
CITY-2
I don't know how to use many features such as PASS, GROUP, PUSH. I know basics like INREC, OUTREC, WHEN, OVERLAY.
Marking the FOLLOWING lines is really quite simple.
Marking the PREVIOUS lines requires some extra efforts.
I'm OOO until tomorrow. If nobody finds a solution before tomorrow, I will post it here.
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2141 Location: USA
This is untested solution; some typos are possible.
Code:
//MARKLINE EXEC PGM=ICETOOL
//*
//TOOLMSG DD SYSOUT=*
//DFMSG DD SYSOUT=*
//*................................................................
//SORTIN DD *
LINE-AB
LINE-PQ
<many lines>
FULL-NAME
COMPANY-NAME
ADDRESS:
OFFICE 201, BENT TREE COMPLEX
4065, GUS ECKERT RD
CITY-ABCD
LINE-AB2
LINE-PQ2
<many lines>
FULL-NAME2
COMPANY-NAME2
ADDRESS:
ADDRESS-LINE1
ADDRESS-LINE2
CITY-2
//*-+----1----+----2----+----3----+----4----+----5----+----6
//SYMNAMES DD *
Main_Rec,1,80,CH
Main_Key,12,8,CH
Main_Code,C'ADDRESS:'
Main_Mark,55,2,CH
*
Join_SEQ,*,6,ZD
SEQ_Len,6
Join_Mark,*,2,CH
Join_ID,*,1,CH
*
Marker_Rec,1,6,CH
Marker_SEQ,=,6,ZD
Marker_Code,*,2,CH
Code_Pre2,C'FN'
Code_Pre1,C'BN'
Code_Mark,C'MM'
Code_Past1,C'A1'
Code_Past2,C'A2'
//*
//*................................................................
//TOOLIN DD *
* Pass1: renumber input, and create the markers file
COPY FROM(SORTIN) TO(MAINSEQ,MARKERS) USING(LNUM)
* Pass 2: mark all required lines as per markers file
COPY JKFROM TO(SORTOUT) USING(MARK)
//*
//*................................................................
//LNUMCNTL DD * Pass1 instructions
INREC OVERLAY=(Join_SEQ:SEQNUM,SEQ_Len,ZD)
OUTFIL FNAMES=(MAINSEQ)
OUTFIL FNAMES=(MARKERS),
INCLUDE=(Main_Key,EQ,Main_Code),
BUILD=(Join_SEQ,SUB,+2,LENGTH=SEQ_Len,Code_Pre2,
/,Join_SEQ,SUB,+1,LENGTH=SEQ_Len,Code_Pre1,
/,Join_SEQ,ADD,+1,LENGTH=SEQ_Len,Code_Post1,
/,Join_SEQ,ADD,+2,LENGTH=SEQ_Len,Code_Post2)
//*................................................................
//MAINSEQ DD SPACE=(TRK,(50,50)) temp storage
//MARKERS DD SPACE=(TRK,(10,10)) temp storage
//*................................................................
//MARKCNTL DD * Pass2 instructions
JOINKEYS F1=MAINSEQ,
FIELDS=(Main_SEQ,A),SORTED
JOINKEYS F2=MARKERS,
FIELDS=(Marker_SEQ,A),SORTED
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:Main_Rec,
F2:Marker_Rec,
?)
OUTREC IFTHEN=(WHEN=(Join_ID,EQ,C'B'), need to mark line?
OVERLAY=(Main_Mark:Join_Mark) insert the marker
OUTREC FNAMES=(SORTOUT),
BUILD=(Main_Rec) truncate unneeded fields
//*................................................................
//SORTOUT DD SYSOUT=*
//*................................................................
Back to top
justjpr New User Joined: 03 Nov 2022Posts: 33 Location: INDIA
Joerg.Findeisen wrote:
If you only need a marker, try this:
Code:
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(12,8,CH,EQ,C'ADDRESS:'),PUSH=(55:12,1,SEQ=1),RECORDS=3)
END
When you are flexible with the tags, see as follows:
Code:
LINE-AB
LINE-PQ
<many lines>
FULL-NAME
COMPANY-NAME
ADDRESS: A1
OFFICE 201, BENT TREE COMPLEX A2
4065, GUS ECKERT RD A3
CITY-ABCD
LINE-AB2
LINE-PQ2
<many lines>
FULL-NAME2
COMPANY-NAME2
ADDRESS: A1
ADDRESS-LINE1 A2
ADDRESS-LINE2 A3
CITY-2
Thanks. This helps. I tried it, works well. I'll try the next solution also. Thanks again for your prompt reply.
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2141 Location: USA
As I can see, no one plans to do anything here by his own mind except copy-and-paste a ready-to-use solution?
It's a pity...
Code:
//MARKLINE EXEC PGM=ICETOOL
//*
//TOOLMSG DD SYSOUT=*
//DFMSG DD SYSOUT=*
//*................................................................
//SORTIN DD *
LINE-AB
LINE-PQ
<many lines>
FULL-NAME
COMPANY-NAME
ADDRESS:
OFFICE 201, BENT TREE COMPLEX
4065, GUS ECKERT RD
CITY-ABCD
LINE-AB2
LINE-PQ2
<many lines>
FULL-NAME2
COMPANY-NAME2
ADDRESS:
ADDRESS-LINE1
ADDRESS-LINE2
CITY-2
//*-+----1----+----2----+----3----+----4----+----5----+----6
//SYMNAMES DD *
Main_Key,12,8,CH
Main_Code,C'ADDRESS:'
Main_Mark,55,2,CH
Main_Rec,1,80,CH
*
Join_SEQ,*,6,ZD
SEQ_Len,6
Join_Mark,*,2,CH
Join_ID,*,1,CH
*
Marker_Rec,1,8,CH
Marker_SEQ,=,6,ZD
Marker_Code,*,2,CH
Code_Pre2,C'FN'
Code_Pre1,C'BN'
Code_Mark,C'MM'
Code_Past1,C'A1'
Code_Past2,C'A2'
//*
//*................................................................
//TOOLIN DD *
* Pass1: renumber input, and create the markers file
COPY FROM(SORTIN) TO(MAINSEQ,MARKERS) USING(LNUM)
* Pass 2: mark all required lines as per markers file
COPY JKFROM TO(SORTOUT) USING(MARK)
//*
//*................................................................
//LNUMCNTL DD * Pass1 instructions
INREC OVERLAY=(Join_SEQ:SEQNUM,SEQ_Len,ZD)
OUTFIL FNAMES=(MAINSEQ)
OUTFIL FNAMES=(MARKERS),
INCLUDE=(Main_Key,EQ,Main_Code),
BUILD=(Join_SEQ,SUB,+2,EDIT=(TTTTTT),
Code_Pre2,
/,Join_SEQ,SUB,+1,EDIT=(TTTTTT),
Code_Pre1,
/,Join_SEQ,ADD,+1,EDIT=(TTTTTT),
Code_Past1,
/,Join_SEQ,ADD,+2,EDIT=(TTTTTT),
Code_Past2)
//*................................................................
//MAINSEQ DD SPACE=(TRK,(50,50)) temp storage
//MARKERS DD SPACE=(TRK,(10,10)) temp storage
//*................................................................
//MARKCNTL DD * Pass2 instructions
JOINKEYS F1=MAINSEQ,
FIELDS=(Join_SEQ,A),SORTED
JOINKEYS F2=MARKERS,
FIELDS=(Marker_SEQ,A),SORTED
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:Main_Rec,
F2:Marker_Rec,
?)
OUTREC IFTHEN=(WHEN=(Join_ID,EQ,C'B'), need to mark line?
OVERLAY=(Main_Mark:Join_Mark) insert the marker
OUTFIL FNAMES=(SORTOUT),
BUILD=(Main_Rec) truncate unneeded fields
//*................................................................
//SORTOUT DD SYSOUT=*
//*................................................................
Code:
********************************* TOP OF DATA *************************
LINE-AB
LINE-PQ
<many lines>
FULL-NAME FN
COMPANY-NAME BN
ADDRESS:
OFFICE 201, BENT TREE COMPLEX A1
4065, GUS ECKERT RD A2
CITY-ABCD
LINE-AB2
LINE-PQ2
<many lines>
FULL-NAME2 FN
COMPANY-NAME2 BN
ADDRESS:
ADDRESS-LINE1 A1
ADDRESS-LINE2 A2
CITY-2
******************************** BOTTOM OF DATA ***********************
Back to top
Please enable JavaScript!