0 instead of blanks in CSV file

 6 Replies
 2 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
pgallucci12
Basic Member
Posts: 5
Basic Member
    When a 4GL program creates a CSV file, and numeric fields defined in that CSV contain ZERO values, BLANKS are substituted. Is there a way to force a ZERO instead? Is there a setting in a configuration file that can do that?

    Example: CSV file contains 2 fields, NAME and COUNT.
    The value in NAME = "J.Jones"
    The value in COUNT = 0
    Currently the CSV record for the above looks like...
    "J.Jones",
    I need it to look like...
    "J.Jones",0
    SueS
    Basic Member
    Posts: 20
    Basic Member

      Hi,

       

      I just went through the same thing a few weeks ago.  Used WRKDEF to define a CSV file. Fields were defined as numeric. Anybody that did not have a value for the particular field should have had a zero but a blank was in the field instead.  A ticket was opened with Infor. The response back was that this is correct; when moving zeroes to a csv file, the fields would be empty.

       

      It seems the only way around it is to define your file in working storage.

       

      jaherb
      Veteran Member
      Posts: 164
      Veteran Member
        What I have had to do in the past is to make this field an alpha field and move zeroes to it and then it would appear. The only issue you need to worry about is that if you are using the double quoted to wrap around alpha fields, you would now have double quotes around this field as well. You could then turn off the double quotes for alpha fields, but not sure if that would work for the system it is going to.
        pgallucci12
        Basic Member
        Posts: 5
        Basic Member
          What I chose to do is to use the STRING command and construct csv records that way.  I have total control over everything that way and simply write out the entire csv record string to the record of a work file using TAPE as the media.
          David@SOM
          Posts: 3
            I have the same challenge, the user wants the zeroes instead of a blank.  I was going to construct the file using a WS layout and then write it out as a workfile. How do you use the Cobol String in the program?   Can you provide a simple example of the String command please?  
            Ragu Raghavan
            Veteran Member
            Posts: 476
            Veteran Member
              if you want the record to look like 1000,abcd,05/01/2016
              STRING "1000" "," "abcd" "," "05/01/2016" DLEIMITED BY SIZE INTO OUT-REC.
              WRITE OUT-REC.

              the file related to OUT-REC is defined as type TAPE in workdef
              David@SOM
              Posts: 3

                Thank you!