RM/COBOL 85 Data Conversion to Text

Dear experts
I have an old data stored in Cobol Data files, I wrote a programs in Cobol to convert to Text, I did some files with no problem, but I faced two issues :
1) If the Cobol Data file File Description (FD) has an Array (Matrix) , what is the Text FD will be ?? example :
            02 CHOAC-ACCUMLATER-NO       PIC 9(10).
            02 CHOAC-TOTAL OCCURS 30 TIMES.
                 04 CHOAC-BEG-BAL-M   PIC S9(9)V999 COMP-3.
                 04 CHOAC-DEBIT-M     PIC S9(9)V999 COMP-3.
                 04 CHOAC-CREDIT-M    PIC S9(9)V999 COMP-3.
                 04 CHOAC-BEG-BAL-O   PIC S9(9)V999 COMP-3.
                 04 CHOAC-DEBIT-O     PIC S9(9)V999 COMP-3.
                 04 CHOAC-CREDIT-O    PIC S9(9)V999 COMP-3.
2) What is the Field  Picture will be in the FD for TEXT output file to have the Minus Sign ,

exmaple :  Below I used DOT instead of V , but what should I use for S ?

Cobol File :   PIC  S9(9)V999
Text File :     PIC   9(9).999  


Thanks in advance
m_jundiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
For 2.)  use as a target of your MOVE
PIC 9(9)V999 SIGN [LEADING|TRAILING] [SEPARATE] USAGE DISPLAY.
I think this is self-explanatory.
I didn't understand your question 1.) Please clarify!

wmp

0
m_jundiAuthor Commented:
Reqgrding Question 1 : if the FD has an array as described in my example , how can I can convert to Text ? in other words what is the the FD for text file  and what is the correct Move Statemnet.

Regarding Question no. 2 : I didn't understand your answer, because I programmed very few in Cobol before many years and Barely I can remember it.
Data File FD for one field  : pic S9(9)V999.
Text file FD : ????

I am attaching a file as an example



convert.txt
0
woolmilkporcCommented:
If the folloWing is your input record:

03 INDIVD-TOTAL-1 OCCURS 30 TIMES.
                 04 INDIVD-BEG-BAL-M-1   PIC S9(9)V999 COMP-3.
                 04 INDIVD-DEBIT-M-1     PIC S9(9)V999 COMP-3.
                 04 INDIVD-CREDIT-M-1    PIC S9(9)V999 COMP-3.
                 04 INDIVD-BEG-BAL-O-1   PIC S9(9)V999 COMP-3.
                 04 INDIVD-DEBIT-O-1     PIC S9(9)V999 COMP-3.
                 04 INDIVD-CREDIT-O-1    PIC S9(9)V999 COMP-3.

- define as the your output record
(assuming you'd like to have a leading sign which is always displayed,
 whether positive or negative):

03 INDIVD-TOTAL-1-O OCCURS 30 TIMES.
                 04 INDIVD-BEG-BAL-M-1-O   PIC +9(9).999.
                 04 INDIVD-DEBIT-M-1-O     PIC +9(9).999.
                 04 INDIVD-CREDIT-M-1-O    PIC +9(9).999.
                 04 INDIVD-BEG-BAL-O-1-O   PIC +9(9).999.
                 04 INDIVD-DEBIT-O-1-O     PIC +9(9).999.
                 04 INDIVD-CREDIT-O-1-O    PIC +9(9).999.

then do a simple 'MOVE INDIVD-TOTAL-1 TO INDIVD-TOTAL-1-O.'
Don't bother the 'OCCURS' thing, COBOL will do it right.

In your example, after definition of TEMPO-REC is complete,
and assuming INDIVD-REC-1 was your record to convert,

simply use 'WRITE TEMPO-REC FROM INDIVD-REC-1.'


wmp





0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

m_jundiAuthor Commented:
Thanks for your reply, I will check and post the results
 I did something else , as u see in my example , I use perform 30 times in order to read the matrix and it is worked.


0
m_jundiAuthor Commented:
1) Regarding Minus Sign it is showing , I used the format in text

2) then do a simple 'MOVE INDIVD-TOTAL-1 TO INDIVD-TOTAL-1-O.'
Don't bother the 'OCCURS' thing, COBOL will do it right.

When I compiled the program it gives an error :
"Identifier refers to table element and thus must be subscrip"





0
woolmilkporcCommented:
Well,
seems RM COBOL is really different ...
if the compiler does say so, you're right to use subsription and a loop to fill your fileds.
 
wmp
 
 
0
m_jundiAuthor Commented:
Thanks woolmilkporc ,

I accept half of your answer

Regards
0
karunamoorthyCommented:
Hello m_jundi,
>>Data File FD for one field  : pic S9(9)V999.
>>Text file FD : ????
You can use like this in output TEXT FD field below
pic -9(9).999

 i.e. replace 'S' with '-'  and 'V' with '.' option.
I hope you understand this one. This will give you the correct text output regarding sign field and decimal field.

And for the other problem regarding  OCCURS clause,
you can either do similar OCCURS cluse in output TEXT FD or else if cobol gives compile error then, you have to move individual columns like MOVE col-1 to col-1-0 ... col-30 to col-30-0.

Hope you can solve this problem now with  this ....
Let me give your comments for further assistance.

Regards,
Karunamoorthy / Chennai


0
benedictheroldCommented:
Hi m_jundi,

1. If there is no change in the data structure of data FD and text FD then you can move the top level variable from data FD to Text FD and it will work. If there is any comp variables only individual moves only will work and there might be a data truncation in group move.

2. You can either use + or - instead of S to show the sign bit.
- --> displays only if there is a negative value
+ --> displays if there is positive or negative value.

Example for 1
---------------------
Data FD
---------------------
01 ALL-DATA
 02 DATA-1 PIC 99 
 02 DATA-2 PIC X(3)
 02 DATA-3 OCCURS 30 TIMES 
  03 DATA-4 PIC S99V999 COMP
  03 DATA-5 PIC S999V999 COMP-3
 
------------------------------
Text FD
------------------------------
01 ALL-DATA-O
 02 DATA-1-O PIC 99 
 02 DATA-2-O PIC X(3)
 02 DATA-3-O OCCURS 30 TIMES 
  03 DATA-4-O PIC +99.999 
  03 DATA-5-O PIC +99.V999 
 
-------------------------------
PROCEDURE DIVISION
-------------------------------
 
MOVE DATA-1 TO DATA-1-O
MOVE DATA-2 TO DATA-2-O
PERFORM 30 TIMES 
MOVE DATA-4(I) TO DATA-4-O(I)
MOVE DATA-5(I) TO DATA-5-O(I)
END PERFORM
 
*where I is the subscript and needs to be incremented properly. 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Mainframe Languages

From novice to tech pro — start learning today.