Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Is it possible to edit a nibble using SORT?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Agni

New User


Joined: 22 Nov 2007
Posts: 83
Location: Chennai

PostPosted: Wed Dec 12, 2007 1:43 pm    Post subject: Is it possible to edit a nibble using SORT?
Reply with quote

Hi all,

I have an input file having varous types of records. The input file is in hexadecimal(packed) format. The first byte will be either x'01' or x'03'. I want to edit the half byte (nibble) only in 01 records in the position 6. Please see the example below.

Input file:
Code:

----+----1----+----2----+----3----+----4----+----5
04C090568F012000501046106158005
10700067F307F000000000F0306F07F


Expected Output:

Code:

----+----1----+----2----+----3----+----4----+----5
04C094568F012000501046106158005
10700067F307F000000000F0306F07F


Note:The other half byte should remain same. Only first half byte needs to be chagned to 4 regardless of the value.

Thanks
Agni.
Back to top
View user's profile Send private message

ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Wed Dec 12, 2007 4:41 pm    Post subject:
Reply with quote

Hi Agni,
I have tried to do it and tested for sample records. Pls see if it is useful to you.

Input
Code:

----+----1----+----2----+----3----+----4
Rec 1
04C090568F0120005010461061580054
10700067F307F000000000F0306F07F0
Rec 2
04C090568F0120005010461061580054
10700167F307F000000000F0306F07F0
Rec 3
04C090568F0120005010461061580054
10700267F307F000000000F0306F07F0


Output
Code:

----+----1----+----2----+----3----+----4
Rec1
04C094568F0120005010461061580054
10700067F307F000000000F0306F07F0
Rec2
04C094568F0120005010461061580054
10700167F307F000000000F0306F07F0
Rec3
04C094568F0120005010461061580054
10700267F307F000000000F0306F07F0


Code
Code:

//SORT1 EXEC PGM=SORT                                                   
//SYSOUT   DD SYSOUT=*                                                 
//SYSOUZ   DD SYSOUT=*                                                 
//SORTIN   DD DISP=SHR,DSN=INPUT DATASET                               
//SORTOUT  DD DSN=OUTPUT DATASET,                                       
//             DISP=(NEW,CATLG,DELETE),RECFM=FB,DSORG=PS               
//*                                                                     
//SYSIN    DD   *                                                       
  OPTION COPY                                                           
  OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,X'01'),                               
  OVERLAY=(6:(6,1,BI,ADD,((+4,SUB,(6,1,BI,DIV,+16))),MUL,+16),         
  TO=BI,LENGTH=1))                                                     
/*                                                                     
//*                                                                     


Also you may wait for Frank's reply for any other better way of doing this.
icon_biggrin.gif

--Parag
Back to top
View user's profile Send private message
Agni

New User


Joined: 22 Nov 2007
Posts: 83
Location: Chennai

PostPosted: Wed Dec 12, 2007 5:08 pm    Post subject: Reply to: Is it possible to edit a nibble using SORT?
Reply with quote

Thanks Parag!!! Its working icon_smile.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Dec 12, 2007 10:23 pm    Post subject:
Reply with quote

The OUTREC statement can be simplified to the following:

Code:

  OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,X'01'),   
    OVERLAY=(6:(6,1,BI,MOD,+16),ADD,+64,   
      TO=BI,LENGTH=1))                     
Back to top
View user's profile Send private message
Agni

New User


Joined: 22 Nov 2007
Posts: 83
Location: Chennai

PostPosted: Thu Dec 13, 2007 12:45 pm    Post subject: Reply to: Is it possible to edit a nibble using SORT?
Reply with quote

Thanks for your reply Frank. I didn't understand OVERLAY part. It would be great if you explain this SORT card. So that it might be useful to me when there is a change in requirement.

Thanks in advance
Agni.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Dec 13, 2007 10:21 pm    Post subject:
Reply with quote

Code:

   OVERLAY=(6:(6,1,BI,MOD,+16),ADD,+64,   
      TO=BI,LENGTH=1))       


6: - puts the result in position 6

6,1,BI,MOD,+16 - this gets the remainder for the 1-byte binary value divided by 16 (X;10'). This gives us the second nibble. For example, if the value is X'3E' then the remainder when divided by X'10' is X'0E'.

ADD,+64 - adds X'40' to the remainder. So for the X'3E' example, we get X'0E' + X'40' = X'4E'.

TO=BI,LENGTH=1 - gives us a 1 byte binary result, e.g. X'4E'.
Back to top
View user's profile Send private message
Agni

New User


Joined: 22 Nov 2007
Posts: 83
Location: Chennai

PostPosted: Fri Dec 14, 2007 10:33 am    Post subject: Reply to: Is it possible to edit a nibble using SORT?
Reply with quote

Thanks Frank! I got it.

Regds
Agni.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts Mass comment and edit elixir1986 IBM Tools 3 Thu Mar 02, 2017 10:09 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us