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

How to Count a particular record in a PS file using DFsort


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

New User


Joined: 25 May 2018
Posts: 5
Location: India

PostPosted: Tue May 29, 2018 1:07 pm
Reply with quote

Hi,

I have a PS file with length 80. I have 10 byte character data from column 70. now I have to count the char data for any characters apart from spaces and put the length in my varchar field. how can I do it in sort.

please post any example sort card on how to achieve this.

Thanks in Advance
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue May 29, 2018 1:42 pm
Reply with quote

You cannot.
Back to top
View user's profile Send private message
Ilavenil

New User


Joined: 16 May 2018
Posts: 4
Location: India

PostPosted: Tue May 29, 2018 3:00 pm
Reply with quote

Hello Mounika,

We cannot do that in single step, but with couple of steps it is possible, if I understood your problem statement in a right way! Assuming that the CHAR(10) starts from 71 to 80 and the length field from 69 to 70.

Code:

//STEP1    EXEC PGM=ICETOOL                                     
//TOOLMSG DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN            DD DSN=BPV081.TEST.SORT,DISP=SHR                     
//T1            DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT         DD DSN=BPV081.TEST.SORT.OUT,DISP=(NEW,CATLG,DELETE),                 
//                    DCB=(RECFM=FB,LRECL=12),DATACLAS=MB020
//TOOLIN    DD *                                                 
COPY FROM(IN) USING(CTL1)                                     
COPY FROM(T1) TO(OUT) USING(CTL2)                             
/*                                                             
//CTL1CNTL DD *                                               
  OUTFIL FNAMES=T1,FTOV,VLTRIM=C' ',                           
  BUILD=(71,10)                                               
/*                                                             
//CTL2CNTL DD *                                               
  OUTFIL VTOF,BUILD=(1:1,2,BI,SUB,+4,TO=ZD,LENGTH=2,3:5,10)   
/*     
//STEP2    EXEC PGM=SORT                                       
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT    DD SYSOUT=*                                         
//SORTJNF1 DD DSN=BPV081.TEST.SORT.OUT,DISP=MOD                 
//SORTJNF2 DD DSN=BPV081.TEST.SORT,DISP=SHR                     
//OUTFILE  DD DSN=BPV081.TEST.SORT.OUT1,DISP=(NEW,CATLG,DELETE),
//           DCB=(RECFM=FB,LRECL=80),DATACLAS=MB020             
//SYSIN DD *                                                   
  JOINKEYS FILE=F1,FIELDS=(3,10,A)                             
  JOINKEYS FILE=F2,FIELDS=(71,10,A)                             
  JOIN UNPAIRED,F1,F2                                           
  REFORMAT FIELDS=(?,F2:1,68,F1:1,12)                           
  OPTION COPY                                                   
  OUTFIL FNAMES=OUTFILE,INCLUDE=(1,1,CH,EQ,C'B'),               
                         BUILD=(2,80)                           
/*           
                                                                                                         


Hope it helps!
Back to top
View user's profile Send private message
Mounika Nemani

New User


Joined: 25 May 2018
Posts: 5
Location: India

PostPosted: Tue May 29, 2018 3:39 pm
Reply with quote

I'm sorry if I am unable to explain properly. I am trying to move a character field to a varchar field throught sortcard.

ex:
input file:
ABC
ABCDEFGI
AJDFAJ

In the above file my pic x(10) field has data less than 10 bytes as well. so, now im trying to move it to varchar(10) field through sort. I wrote the below sort card.
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:X'000A',
3:71,10)

however im trying to see If I can count the number of chars in the filed and put it in the length part of varchar field.
ex:
first line of input has 3 characters. so, X'0003' should be moved to the length.

please help me if we can achieve that counting part in the sort card.
Back to top
View user's profile Send private message
Ilavenil

New User


Joined: 16 May 2018
Posts: 4
Location: India

PostPosted: Tue May 29, 2018 4:18 pm
Reply with quote

Mounika,

The step 1 does that exactly. It moves the CHAR(10) to VB file by trimming trailing spaces. Again the VB data is converted into FB and from the RDW the length is calculated. The final output of step 1 has the VARCHAR equivalent of the CHAR(10) from the input file. Try running the job with your input, study the output files, you will get to know what it does.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue May 29, 2018 8:14 pm
Reply with quote

Mounika Nemani,

If you have only one field that you are trying to find the data length of, and it is just 10 bytes then probably you can do this in one step with a bunch of IFTHENs evaluating the trailing blanks and find the data length.

Something like this:
Code:
//STEP01  EXEC PGM=SORT                         
//SORTIN    DD *                                 
ABC                                             
ABCDEFGI                                         
AJDFAJ                                           
//SORTOUT   DD SYSOUT=*                     
//SYSOUT    DD SYSOUT=*                     
//SYSIN     DD *                                 
 OPTION COPY                                     
 OUTREC IFTHEN=(WHEN=INIT,BUILD=(X'000A',1,10)),
        IFTHEN=(WHEN=(4,9,CH,EQ,C' '),           
        OVERLAY=(1,2,BI,SUB,+9,TO=BI,LENGTH=2)),
        IFTHEN=(WHEN=(5,8,CH,EQ,C' '),           
        OVERLAY=(1,2,BI,SUB,+8,TO=BI,LENGTH=2)),
        IFTHEN=(WHEN=(6,7,CH,EQ,C' '),           
        OVERLAY=(1,2,BI,SUB,+7,TO=BI,LENGTH=2)),     
        IFTHEN=(WHEN=(7,6,CH,EQ,C' '),               
        OVERLAY=(1,2,BI,SUB,+6,TO=BI,LENGTH=2)),     
        IFTHEN=(WHEN=(8,5,CH,EQ,C' '),               
        OVERLAY=(1,2,BI,SUB,+5,TO=BI,LENGTH=2)),     
        IFTHEN=(WHEN=(9,4,CH,EQ,C' '),               
        OVERLAY=(1,2,BI,SUB,+4,TO=BI,LENGTH=2)),     
        IFTHEN=(WHEN=(10,3,CH,EQ,C' '),             
        OVERLAY=(1,2,BI,SUB,+3,TO=BI,LENGTH=2)),     
        IFTHEN=(WHEN=(11,2,CH,EQ,C' '),             
        OVERLAY=(1,2,BI,SUB,+2,TO=BI,LENGTH=2)),     
        IFTHEN=(WHEN=(12,1,CH,EQ,C' '),             
        OVERLAY=(1,2,BI,SUB,+1,TO=BI,LENGTH=2)) 


EDIT: You might want to add another IFTHEN after the very first IFTHEN BUILD above, to look for all spaces and then subtract 10 if you are expecting all blanks in the input field.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top