Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 9405

COBOL Programming :: Need information on COBOL MOVE CORRESPONDING

$
0
0
Author: subratarec
Subject: Need information on COBOL MOVE CORRESPONDING
Posted: Tue Jun 28, 2016 10:38 pm (GMT 5.5)

Hi,

I have one query related COBOL MOVE CORRESPONDING stmt. I mostly work with PL1 language. But I know COBOL also and in my current project I have started working on COBOL again after couple of years.

Query:
--------------------------------------------------------------------------------------
One small COBOL program to create CSV output. COBOL program will read one PS dataset and for each respective read it will create CSV ourput.

Example:
INPUT -
Code:
AAAAABBBBBBCCCCCDDDDDEEE
FFFFFFGGGGGGHHHHHIIIIIIIJJJJJJJJJ
;
;
KKKKKLLLLLLLLMMMMMNNNNNOOOO


OUTPUT -
Code:
AAAAA,BBBBBB,CCCCC,DDDDD,EEE
FFFFFF,GGGGGG,HHHHH,IIIIIII,JJJJJJJJJ
;
;
KKKKK,LLLLLLLL,MMMMM,NNNNN,OOOO


To Achieve this I created 2 COBOL Structures one for INPUT and another for OUTPUT. Both the structures are having same elements (names are same) under different Group 01 level. Only difference is in OUTPUT structure I have kept FILLER after each 05 element and have used VALUE clause to get it initialized with ','.

Example:
-----------------
INPUT:
---------------------
Code:
01 INPUT-FILE-READ.
     05 A-VALUE  PIC X(5).
     05 B-VALUE  PIC X(5).
     ;
     ;
     05 Z-VALUE  PIC X(5).


OUTPUT:
------------------------------
Code:
01 OUTPUT-FILE-READ.
     05 A-VALUE  PIC X(5).
     05 FILLER     PIC X(1) VALUE ','.
     05 B-VALUE  PIC X(5).
     ;
     ;
     05 FILLER    PIC  X(1) VALUE ','.
     05 Z-VALUE  PIC X(5).


Then I have used MOVE CORRESPONDING to move all the values from INPUT to OUTPUT. There is no issue and values are moving correctly but I expected that when I will code "WRITE OUTPUT-FILE-READ the comma will also come. But instead of that LOW_VALUES are coming.

If I do separate move (moving each and every elements) and then write then comma is coming correctly. But if the structure is very big then it is not good (I think) to go for separate MOVE (cause when we already hve same elements name and MOVE CORRESPONDING is there)

Could someone please let me know wht is this happening and how to resolve the same?

Thanks


Viewing all articles
Browse latest Browse all 9405

Trending Articles