IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Inserting lines of literal text at CALCULATED INTERVALS


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Wed Aug 22, 2007 10:10 am
Reply with quote

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
...
... ;
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Aug 22, 2007 6:45 pm
Reply with quote

Code:
// EXEC PGM=SORT   
//SORTIN DD *     
UPDATE X WHERE     
...               
... ;             
$                 
UPDATE X WHERE     
...               
... ;             
$                 
UPDATE X WHERE     
...               
... ;             
$                                                                     
//SORTOUT DD SYSOUT=*                                                 
//SYSOUT DD SYSOUT=*                                                 
//SYSIN DD *                                                         
 OPTION COPY                                                         
 INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'$'),OVERLAY=(81:SEQNUM,9,ZD))       
 OUTFIL IFTHEN=(WHEN=(81,9,ZD,EQ,2),BUILD=(1,80,/,C'COMMIT;',73X)),   
        IFTHEN=(WHEN=NONE,BUILD=(1,80))                               

Code:
// EXEC PGM=SORT       
//SORTIN DD *         
UPDATE X WHERE         
...                   
... ;                 
UPDATE X WHERE         
... ; ABC' AND         
... ;                 
UPDATE X WHERE         
...                   
... ;                 
//SORTOUT DD SYSOUT=* 
//SYSOUT DD SYSOUT=*   
//SYSIN DD *       
  OPTION COPY                                                           
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
  INREC IFTHEN=(WHEN=(1,80,SS,EQ,C';                                    *
                                                       '),                 
  OVERLAY=(81:SEQNUM,9,ZD))                                             
  OUTFIL IFTHEN=(WHEN=(81,9,ZD,EQ,2),BUILD=(1,80,/,C'COMMIT;',73X)),     
        IFTHEN=(WHEN=NONE,BUILD=(1,80))
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Aug 22, 2007 8:55 pm
Reply with quote

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.

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
update 1 where
...
... ;
$
update 2 where
...
... ;
$
update 3 where
...
... ;
$
update 4 where
...
... ;
$
update 5 where
...
... ;
$
update 6 where
...
... ;
$
update 7 where
...
... ;
$
//SORTOUT DD SYSOUT=*
//SYSIN DD *
 OPTION COPY
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:2C'00000001')),
    IFTHEN=(WHEN=(1,1,CH,EQ,C'$'),
       OVERLAY=(81:SEQNUM,8,ZD,89:81,8,ZD,MOD,+2,TO=ZD,LENGTH=8))
 OUTFIL IFOUTLEN=80,
    IFTHEN=(WHEN=(89,8,ZD,EQ,+0),
       BUILD=(1,80,/,C'COMMIT;'))
/*


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?
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Thu Aug 23, 2007 5:54 am
Reply with quote

in the second example, i meant any line containing a semicolon ';' as the last displayable char.

eg - the following lines would count (as 1 match) :

abc;
;
;;


the following lines would not count :

;abc
';'
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Aug 23, 2007 8:27 pm
Reply with quote

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?
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Fri Aug 24, 2007 6:46 am
Reply with quote

all the examples cited would count.

recfm = FB, and LRECL = 80
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Fri Aug 24, 2007 7:17 am
Reply with quote

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 ?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Aug 24, 2007 8:20 pm
Reply with quote

Quote:
looks like SEQNUM is acting as a (local) counter within the scope of an IFTHEN test


Yes, that's correct.

Quote:
so just out of curiousity, how would i report the actual inrec count


That depends on what you mean by "inrec count" and what you mean by "report". Show me an example of your input records and what you want for output.


Quote:
all the examples cited would count.

recfm = FB, and LRECL = 80


Ok, I think I have enough information to work out a solution. I'll post it later today.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Aug 24, 2007 10:16 pm
Reply with quote

Here's a DFSORT job that uses the JFY function to do your second example with ; at the end.

Code:

//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
 OPTION COPY                                                     
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:1,80,JFY=(SHIFT=RIGHT))),   
     IFTHEN=(WHEN=INIT,OVERLAY=(82:2C'00000001')),               
     IFTHEN=(WHEN=(160,1,CH,EQ,C';'),                             
       OVERLAY=(82:SEQNUM,8,ZD,90:82,8,ZD,MOD,+2,TO=ZD,LENGTH=8))
 OUTFIL IFOUTLEN=80,                                             
    IFTHEN=(WHEN=(90,8,ZD,EQ,+0),                                 
       BUILD=(1,80,/,C'COMMIT;'))                                 
/*
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Sun Aug 26, 2007 5:35 am
Reply with quote

thanks Frank - works fine ...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts TEXT-TO-PDF Compuware & Other Tools 1
No new posts I need a 4 lines block where substrin... DFSORT/ICETOOL 12
No new posts Copy few lines from SYSOUT of 10 mill... All Other Mainframe Topics 5
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
No new posts Merge 2 lines based on Space from a S... DFSORT/ICETOOL 5
Search our Forums:

Back to Top