Mahmoud Al Jundi
asked on
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
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
ASKER
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
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
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
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
ASKER
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.
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.
ASKER
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"
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"
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
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
ASKER
Thanks woolmilkporc ,
I accept half of your answer
Regards
I accept half of your answer
Regards
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
>>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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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