I have a requirement to insert a line of text (literal) at calculated intervals -
Input and output are both FB80
The interval is defined as the Nth occurrance of a given character (say '$' at position 1)
eg -
suppose interval = 2, and my insert line is defined as the literal 'COMMIT;'
then with input file :
update X where
...
... ;
$
update X where
...
... ;
$
update X where
...
... ;
$
For output I want :
update X where
...
... ;
$
update X where
...
... ;
$
COMMIT;
update X where
...
... ;
$
also, instead of counting on a given character in pos 1, i would like to count against each occurance of a semicolon ';' where there are no trailing (non space) characters.
so the following input :
update X where
...
... ;
update X where
... ; abc' and
... ;
update X where
...
... ;
would yield :
update X where
...
... ;
update X where
... ; abc' and
... ;
COMMIT;
update X where
...
... ;
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
jzhardy,
Shankar's first job won't actually do what you want if there are more than 3 occurrences of the target character and I have no idea what Shankar's second job is supposed to be doing.
For your first example with the $ target, this DFSORT job will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed accordingly for other attributes.
For your second example with the ; target, it's not clear to me what you're looking for. Is it a ; in some particular position (which position?) with only blanks after it, or a ; anywhere in the record with only blanks after it, or something else? A better example might help.
Also, what is the RECFM and LRECL of your input file?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
If have a DFSORT solution in mind, but the exact solution depends on the answer to the following two questions:
1) Can there be lines with a blank somewhere before the ; at the end? If so, would those lines count? For example, could you have lines anything like this, and if so would they count?
Code:
A B C ;
;
A ;
B C;
'Mickey Mouse';
Or are there never any blanks before the ; at the end? Or do blanks before the ; at the end prevent the line from counting?
2) Again, what is the RECFM and LRECL of your input file?
one other comment about your solution - i had thought of doing something similar, but I was under the impression that SEQNUM always matched the inrec count, regardless of any qualifying conditions ... it looks like SEQNUM is acting as a (local) counter within the scope of an IFTHEN test ... so just out of curiousity, how would i report the actual inrec count ?