Page 1 of 1

Parsing and converting to binary

PostPosted: Thu Jul 12, 2012 1:29 pm
by dja2
firstly, this is my first attempt at a question in this forum, so if I miss things out of my explanation, please be patient...

I am attempting to convert an input file delimited by "¦', and converting those numeric input fields to four-byte binary fields.
Using the included JCL, (with no attempt at conversion), the resulting parsed fields a left-justified characters. Is it possible to parse these fields so the resulting fields are four-byte binary?

So, during the "BUILD" phase, is it possible, to convert, (for instance), "CONID" directly to a four-byte binary field ?

The fields in question are those that end in "...ID".
 UNIT,%00     
TEAM,%01     
RM,%02       
CONID,%03   
INTCSTID,%04
CONNAME,%05 
CUSTNAME,%06
CIN,%07     
CIS,%08     
APPID,%09   
FACID,%10   
SC,%11       
AN,%12       
BSORT,%13   
BAN,%14
//SYSIN    DD *                                   
  SORT FIELDS=COPY                               
  INREC PARSE=(UNIT=(ENDBEFR=C'¦',FIXLEN=60),     
               TEAM=(ENDBEFR=C'¦',FIXLEN=60),     
               RM=(ENDBEFR=C'¦',FIXLEN=90),       
               CONID=(ENDBEFR=C'¦',FIXLEN=15),   
               INTCSTID=(ENDBEFR=C'¦',FIXLEN=15),
               CONNAME=(ENDBEFR=C'¦',FIXLEN=80), 
               CUSTNAME=(ENDBEFR=C'¦',FIXLEN=120),
               CIN=(ENDBEFR=C'¦',FIXLEN=20),     
               CIS=(ENDBEFR=C'¦',FIXLEN=20),     
               APPID=(ENDBEFR=C'¦',FIXLEN=15),   
               FACID=(ENDBEFR=C'¦',FIXLEN=15),   
               SC=(ENDBEFR=C'¦',FIXLEN=6),       
               AN=(ENDBEFR=C'¦',FIXLEN=8),       
               BSORT=(ENDBEFR=C'¦',FIXLEN=15),   
               BAN=(ENDBEFR=C'¦',FIXLEN=8)),     
         BUILD=(SC,AN,                 
       C' KEY ',UNIT,TEAM,RM,
       C' CONID ',CONID,     
       C' INTCSTID ',INTCSTID,
       C' CIN ',CIN,         
       C' CIS ',CIS,         
       C' APPID ',APPID,     
       C' FACID ',FACID)     


and the input file, (upto the sixth field) looks like...

UNIT1 TEST¦TEAM1¦RM1¦1234567890¦1234567899¦CONNECTION NAME¦CU
UNIT2 TEST¦TEAM1¦RM1¦1234567890¦1234567899¦CONNECTION NAME¦CU
UNIT2 TEST¦TEAM1¦RM1¦1234567890¦1234567899¦CONNECTION NAME¦CU
UNIT2 TEST¦TEAM1¦RM1¦1234567890¦1234567899¦CONNECTION NAME¦CU
UNIT2 TEST¦TEAM1¦RM1¦1234567890¦1234567899¦CONNECTION NAME¦CU

Re: Parsing and converting to binary

PostPosted: Thu Jul 12, 2012 10:09 pm
by skolusu
dja2,

It is quite simple to convert the numeric fields to Binary.

Assuming you have only positive numbers then change the CONID field to the following

C' CONID ',CONID,UFF,BI,LENGTH=4,


If you have both positive and negative numbers then you need to use SFF format for input and FI format for output like shown below
C' CONID ',CONID,SFF,FI,LENGTH=4,

Re: Parsing and converting to binary

PostPosted: Fri Jul 13, 2012 2:16 pm
by dja2
Kosulu, Thanks again for the reply. This not only solved my problem, but also helped to answer a lot of other questions lurking in my brain.