|
View previous topic :: View next topic
|
| Author |
Message |
pdighade
New User
Joined: 21 Jul 2008 Posts: 40 Location: pune
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
| Back to top |
|
 |
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
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 |
|
 |
Srikanth Kyatham
New User
Joined: 23 Jun 2021 Posts: 1 Location: India
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| 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 |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Please don’t tailgate older posts . |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|