Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Variable length(Pipe delimter) to Fixed length

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Variable length(Pipe delimter) to Fixed length
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

Active Member


Joined: 29 Apr 2008
Posts: 686
Location: Maryland

PostPosted: Mon Jan 06, 2020 6:23 pm    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 686
Location: Maryland

PostPosted: Mon Jan 06, 2020 8:45 pm    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 686
Location: Maryland

PostPosted: Mon Jan 06, 2020 11:10 pm    Post subject:
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

Active User


Joined: 15 Aug 2015
Posts: 105
Location: Germany

PostPosted: Tue Jan 07, 2020 3:48 pm    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 686
Location: Maryland

PostPosted: Tue Jan 07, 2020 7:13 pm    Post subject:
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

Active User


Joined: 15 Aug 2015
Posts: 105
Location: Germany

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

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

Senior Member


Joined: 21 Sep 2010
Posts: 2334
Location: NY,USA

PostPosted: Wed Jan 08, 2020 1:47 am    Post subject:
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.
http://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    Post subject: Reply to: Variable length(Pipe delimter) to Fixed length
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts COBOL - Array result in single variab... vinu78 COBOL Programming 3 Thu Feb 20, 2020 5:29 pm
No new posts Variable tso ISR Renato Zangerolami TSO/ISPF 4 Fri Feb 07, 2020 7:30 pm
No new posts SFTP to a Unix Pipe file yuvan All Other Mainframe Topics 4 Tue Jan 28, 2020 9:04 pm
No new posts OMIT first and last column of a pipe-... karthikb_itpro DFSORT/ICETOOL 1 Fri Nov 01, 2019 8:24 pm
No new posts Can GLobal variable used under TSOE/REXX Kaliragavendran CLIST & REXX 5 Tue Sep 24, 2019 7:16 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us