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

Partial Sort conditions for PD fields


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

New User


Joined: 06 Jan 2025
Posts: 7
Location: India

PostPosted: Mon Jan 06, 2025 11:02 pm
Reply with quote

Hi,

I have a field length of 18( in the file it's defined as comp3 field as expanded below) in the 80 bytes file...I am trying to omit the records as below.
Field position 2 to 3 : value is 91
Field position 5 to 6 : values are 83, 69 and 68

In comp3 it defined as 10 bytes field starting position is 42 till 51. As in attachment if 43 position is having '91' and (if second nibble of 44 and first nibble of position 45 having values as 83, 69 and 68).


I thought of achieving it in a 2 step sort.
1. Converting PD to zd and write in the position 81 to 98 by creating a new file 98 bytes file
2. Omit cond based on the above scenario and write using outrec up to 80 bytes

Do we able to achieve this in a simpler code?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10894
Location: italy

PostPosted: Mon Jan 06, 2025 11:21 pm
Reply with quote

DO NOT POST SCREENSHOTS
they clobber the browser window and make it unreadable

will please a moderator delete the screen shot

thank You
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1371
Location: Bamberg, Germany

PostPosted: Tue Jan 07, 2025 1:37 am
Reply with quote

Use the code button to provide sample data, AND preview anything before you post.
Back to top
View user's profile Send private message
Karthi89

New User


Joined: 06 Jan 2025
Posts: 7
Location: India

PostPosted: Tue Jan 07, 2025 8:59 am
Reply with quote

Karthi89 wrote:
Hi,

I have a field length of 18( in the file it's defined as comp3 field as expanded below) in the 80 bytes file...I am trying to omit the records as below.
Field position 2 to 3 : value is 91
Field position 5 to 6 : values are 83, 69 and 68

In comp3 it defined as 10 bytes field starting position is 42 till 51. As in attachment if 43 position is having '91' and (if second nibble of 44 and first nibble of position 45 having values as 83, 69 and 68).


I thought of achieving it in a 2 step sort.
1. Converting PD to zd and write in the position 81 to 98 by creating a new file 98 bytes file
2. Omit cond based on the above scenario and write using outrec up to 80 bytes

Do we able to achieve this in a simpler code?





can we use bit notations in omit conditions.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1371
Location: Bamberg, Germany

PostPosted: Tue Jan 07, 2025 9:19 am
Reply with quote

Yes. RTFM https://www.ibm.com/docs/en/zos/3.1.0?topic=statement-bit-logic-tests
Back to top
View user's profile Send private message
Karthi89

New User


Joined: 06 Jan 2025
Posts: 7
Location: India

PostPosted: Tue Jan 07, 2025 2:03 pm
Reply with quote

I tried something as below and it isn't working as expected...No errors shown..

Inrec overlay=(81:42,10,pd,to=zd,length=18)
sort fields=copy
outrec ifthen=(when=82,2,zd,eq,91,and,(85,2,zd,eq,68,or,85,2,zd,eq,69)),build=(1,80)


Any suggestions pls?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1371
Location: Bamberg, Germany

PostPosted: Tue Jan 07, 2025 2:36 pm
Reply with quote

Show sample data as written before. Use the code button where appropriate.
Back to top
View user's profile Send private message
Karthi89

New User


Joined: 06 Jan 2025
Posts: 7
Location: India

PostPosted: Tue Jan 07, 2025 2:47 pm
Reply with quote

Code:


the pd format as x'0[b]11[/b]8[b]68[/b]290938000000'

I need to exclude the record has 11 and 68 as in below


Packed format as below starts at position 42  till 51
0188998000
016203000F
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2173
Location: USA

PostPosted: Tue Jan 07, 2025 7:02 pm
Reply with quote

Karthi89 wrote:
I have a field length of 18 (in the file it's defined as comp3 field as expanded below) in the 80 bytes file...


The maximum size of any COMP-3 field allowed by IBM architecture is 16 bytes.

When you convert it TO=ZD,LENGTH=18, it is not COMP-3 anymore!

RTFM.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2173
Location: USA

PostPosted: Thu Jan 09, 2025 1:50 am
Reply with quote

Karthi89 wrote:
I tried something as below and it isn't working as expected...No errors shown..

Inrec overlay=(81:42,10,pd,to=zd,length=18)
sort fields=copy
outrec ifthen=(when=82,2,zd,eq,91,and,(85,2,zd,eq,68,or,85,2,zd,eq,69)),build=(1,80)


Any suggestions pls?


As usually, any recommendation to RTFM eliminates any desire to do the job?

Code:
//SYSIN DD *       
 INREC OVERLAY=(81:43,3,HEX)  X'910680'->C'910680'
*                               ||  ||     || ||<-----------------85
*                               ||  ||     || |<------------------84
*                               ||  ||     ||<-----------------82
*                               ||  ||     |<------------------81
*                               ||  ||<---------------------45
*                               ||<-------------------------43
 SORT FIELDS=COPY
 OUTFIL OMIT=(81,2,CH,EQ,C'91',
          AND,84,2,CH,EQ,L(C'68',C'69',C'83')),
        BUILD=(1,80)
 END
//*
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2173
Location: USA

PostPosted: Thu Jan 09, 2025 10:42 pm
Reply with quote

If, by a chance, there is someone who wants to learn something, here is another option, a bit more compact one:
Code:
//SYSIN DD *       
 INREC OVERLAY=(81:43,3,HEX)  X'910680'->C'910680'
*                               ||  ||     || ||<-----------------85
*                               ||  ||     || |<------------------84
*                               ||  ||     ||<-----------------82
*                               ||  ||     |<------------------81
*                               ||  ||<---------------------45
*                               ||<-------------------------43
 SORT FIELDS=COPY
 OUTFIL OMIT=(81,2,CH,EQ,C'91',
          AND,84,2,SS,EQ,C'68,69,83'),
        BUILD=(1,80)
 END
//*
Back to top
View user's profile Send private message
Karthi89

New User


Joined: 06 Jan 2025
Posts: 7
Location: India

PostPosted: Mon Jan 13, 2025 12:51 pm
Reply with quote

Hi, Thanks for your reply. The above codes worked fine.


I missed to post a reply here. I tried as below and it worked fine.

Code:

INREC OVERLAY=(81:42,10,PDTO=ZD,LENGTH=18)
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,OMIT=(82,2,ZD,EQ,91,AND,(85,2,ZD,EQ,68,OR
                               85,2,ZD,EQ,69,OR,85,2,ZD,EQ,83)),BUILD=(1,80)
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1371
Location: Bamberg, Germany

PostPosted: Mon Jan 13, 2025 4:24 pm
Reply with quote

PDTO is not a valid keyword. You may have posted incomplete data.
Back to top
View user's profile Send private message
Karthi89

New User


Joined: 06 Jan 2025
Posts: 7
Location: India

PostPosted: Mon Jan 13, 2025 4:27 pm
Reply with quote

yes, it should be as below...Thanks for pointing out
Code:

INREC OVERLAY=(81:42,10,PD,TO=ZD,LENGTH=18)
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,OMIT=(82,2,ZD,EQ,91,AND,(85,2,ZD,EQ,68,OR
                               85,2,ZD,EQ,69,OR,85,2,ZD,EQ,83)),BUILD=(1,80)
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2173
Location: USA

PostPosted: Mon Jan 13, 2025 7:22 pm
Reply with quote

Karthi89 wrote:
yes, it should be as below...Thanks for pointing out
Code:

INREC OVERLAY=(81:42,10,PD,TO=ZD,LENGTH=18)
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,OMIT=(82,2,ZD,EQ,91,AND,(85,2,ZD,EQ,68,OR
                               85,2,ZD,EQ,69,OR,85,2,ZD,EQ,83)),BUILD=(1,80)

The major problem: if by a chance your 42,10 field is not fully correct packed decimal, you'll get ABEND S0C7 from SORT, without any detailed info... sterb050.gif

From this point of view, my HEX approach is safer (and more simple).

Another way for fool-protection would be: add data verification
Code:
...WHEN=(42,10,PD,EQ,NUM)...
Back to top
View user's profile Send private message
Karthi89

New User


Joined: 06 Jan 2025
Posts: 7
Location: India

PostPosted: Thu Jan 16, 2025 3:42 pm
Reply with quote

Thanks a lot for your response and detailed explanation.

I will go with hex option.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2173
Location: USA

PostPosted: Thu Jan 16, 2025 9:16 pm
Reply with quote

Karthi89 wrote:
yes, it should be as below...Thanks for pointing out
Code:

INREC OVERLAY=(81:42,10,PD,TO=ZD,LENGTH=18)
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,OMIT=(82,2,ZD,EQ,91,AND,(85,2,ZD,EQ,68,OR
                               85,2,ZD,EQ,69,OR,85,2,ZD,EQ,83)),BUILD=(1,80)

It also would be nice to make any code, even the simplest one, as clear to understand as possible. I mention this point every time, but it doesn't help... icon_rolleyes.gif
Code:
 INREC OVERLAY=(81:42,10,PD,TO=ZD,LENGTH=18)
 SORT FIELDS=COPY
 OUTFIL FNAMES=SORTOUT,
        OMIT=(82,2,ZD,EQ,91,
         AND,(85,2,ZD,EQ,68,
           OR,85,2,ZD,EQ,69,
           OR,85,2,ZD,EQ,83)),
        BUILD=(1,80)

or even better
Code:
 INREC OVERLAY=(81:42,10,PD,TO=ZD,LENGTH=18)
 SORT FIELDS=COPY
 OUTFIL FNAMES=SORTOUT,
        OMIT=(82,2,ZD,EQ,91,
          AND,85,2,ZD,EQ,L(68,69,83)),
        BUILD=(1,80)
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 Sort to insert record in an empty file. DFSORT/ICETOOL 5
No new posts Help with SORT - I need to validate d... DFSORT/ICETOOL 11
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top