View previous topic :: View next topic
|
Author |
Message |
swapnil781
New User
Joined: 29 Jul 2009 Posts: 10 Location: Bangalore
|
|
|
|
Hi,
I have a FILE1 with LRECL = 3445 (FB),
As per my requirements I need to Select fields and need to create a new file with LRECL = 2805. I am able to do this using SORT but as per my requirment I need to implement this task using SELCOPY.
Sort card to change the LRECL to 2805:
SORT FIELDS=COPY
INREC FIELDS=(1:1,1729,45X,1775:1731,271,2046:2004,448,
2494:2458,248,2742:3102,30,2772:3214,1,
2773:3337,18,2791:3428,15)
Similarly SELCOPY to implement the above sort functionality
READ INFILE NORDW
IF EOF INFILE
THEN EOJ
MOVE 1729 FROM 1 TO 1
THEN POS 1730,1774 = X'40'
THEN MOVE 271 FROM 1731 TO 1775
THEN MOVE 448 FROM 2004 TO 2046
THEN MOVE 248 FROM 2458 TO 2494
THEN MOVE 030 FROM 3102 TO 2742
THEN MOVE 001 FROM 3214 TO 2772
THEN MOVE 018 FROM 3337 TO 2773
THEN MOVE 015 FROM 3428 TO 2791
WRITE OUTFILE
When I try to implement this using SELCOPY, then fields from lenth 2046 - 2494 are appearing as Blank, however the data is populated correctly to first 1729 bytes and later 2742 onwards. I believe this is due to the Spaces which are been indroduced from POS 1730,1774.
Can you please help me with this.
Thanks in advance.
Swapnil |
|
Back to top |
|
 |
David Robinson
Active User
Joined: 21 Dec 2011 Posts: 199 Location: UK
|
|
|
|
If you can do it with SORT, why on earth do you want to change it to SELCOPY?
SELCOPY is a great product, but SORT will me far, far more efficient. |
|
Back to top |
|
 |
swapnil781
New User
Joined: 29 Jul 2009 Posts: 10 Location: Bangalore
|
|
|
|
Hi David,
Thanks for your message.
I do understand Sort is more efficient then SELCOPY, but due to Requirement criteria we are bounded to use SELCOPY. The support team is insisting to Implement SELCOPY.
Hope you could help me with the solution.
Thanks. |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I don't know SELCOPY. Does these "overlap"?
Code: |
THEN MOVE 448 FROM 2004 TO 2046 |
If so, every single byte from 2046 for the remainder of the 448 bytes will have the value of the byte which first causes the overlap.
If your Support people are so keen on SELCOPY, they should have been able to tell you this, and tell you how to fix it.
If this is not the problem, get them to locate it and suggest a fix anyway. There is a lot of SORT experience here, but an unknown-but-small amount of SELCOPY. |
|
Back to top |
|
 |
swapnil781
New User
Joined: 29 Jul 2009 Posts: 10 Location: Bangalore
|
|
|
|
Hi Bill,
Thanks for your Message.
There is no overlap from 2046, but after moving spaces from 1730 to 1774 (45 bytes), spaces are followed till 2494, But from 2742 onwards data is populated correctly.
Being into new assignment people are not much aware for Selcopy at myside, Thats is why I took help of this forum. I am trying to fix this at my end but chances are bleak. |
|
Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Is not the SELCOPY documentation freely downloadable from Compute (Bridgend)? |
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, if you are sure.
In your SORT control cards, if you changed your FIELDS (which would have been better as BUILD) to an OVERLAY, you would get overlap and "propagation" of the overlapping part. If the bytes up to the overlap were space, then the entire result would be space no matter what is in position 2046 onwards originally.
Code: |
THEN MOVE 448 FROM 2004 TO 2046 |
If 2004 and 2046 are within the same data area, you have an overlap, because 2004 for a length of 448 more than crashes into 2046.
If they are in different data areas (say 2004 in input area and 2046 in output area) then you do not have that problem.
Anyway, your Support people are more familiar with SELCOPY than we are. |
|
Back to top |
|
 |
Nick Jones
New User
Joined: 28 Apr 2009 Posts: 13 Location: UK
|
|
|
|
Beware that SELCOPY does indeed perform data propagation on an overlapped MOVE from a source position which is at a lower address than that of the destination position. e.g.
Code: |
POS 1 = 'ABCDEFGHIJ'
MOVE 6 FROM 1 TO 3 * POS 1 will become 'ABABABABIJ' |
To avoid propagation, you should define a work buffer and build the output record data in a different location to the input record. Also use EQUate statements to assign meaningful names to these areas. i.e.
Code: |
EQU INREC 1 * Buffer Input record position.
EQU OUTREC 5001 * Buffer Output record position.
OPTION WORKLEN=10000 * Define a work buffer.
READ INFILE INTO INREC NORDW
MOVE 1729 FROM INREC+0000 TO OUTREC+0000
POS OUTREC+1729, OUTREC+1773 = X'40' * 45 blanks.
MOVE 271 FROM INREC+1730 TO OUTREC+1774
MOVE 448 FROM INREC+2003 TO OUTREC+2045
MOVE 248 FROM INREC+2457 TO OUTREC+2493
MOVE 030 FROM INREC+3101 TO OUTREC+2741
MOVE 001 FROM INREC+3213 TO OUTREC+2771
MOVE 018 FROM INREC+3336 TO OUTREC+2772
MOVE 015 FROM INREC+3427 TO OUTREC+2790
WRITE OUTFILE FROM OUTREC |
|
|
Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Excellent Nick. thanks. Looks at least 200% nicer than the original.
I hope TS's Support people don't feel that now it is so much simpler and easier, that it is too complicated for them to understand... |
|
Back to top |
|
 |
swapnil781
New User
Joined: 29 Jul 2009 Posts: 10 Location: Bangalore
|
|
|
|
Excellent Nick. Thanks it is working now.
Many Thanks to all for providing your inputs. |
|
Back to top |
|
 |
|