Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Convert HEX TO EBCDIC format

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

New User


Joined: 08 Mar 2009
Posts: 16
Location: London

PostPosted: Sun Sep 06, 2009 8:54 pm    Post subject: Convert HEX TO EBCDIC format
Reply with quote

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
View user's profile Send private message

MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Sun Sep 06, 2009 9:07 pm    Post subject: Reply to: Convert HEX TO EBCDIC format
Reply with quote

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
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Sun Sep 06, 2009 9:40 pm    Post subject:
Reply with quote

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
View user's profile Send private message
santosh.ambaprasad

New User


Joined: 08 Mar 2009
Posts: 16
Location: London

PostPosted: Tue Sep 08, 2009 3:11 am    Post subject: Reply to: Convert HEX TO EBCDIC format
Reply with quote

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
View user's profile Send private message
santosh.ambaprasad

New User


Joined: 08 Mar 2009
Posts: 16
Location: London

PostPosted: Tue Sep 08, 2009 3:13 am    Post subject: Reply to: Convert HEX TO EBCDIC format
Reply with quote

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
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Tue Sep 08, 2009 6:23 am    Post subject:
Reply with quote

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
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 Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts FTP data transfer from PC to Mainfram... AJAYREDDY All Other Mainframe Topics 8 Wed Aug 23, 2017 9:59 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us