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

Split a record with data in a different column


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

New User


Joined: 15 Sep 2017
Posts: 2
Location: Mexico

PostPosted: Fri Sep 23, 2022 7:01 am
Reply with quote

I want to split a record in name and percent, only records that contain the symbol %

input file LRECL=40
Code:

JOZD HABWRT ROPWZ 50.00%               
RAZ ARRZNZ ROPWZ 50.00%                 
FDDGG EGGDG XSFDGG
RAYZRDO JAMWNWZ ZRBWRZWZ 50%           
ZRWJZNDRO JAMWNWZ ZRBWRZWZ 50%         
GGGHGGHGH JHJJHJ
RAYZRDO JAMWNWZ ZRBWRZWZ 50%           
GRWNNYS DAZZ YW-8-98271 25%             
ZNZ Y MOJAYZ V Y8-746-218 25%           
ZNTONAO MOJAYZ Y8-166-7V 25%           
MNMBBB DSFSFFSFFFSFSF
JOSW OTWRO YZSZR 34%%                   
DAWGO OTWRO YZSZR 33%                   
ROSZ MZRAZ OTWRO YZSZR 33%
GGHGGHGGHGHGHG             
JWSSW YZMARZ GAZMZN 100%
GJGJGJHGJHGHJG               
JOZD HABWRT ROPWZ 50.00%               
RAZ ARRZNZ ROPWZ 50.00%
HGHGHGHG                 
RAA XAZ ZHA DW RAZO 100.00%
GHFFGFGFGFG             
RWTAYAZ YWYARAZ DAZRTW NNANWS  100% 


the output should be like below, LRECL=48
Code:

JOZD HABWRT ROPWZ                       |50.00%
RAZ ARRZNZ ROPWZ                        |50.00%
RAYZRDO JAMWNWZ ZRBWRZWZ                |50%   
ZRWJZNDRO JAMWNWZ ZRBWRZWZ              |50%   
RAYZRDO JAMWNWZ ZRBWRZWZ                |50%   
GRWNNYS DAZZ YW-8-98271                 |25%   
ZNZ Y MOJAYZ V Y8-746-218               |25%   
ZNTONAO MOJAYZ Y8-166-7V                |25%   
JOSW OTWRO YZSZR                        |34%   
DAWGO OTWRO YZSZR                       |33%   
ROSZ MZRAZ OTWRO YZSZR                  |33%   
JWSSW YZMARZ GAZMZN                     |100%   
JOZD HABWRT ROPWZ                       |50.00%
RAZ ARRZNZ ROPWZ                        |50.00%
RAA XAZ ZHA DW RAZO                     |100.00%
RWTAYAZ YWYARAZ DAZRTW NNANWS           |100%

Please anybody help me to achieve this.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Fri Sep 23, 2022 8:35 am
Reply with quote

Per your profile, you're an analyst with COBOL experience who joined the forum 5 years ago.

What have you tried so far?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Fri Sep 23, 2022 10:13 am
Reply with quote

Inrec parse into four elements
Then outfile build according how you want ( specially last one) and use omit cond to eliminate fourth parse element eq spaces.

I hope this will work.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri Sep 23, 2022 11:52 am
Reply with quote

Input:
Code:
JOZD HABWRT ROPWZ 50.00%                 
RAZ ARRZNZ ROPWZ 50.00%                   
FDDGG EGGDG XSFDGG                       
RAYZRDO JAMWNWZ ZRBWRZWZ 50%             
ZRWJZNDRO JAMWNWZ ZRBWRZWZ 50%           
GGGHGGHGH JHJJHJ                         
RAYZRDO JAMWNWZ ZRBWRZWZ 50%             
GRWNNYS DAZZ YW-8-98271 25%               
ZNZ Y MOJAYZ V Y8-746-218 25%             
ZNTONAO MOJAYZ Y8-166-7V 25%             
MNMBBB DSFSFFSFFFSFSF                     
JOSW OTWRO YZSZR 34%%                     
DAWGO OTWRO YZSZR 33%                     
ROSZ MZRAZ OTWRO YZSZR 33%               
GGHGGHGGHGHGHG                           
JWSSW YZMARZ GAZMZN 100%                 
GJGJGJHGJHGHJG                           
JOZD HABWRT ROPWZ 50.00%                 
RAZ ARRZNZ ROPWZ 50.00%                   
HGHGHGHG                                 
RAA XAZ ZHA DW RAZO 100.00%               
GHFFGFGFGFG                               
RWTAYAZ YWYARAZ DAZRTW NNANWS  100%       
Z 0%                                     
Y Y Y 0%


