Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Inserting lines of literal text at CALCULATED INTERVALS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 31
Location: brisbane

PostPosted: Wed Aug 22, 2007 10:10 am    Post subject: Inserting lines of literal text at CALCULATED INTERVALS
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    Post subject:
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 Moderator


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

PostPosted: Wed Aug 22, 2007 8:55 pm    Post subject:
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

New User


Joined: 31 Oct 2006
Posts: 31
Location: brisbane

PostPosted: Thu Aug 23, 2007 5:54 am    Post subject:
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 Moderator


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

PostPosted: Thu Aug 23, 2007 8:27 pm    Post subject:
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

New User


Joined: 31 Oct 2006
Posts: 31
Location: brisbane

PostPosted: Fri Aug 24, 2007 6:46 am    Post subject:
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

New User


Joined: 31 Oct 2006
Posts: 31
Location: brisbane

PostPosted: Fri Aug 24, 2007 7:17 am    Post subject:
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 Moderator


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

PostPosted: Fri Aug 24, 2007 8:20 pm    Post subject:
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 Moderator


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

PostPosted: Fri Aug 24, 2007 10:16 pm    Post subject:
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

New User


Joined: 31 Oct 2006
Posts: 31
Location: brisbane

PostPosted: Sun Aug 26, 2007 5:35 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting on text - but in non-alphabet... Roy Ware SYNCSORT 5 Wed Aug 23, 2017 9:15 pm
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us