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 revert the contents of a file that are reversed

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
raajan_p

New User


Joined: 19 Sep 2005
Posts: 17

PostPosted: Mon Oct 24, 2005 4:56 pm    Post subject: How to revert the contents of a file that are reversed
Reply with quote



I have a ps file. Due to a problem in ftp the contents of the file are reversed. Now I want manipulate this file to get the original contents with the help of jcls. Can you help me?
Back to top
View user's profile Send private message

spanda

New User


Joined: 31 Aug 2005
Posts: 48
Location: U.K.

PostPosted: Mon Oct 24, 2005 5:42 pm    Post subject: Re: Need to know whether it can be done through JCL-Urgent
Reply with quote

Could you be a little more specific about your problem? Do you mean the file contents are just in reverse sort order (last record appearing at the top)?

If the contents of your file are simply appearing upside down, then you could probably sort them in the reverse order, provided the file has a sort key.

Panda.
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 Oct 24, 2005 9:45 pm    Post subject:
Reply with quote

Quote:
If the contents of your file are simply appearing upside down, then you could probably sort them in the reverse order, provided the file has a sort key.


And if records don't have a key, you can add a sequence number to each record with DFSORT's INREC statement, sort the records descending on the sequence number with DFSORT's SORT statement, and then remove the sequence numbers with DFSORT's OUTREC statement.
Back to top
View user's profile Send private message
raajan_p

New User


Joined: 19 Sep 2005
Posts: 17

PostPosted: Tue Oct 25, 2005 2:50 pm    Post subject: Re: How to revert the contents of a file that are reversed
Reply with quote

Thanks a lot for replies.

In my case consider the following details

Input file

record length-80
contains 50 records

do to problem in FTP the output file now is in following format

record length-80
contains 50 records

but each record has been reversed. for eg

before FTP the value present in 1st byte is now present in 80th byte after FTP.
similarly value at 2nd byte is now present in 79th byte after FTP and so on.
how can i get back the original format. can it be done through JCL.
Back to top
View user's profile Send private message
spanda

New User


Joined: 31 Aug 2005
Posts: 48
Location: U.K.

PostPosted: Tue Oct 25, 2005 3:04 pm    Post subject: Re: How to revert the contents of a file that are reversed
Reply with quote

It may not be so easy to reverse the data in the record simply by the use of JCL. Other forum users may have ideas.

I believe you will have to use some programming language (REXX may work best) to fix your problem.

Being an assembler developer, I can think of the MVCIN instruction for reversing the order of the bytes of a string or a record. I think I am getting carried away from the subject here.

Panda.
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 Oct 25, 2005 9:38 pm    Post subject:
Reply with quote

rajaan_p,

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

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT  DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  OUTREC FIELDS=(80,1,79,1,78,1,77,1,76,1,75,1,74,1,73,1,72,1,71,1,
                 70,1,69,1,68,1,67,1,66,1,65,1,64,1,63,1,62,1,61,1,
                 60,1,59,1,58,1,57,1,56,1,55,1,54,1,53,1,52,1,51,1,
                 50,1,49,1,48,1,47,1,46,1,45,1,44,1,43,1,42,1,41,1,
                 40,1,39,1,38,1,37,1,36,1,35,1,34,1,33,1,32,1,31,1,
                 30,1,29,1,28,1,27,1,26,1,25,1,24,1,23,1,22,1,21,1,
                 20,1,19,1,18,1,17,1,16,1,15,1,14,1,13,1,12,1,11,1,
                 10,1,09,1,08,1,07,1,06,1,05,1,04,1,03,1,02,1,01,1)
/*
Back to top
View user's profile Send private message
spanda

New User


Joined: 31 Aug 2005
Posts: 48
Location: U.K.

PostPosted: Wed Oct 26, 2005 5:01 pm    Post subject: Re: How to revert the contents of a file that are reversed
Reply with quote

Frank,

That is a definitely a nice way reversing the bytes on a FB record. Could the same (or something similar) be used for VB records?

Any Syncsort method to reverse a VB record, without actually having to write a utility?

Thanks,
Panda.
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 Oct 26, 2005 8:52 pm    Post subject:
Reply with quote

Quote:
That is a definitely a nice way reversing the bytes on a FB record. Could the same (or something similar) be used for VB records?


For VB, you just need to take the 4-byte RDW into account, e.g.

Code:

  OUTREC FIELDS=(1,4,84,1,83,1,82,1,81,1,80,1,79,1,78,1,77,1,76,1,75,1,
...
  ... 05,1)
Back to top
View user's profile Send private message
spanda

New User


Joined: 31 Aug 2005
Posts: 48
Location: U.K.

PostPosted: Thu Oct 27, 2005 2:51 am    Post subject: Re: How to revert the contents of a file that are reversed
Reply with quote

But in a VB file, the records may be of different lengths. And the OUTREC statement you've suggested assumes that the input record length is 80.

Any thoughts on this?

Thanks,
Panda.
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: Thu Oct 27, 2005 3:34 am    Post subject:
Reply with quote

Quote:
But in a VB file, the records may be of different lengths. And the OUTREC statement you've suggested assumes that the input record length is 80.


Yes, that's what I assumed since you didn't say otherwise. For a true VB file, you'd need to use IFTHEN to set up a different BUILD for each record length, e.g.

Code:

  OUTREC IFTHEN=(WHEN=(1,2,BI,EQ,+6),
      BUILD=(1,4,6,1,5,1)),
    IFTHEN=(WHEN=(1,2,BI,EQ,+7),
      BUILD=(1,4,7,1,6,1,5,1)),
    ...


Rather tedious, but it can be done if you have DFSORT with the Dec, 2004 PTF for IFTHEN.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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