I need to generate a sort card using the values present in a dataset.
Input:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
1 INVALIDVALUE X'BA' C'_'
2 INVALIDVALUE X'BB' C'_'
3 INVALIDVALUE X'39' C'__'
4 INVALIDVALUE X'41' C'__'
5 VALIDVALUE X'C1' C'A'
6 INVALIDVALUE X'5C' C'_'
7 INVALIDVALUE X'54' C'__'
8 INVALIDVALUE X'69' C'__'
9 INVALIDVALUE X'BA' C'_'
10 VALIDVALUE X'40' C' '
**************************** Bottom of Data ****************************
Outptut:
Code:
***************************** Top of Data ******************************
OPTION COPY
INREC IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(X'BA',C'_'))),
IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(X'BB',C'_'))),
IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(X'39',C'__'))),
IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(X'41',C'__'))),
IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(X'5C',C'_'))),
IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(X'54',C'__'))),
IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(X'69',C'__')))
**************************** Bottom of Data ****************************
I was able to generate the output, but its a crude way of doing it and it involved many steps to achieve the needful. Can anyone help me with a better approach like getting it done in a fewer steps ?
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Quote:
would be just around 10
okay, so that is something varying. That is what I meant to ask. And if all you are doing is just FINDREP, you might not need the IFTHEN construct, a simple INREC with multiple INOUTs would do.
Also since you might end up replacing 1 byte with 2 bytes, make sure you are not messing up other data, or you could also end up in an OVERRUN error, if any of those 'invalid' characters occur in the last byte of your input record.
Like I mentioned earlier in this thread, you don't really need the IFTHEN construct here, and I am not sure if you paid attention to - replacing 1 byte with 2 bytes, you could end up in trouble later if such an input comes. Another thing, I see the - X'BA' C'_' repeated in your input. You might want to remove duplicates before building your sort card.
Good luck.
Like I mentioned earlier in this thread, you don't really need the IFTHEN construct here, and I am not sure if you paid attention to - replacing 1 byte with 2 bytes, you could end up in trouble later if such an input comes. Another thing, I see the - X'BA' C'_' repeated in your input. You might want to remove duplicates before building your sort card.
Good luck.
Arun Raj,
Thanks a lot.
Its working as expected.
Yes, In some places we are replacing 1 byte with 2 bytes. But it needs to be that way.
One of the find replace conditions is repeated twice. But would that make any difference in the performance ? I would get try to get rid of it though.
Also, I have a doubt. In the trailer record, you have used a space. But since space is probably the most frequently occurred character, I suppose it be better to use any different character say "@' or something similar.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Quote:
One of the find replace conditions is repeated twice. But would that make any difference in the performance ? I would get try to get rid of it though
You could simply change the SORT FIELDS=COPY to sort on the 'invalid' hex value and remove duplicates in the same step.
Quote:
Also, I have a doubt. In the trailer record, you have used a space. But since space is probably the most frequently occurred character, I suppose it be better to use any different character say '@' or something similar.
You could do that and you can also limit the 'area of search' by using the STARTPOS and ENDPOS parameters to avoid a whole record scan if that applies to your requirement.