MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Edit one file using other file input

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Mon Dec 04, 2006 5:25 pm    Post subject: Edit one file using other file input Reply with quote

Hi,

I have a requirment to edit 1 st file based on the 2nd file data. Conditions and data both are availble in the 2nd file. Here is my requirement

1st file data: LRECL = 80
Code:

             1            20        30        40       
           001         2007L     .0667     .0667

           002         2007L     .0667     .0667

           003         2007L     .0667     .0667

           004         2007L     .0667     .0667

           005         2007L     .0667     .0667

           006         2007L     .0667     .0667

2nd file, which has conditions and data to be used in the first file. This file can have any of the following 2 lines ( only one at any time)
Code:

   2008 Scale Hold
   2007 Scale Change  .0777


If it is 2007 Scale Hold,

The following logic to be applied in 2nd file

Replace field at postion 20 in 2nd file with the new value 2008

If it is 2007 Scale Change

The following logic to be applied in 2nd file
Replace field at postion 20 in 2nd file with 2008 and fields at 30 & 40 with new value .0777.

Please let me know if you need any further details

Thanks for your help
Anand
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Dec 04, 2006 6:19 pm    Post subject: Reply with quote

Here's a DFSORT job that will do what you asked for. SORTIN for S1 can have 2008 Scale Hold or 2007 Scale Change starting in position 3 (if they don't start in position 3, change the job appropriately).

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
   2008 Scale Hold
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTREC BUILD=(C'Flag,''',15,1,C'''',80:X)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD *
001                2007L     .0667     .0667
002                2007L     .0667     .0667
003                2007L     .0667     .0667
004                2007L     .0667     .0667
005                2007L     .0667     .0667
006                2007L     .0667     .0667
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:Flag)),
    IFTHEN=(WHEN=(81,1,CH,EQ,C'H'),OVERLAY=(20:C'2008 ')),
    IFTHEN=(WHEN=NONE,OVERLAY=(20:C'2008 ',
      30:C'.0777',40:C'.0777'))
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 05, 2006 12:19 pm    Post subject: Reply with quote

Thank you Frank for your valuable time.

I have misstated my requirement and I apologize for that. The second file values are variables they are not always constant, except strings " scale hold" and "scale change". Here is the sample 2nd file structure

year1 scale hold
year2 scale change rate1

If it is Scale Hold,

The following logic to be applied in 2nd file

Replace field at postion 20 in 2nd file with the new value year1

If it is Scale Change

The following logic to be applied in 2nd file
Replace field at postion 20 in 2nd file with year2 and fields at 30 & 40 with new value .rate1.

From your solution, I think I need to make modifications to the flag record in the first step, to include the rate information and year information, which I should use in the second step. Please let me know if that works

Thanks
Anand
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Dec 05, 2006 12:47 pm    Post subject: Reply with quote

Well, that does make a difference. Your posts are very confusing with respect to what positions the relevant fields are in and whether the values are lowercase or initial cap, but this revised DFSORT job should give you the idea. In this case, we create and use three symbols, Flag, Year and Rate. (Rate will be blank and unused in the hold case.)

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
2007 scale change .0777
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL BUILD=(C'Flag,''',12,1,C'''',80:X,/,
    C'Year,''',1,4,C'''',/,
    C'Rate,''',19,5,C'''')
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD *
001                2007L     .0667     .0667
002                2007L     .0667     .0667
003                2007L     .0667     .0667
004                2007L     .0667     .0667
005                2007L     .0667     .0667
006                2007L     .0667     .0667
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:Flag)),
    IFTHEN=(WHEN=(81,1,CH,EQ,C'h'),OVERLAY=(20:Year)),
    IFTHEN=(WHEN=NONE,OVERLAY=(20:Year,
      30:Rate,40:Rate))
/*


For the change case with

2007 scale change .0777

SORTOUT has:

Code:

001                2007L     .0777     .0777       
002                2007L     .0777     .0777       
003                2007L     .0777     .0777       
004                2007L     .0777     .0777       
005                2007L     .0777     .0777       
006                2007L     .0777     .0777       


For the hold case with:

2008 scale hold

SORTOUT has:

Code:

001                2008L     .0667     .0667   
002                2008L     .0667     .0667   
003                2008L     .0667     .0667   
004                2008L     .0667     .0667   
005                2008L     .0667     .0667   
006                2008L     .0667     .0667   

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 05, 2006 1:04 pm    Post subject: Reply with quote

Thank You Frank,

While I am trying to execute, I am getting the following error in first step i.e flag creation step S1.

WER268A OUTFIL STATEMENT : SYNTAX ERROR

I could not find out the syntax error. I have used the same job that you have in your note

Thanks
Anand
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Dec 05, 2006 1:07 pm    Post subject: Reply with quote

Quote:

WER268A OUTFIL STATEMENT : SYNTAX ERROR


Anand_R,

You are running SYNCSORT which does NOT support BUILD, IFTHEN parms.

Hope this helps..

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 05, 2006 1:13 pm    Post subject: Reply with quote

Thank you Kolusu, You are right I am using syncsort. Is there any way I can use the same logic and use the appropriate keywords in syncsort to achieve the desired results

Thanks for your help
Anand
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Dec 05, 2006 1:51 pm    Post subject: Reply with quote

Quote:
While I am trying to execute, I am getting the following error in first step i.e flag creation step S1.

WER268A OUTFIL STATEMENT : SYNTAX ERROR


As Kolusu pointed out, the WER messages indicate you're using Syncsort, not DFSORT. Note that my job works fine with DFSORT. I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 05, 2006 1:52 pm    Post subject: Reply with quote

Thank You Frank for all your help so far

Regards
Anand
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Dec 05, 2006 2:22 pm    Post subject: Reply with quote

Anand,

Try this code.

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
2007 scale change .0777                                       
/*                                                             
//SORTOUT  DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD *                                             
  OPTION COPY                                                 
  OUTFIL OUTREC=(C'FLAG,''',12,01,C'''',80:X,/,               
                 C'YEAR,''',01,04,C'''',/,                     
                 C'RATE,''',19,05,C'''')                       
/*
//STEP0200 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                   
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                   
//SORTIN   DD *                                         
001                2007L     .0667     .0667             
002                2007L     .0667     .0667             
003                2007L     .0667     .0667             
004                2007L     .0667     .0667             
005                2007L     .0667     .0667             
006                2007L     .0667     .0667             
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *                                       
  OPTION COPY                                           
  INREC FIELDS=(01,80,81:FLAG,30,5,X,40,5)               
  OUTREC FIELDS=(01,19,                                 
                 20:YEAR,                               
                 24,58,                                 
                 82:81,1,CHANGE=(5,C'c',RATE),           
                                 NOMATCH=(30,5),         
                 87,01,                                 
                 88:81,1,CHANGE=(5,C'c',RATE),           
                                 NOMATCH=(40,5))         
  OUTFIL OUTREC=(01,29,                                 
                 82,05,                                 
                 35,05,                                 
                 88,05,                                 
                 45,36)                                 
/*         


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 05, 2006 4:49 pm    Post subject: Reply with quote

Thank You kolsu, It's a perfect solution, it is working as expected
Back to top
View user's profile Send private message
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 05, 2006 4:54 pm    Post subject: Reply with quote

Hi Kolusu,

I have also another requirement to drop some records from a file using another control file, where it will have all the records that needs to be dropped. I searched through form with word 'drop' and could not find desired results.

For instance input file have the following data

001 2007L .0777 .0777
002 2007L .0777 .0777
003 2007L .0777 .0777
004 2007L .0777 .0777
005 2007L .0777 .0777
006 2007L .0777 .0777

2nd control file have the following date

001
002
005

Final output file should have only the following records
003 2007L .0777 .0777
004 2007L .0777 .0777
006 2007L .0777 .0777

Thanks
Anand
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Dec 05, 2006 5:01 pm    Post subject: Reply with quote

Anand_R,


Does input file contain duplicates? if they are unique then you can use "nodups" parm. Check these links

http://www.mvsforums.com/helpboards/viewtopic.php?t=254&highlight=nodups

http://www.mvsforums.com/helpboards/viewtopic.php?t=8&highlight=nodups

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Tue Dec 05, 2006 5:45 pm    Post subject: Reply with quote

Thank You Kolusu for your timely help always
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group