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

Require help with sequence number


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

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Tue Apr 17, 2012 9:29 am
Reply with quote

Hi,

Actually, my requirement is to put sequence number at a particular position based on record type. It is a variable lenght file.

TYPE --- Position for Sequnce number (8)
--------- -----------------------------
1644 --- 107
1240 --- 689
1540 --- 151
1740 --- 179


I tried doing it (only for 2 rec types) and below is my attempt:

Code:
//SYSIN DD *                                                           
  RECORD TYPE=V                                                         
  OPTION COPY                                                           
  INREC IFTHEN=(WHEN=(56,4,CH,EQ,C'1240'),OVERLAY=(693:SEQNUM,8,ZD)),   
        IFTHEN=(WHEN=(56,4,CH,EQ,C'1644'),OVERLAY=(111:SEQNUM,8,ZD))   
// 




But the issue with it is that the sequence number resets for next record type.

For eg. It is coming like like


1240 - 000001
1240 - 000002
1240 - 000003
1644 - xxxxxxx000001
1644 - xxxxxxx000002
1644 - xxxxxxx000003
1644 - xxxxxxx000004


But I require something like:

1240 - 000001
1240 - 000002
1240 - 000003
1644 - xxxxxxx000004
1644 - xxxxxxx000005
1644 - xxxxxxx000006
1644 - xxxxxxx000007

Any kind of help will be really appreciated.

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Apr 17, 2012 11:52 am
Reply with quote

Every time you use SEQNUM it is a different one.

So, if you have SEQNUM on WHEN=INIT, inserted at the beginning of your records (because your records are variable) (unless there is an "unused" portion of the fixed part of the record you could re-use temporarily) and then with the WHEN=(condition) copy the added field to where you want it for that particular record-type.

After each record is processed, you have to "clean up" the now surplus SEQNUM, with BUILD,
Back to top
View user's profile Send private message
nagaraj_bez

New User


Joined: 09 Jun 2005
Posts: 10

PostPosted: Tue Apr 17, 2012 11:56 am
Reply with quote

Hi Mohitsaini,

Try the following steps.
Step-1: Number all records
Step-2: using overlay as u have tried, write the output record based on conditions.

Example:
input :

1234561240
1234561644
expected output :
add seq number in 7th position( before 1240) for 1240, 11th position(after 1644) for 1644 condition

123456000000011240
123456164400000002

Step1 o/p : (added seq number at starting 1-8 position)
000000011234561240
000000021234561644

Step2 o/p: based on condition
123456000000011240
123456164400000002
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Apr 17, 2012 9:49 pm
Reply with quote

mohitsaini,

Use the following DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your Input VB File,DISP=SHR                             
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8X,5)),               
  IFTHEN=(WHEN=(64,4,SS,EQ,C'1240,1540,1644,1740'),         
  OVERLAY=(5:SEQNUM,8,ZD),HIT=NEXT),                       
  IFTHEN=(WHEN=(64,4,CH,EQ,C'1240'),OVERLAY=(701:5,8)),     
  IFTHEN=(WHEN=(64,4,CH,EQ,C'1540'),OVERLAY=(163:5,8)),     
  IFTHEN=(WHEN=(64,4,CH,EQ,C'1644'),OVERLAY=(119:5,8)),     
  IFTHEN=(WHEN=(64,4,CH,EQ,C'1740'),OVERLAY=(191:5,8))     
                                                           
  OUTREC BUILD=(1,4,13)                                     
//*
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Tue Apr 24, 2012 3:20 pm
Reply with quote

Thanks it is working . ..
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 Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top