Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Creating CSV file using Sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
pdighade

New User


Joined: 21 Jul 2008
Posts: 40
Location: pune

PostPosted: Sun Mar 24, 2013 9:10 am    Post subject: Creating CSV file using Sort
Reply with quote

Hi,

I have a requirement to convert the FB file into CSV format . I would like to do using DFSORT. Could you please help me how to achieve this using DFSORT.

Records format of the file

Code:
01  CUSTTEXT-RECORD.
           05  CUSTTEXT-KEY            PIC 9(12).
           05  CUSTTEXT-STATUS         PIC X.
           05  CUSTTEXT-LAST-NAME      PIC X(28).
           05  CUSTTEXT-FIRST-NAME     PIC X(20).
           05  CUSTTEXT-STREET-ADDR-01 PIC X(48).
           05  CUSTTEXT-STREET-ADDR-02 PIC X(48).
           05  CUSTTEXT-CITY           PIC X(16).
           05  CUSTTEXT-STATE          PIC X(2).
           05  CUSTTEXT-POSTAL-CODE    PIC X(12).
           05  FILLER                  PIC X(325).
      *
      ***  CUSTTXB1 - End-of-Copy File - - - - - - - - - - - CUSTTXB1 *
      *****************************************************************
      *


Sample Input

Code:
000000000100 Anderson                    Adrian              1113 Peachtree Plaza, Suite 111                                                                 Atlanta         GA26101
000000000200 Brown                       Billie              224 Baker Boulevard                                                                             Baltimore       MD35702
000000000300 Carson                      Cameron             336 Crenshaw Blvd.                                                                              Cupertino       CA96154
000000000400 Davidson                    Dion                448 Main Street                                                                                 Wilmington      DE27323



The output of program should be as shown below


Sample Output

Code:
100,,Anderson,Adrian,1113 Peachtree Plaza, Suite 111,,Atlanta,GA,26101
200,,Brown,Billie,224 Baker Boulevard,,Baltimore,MD,35702
300,,Carson,Cameron,336 Crenshaw Blvd.,,Cupertino,CA,96154
400,,Davidson,Dion,448 Main Street,,Wilmington,DE,27323


If any field in the input file is blank then only ,(comma) should come there to represent that field. E.g In above example status and and Addr-02 is blank and hence you can
see additional commas for this field in output . Could you please help me?

Code'd
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Sun Mar 24, 2013 10:16 am    Post subject: Reply to: Creating CSV file using Sort
Reply with quote

see here
http://www-01.ibm.com/support/docview.wss?uid=isg3T7000094
==> Deconstruct and reconstruct CSV records

for what reason is this topic the exact duplicate of
http://ibmmainframeforum.com/viewtopic.php?f=13&t=8930&p=43526#p43526
??? ???

people helping here are the same helping there,
double posting will not get double answers in the same time, or the same answers in half of the time
it will only bother people, and lower Your benevolence factor icon_evil.gif
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Mon Mar 25, 2013 10:25 pm    Post subject:
Reply with quote

Please try below mentioned sort card


Code:
 SORT FIELDS=COPY                                                   
 INREC IFTHEN=(WHEN=INIT,                                           
    BUILD=(1:1,12,                                                   
    13:C',',                                                         
    14:13,01,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=4),         
    18:14,28,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=31),       
    49:42,20,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=23),       
    72:62,48,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=51),       
    123:110,48,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=51),     
    174:158,16,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=19),     
    193:174,02,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=05),     
    198:176,12,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=15))),   
    IFTHEN=(WHEN=INIT,                                               
    BUILD=(1:1,223,                                                 
    SQZ=(SHIFT=LEFT,PAIR=QUOTE,PREBLANK=C'"',MID=C',')))             
    OUTREC FINDREP=(IN=C'"',OUT=C'')                                 


Output:

Code:
000000000100,,Anderson,Adrian,1113 Peachtree Plaza, Suite 111,,Atlanta,GA,26101
000000000200,,Brown,Billie,224 Baker Boulevard,,Baltimore,MD,35702             
000000000300,,Carson,Cameron,336 Crenshaw Blvd.,,Cupertino,CA,96154             
000000000400,,Davidson,Dion,448 Main Street,,Wilmington,DE,27323               



Note: In your sample output CUSTTEXT-KEY is displayed as 4 digits. Is it always be 4 digits?
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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us