IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

Interchange columns

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC

 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
View previous topic :: View next topic  
Author Message
dinesh_deadman



Joined: 10 Aug 2007
Posts: 19
Location: Chicago

Posted: Wed Oct 08, 2008 9:17 pm    Post subject: Interchange columns  

Hello...

I have an input file of format 4092 VB.

COL-1 COL-2 COL-3
------- ------- --------
AAAA BBBB 1111
CCCC DDDD 2222
EEEE FFFF 3333

Output file should look like,

COL-1 COL-2 COL-3
------- ------- --------
AAAA 1111 BBBB
CCCC 2222 DDDD
EEEE 3333 FFFF

Can this be done in one sort step? Any help is highly appreciated.

Tx,
Dinesh Patel
Back to top  
Frank Yaeger



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

Posted: Wed Oct 08, 2008 9:31 pm    Post subject:  

Yes, you can use DFSORT's INREC or OUTREC statement to do that.

If the VB input record looked like this (rrrr is the RDW):

rrrrAAAABBBB1111data

and you wanted the VB output record to look like this:

rrrrAAAA1111BBBBdata

you could use these DFSORT statements:

Code:
  OPTION COPY                         
  INREC BUILD=(1,8,9:13,4,13:9,4,17)   


It isn't clear what positions your fields are actually in. If you need more specific help, please give the starting position and length of each field (COL-1, COL-2 and COL-3) and indicate whether or not there are other fields after those three.
Back to top  
dinesh_deadman



Joined: 10 Aug 2007
Posts: 19
Location: Chicago

Posted: Wed Oct 08, 2008 9:42 pm    Post subject:  

My bad!

Record length - 202
Record format- VB

These are the final fields.

Starting & Ending Positions I want to be interchanged are,

Current:

Positions -> 192-194 - CHAR(03) or X(03)
-> 195-202 - CHAR(08) or X(08)

Proposed:

Positions -> 192-199 - CHAR(08) or X(08)
-> 200-202 - CHAR(03) or X(03)

Will this work?

OPTION COPY
INREC BUILD=(1,11,192:200,3,195:192,8,202)

Thanks,
Dinesh Patel
Back to top  
arcvns



Joined: 17 Oct 2006
Posts: 706
Location: Chennai, India

Posted: Wed Oct 08, 2008 10:14 pm    Post subject:  

Dinesh,

Dont you want to copy fields from pos-12 to pos-191?
Back to top  
dinesh_deadman



Joined: 10 Aug 2007
Posts: 19
Location: Chicago

Posted: Wed Oct 08, 2008 10:23 pm    Post subject:  

I want to copy all the data in input file from 1 - 202 into output file with those two fields reformatted, in the sense interchanged positions.

Please let me know if this is not clear enough.
Back to top  
arcvns



Joined: 17 Oct 2006
Posts: 706
Location: Chennai, India

Posted: Wed Oct 08, 2008 10:42 pm    Post subject:  

If I understand your requirement correctly, this should work for you. I have just modifed the previous suggestion as per your layout.

Code:   OPTION COPY                         
  INREC BUILD=(1,191,192:195,8,200:192,3)
Back to top  
dinesh_deadman



Joined: 10 Aug 2007
Posts: 19
Location: Chicago

Posted: Thu Oct 09, 2008 12:02 am    Post subject:  

Thanks for the detailed response... but, for some reason it does not give me the desired results...

here is my JCL

