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

How to change sequential number automatically?


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

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Aug 14, 2009 12:50 pm
Reply with quote

I want the sequential number set automatically.

for instance,
Input are two files, both file have the same record length: 30bytes:

FILEA:
Code:
----+----1----+----2----+----3---
*********************************
HDR SYSTMEA 20090814 11111       
DATA11111111111111111111111111   
DATA22222222222222222222222222   
DATA33333333333333333333333333   
DATA44444444444444444444444444   
TRL SYSTEMA 0000004             
*********************************

FILEB:
Code:
----+----1----+----2----+----3
******************************
DATA55555555555555555555555555
DATA66666666666666666666666666
DATA77777777777777777777777777
DATA88888888888888888888888888
DATA99999999999999999999999999
******************************


Output will be like this:
FILEC:
Code:

----+----1----+----2----+----3
******************************
HDR SYSTMEA 20090814 11112   
DATA55555555555555555555555555
DATA66666666666666666666666666
DATA77777777777777777777777777
DATA88888888888888888888888888
DATA99999999999999999999999999
TRL SYSTEMA 0000005           
******************************


In the header line,
'20090814' is the timestamp when the job runs.
'11112 ' is the sequential number which I want to automatically add 1 to the previous sequential number.


In the trailer line,
'0000005' is the number of records of the second input file(here is FILEB).


