Double Quotes on Empty fields in 4gl CSV file

Sort:
You are not authorized to post a reply.
Author
Messages
Nancy
Basic Member
Posts: 13
Basic Member
    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: 468
    Veteran Member
      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

        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

            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.
              You are not authorized to post a reply.