Page 1 of 1

Reading the CSV data in COBOL and move it to PACKED-DECIMAL

PostPosted: Tue Dec 03, 2019 5:11 pm
by wik123
Hi Team,

In my one of the code, I am reading the data from CSV file and assigning to working fields by Unstrung function delimited by ';'.

Issue:
When I am reading the file for the decimal values (like 2.33 / 11.03 .. etc) data is not populating properly if i define working field as 9(2)V9(2)
So i had define as X(5) and doing the data population.


01-Working.
03 CSV-EE-WRDE1                 PIC 9(02)V9(2).
03 CSV-EE-WRDE2                 PIC S9(02)V9(2)

01 CSV-FILE
03 CSV-EE-ST-DATUM           PIC X(10).  
03 CSV-EE-WRDE                 PIC X(05).       <--- which is decimal like 2.33  
03 CSV-KOOPSOM                PIC X(13).

Procedure:
UNSTRING CSV-RECORD            
    DELIMITED BY C-DELIMITER    
              OR  ALL LOW-VALUES
    INTO CSV-EE-ST-DATUM,      
            CSV-EE-WRDE
            CSV-KOOPSOM
    TALLYING IN H-NO-OF-FIELDS
END-UNSTRING.                

 



But later below steps, i need to insert the data to table field


Move  CSV-EE-WRDE  to CSV-EE-WRDE1      <---- move is not populating as expected
Move  CSV-EE-WRDE1  to CSV-EE-WRDE2    <---- move is not populating as expected

Table Move

Move  SV-EE-ST-DATUM   TO   EINDLABEL-LABEL
Move   CSV-EE-WRDE2      TO  CONTRACTValue
Move CSV-KOOPSOM       TO   RUBRIEK              

INSERT INTO Table-Name (field1, field2, field3) from (EINDLABEL-LABEL,CONTRACTValue ,RUBRIEK      )

 





Table field declaration ( which is already existed, alter not possible )  
10 EINDLABEL-LABEL      PIC X(10).                        
10 CONTRACTValue        PIC 9(02)V9(02) USAGE PACKED-DECIMAL.
10 RUBRIEK                    PIC X(13).

 


Could any one help me getting proper values for the decimal part.


Thanks in advance.

Re: Reading the CSV data in COBOL and move it to PACKED-DECI

PostPosted: Tue Dec 03, 2019 7:34 pm
by Robert Sample
Don't post in multiple fora -- the people responding on this forum also respond to the other forum. Topic locked.