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
 
Moving a field from a Record the the next Record

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

New User


Joined: 19 Nov 2008
Posts: 90
Location: Spain

PostPosted: Mon Sep 14, 2009 6:43 pm    Post subject: Moving a field from a Record the the next Record
Reply with quote

Hi There

I have a rather interesting request in hand, and I was wondering if it could be completed using DFSORT or ICETOOL , which would save me the hassle of making a program for such an easy task.

My request is:

I have a file with a lots of records, with this fields

Office
Date
Begining amount
Ending Amount
Incoming amount
Outcoming amount

Well, the things is, the input file has many recors, and only the first record, the one for the date 2009-01-02 has the begining and ending amount informed for each office. I don't have this field for the rest of the year dates. I need to process movements from a series of files with a wide range of dates, let's say, a year. It is needed to build an initial stat.

A sample input file would be like this:

Code:

OFF  DATE          BEGIN AMOUNT   ENDING AMOUNT        INCOMING       OUTCOMING
XXXX YYYY-MM-DD 999999999999999 999999999999999 999999999999999 999999999999999 (FORMAT)
0001 2009-01-02           50000           50000             150             300     
0001 2009-01-03                                             300             300   
0001 2009-01-04                                             450             300   
0001 2009-01-05                                              25            5000 
0002 2009-01-02          450000          450000             450           56000
0002 2009-01-03                                             100               0       
0002 2009-01-04                                              50               0       
0002 2009-01-05                                              50           80000 
0002 2009-01-06                                             150             450   
0002 2009-01-07                                             200             500


I need to sort the records in ASC order by the OFFICE and DATE Fields, but the tricky part is that the next begining and endind record have to be calculated from the previous record like this:

New Record Begining Amount = Previous Record endind amount
The Ending Amount for that new record would be calculated like this:

Ending amount = Begining Amount + Incoming - outcoming.

Easy task for a program, but can be done with a Sort?

The desired result file would be like this:

Code:

OFF  DATE          BEGIN AMOUNT   ENDING AMOUNT        INCOMING       OUTCOMING         
XXXX YYYY-MM-DD 999999999999999 999999999999999 999999999999999 999999999999999 (FORMAT)
0001 2009-01-02           50000           50000             150             300         
0001 2009-01-03           50000           50000             300             300         
0001 2009-01-04           50000           50150             450             300         
0001 2009-01-05           50150           45175              25            5000         
0002 2009-01-02          450000          450000             450           56000         
0002 2009-01-03          450000          450100             100               0         
0002 2009-01-04          450100          450150              50               0         
0002 2009-01-05          450150          370200              50           80000         
0002 2009-01-06          370200          369900             150             450         
0002 2009-01-07          369900          369600             200             500         


I could easily calculate the new value for ending amount in an outrec step, bu't I'd like to know is there is a way to do all this in a single step through the usage of DFSORT or ICETOOL.

The File specs are not defined yet, but what is certain is that the input file is FB Format, and the OFFICE and DATE Fields are 4 annd 10 CH in length, and the amount fields are 17 bytes ZD length. Let's assume the whole record length is 150 bytes, it doesn't really matters at this point.

Any hints or possibility to do this. I don't know if I can move a field from the previous record to the next one.

As usual, thanks a lot for your support.

I'm sorry if something is not clear enough. I'll Provide more info if needed

Best Regards

Oliver
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Tue Sep 15, 2009 1:16 am    Post subject: Reply to: Moving a field from a Record the the next Record
Reply with quote

Ojdiaz,

The following DFSORT/ICETOOL JCL will give you the desired results.

The assumed the following

You dont have the header of 2 as shown in your same output.

1. Begin amount starts in pos 17 for 17 bytes
2. End amount starts in pos 35 for 17 bytes
3. Incoming amount starts in pos 53 for 17 bytes
4. Outcoming amount starts in pos 71 for 17 bytes
Code:
 
//STEP0100 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD DSN=&&I1,DISP=SHR                                         
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)             
//T2       DD DSN=&&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)             
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
  SORT FROM(IN) USING(CTL1)                                             
  COPY FROM(T1) USING(CTL2)                                             
  SORT FROM(T2) USING(CTL3)
