IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

"Flip bit" on a character field ie 'FF' - hex(char


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Alain Joyal

New User


Joined: 07 Mar 2008
Posts: 5
Location: Bromont, Quebec

PostPosted: Wed Nov 19, 2008 1:19 am
Reply with quote

Hi...

Sorry for the title, I ask to somes peoples here and they cannot explain me whats it that format.. So, we extract data from an IMS database. We transform this data and after that we load this data in DB2. Somes fields are in a strange format (please tell me if you know the name of this format). We need to transform theses fields (characters fields and packed decimal fields) to a standard format. In my mind, I named theses formats : high value formats.

I success to transform the packed decimal fields... For a packed decimal field, all we have to do is to take 9999999 and substract from this number what I have in this field.

Input :


Code:
--3--- 
 i.Ì%   
481764 
0998C0


DFSORT :

Code:
OPTION COPY                                                         
                                   
INREC IFTHEN=(WHEN=(29,4,PD,NE,+0),                                 
        OVERLAY=(29:+9999999,SUB,29,4,PD,TO=PD,LENGTH=4))           
  OUTREC FIELDS=(1,132)     


Output :

Code:
--3--- 
 .Ø..   
418234 
0001C0 


For charater field, I don't figure how to do it... I know the logic... I could do this in REXX... I take the hexadecimal high value FF and subtract from this the hexadecimal value of a character. And I will have to do this for each character of my field. But I want to do this in DFSORT instead of REXX.

My field is starting at 27... For a length of 19.

Input =

Code:
----3----+----4----+- 
   Æ        ¤    ×××   
40090033323390121BBB4 
06CE6AA8788CFEB8DFFF0


Output expected =

Code:
----3----+----4----+- 
 93/95EGHPGC-1UPS     
4FF6FFCCCDCC6FEDE4444 
093195578773014720000


So if you have an idea, please tell me... Also, it's my first I post here, so if you think I put too much information of not enough please tell me, I will try to do better next time.

Regards

Alain
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Nov 19, 2008 1:31 am
Reply with quote

Hi Alain! welcome to the forums..

I am sorry, but Your explanation is not clear at all,

I would start from the copy books that describe the segments layout,
after having a clear picture of the layout everything should come out easily!

Code:
 i.Ì%   
481764 
0998C0


the thing at least in the first five bytes is the packed positive number 408919786
the c in the right lower nibble is the sign
and the rigthmost x'40' is a blank, butas I said before only the copybook will tell what is what !

one thing I do not understand is why take the complement...
it' s not binary math were a negative is stored in two complements..

please be a bit more specific, by posting a couple of fileds and the relative cobol/... declarations
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Nov 19, 2008 2:00 am
Reply with quote

Quote:

I take the hexadecimal high value FF and subtract from this the hexadecimal value of a character. And I will have to do this for each character of my field. But I want to do this in DFSORT instead of REXX.


The following DFSORT conctrol cards will give you the desired results. I assumed that your input is 80 bytes and FB recfm.

Code:

//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC IFOUTLEN=80,                                             
  IFTHEN=(WHEN=INIT,OVERLAY=(81:19X'FF')),                       
  IFTHEN=(WHEN=INIT,OVERLAY=(27:81,8,BI,SUB,27,8,BI,BI,LENGTH=8,
                                89,8,BI,SUB,35,8,BI,BI,LENGTH=8,
                                95,3,BI,SUB,43,3,BI,BI,LENGTH=3))
/*


The output from this job is

Code:

+----3----+----4----+---
    93/95EGHPGC-1UPS   


Hope this helps...

Cheers
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Nov 19, 2008 2:03 am
Reply with quote

Quote:
I take the hexadecimal high value FF and subtract from this the hexadecimal value of a character. And I will have to do this for each character of my field. But I want to do this in DFSORT instead of REXX.


You don't have to do it one byte at a time. You can do it 8 bytes at a time like this (8+8+3 = 19):

Code:

  OVERLAY=(27:+18446744073709551615,SUB,27,8,BI,TO=BI,LENGTH=8,
      +18446744073709551615,SUB,35,8,BI,TO=BI,LENGTH=8,               
      +16777215,SUB,43,3,BI,TO=BI,LENGTH=3)                           


Note that :+18446744073709551615 = X'FFFFFFFFFFFFFFFF' (8 bytes) and +16777215 = X'FFFFFF' (3 bytes).
Back to top
View user's profile Send private message
Alain Joyal

New User


Joined: 07 Mar 2008
Posts: 5
Location: Bromont, Quebec

PostPosted: Wed Nov 19, 2008 2:30 am
Reply with quote

Hi Enrico, thanks for the welcome.

Sorry but I haven't any copybook. All that I have, is an executable PL/I code. So no source code of how it is doing. I've check the input, and the output and I've tried to figure out what the transform is. It is also why I try to explain the logic I see.

For the packed decimal, it is working. I put this example to show you what I've done so far. We really take 9999999 minus the extracted field and the result is what we need.

9999999 - 8919786 = 1080213

Here mores lines...

Input =

Code:
--3---
 i.Ì%
481764
0998C0
------
 i...
482324
0999C0
------
 i...
482324
0999C0
------
 i...
482324
0999C0
------
 i.h.
483834
0988C0
------


Output =

Code:
--3---
 .Ø..
418234
0001C0
------
 .ø-@
417674
0000C0
------
 .ø-@
417674
0000C0
------
 .ø-@
417674
0000C0
------
 ./.%
416164
0011C0
------


Like I said, this is OK. Maybe mores explanations will help you understand what we do with the PD field. It is what we extract from IMS via Data Refresher. We transform this field with the new DFSORT code I post previously. I gave me for example 1080213. First character is 0 indicating that the century is 19. If I see 1, the century is 20. (Maybe olders of you know the COPICS application, this is how they resolve Y2K) Next step, I execute the following code. (It was another PL1 code that I just replaced) :

OPTION COPY
INREC IFTHEN=(WHEN=(29,4,PD,NE,+0),
OVERLAY=(134:29,4,PD,ADD,+19000000,LENGTH=10))
OUTREC FIELDS=(1,132,1X,
135,4,C'-',139,2,C'-',141,2)

This will give me 2008-02-13. I load this field in DB2. Maybe it could be done in one pass. But I don't want to do for this time. It's a big process for plenty of tables. I just want to eliminate PL1 codes I haven't the source code.

Like he said... For the packed decimal, all is working. If you knew a better way to do this feel free to tell me. Maybe the format is like you said a complement ? If I understand, they are stored as complement in IMS so I need to transform them to load them in DB2.

My problem, is that i need to take 'the complement' of characters fields. Here mores lines for the CH fields...

Input =

Code:
----5----+----6----+-
     ×××××××××××××××
43333BBBBBBBBBBBBBBB4
0C7A8FFFFFFFFFFFFFFF0
---------------------
   ¤   ¤   ¤    ××××
4009123900092220BBBB4
0D6FDCCFEFFF98CCFFFF0
---------------------
   ¤   ¤   ¤    ××××
4009123900093230BBBB4
0CEFDCCFEFFFBCEDFFFF0
---------------------
   ¤    ¤   ¤   ××××
4009333393239331BBBB4
0CDFCD8EFBCEFDECFFFF0
---------------------
   ¤    ¤   ¤   ¤   
400932129323901093314
0CDFCCD8FBCEFECDFDEC0
---------------------
   ¤    ¤       ¤   
400932129002000093314
0BDFCCD8FE7DED8CFDEC0
---------------------
   ¤       ¤   ¤   ×
4009313231293239331B4
0BDFCBCCED8FBCEFDECF0
---------------------
   ¤   ¤   ¤   ×××××
400912390009222BBBBB4
0BDFDCCFEFFF98CFFFFF0
---------------------
   ¤   ¤   ¤    ××××
4009123900093230BBBB4
0BAFDCCFEFFFBCEDFFFF0
---------------------


Output =

Code:
----5----+----6----+-
 CHEG               
4CCCC4444444444444444
038570000000000000000
---------------------
 29-SLC-100-OPL3     
4FF6EDC6FFF6DDDF44444
029023301000673300000
---------------------
 31-SLC-100-DLA2     
4FF6EDC6FFF6CDCF44444
031023301000431200000
---------------------
 32-CBGA-DLA-BAT     
4FF6CCCC6CDC6CCE44444
032032710431021300000
---------------------
 32-CLSP-DLA-1T2-BAT
4FF6CDED6CDC6FEF6CCE4
032033270431013202130
---------------------
 42-CLSP-18K1273-BAT
4FF6CDED6FFDFFFF6CCE4
042033270182127302130
---------------------
 42-CUCLASP-DLA-BAT 
4FF6CECDCED6CDC6CCE44
042034331270431021300
---------------------
 42-SLC-100-OPL     
4FF6EDC6FFF6DDD444444
042023301000673000000
---------------------
 45-SLC-100-DLA2     
4FF6EDC6FFF6CDCF44444
045023301000431200000
---------------------


Take each character of the input field. Substract the hexadecimal value of the character from the hexadecimal value FF. This will give me the needed result.

Hope this will help.

I was thinking that showing character preceding my field and coming after will help you determining the boundary. Maybe it's not a good idea ?

Regards

Alain
Back to top
View user's profile Send private message
Alain Joyal

New User


Joined: 07 Mar 2008
Posts: 5
Location: Bromont, Quebec

PostPosted: Wed Nov 19, 2008 2:44 am
Reply with quote

Thanks to you Frank, Skolusu and Enrico for your help

And Frank... Taking FF and substracting each character was a logic I implemented in REXX to understand how it work. It was taking much processing power. So I try it in DFSORT. I was very impressed from the result.

I will try what you and Skolusu tell me and will tell you how it is working

Have a nice day

Alain
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Wed Nov 19, 2008 2:54 am
Reply with quote

I have seen these "complement" methods used to create a descending index in old IMS systems.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Nov 19, 2008 3:34 am
Reply with quote

Quote:
Maybe olders of you know the COPICS application


/soapbox on

Yess! I might even have worked with the person who was the brain of the whole thing

Is it possible that the COPICS You are using had it' s origin in Italy in the seventies ??

There was a laboratory who developed the COPICS application in italy in Rome IIRC about 35/40 years years ago,
but I do not remember if the same product was exported abroad

if that is the case
The Brain of the whole thing was a colleague of mine, was just the type of person to store the data in the most cryptic way

I became the account SE of his largest customer
when he left the IBM branch office for the development laboratory
Back to top
View user's profile Send private message
Alain Joyal

New User


Joined: 07 Mar 2008
Posts: 5
Location: Bromont, Quebec

PostPosted: Wed Nov 19, 2008 5:31 pm
Reply with quote

Quote:
Is it possible that the COPICS You are using had it' s origin in Italy in the seventies ??


Don't know, I was not even born at this time icon_wink.gif But it is really possible... A lot of variables seems to be a mix of english-italien language. Like COUNTER-UNO, LINE-TRATTI. And yes we have IBM products because we are in the micro electronic division of IBM.

But hey... Really... Maybe the data is store in a cryptic way but it is working really great. No loss of performance since all that time.

Have a nice day

Alain
Back to top
View user's profile Send private message
Alain Joyal

New User


Joined: 07 Mar 2008
Posts: 5
Location: Bromont, Quebec

PostPosted: Wed Nov 19, 2008 7:07 pm
Reply with quote

Hi guys

Thanks... It has worked...

I choose the way Skolusu show me...

Here my resulting control card...

Code:
OPTION COPY                                                         
INREC IFOUTLEN=103,                                                 
      IFTHEN=(WHEN=INIT,OVERLAY=(105:19X'FF')),                     
      IFTHEN=(WHEN=(26,1,CH,NE,X'40'),                               
        OVERLAY=(26:X'60'),HIT=NEXT),                               
      IFTHEN=(WHEN=(26,1,CH,EQ,X'40'),                               
        OVERLAY=(27:105,8,BI,SUB,27,8,BI,BI,LENGTH=8,               
                    113,8,BI,SUB,35,8,BI,BI,LENGTH=8,               
                    121,3,BI,SUB,43,3,BI,BI,LENGTH=3),HIT=NEXT),     
      IFTHEN=(WHEN=(46,1,CH,NE,X'40'),                               
        OVERLAY=(46:X'60'),HIT=NEXT),                               
      IFTHEN=(WHEN=(46,1,CH,EQ,X'40'),                               
        OVERLAY=(47:+9999999,SUB,47,4,PD,TO=PD,LENGTH=4))           
OUTREC FIELDS=(1,103) 


Thanks for all your help

Regards

Alain
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Join 2 files according to one key field. JCL & VSAM 3
Search our Forums:

Back to Top