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

Variable length(Pipe delimter) to Fixed length


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

New User


Joined: 06 Jan 2020
Posts: 2
Location: India

PostPosted: Mon Jan 06, 2020 4:44 pm
Reply with quote

I want to convert a variable length file that does not have ‘fixed’ columns lengths and also has a non-fixed decimal.

Ex:
123|ABC|12.5043|
12345|ABC|112.5043|
1|ABC|2.50000043|

I want to have a fixed file with the decimal in 9(6)v99. Can some one please guide me. Thanks in advance

Thanks
Sreekanth
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Mon Jan 06, 2020 6:23 pm
Reply with quote

There are two separate issues:

1) To split CSV character-type fields by separators you need to use PARSE=…,BUILD=… parameters in either INREC/OUTREC/OUTFIL statements. The separator used instead of "comma" must be specified in ENDBEFR=C'|' and/or other separators.

2) More complicated case is, parsing numeric values with variable decimal point position. A special PARSE/BUILD combination is needed with ENDBEFR=C'.' parameter, in order to split actual whole/fractional parts of the numeric value. The provided SORT formats ZD/UFF/SFF cannot detect decimal point position.

Unfortunately, none of SORT manuals give any clue on how to parse flexible numeric values with variable decimal point position, but there are examples of similar operations in this forum.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Mon Jan 06, 2020 8:45 pm
Reply with quote

Here is an example of parsing numeric fields with variable decimal point position
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Mon Jan 06, 2020 11:10 pm
Reply with quote

Code:
//VARPOINT EXEC PGM=SORT                             
//*                                                     
//SYSOUT   DD  SYSOUT=*                                 
//*                                                     
//SORTIN   DD  *                                         
123|ABC|12.5043|                                         
12345|ABC|112.5043|                                     
1|ABC|2.50000043|                                       
//*                                                     
//SORTOUT  DD  SYSOUT=*                                 
//*                                                     
//SYSIN    DD  *                                         
 INREC PARSE=(%1=(STARTAT=NONBLANK,                     
                  ENDBEFR=C'|',                         
                  ENDBEFR=C' ',                         
                  FIXLEN=5),                             
              %2=(ENDBEFR=C'|',                         
                  ENDBEFR=C' ',                         
                  FIXLEN=3),                             
              %3=(ENDBEFR=C'.',                         
                  ENDBEFR=C'|',                         
                  ENDBEFR=C' ',                         
                  FIXLEN=6),                             
              %4=(ENDBEFR=C'|',                         
                  ENDBEFR=C' ',                         
                  FIXLEN=2)),                           
       BUILD=(%1,JFY=(SHIFT=RIGHT,LEAD=C'00000'),       
            X,%2,                                       
            X,%3,JFY=(SHIFT=RIGHT,LEAD=C'000000'),       
              %4,JFY=(SHIFT=LEFT,TRAIL=C'00'))           
*                                                       
 SORT FIELDS=COPY                                       
*                                                       
 END                                                     
//*                                                     

Code:
********************************* TOP OF DATA ******
00123 ABC 00001250                                 
12345 ABC 00011250                                 
00001 ABC 00000250                                 
******************************** BOTTOM OF DATA ****
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Jan 07, 2020 3:48 pm
Reply with quote

Why not chose a simpler form for %1 and %3 variables?
Code:
BUILD=(%1,UFF,M11,X,%2,X,%3,UFF,M11,       
       %4,JFY=(SHIFT=LEFT,TRAIL=C'00'))
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Tue Jan 07, 2020 7:13 pm
Reply with quote

Joerg.Findeisen wrote:
Why not chose a simpler form for %1 and %3 variables?
Code:
BUILD=(%1,UFF,M11,X,%2,X,%3,UFF,M11,       
       %4,JFY=(SHIFT=LEFT,TRAIL=C'00'))

The reason is: I do not keep in mind all those formats M1-M100500, and I'm lazy to re-check the manual every time. icon_razz.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Tue Jan 07, 2020 7:51 pm
Reply with quote

Accepted. icon_lol.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Wed Jan 08, 2020 1:47 am
Reply with quote

Quote:
I want to convert a variable length file that does not have ‘fixed’ columns lengths and also has a non-fixed decimal.

If you could have done Google and did some Research then you would have got many links and solutions to convert CSV (VB ) Data to FB including Decimals.
e.g.
ibmmainframes.com/about54790.html
Back to top
View user's profile Send private message
SreekanthMada

New User


Joined: 06 Jan 2020
Posts: 2
Location: India

PostPosted: Wed Jan 08, 2020 12:02 pm
Reply with quote

Thanks sergeyken, Joerg.Findeisen, Rohit Umarjikar

Its working icon_biggrin.gif
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 Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top