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



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

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

Postby wik123 » Tue Dec 03, 2019 5:11 pm

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.
wik123
 
Posts: 1
Joined: Tue Dec 03, 2019 4:18 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Robert Sample » Tue Dec 03, 2019 7:34 pm

Don't post in multiple fora -- the people responding on this forum also respond to the other forum. Topic locked.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post