Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

JCL to check a specific record & change the previous record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
scentofnature

New User


Joined: 03 Aug 2015
Posts: 6
Location: India

PostPosted: Mon Aug 03, 2015 1:49 pm    Post subject: JCL to check a specific record & change the previous record
Reply with quote

My requirement :

Have a File, when the field (131-150) shown below in the example (record #4 in the example) has the value spaces, the previous record in the file needs to be changed. In the previous record, at column 881 or 882 or 880, if the string has the value as 'MORE'it needs to be replaced by 'LAST'. This needs to be done via JCL, can this be done via JCL?

RECFM VB LRECL 32754 Rec# 31 - CAPS OFF RDW OFF
:EPI:-REF-NO :EPI:-DTPD-CD :EPI:-FQ-CD :EPI:-RGN-CD
C(20) (131-150) C(4) (151-154) C(2) (155-156) C(3) (157-159
-------------------- -------------- -------------- -------------

EPS1507070074549 D 03
EPS1507070074550 D 03
EPS1507070074551 D 03
D 03

BROWSE XEPI01.EPI8.JI545D0R.FMTDATA
Command ===>
-+----8----+----9----+----0----+----1----+----2----+
28E:11/MORE..:13A::STAT//535..:20C::SEME//EPS1507070
28E:12/MORE..:13A::STAT//535..:20C::SEME//EPS1507070
28E:13/MORE..:13A::STAT//535..:20C::SEME//EPS1507070
28E:14/MORE..:13A::STAT//535..:20C::SEME//EPS1507070
Back to top
View user's profile Send private message

Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Mon Aug 03, 2015 2:38 pm    Post subject:
Reply with quote

Quote:
This needs to be done via JCL, can this be done via JCL?


No. JCL can only be used to execute programs/utilities. You likely need a SORT (DFSORT or SYNCSORT) utility solution....

Garry.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Aug 03, 2015 2:59 pm    Post subject: Reply to: JCL to check a specific record & change the previous record
Reply with quote

Can you show some clearer sample data and expected output. It doesn't need to be your actual data, but it must reflect the relationship of your actual data.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Aug 03, 2015 3:11 pm    Post subject: Reply to: JCL to check a specific record & change the previous record
Reply with quote

when posting data and code use the code tags
they force the use of a fixed pitch font and preserve the spaces,
making things more understandable for people who spend their time helping

without
>>>"1234567890"<<<
>>>" " <<<

with
Code:
>>>"1234567890"<<<
>>>"          "<<<
Back to top
View user's profile Send private message
scentofnature

New User


Joined: 03 Aug 2015
Posts: 6
Location: India

PostPosted: Mon Aug 03, 2015 3:58 pm    Post subject:
Reply with quote

Thanks Gary. Yes I would need a sync sort utility.

Bill trying to explain with smaller sample size data.

Here is my 25 character input file.

Code:

----+----1----+----2----+
*************************
535EPIS01001228E::01:MORE
535EPIS01001328E::02:MORE
535EPIS01001428E::03:MORE
535EPIS01001528E::04:MORE
535EPIS01001628E::05:MORE
535EPIS01001728E::06:MORE
535          28E::07:MORE

Columns 4 to 13, is the key.
Code:

>>>'EPIS010017'<<<< 
>>>'          '<<<< 


a) If a record has spaces from 4-13th column, and the 21st or 22nd column of the previous record has the value >>>'MORE'<<<
b) The previous record's string >>>'MORE'<<< needs to be changed to >>>'LAST'<<<. This is only specific to the previous record for the record which has columns 4 to 13 as spaces.
output would look like below.

Output file
Code:

----+----1----+----2----+----3--
535EPIS01001228E::01:MORE       
535EPIS01001328E::02:MORE       
535EPIS01001428E::03:MORE       
535EPIS01001528E::04:MORE       
535EPIS01001628E::05:MORE       
535EPIS01001728E::06:LAST       
535          28E::07:MORE       
Back to top
View user's profile Send private message
scentofnature

New User


Joined: 03 Aug 2015
Posts: 6
Location: India

PostPosted: Mon Aug 03, 2015 4:13 pm    Post subject:
Reply with quote

Gary, Bill,

Guess this topic needs to be transferred to syncsort. As I cannot use dfsort and icetool in my office. Can we do that ? . I am not sure how to transfer the topic from one page to another.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Aug 03, 2015 4:20 pm    Post subject: Reply to: JCL to check a specific record & change the previous record
Reply with quote

OK, that's much clearer.

You can use JOINKEYS with the same DSN for both input files. By specifying, in the JNFnCNTL files, offset sequence numbers for the records, it means you can get to look at the "current" and "previous" records at the same time. Here's a discussion.

You can only just get this to work, as your LRECL is two bytes short of the maximum for a VB in DFSORT. You will have to make a "flag" out of your key.

You will need a variable-length REFORMAT record. Something like:

Code:
  REFORMAT FIELDS=(F1:1,4,F2:1,1,F1:5)


That would prepend your flag to the data from your variable-length record.

