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

To re-format the file using SORT card


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

New User


Joined: 25 Nov 2021
Posts: 4
Location: India

PostPosted: Thu Nov 25, 2021 5:36 am
Reply with quote

Hi All,

Could you please help me with a solution for my requirement.

I have the flat file of 39 LRECL with data as below
- 3 char Seq, 3 char Num, 8 char date (4 occurrences), 1 char ID

Code:
001ABC20210930                        U                                   
002DEF202107302021110520211203        U
003XYZ2020051020210410                U
004WRT                                U


Output should be - Each record with multiple date occurrence should come one below another as shown below with the output LRECL as 16 byte. If the date is not there, the record should be displayed as it is.
Format is 3 char Seq, 3 char Num, 8 char Date, 1 char space, 1 char ID

Code:
001ABC20210930 U
002DEF20210730 U
002DEF20211105 U
002DEF20211203 U
003XYZ20200510 U
003XYZ20210410 U
004WRT         U


Can you please let me know whether this requirement can be accomplished using SORT or should I need to go with COBOL program.

Thanks
Chib
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


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

PostPosted: Thu Nov 25, 2021 9:58 pm
Reply with quote

Code:
OPTION COPY                                                       
  OUTFIL FNAMES=(SORTOUT),                                           
    REMOVECC,                                                       
    IFTHEN=(WHEN=(23,1,CSF,EQ,NUM),                                 
            BUILD=(1,14,X,39,1,/,1,6,15,8,X,39,1,/,1,6,23,8,X,39,1)),
    IFTHEN=(WHEN=(15,1,CSF,EQ,NUM),                                 
            BUILD=(1,14,X,39,1,/,1,6,15,8,X,39,1)),                 
    IFTHEN=(WHEN=(7,1,CSF,EQ,NUM),                                   
            BUILD=(1,14,X,39,1)),                                   
    IFTHEN=(WHEN=NONE,BUILD=(1,6,16:39,1))                           
  END
Back to top
View user's profile Send private message
Chidane

New User


Joined: 25 Nov 2021
Posts: 4
Location: India

PostPosted: Fri Nov 26, 2021 9:01 am
Reply with quote

Thanks very much Joerg.
I just tried this logic with 4 date occurrences as I have mentioned in my requirement and it worked.

I was asked, whether date occurrences can be increased from 4 to 50. So whether in that case, should we need to have the
IFTHEN statement 50 times covering all the 50 positions where date will come. Or whether there is any other way.

Thanks
Chib
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1231

PostPosted: Fri Nov 26, 2021 8:57 pm
Reply with quote

The joke is: SORT card does not participate in the whole process, not a bit! icon_pai.gif
Back to top
View user's profile Send private message
Chidane

New User


Joined: 25 Nov 2021
Posts: 4
Location: India

PostPosted: Sat Nov 27, 2021 4:39 am
Reply with quote

I was of the impression that it comes under SORT card.
Sorry for that.

Regards
Chib
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


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

PostPosted: Sat Nov 27, 2021 5:34 pm
Reply with quote

Chidane wrote:
I was asked, whether date occurrences can be increased from 4 to 50. So whether in that case, should we need to have the
IFTHEN statement 50 times covering all the 50 positions where date will come.

You can repeat the logic for more fields of course. If you use PARSE and symbols it will be easier to fulfill the requirement. See with four parsed fields:
Code:
//WHATEVER EXEC PGM=ICEMAN                         
//SYMNAMES DD *                                   
POSITION,7                                         
p_01,*,8                                           
p_02,*,8                                           
p_03,*,8                                           
p_04,*,8                                           
ident,*,1                                         
/*                                                 
//SYMNOUT  DD SYSOUT=*                             
//SORTIN   DD *                                   
001ABC20210930                        U           
002DEF202107302021110520211203        U           
003XYZ2020051020210410                U           
004WRT                                U           
/*                                                 
//SYSOUT   DD SYSOUT=*                             
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                   
  OPTION COPY                                     
  OUTFIL FNAMES=(SORTOUT),                         
    REMOVECC,                                     
    IFTHEN=(WHEN=INIT,                             
            PARSE=(%=(ABSPOS=7),                   
                   %01=(FIXLEN=8,REPEAT=4))),     
    IFTHEN=(WHEN=(p_04,CSF,EQ,NUM),               
            BUILD=(1,6,%01,X,ident,/,             
                   1,6,%02,X,ident,/,             
                   1,6,%03,X,ident,/,             
                   1,6,%04,X,ident)),             
    IFTHEN=(WHEN=(p_03,CSF,EQ,NUM),               
            BUILD=(1,6,%01,X,ident,/,             
                   1,6,%02,X,ident,/,             
                   1,6,%03,X,ident)),             
    IFTHEN=(WHEN=(p_02,CSF,EQ,NUM),               
            BUILD=(1,6,%01,X,ident,/,             
                   1,6,%02,X,ident)),             
    IFTHEN=(WHEN=(p_01,CSF,EQ,NUM),               
            BUILD=(1,6,%01,X,ident)),             
    IFTHEN=(WHEN=NONE,BUILD=(1,6,16:ident))       
  END
/*
Back to top
View user's profile Send private message
Chidane

New User


Joined: 25 Nov 2021
Posts: 4
Location: India

PostPosted: Sat Nov 27, 2021 5:42 pm
Reply with quote

Hi All,

If I have the date occurrences as 50 (coming in fixed positions), whether I need to have 50 BUILD statements or whether there is any other way to get this done.

Appreciate your help.

Thanks
Chib
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


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

PostPosted: Sun Nov 28, 2021 12:23 pm
Reply with quote

Chidane wrote:
..or whether there is any other way to get this done.

Use a programming language of your choice that supports loops and iterations. In REXX it's less than twenty lines of code including your sample data.
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 Removing date values lines/records fr... SYNCSORT 2
No new posts Read file names from existing file th... DFSORT/ICETOOL 6
No new posts File Status Error code 39 when Proces... COBOL Programming 2
No new posts Convert PS to TXT file using jcl JCL & VSAM 7
This topic is locked: you cannot edit posts or make replies. Sort to include records of file 2 int... Java & MQSeries 1
Search our Forums:

Back to Top