Double Quotes on Empty fields in 4gl CSV file

 5 Replies
 0 Subscribed to this topic
 18 Subscribed to this forum
Sort:
Author
Messages
Nancy
Basic Member
Posts: 13
Basic Member
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
I have written a 4gl program to output a csv file as an extract for one of our vendors.   

My problem is that the vendor wants double quotes around all fields in the file - even it the field has nothing in it.

With quote char defaulted - everything in the file has double quotes around it except the fields without values.

I tried setting the quote-char to low-values and manually stringing the doube quotes in front and behind each of fields.
This did not correct the problem.

I also changed my quote char to "?" just to see what that would do and the file works great.  All fields - even the empty ones have "?"s around them - so it
only does it when using the double quote as the quote char for the output file.

Has anyone else ran into this?  Is there a way to get the double quotes to show up even on empty fields?
Ragu Raghavan
Veteran Member
Posts: 477
Veteran Member
New Poster
New Poster
Congrats on posting!
Engaged Poster
Engaged Poster
Wow, you're on a roll!
Avid Poster
Avid Poster
Seriously, you're a posting maniac!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!
one way of doing it:
1. in workdef, set up the file not to have double quotes
2. In the PD, instead of moving a value, use a STRING. For example:

instead of
MOVE EMP-LAST-NAME TO CSV-LAST-NAME

try this
MOVE SPACES TO CSV-LAST-NAME.
STRING """" EMP-LAST-NAME """" DELIMITED BY SPACES INTO CSV-LAST-NAME.
Nancy
Basic Member
Posts: 13
Basic Member
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!

This is how I have WS-NPI defined in WS -
02  WS-NPI                       PIC X      VALUE LOW-VALUES.

IN PD i use this statement -
STRING """WS-NPI""" DELIMITED BY SPACES INTO OUT-NPI.

When I run the program - this is what I get in the output file for this field-
,"WS-NPI",


I really want the field to be ,"",

Any other thoughts would be appreciated, Thanks.

Donna Wirt
Basic Member
Posts: 17
Basic Member
Add an IF statement:

IF (WS-WHATEVER = SPACES)
    MOVE """" TO CSV-FIELD-NAME
ELSE
    MOVE WS-WHATEVER TO CSV-FIELD-NAME
END-IF.
Nancy
Basic Member
Posts: 13
Basic Member
New Poster
New Poster
Congrats on posting!
Engaged Reader
Engaged Reader
You are an engaged reader!
Avid Reader
Avid Reader
Avid Reader art thou!

With this code "MOVE """"           TO OUT-NPI."

This is the result I get in the file -
,",


This field will always be null but the vendor wants ,"", in the csv output file.
Donna Wirt
Basic Member
Posts: 17
Basic Member
Then I would try this:

String """ """ delimited by " " into WS-WHATEVER field.