|
View previous topic :: View next topic
|
| Author |
Message |
IanWorthington
New User
Joined: 19 Sep 2019 Posts: 3 Location: United Kingdom
|
|
|
|
We're currently using ICETOOL/DFSORT to format a bunch of fields in a data dump. One of the fullwords that we currently decode using:
57:63,4,HEX,
is, in reality, actually a collection of bits that I'd rather decode bit-by-bit into some meaningful character to represent its function if set, or a dot (or lower case character, maybe) if not set.
Is such a decoding easily possible in dfsort, or should I be looking at doing this in Rexx?
Any pointers to where in the rather extensive documentation I might start with this would be much appreciated.
Thanks,
Ian |
|
| Back to top |
|
 |
Marso
REXX Moderator

Joined: 13 Mar 2006 Posts: 1356 Location: Israel
|
|
|
|
to the forum
Try:
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10902 Location: italy
|
|
| Back to top |
|
 |
IanWorthington
New User
Joined: 19 Sep 2019 Posts: 3 Location: United Kingdom
|
|
|
|
Thanks Enrico
This looks promising, but seems to deal only options on the INCLUDE statement, whereas it looks like I need something that works on the BUILD statement, no? Or have I missed something? |
|
| Back to top |
|
 |
Marso
REXX Moderator

Joined: 13 Mar 2006 Posts: 1356 Location: Israel
|
|
|
|
| IanWorthington wrote: |
| a collection of bits that I'd rather decode bit-by-bit into some meaningful character to represent its function if set, or a dot (or lower case character, maybe) if not set. |
Sorry for misunderstanding the question. Maybe this is closer to what you want:
| Code: |
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=HLQ.MY.TEST.DATA.IN
//SORTOUT DD DISP=SHR,DSN=HLQ.MY.TEST.DATA.OUT
//SYSIN DD *
INREC FIELDS=(1,5,6,1,TRAN=BIT,7,10)
SORT FIELDS=COPY
OUTREC BUILD=1,5,C' ',6,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
7,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
8,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
9,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
10,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
11,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
12,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
13,1,CHANGE=(1,C'0',C'.',C'1',C'Y'),
14,10)
//* |
with the input:
| Code: |
LINE 5 FIVE
LINE 3 THREE
LINE 1 ONE
LINE 2 TWO
LINE 4 FOUR |
I get the following output:
| Code: |
LINE YYYY.Y.Y FIVE
LINE YYYY..YY THREE
LINE YYYY...Y ONE
LINE YYYY..Y. TWO
LINE YYYY.Y.. FOUR |
Of course, a lots of bits will require a whole lot of CHANGE cards ): |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1436 Location: Bamberg, Germany
|
|
|
|
Use possibilities provided
| Code: |
//WHATEVER EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
LINE 99 Ninetynine
LINE 05 FIVE
LINE 03 THREE
LINE 01 ONE
LINE 02 TWO
LINE 04 FOUR
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1,5,6:6,2,ZD,TO=BI,LENGTH=2))
SORT FIELDS=(COPY)
OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,5,X,6,2,TRAN=BIT)),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'0',C'.',C'1',C'Y'),STARTPOS=7,DO=16))
END
/*
|
gives
| Code: |
LINE .........YY...YY
LINE .............Y.Y
LINE ..............YY
LINE ...............Y
LINE ..............Y.
LINE .............Y..
|
|
|
| Back to top |
|
 |
IanWorthington
New User
Joined: 19 Sep 2019 Posts: 3 Location: United Kingdom
|
|
|
|
Hi Marso --
That was /exactly/ what I was after, many thanks for that. A whole lot of CHANGE cards were indeed required, but that was fine: I wanted to choose the symbol for each bit independently.
Again, many thanks.
i |
|
| Back to top |
|
 |
Marso
REXX Moderator

Joined: 13 Mar 2006 Posts: 1356 Location: Israel
|
|
|
|
| Joerg.Findeisen wrote: |
Use possibilities provided
| Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1,5,6:6,2,ZD,TO=BI,LENGTH=2))
SORT FIELDS=(COPY)
OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,5,X,6,2,TRAN=BIT)),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'0',C'.',C'1',C'Y'),STARTPOS=7,DO=16))
END
/*
|
|
That is better than my proposed solution if all bits are '.' or 'Y'.
Mine offers other possibilities like:
| Code: |
7,1,CHANGE=(4,C'0',C'CLO ',C'1',C'OPE '),
8,1,CHANGE=(4,C'0',C'DIS ',C'1',C'ENA '),
|
so it will mostly depends on what the data represents |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1436 Location: Bamberg, Germany
|
|
|
|
| @Marso: That is correct. As your sample had the 1:1 translation functionality implemented, I used that to simplify. If one wants a more readable form your suggestion would be the right way to go. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|