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

Creating CSV file using Sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   This topic is locked: you cannot edit posts or make replies.
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10791
Location: italy

PostPosted: Sun Mar 24, 2013 10:16 am
Reply with quote

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

for what reason is this topic the exact duplicate of
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
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
Srikanth Kyatham

New User


Joined: 23 Jun 2021
Posts: 1
Location: India

PostPosted: Thu Jun 24, 2021 11:13 am
Reply with quote

SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:3,15,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=18),
19:18,8,PD,EDIT=(STTTTTTTT),SIGNS=(+,-),
30:28,30,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=33),
63:58,1,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=4),

It is not working am getting CC16
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


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

PostPosted: Thu Jun 24, 2021 11:28 am
Reply with quote

Srikanth Kyatham wrote:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:3,15,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=18),
19:18,8,PD,EDIT=(STTTTTTTT),SIGNS=(+,-),
30:28,30,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=33),
63:58,1,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=4),

It is not working am getting CC16

Create a new Topic for your own bugs!
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Thu Jun 24, 2021 4:06 pm
Reply with quote

Please don’t tailgate older posts .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To pull the file with Date and Time u... TSO/ISPF 14
No new posts Is the Output of Sort/Join dependent ... DFSORT/ICETOOL 2
No new posts regarding COBOL WRITE verb (VB File H... COBOL Programming 6
No new posts Trying to use sort to do two function... DFSORT/ICETOOL 14
No new posts COBOL Table data to a flat file with ... COBOL Programming 8
Search our Forums:

Back to Top