//CTL1CNTL DD *                                                       
  SORT FIELDS=(1,4,CH,A,6,10,CH,A),EQUALS                             
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(151:SEQNUM,8,ZD,RESTART=(1,4),     
         159:17,17,UFF,ADD,(53,17,UFF,SUB,71,17,UFF),PD,LENGTH=10)),   
  IFTHEN=(WHEN=(151,8,ZD,EQ,1),OVERLAY=(159:35,17,UFF,PD,LENGTH=10))   
  OUTFIL FNAMES=T1,REMOVECC,SECTIONS=(1,4,                             
  TRAILER3=(1,16,151:8C'$',TOT=(159,10,PD,PD,LENGTH=10)))             
//*
//CTL2CNTL DD *                                                         
  INREC IFTHEN=(WHEN=(151,8,CH,EQ,C'$$$$$$$$'),                         
  OVERLAY=(159:159,10,PD,MUL,-1,PD,LENGTH=10))                         
  OUTFIL FNAMES=T2,REMOVECC,BUILD=(1,168,+0,TO=PD,LENGTH=10,X),         
  SECTIONS=(1,16,151,8,                                                 
  TRAILER3=(1,168,169:SUBTOT=(159,10,PD,PD,LENGTH=10),'$'))             
//*
//CTL3CNTL DD *                                                         
  OMIT COND=(151,8,CH,EQ,C'$$$$$$$$')                                   
  SORT FIELDS=(1,4,CH,A,6,10,CH,A),EQUALS                               
  SUM FIELDS=(169,10,PD)                                               
  OUTFIL FNAMES=OUT,IFOUTLEN=150,                                       
  IFTHEN=(WHEN=(151,8,ZD,GT,1),                                         
  OVERLAY=(17:169,10,PD,SUB,159,10,PD,EDIT=(IIIIIIIIIIIIIIIIT),         
           35:169,10,PD,M10,LENGTH=17))                                 
/*
Back to top
View user's profile Send private message
ojdiaz

New User


Joined: 19 Nov 2008
Posts: 90
Location: Spain

PostPosted: Tue Sep 15, 2009 11:52 am    Post subject:
Reply with quote

Hi Skolosu.

Thanks a Lot for your reply.

Could you please clarify what do you mean when you say:

Quote:

You dont have the header of 2 as shown in your same output.


What I Like about this forum is that each day I learn new stuff. I haven't used before some of the options of the outfil that you used, So I'll use and test the code and I'll try to understand it entirely and I'll let you know the results

Thanks again

Oliver
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Sep 15, 2009 9:34 pm    Post subject:
Reply with quote

ojdiaz wrote:
Hi Skolosu.

Thanks a Lot for your reply.

Could you please clarify what do you mean when you say:

Quote:

You dont have the header of 2 as shown in your same output.


Thanks again

Oliver



Oliver,

what i meant is that your input file does NOT have these 2 records. All you have is your data records

Code:

OFF  DATE          BEGIN AMOUNT   ENDING AMOUNT        INCOMING       OUTCOMING         
XXXX YYYY-MM-DD 999999999999999 999999999999999 999999999999999 999999999999999 (FORMAT)
Back to top
View user's profile Send private message
ojdiaz

New User


Joined: 19 Nov 2008
Posts: 90
Location: Spain

PostPosted: Wed Sep 16, 2009 3:48 pm    Post subject:
Reply with quote

Oh!!! Taht's right! I'm sorry if it was a silly question. Indeed those two records are not in my input file. I wrote them just for explanation purposes.

I'll keep workinig on this and I'll let you know the results as soon as posible

Thanks a lot again

Oliver
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 Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts Moving a PS file as body of a mail! Vignesh Sid JCL & VSAM 4 Tue Nov 21, 2017 9:23 pm
No new posts Extract Record using range of Data scorp_rahul23 DFSORT/ICETOOL 3 Wed Nov 15, 2017 11:54 pm

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