How can I get the output like FILEC?
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 14, 2009 9:24 pm
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input fileA (FB/30)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  INCLUDE COND=(1,3,CH,EQ,C'HDR',OR,1,3,CH,EQ,C'TRL')
  OUTFIL IFOUTLEN=80,
   IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),
    BUILD=(C'HCON1,''',1,21,C'''',/,
      C'HSEQNO,''',22,5,ZD,ADD,+1,TO=ZD,LENGTH=5,C'''')),
   IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
    BUILD=(C'TCON1,''',1,12,C''''))
/*
//S2    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input fileB (FB/30)
//SORTOUT DD DSN=...  output file (FB/30)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER1=(HCON1,HSEQNO),
    TRAILER1=(TCON1,COUNT=(EDIT=(TTTTTTT)))
/*
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sat Aug 15, 2009 6:56 am
Reply with quote

Excellent! It is efficient!

I'm so grateful to your kind help!
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sat Aug 15, 2009 12:27 pm
Reply with quote

I found a bug in the code.

In FILEA, how if the first 3 columns of the data between header and trailer contain "HDR", or "TRL"?

In this case, header and trailer cannot be selected out correctly in the first SORT step,right?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Aug 15, 2009 8:03 pm
Reply with quote

NO, WRONG

there is no bug in the code,
the only bug is in Your way of setting the requirements

from Your original request HDR implies header, TRL implies trailer,
which in any civil country means ...
HDR comes first, TRL comes last, none of it come in within the data,
build better data and the issue will automagically disappear
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Aug 15, 2009 8:21 pm
Reply with quote

There's no bug in the code -- if you have HDR or TRL in the first 3 columns of records other than the header and trailer, you should have specified that in your original requirements. And you should have specified how to identify the header and trailer records, then.

Your inability to adequately specify your requirements does not constitute a bug in the code -- it merely highlights your lack of ability to create good requirements.
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sat Aug 15, 2009 9:01 pm
Reply with quote

My fault!

Next time, I'll pay more attention to how to state my self clearly.

Thanks everyone's attention for this requirement.
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: Sat Aug 15, 2009 10:17 pm
Reply with quote

Quote:
In FILEA, how if the first 3 columns of the data between header and trailer contain "HDR", or "TRL"?

In this case, header and trailer cannot be selected out correctly in the first SORT step,right?


Well, yes, but why didn't you say that in the first place?

Here's a version of the DFSORT job that will work even if a data record in FILEA has 'HDR' or 'TRL':

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input fileA (FB/30)
//OUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//TOOLIN   DD    *
SUBSET FROM(IN) TO(OUT) FIRST LAST INPUT KEEP USING(CTL1)
/*
//CTL1CNTL DD *
  OUTFIL IFOUTLEN=80,
   IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),
    BUILD=(C'HCON1,''',1,21,C'''',/,
      C'HSEQNO,''',22,5,ZD,ADD,+1,TO=ZD,LENGTH=5,C'''')),
   IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
    BUILD=(C'TCON1,''',1,12,C''''))
/*
//S2    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input fileB (FB/30)
//SORTOUT DD DSN=...  output file (FB/30)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER1=(HCON1,HSEQNO),
    TRAILER1=(TCON1,COUNT=(EDIT=(TTTTTTT)))
/*
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sun Aug 16, 2009 6:03 am
Reply with quote

hi, Frank,
You are always a nice man.
Appreciate your help!
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sun Aug 16, 2009 6:27 am
Reply with quote

It seems that the latter solution is more effective, both in terms of time and space.
Because in the first step:
In solution 1, all input records are to be processed.
In solution 2, only the first and the last records are to be processed.

In my requirement, the data size between header and trailer is rather huge.

So, I think the second solution is more effective.

Thanks again to everyone concerned, especially Frank.
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: Mon Aug 17, 2009 10:21 pm
Reply with quote

Quote:
In solution 1, all input records are to be processed.
In solution 2, only the first and the last records are to be processed.


Actually, all of the input records are processed with both jobs. As to which one is actually more efficient, you'd have to run them both (with a large number of records) to determine that.
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Tue Aug 18, 2009 9:37 am
Reply with quote

Generally, for the same input D/S and function, using DFSort is more efficient than using other PGM, right?

Is the DFSort system embedded?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Aug 18, 2009 7:17 pm
Reply with quote

Hello,

Quote:
using DFSort is more efficient than using other PGM, right
Maybe, maybe not. It would depend on the requirement.

Quote:
Is the DFSort system embedded?
What does this mean?
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: Tue Aug 18, 2009 9:39 pm
Reply with quote

Quote:
Generally, for the same input D/S and function, using DFSort is more efficient than using other PGM, right?


Well, DFSORT is very efficient, but it's a generalized utility so it has to handle all kinds of situations which involves overhead that a program written with specific knowledge of the application might be able to avoid. It's certainly possible for a well written program to be more efficient in some cases.

Quote:
Is the DFSort system embedded?


DFSORT is not a "system" - it's a program that runs on the z/OS system. I don't believe it would be considered to be "embedded" in any sense of that word. But maybe you should explain what you mean by "embedded".
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Wed Aug 19, 2009 7:10 am
Reply with quote

[quote="Frank Yaeger"]
Quote:
But maybe you should explain what you mean by "embedded".


When we use DFSort , we don't specify the path of the PGM, so, I thought it is system embedded(it resides in the default library).

Now, I have a new requirement:
when the sequential number reached 99999, the subsequent sequential number should be set to '00001'.
If so, how should the DFSort be used?

For the following input file FILEA:
Code:
----+----1----+----2----+----3---
*********************************
HDR SYSTMEA 20090814 99999       
DATA11111111111111111111111111   
DATA22222222222222222222222222   
DATA33333333333333333333333333   
DATA44444444444444444444444444   
TRL SYSTEMA 0000004             
*********************************

and input file FILEB:
Quote:
----+----1----+----2----+----3
******************************
DATA55555555555555555555555555
DATA66666666666666666666666666
DATA77777777777777777777777777
DATA88888888888888888888888888
DATA99999999999999999999999999
******************************


The output file FILEC should be like this:
Code:
----+----1----+----2----+----3
******************************
HDR SYSTMEA 20090814 00001   
DATA55555555555555555555555555
DATA66666666666666666666666666
DATA77777777777777777777777777
DATA88888888888888888888888888
DATA99999999999999999999999999
TRL SYSTEMA 0000005           
******************************


Thanks in advance.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Aug 19, 2009 7:19 am
Reply with quote

Quote:
When we use DFSort , we don't specify the path of the PGM, so, I thought it is system embedded(it resides in the default library).
This just means the load module has been placed in a system area (LINKLIST) so you don't have to point a STEPLIB or JOBLIB to it. The site systems programmers will do this for common routines -- often, even vendor software such as Compuware's Xpediter or CA's CA-11 will have entries in the LINKLIST due to frequent use. By no means could such a program be considered "embedded" -- I would consider something in the nucleus to be "embedded" (possibly).
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Wed Aug 19, 2009 9:44 am
Reply with quote

Hi, Robert,
I understood. In other words, DFsort is just like third-part software.
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 19, 2009 8:49 pm
Reply with quote

Quote:
When we use DFSort , we don't specify the path of the PGM, so, I thought it is system embedded(it resides in the default library).


I've never heard the term "embedded" used to mean "resides in the default library".

Your System Programmers set up DFSORT at your site so it can be found by default when you specify PGM=SORT. That's called the "system order of search" and is a standard z/OS function.

Quote:
I understood. In other words, DFsort is just like third-part software.


DFSORT is from IBM. For z/OS, "third party software" usually refers to software from companies other than IBM. DFSORT is actually an optional feature of z/OS. It is shipped with z/OS and just has to be enabled/licensed via PARMLIB.
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 19, 2009 8:59 pm
Reply with quote

Here's a modified DFSORT/ICETOOL job for your new requirement:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input fileA (FB/30)
//OUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//TOOLIN   DD    *
SUBSET FROM(IN) TO(OUT) FIRST LAST INPUT KEEP USING(CTL1)
/*
//CTL1CNTL DD *
  OUTFIL IFOUTLEN=80,
   IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR',AND,22,5,ZD,EQ,99999),
    BUILD=(C'HCON1,''',1,21,C'''',/,C'HSEQNO,''00001''')),
   IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR'),
    BUILD=(C'HCON1,''',1,21,C'''',/,
      C'HSEQNO,''',22,5,ZD,ADD,+1,TO=ZD,LENGTH=5,C'''')),
   IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
    BUILD=(C'TCON1,''',1,12,C''''))
/*
//S2    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input fileB (FB/30)
//SORTOUT DD DSN=...  output file (FB/30)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER1=(HCON1,HSEQNO),
    TRAILER1=(TCON1,COUNT=(EDIT=(TTTTTTT)))
/*
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Thu Aug 20, 2009 7:03 am
Reply with quote

Yes, it works.
Thanks for your dedicated help!
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Aug 28, 2009 9:05 am
Reply with quote

Hello, Frank Yaeger,

Thanks for your answer.

If the INPUT file is VB format, job you provided goes wrong.

Can you help with the following error:
Code:
 ICE632I 0 SOURCE FOR ICETOOL STATEMENTS:  TOOLIN                               
                                                                               
                                                                               
 ICE630I 0 MODE IN EFFECT:  STOP                                               
                                                                               
           SUBSET FROM(IN) TO(OUT) FIRST LAST INPUT KEEP USING(CTL1)           
 ICE606I 0 DFSORT CALL 0001 FOR COPY FROM IN       TO OUTFIL   USING CTL1CNTL TE
 ICE602I 0 OPERATION RETURN CODE:  16                                           
                                                                               
                                                                               
 ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE:  16                 
******************************** BOTTOM OF DATA ********************************
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 28, 2009 8:22 pm
Reply with quote

You didn't say you had a VB file so I didn't code for that. You have to handle a VB file different than an FB file. A VB file has an RDW in positions 1-4 and variable length records. I'm not feeling well today, so I'll ask Kolusu to help you.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Aug 28, 2009 11:35 pm
Reply with quote

dejunzhu,

Use the following DFSORT JCL

Code:

//S1       EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=your input vb file,DISP=SHR
//SORTOUT  DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)     
//SYSIN    DD *                                                     
  INCLUDE COND=(5,3,SS,EQ,C'HDR,TRL')                               
  SORT FIELDS=COPY                                                   
                                                                     
  OUTREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,BUILD=(1,4,5,30,80:X)),       
  IFTHEN=(WHEN=(5,3,CH,EQ,C'HDR'),BUILD=(1,4,C'HCON1,''',5,21,C'''',
  40:C'HSEQNO,''',26,5,ZD,ADD,+1,TO=ZD,LENGTH=5,C''''),HIT=NEXT),   
  IFTHEN=(WHEN=(5,5,CH,EQ,C'HCON1',AND,48,5,ZD,EQ,0),               
  OVERLAY=(48:48,5,ZD,ADD,+1,TO=ZD,LENGTH=5)),                       
  IFTHEN=(WHEN=(5,3,CH,EQ,C'TRL'),BUILD=(1,4,C'TCON1,''',5,12,C''''))
                                                                     
  OUTFIL VTOF,REMOVECC,BUILD=(5,35,80:X),HEADER1=(40,40,80:X)       
/*                                                                   
//S2       EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                               
//SORTIN   DD DSN=Your input file2,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD    *                                                   
  OPTION COPY                                                       
  OUTFIL REMOVECC,                                                   
    HEADER1=(HCON1,HSEQNO),                                         
    TRAILER1=(TCON1,COUNT=(EDIT=(TTTTTTT)))                         
/*
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Mon Aug 31, 2009 7:55 am
Reply with quote

Hi,kolusu
thanks for your answer.
The source your provided is effective.
I wan to get the same result with the following source, but error occurred.
Code:
//* -----------------------------------------------------------* 
//S1    EXEC  PGM=ICETOOL                                         
//TOOLMSG   DD  SYSOUT=*                                         
//DFSMSG    DD  SYSOUT=*                                         
//IN        DD DSN=EV6954.LJ84.DS.BPDM.OLD,DISP=SHR  ==>OLD I/F   
//OUT       DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//TOOLIN    DD    *                                               
SUBSET FROM(IN) TO(OUT) FIRST LAST INPUT KEEP USING(CTL1)         
/*                                                               
//CTL1CNTL DD *                                                   
 OUTFIL VTOF,IFOUTLEN=80,                                         
   IFTHEN=(WHEN=(5,3,CH,EQ,C'HDR',AND,32,5,ZD,EQ,99999),         
    BUILD=(C'HCON1,''',5,13,DATENS=(4MD),TIMENS=(24),C'''',/,     
      C'HSEQNO,''00001''',80:X)),                                 
   IFTHEN=(WHEN=(5,3,CH,EQ,C'HDR'),                               
    BUILD=(C'HCON1,''',5,13,DATENS=(4MD),TIMENS=(24),C'''',/,     
      C'HSEQNO,''',32,5,ZD,ADD,+1,TO=ZD,LENGTH=5,C'''',80:X)),   
   IFTHEN=(WHEN=(5,3,CH,EQ,C'TRL'),                               
    BUILD=(C'TCON1,''',5,13,C'''',80:X))                         
/*                                                               
//S2       EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                           
//SORTIN   DD DSN=EV6954.LJ84.DS.UNLOAD.TDDB20,DISP=SHR,         
//          UNIT=3390,VOL=SER=(BFF157,BFF156)                   
//SORTOUT  DD DSN=EV6954.TEST,DISP=(,CATLG),                     
//          UNIT=3390,VOL=SER=BFF234,SPACE=(CYL,(300,100),RLSE),
//          DCB=*.S1.IN                                         
//SYSIN    DD    *                                               
  OPTION COPY                                                   
  OUTFIL REMOVECC,                                               
    HEADER1=(HCON1,HSEQNO),                                     
    TRAILER1=(TCON1,COUNT=(EDIT=(TTTTTTT)))                     
/*                                                               


error message:
Code:
              IFTHEN=(WHEN=(5,3,CH,EQ,C'TRL'),                                 
               BUILD=(C'TCON1,''',5,13,C'''',80:X))                             
 ICE146I 0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW   
           DEBUG NOABEND,ESTAE                                                 
           OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTDD=CTL1,SORTIN=IN,S
                          TOUT=OUT,DYNALLOC,EQUALS,NOCHECK,COPY                 
           OMIT COND=ALL                                                       
           OUTFIL FNAMES=OUT                                                   
 ICE201I F RECORD TYPE IS V - DATA STARTS IN POSITION 5                         
 ICE126A 9 INCONSISTENT OUT      IFTHEN 1 REFORMATTING FIELD FOUND             
 ICE751I 0 C5-K90013 C6-K90013 C7-K90000 C8-K42135 E9-K90013 E7-K44563         
 ICE052I 3 END OF DFSORT                                                       
******************************** BOTTOM OF DATA ********************************


Would you please help to correct my code?
Thanks.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Aug 31, 2009 9:50 am
Reply with quote

Hello,

What business reason is there to not use the working solution provided. . . icon_confused.gif
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 Goto page 1, 2  Next

 


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 3270 personal communications. Can't c... TSO/ISPF 2
Search our Forums:

Back to Top