You test the flag (which would be 5.1 on the REFORMAT record) and make any required adjustment. Then use BUILD=(1,4,6) to output your record.

In your case, you'd need the "next" record to have a lower sequence number than the "current" record.

Your LRECL is very inefficient for DASD. Is your data on tape, or only a small volume?
Back to top
View user's profile Send private message
scentofnature

New User


Joined: 03 Aug 2015
Posts: 6
Location: India

PostPosted: Mon Aug 03, 2015 5:04 pm    Post subject:
Reply with quote

Bill,

Actually my record format and length is VB , 32754. I showed that example just for a better understanding. understood the JOIN KEYS part for comparison. Still I am not sure of how to change the string of the previous record. >>>"MORE"<<< to >>>"LAST"<<<<
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Aug 03, 2015 5:13 pm    Post subject: Reply to: JCL to check a specific record & change the previous record
Reply with quote

I think I covered the huge VB part in the previous post.

In the Main Task of the JOINKEYS, use INREC with two IFTHEN=(WHEN=(logicalexpression) to test for your MORE in two different places and use OVERLAY to put the LESS in their place.

This represents your data:

Code:

A
B
C
D


The JOINKEYS will give you this (assuming you get the sequence numbers correctly offset):

Code:
- A
A B
B C
C D
D -


You JOIN with UNPAIRED,F1

The second column above is a representation of the "flag" you have to create in JNF2CNTL. A flag for record A, which will be ignored. A flag for record B, which will be available at the same time as record A. Do your test on the data for record A and the flag and do the OVERLAY if necessary.

You need to arrange the final BUILD to drop the flag. Simplest could be to use OUTREC BUILD=(1,4,6)
Back to top
View user's profile Send private message
scentofnature

New User


Joined: 03 Aug 2015
Posts: 6
Location: India

PostPosted: Tue Aug 04, 2015 12:43 am    Post subject: It worked.
Reply with quote

Hello Bill,

Used the below and it worked. Thanks Bill used your core idea and made a few changes

Actually has two steps

Code:
 

Step1

 INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5,10000,10006:SEQNUM,10,ZD))
  SORT FIELDS=(10006,10,ZD,D)                                   
  OUTFIL IFTHEN=(WHEN=GROUP,BEGIN=(761,12,CH,EQ,C' '),           
         RECORDS=2,PUSH=(10017:ID=1,SEQ=1)),                     
         IFTHEN=(WHEN=(10018,1,ZD,EQ,2),                         
         FINDREP=(INOUT=(C'MORE',C'LAST'),                       
         STARTPOS=883,ENDPOS=893))       

Step2

   INCLUDE COND=(761,12,CH,NE,C' ')               
   SORT FIELDS=(10006,10,ZD,A)                     
   OUTFIL BUILD=(1,4,5,10005)                     

                       
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Aug 04, 2015 1:56 am    Post subject: Reply to: JCL to check a specific record & change the previous record
Reply with quote

Wow. That's sorting all the data, twice, and making it fixed-length 1009 bytes long. What happened to your 32000+ LRECL? Your FINDREP goes for longer than would be necessary from what you have said. What's the INCLUDE for? You never mentioned dropping any records. What do you need the ID for?

If your data is small enough so that you don't mind the two SORTs, at least extend the records "at the front" so you can keep them variable (and avoid rubbish appearing, and avoid S0C4s, perhaps).
Back to top
View user's profile Send private message
scentofnature

New User


Joined: 03 Aug 2015
Posts: 6
Location: India

PostPosted: Tue Aug 04, 2015 2:18 am    Post subject:
Reply with quote

a) the output file can only have max of 9500 records at the time, therefore used 10,000 although the output file can hold 32000 records.
b) dropping was a new requirement added today, unfortunately.
c) findrep just to make sure I have extra comfort, for finding the MORE tag just in case.
sure I will extend the records.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Aug 04, 2015 2:39 am    Post subject: Reply to: JCL to check a specific record & change the previous record
Reply with quote

The LRECL is the maximum bytes per record (including the mandatory four bytes for the RDW if the records are variable-length). It is nothing to do with the number of records on a file.

You have an LRECL of 32000+, which represents the maximum record-length, which, if correct, implies that you are/will truncate records. If it is not correct, make the LRECL correct, as it is wreaking havoc with you space allocation if the dataset is on DASD.

As long as you can't get any "false hits", the FINDREP is OK. But if a surname happened to follow your original up-to-three, then MORETON in the surname would become LASTTON.

Code:
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,SEQNUM,10,ZD,5))


That'll get you RDW, 10-digit sequence number (so allowing for up to 9,999,999,999 records) and then from byte five to the end of the current record.

After the SORT, you do longer need the sequence number field, so you can re-use that for your SEQ from the GROUP. With SEQ=1, remember that having more than 10 records in a group can be problematic. Specifically 12, or 22, or 32. You get to see why?

To return the record to its original form (with changes if necessary) will be BUILD=(1,4,15). Also remember to further offset your fields by the length of the extension.
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us