Code:
Code:
OPTION COPY                                                       
INCLUDE COND=(1,40,SS,EQ,C'%')                       
INREC IFTHEN=(WHEN=INIT,                                           
  PARSE=(%01=(FIXLEN=40,                                           
              ENDBEFR=C' 0',                                       
              ENDBEFR=C' 1',                                       
              ENDBEFR=C' 2',                                       
              ENDBEFR=C' 3',                                       
              ENDBEFR=C' 4',                                       
              ENDBEFR=C' 5',                                       
              ENDBEFR=C' 6',                                       
              ENDBEFR=C' 7',                                       
              ENDBEFR=C' 8',                                       
              ENDBEFR=C' 9'),                                     
         %=(STARTAT=C'%',FIXLEN=1),                               
         %02=(SUBPOS=8,FIXLEN=7,ENDBEFR=C'%',                     
              STARTAT=C' 0',                                       
              STARTAT=C' 1',                                       
              STARTAT=C' 2',                                       
              STARTAT=C' 3',                                       
              STARTAT=C' 4',                                       
              STARTAT=C' 5',                                       
              STARTAT=C' 6',                                       
              STARTAT=C' 7',                                       
              STARTAT=C' 8',                                       
              STARTAT=C' 9')),                                     
    BUILD=(%01,%02,SQZ=(SHIFT=LEFT,LEAD=C'|',TRAIL=C'%',LENGTH=8)))
END


Output:
Code:
JOZD HABWRT ROPWZ                       |50.00%   
RAZ ARRZNZ ROPWZ                        |50.00%   
RAYZRDO JAMWNWZ ZRBWRZWZ                |50%       
ZRWJZNDRO JAMWNWZ ZRBWRZWZ              |50%       
RAYZRDO JAMWNWZ ZRBWRZWZ                |50%       
GRWNNYS DAZZ YW-8-98271                 |25%       
ZNZ Y MOJAYZ V Y8-746-218               |25%       
ZNTONAO MOJAYZ Y8-166-7V                |25%       
JOSW OTWRO YZSZR                        |34%       
DAWGO OTWRO YZSZR                       |33%       
ROSZ MZRAZ OTWRO YZSZR                  |33%       
JWSSW YZMARZ GAZMZN                     |100%     
JOZD HABWRT ROPWZ                       |50.00%   
RAZ ARRZNZ ROPWZ                        |50.00%   
RAA XAZ ZHA DW RAZO                     |100.00%   
RWTAYAZ YWYARAZ DAZRTW NNANWS           |100%     
Z                                       |0%       
Y Y Y                                   |0%       
Back to top
View user's profile Send private message
cuauhtli

New User


Joined: 15 Sep 2017
Posts: 2
Location: Mexico

PostPosted: Fri Sep 23, 2022 8:09 pm
Reply with quote

Thank you so much Joerg.Findeisen is an excellent contribution. I was trying a cobol program with unstring and reverse but your code is better.
Thanks again.!!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Sat Sep 24, 2022 1:15 am
Reply with quote

The parameters STARTAT=… and SUBPOS= are in fact not required in this specific case. By default PARSE continues from previous stop point.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Sat Sep 24, 2022 8:51 pm
Reply with quote

One SUBPOS is required as the first digit of the percentage is part of the previous PARSE. However the code can be reduced to this:
Code:
INREC IFTHEN=(WHEN=INIT,                                           
  PARSE=(%01=(FIXLEN=40,                                           
              ENDBEFR=C' 0',                                       
              ENDBEFR=C' 1',                                       
              ENDBEFR=C' 2',                                       
              ENDBEFR=C' 3',                                       
              ENDBEFR=C' 4',                                       
              ENDBEFR=C' 5',                                       
              ENDBEFR=C' 6',                                       
              ENDBEFR=C' 7',                                       
              ENDBEFR=C' 8',                                       
              ENDBEFR=C' 9'),                                     
         %02=(SUBPOS=1,FIXLEN=7,ENDBEFR=C'%')),                   
    BUILD=(%01,%02,SQZ=(SHIFT=LEFT,LEAD=C'|',TRAIL=C'%',LENGTH=8)))

Thanks for your suggestion. icon_wink.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Sat Sep 24, 2022 9:36 pm
Reply with quote

I suggest don’t wait here .. understand the logic and read manuals so that you can do it yourself next time or at least you can give a try.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Sun Sep 25, 2022 12:22 am
Reply with quote

Just my 2cents worth here.

Although the SORT way is easier in many ways as opposed to a COBOL program, are there programmers down the line in your organization who will inherit this code and be as conversant in the SORT commands and techniques as opposed to a general purpose language?

If you still need COBOL for other processing here, consider if it might be best for one program to have all of the processing.

Not saying yes or no - just things to consider.
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 Copy only TEXT or String from a record SYNCSORT 4
No new posts db2 vs static data COBOL Programming 1
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts how to complete the end of a record w... DFSORT/ICETOOL 2
Search our Forums:

Back to Top