View previous topic :: View next topic
|
Author |
Message |
santosh.ambaprasad
New User
Joined: 08 Mar 2009 Posts: 16 Location: London
|
|
|
|
Hi
Can you please help me on this:
I have a file which carries 100K records in HEX format.
I need to convert this to EBCDIC format
Can I do this using SORT?
I wrote REXX but it is taking almost 2hrs to do this conversion...
I guess ALTSEQ in sort helps but not sure how to use it.
Thanks
Santosh S |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
This sounds like the Rexx is not very well optimized. 100K records is not too many for Rexx to handle. It is slower than SORT but for 100K records it should not take more than a minute or two at the most. If the Rexx is short, post it here.
From your description, it sounds like the all of the records are 2 character representations of Hex [0-9A-F] that you want to convert to corresponding single characters eg hex 'C1F2' -> 'A2'. Is that right?
If not, then you are probably using substring too much. Use Parse instead. Limit the use of stem variables to just those you use for I/O and don't do the conversion character by character (the only reason I can imagine it takes 2 hours) - do the whole line at one time. |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
On my slow system with input data set 100,000 records, FB80/27920, this takes 2.4 seconds elapsed, 1.9 seconds of CPU, with only 655 EXCPs:
Code: |
/*Rexx */
"ALLOC DA(HEXIN) SHR REUSE F(IN)"
"ALLOC DA(HEXOUT) SHR REUSE F(OUT)"
"EXECIO * DISKR IN (STEM DATA. FINIS"
Do c=1 to data.0
data.c=x2c(data.c)
End
"EXECIO * DISKW OUT (STEM DATA. FINIS"
"FREE F(IN OUT"
return |
using data.c=x2c(strip(data.c)) instead just adds 0.1 seconds of CPU time. |
|
Back to top |
|
|
santosh.ambaprasad
New User
Joined: 08 Mar 2009 Posts: 16 Location: London
|
|
|
|
Thanks alot. I will bear this in Mind.
the below is the REXX I wrote: This is taking 5.4Min for 4K records. thus 100K will take 2hrs...
/* THIS IS REXX */
CALL INITIALIZE_PROGRAM_VARIABLES
CALL READ_INPUTDD
DO INCOUNT = 1 TO INRECORD.0
CALL CONVERT_RECORD
C.OUTCOUNT = B
OUTCOUNT = OUTCOUNT + 1
END
CALL WRITE_OUTDD
/*-----------------------------------------------------------------*/
INITIALIZE_PROGRAM_VARIABLES:
OUTCOUNT = 1
EBCDIC.1 = ' 1234567890 '
ASCII.1 = '5E31323334353637383930DFB4'
EBCDIC.2 = ' !"@$%&/()=?`'
ASCII.2 = 'B02122A72425262F28293D3F60'
EBCDIC.3 = 'qwertzuiop +'
ASCII.3 = '71776572747A75696F70FC2B'
EBCDIC.4 = 'QWERTZUIOP *'
ASCII.4 = '51574552545A55494F50DC2A'
EBCDIC.5 = 'asdfghjkl #'
ASCII.5 = '6173646667686A6B6CF6E423'
EBCDIC.6 = "ASDFGHJKL '"
ASCII.6 = '4153444647484A4B4CD6C427'
EBCDIC.7 = '<yxcvbnm,.-'
ASCII.7 = '3C79786376626E6D2C2E2D'
EBCDIC.8 = '>YXCVBNM;:_'
ASCII.8 = '3E59584356424E4D3B3A5F'
/* NOW ALL THE ALTS AND BLANK */
EBCDIC.9 = '{ }\@ O '
ASCII.9 = '7B5B5D7D5C407E7C20'
ASCII = ''
EBCDIC = ''
DO I = 1 TO 9
ASCII = ASCIIOOASCII.I
EBCDIC = EBCDICOOEBCDIC.I
END
RETURN 0
/*-----------------------------------------------------------------*/
CONVERT_RECORD:
B = ' '
J = 1
DO I = 1 TO 200 BY 2
EBCCNT=1
DO ASCNT = 1 TO 210 BY 2
XX = SUBSTR(INRECORD.INCOUNT,I,2)
YY = SUBSTR(ASCII,ASCNT,2)
IF XX = YY THEN
B.J = SUBSTR(EBCDIC,EBCCNT,1)
EBCCNT = EBCCNT + 1
END
B=B OO B.J
J=J+1
END
RETURN 0
/*-----------------------------------------------------------------*/
READ_INPUTDD:
"EXECIO * DISKR INPUTDD (STEM INRECORD."
RETURN 0
/*-----------------------------------------------------------------*/
WRITE_OUTDD:
/* PUSH THE ARRAY ONTO OUTDD */
"EXECIO * DISKW OUTDD (STEM C.)"
RETURN 0 |
|
Back to top |
|
|
santosh.ambaprasad
New User
Joined: 08 Mar 2009 Posts: 16 Location: London
|
|
|
|
However i wrote a SELCOPY to do the same:
It took just 0.47 mins to covert the entire file and output is satisfactory:
//STEP01 EXEC PGM=SELCOPY
//SYSUDUMP DD SYSOUT=E
//SYSPRINT DD SYSOUT=E
//DD1 DD DISP=OLD,DSN=&&ASCII
//DD2 DD DSN=&&EBCDIC,
// DISP=(,PASS,DELETE),
// SPACE=(CYL,(100,100),RLSE),DATACLAS=DATAM16,
// DCB=(LRECL=90,RECFM=FB,BLKSIZE=900)
//SYSIN DD *
READ DD1
CVAE 90 AT 1
WRITE DD2 |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
Glad you found a solution. Just a note that as far as Rexx goes, it would be worthwhile to take a few minutes and review the whole list of built in functions because there are many string processing built-ins that can handle large amounts of data. As you can see. the x2c() function does in 1 fast call what you had in many lines. More importantly though, run a few tests on different methods to get an idea of what is relatively slow (stems, string concatenation) and what is sort of slow (loops, I/O) and what is fast (some of the built in functions). It is sometimes an interesting exercise even if it is just done to learn. |
|
Back to top |
|
|
|