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
 

 

How to change sequential number automatically?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to change sequential number automatically?
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 Moderator


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

PostPosted: Fri Aug 14, 2009 9:24 pm    Post subject:
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    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Sat Aug 15, 2009 8:03 pm    Post subject: Reply to: How to change sequential number automatically?
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: 7904
Location: Bellevue, IA

PostPosted: Sat Aug 15, 2009 8:21 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Sat Aug 15, 2009 10:17 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Aug 17, 2009 10:21 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Aug 18, 2009 7:17 pm    Post subject:
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 Moderator


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

PostPosted: Tue Aug 18, 2009 9:39 pm    Post subject:
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    Post subject:
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: 7904
Location: Bellevue, IA

PostPosted: Wed Aug 19, 2009 7:19 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Aug 19, 2009 8:49 pm    Post subject:
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 Moderator


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

PostPosted: Wed Aug 19, 2009 8:59 pm    Post subject:
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    Post subject:
Reply with quote

Yes, it works.
Thanks for your dedicated help!
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Sequence number add in SORT pshongal SYNCSORT 3 Fri Sep 02, 2016 3:32 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts How to change dataset attributes of m... ignich7 JCL & VSAM 3 Thu Jul 21, 2016 9:17 pm
No new posts creating a physical sequential file i... Shaheen Shaik JCL & VSAM 8 Wed Jun 29, 2016 3:46 pm


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