//SORT1 EXEC PGM=ICEMAN
//SORTIN DD DSN=DBA.DS188.BMC.CM.DATA,DISP=SHR
//SORTOUT DD DSN=DBA.DS188.BMC.CM.DATA.OUTPUT,
// SPACE=(TRK,(1,1),RLSE),
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=202,RECFM=FB)
//SYSUDUMP DD SYSOUT=D
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,191,192:195,8,200:192,3)
/*

- -- -- -- -- -- -- -- -
Here is the input (only last fields can be seen)
****************
IFRSW< SPACES >
IFRSWUNKNOWN UNK
IFRSWUNKNOWN UNK

Here is the output...
****************
IFRSW< SPACES >
IFRSWNOWN UNKUNK
IFRSWNOWN UNKUNK

Desired output
****************
IFRSW< SPACES >
IFRSWUNKUNKNOWN
IFRSWUNKUNKNOWN



Could you tell where the problem is?

Dinesh Patel
Back to top  
Frank Yaeger



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

Posted: Thu Oct 09, 2008 1:23 am    Post subject:  

You're getting the "wrong" answer because you're giving the "wrong" information. In all your previous posts, you said the input file has RECFM=VB. But based on your latest post where you use RECFM=FB for SORTOUT, and on the output you say you got with your INREC statement, it appears that your input file has RECFM=FB. Also, your previous descriptions of your fields do NOT match the data you are now showing.

Based on your latest post, this would be the DFSORT job you need:

Code:
//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/202)
//SORTOUT DD DSN=...  output file (FB/202)
//SYSIN    DD    *
  OPTION COPY
  INREC BUILD=(1,191,192:200,3,195:192,8)
/*


In the future, please try to provide accurate information from the start.
Back to top  
dinesh_deadman



Joined: 10 Aug 2007
Posts: 19
Location: Chicago

Posted: Tue Oct 28, 2008 9:11 pm    Post subject:  

Frank,

I got a similar request again.

I am trying to move first 2 bytes of data to 10-11 position similarly
data from 3-11 position data should be moved to first two bytes. and am
trying below sort card - not sure what mistake I made - it says OVERLAPPING has occured

Current
-------
AA123456789

To be
-----
123456789AA


//SORT1 EXEC PGM=SORT
//SORTIN DD DSN=INFILE,DISP=SHR
//SORTOUT DD DSN=OUTFILE,
// SPACE=(CYL,(1,1),RLSE),
// DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=82,RECFM=FB)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(12,82,1:9,2,3:1,9)
/*

This time no goofing with details provided... :-)

Dinesh Patel
Back to top  
Frank Yaeger



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

Posted: Tue Oct 28, 2008 9:32 pm    Post subject:  

Code:
  INREC BUILD=(12,82,1:9,2,3:1,9)


You got the overlapping message because you have overlapping fields. 12,82 copies input positions 12-93 to output positions 1-82. Then you have 1: which is less than 83 so you get the overlapping message.

Why are you using 12,82? Why are you using 9,2 and 1,9? Why are you using LRECL=82? None of this corresponds to what you said you want to do, and what you said you want to do doesn't make sense anyway.

The only thing that does make sense is your input/output record example. It shows that you want to move input positions 3-11 to output positions 1-9 and input positions 1-2 to output positions 10-11. To do that, you would use these DFSORT control statements:

Code:
  OPTION COPY               
  INREC BUILD=(1:3,9,10:1,2)


This will give you an output LRECL of 11.

I don't know what your input LRECL is or whether you want to copy the remaining characters (12-?) to the output records. If, for example, your input file has LRECL=80 and you want to copy the remaing characters to the output records, you would use:

Code:
  OPTION COPY               
  INREC BUILD=(1:3,9,10:1,2,12,69)
Back to top  
dinesh_deadman



Joined: 10 Aug 2007
Posts: 19
Location: Chicago

Posted: Tue Oct 28, 2008 10:04 pm    Post subject:  

Input - FB 82
Output - FB 77
First 9 bytes are spaces. I want to cut the length from 82 to 77.
Instead of last 5 bytes, I want to eliminate first 5 bytes.

Current:
--------
1 2 3 4 5 6 7 8 9 10 11 ...... 82
<first 9 spaces> A A ...... A

Output:
-------
1 2 3 4 5 6 7 8 9 10 11 .......77
<4 sp> A A A A A A .......A

Will this work?

OPTION COPY
INREC BUILD=(10:5,72)

Dinesh Patel
Back to top  
Frank Yaeger



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

Posted: Tue Oct 28, 2008 10:25 pm    Post subject:  

Code:
  INREC BUILD=(10:5,72)


This will copy input bytes 5-76 to output bytes 10-81. I don't think that's what you want.

If the input data you want to keep starts at position 10 and you want it to start in output position 5, you would use:

Code:
   INREC BUILD=(5:10,73)
Back to top  
dinesh_deadman



Joined: 10 Aug 2007
Posts: 19
Location: Chicago

Posted: Tue Oct 28, 2008 10:55 pm    Post subject:  

It worked.

Thanks,
Dinesh Patel
Back to top  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> DFSORT/ICETOOL
Page 1 of 1
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM