How to display string in the reverse order using occurs
clause?
Answer Posted / nk
01 MY-STRING PIC X(9) VALUE 'ABCDEFGHI'.
01 FILLER REDEFINES MY-STRING.
05 CHAR OCCURS 9 TIMES. (could use INDEXED BY here)
01 OUT-STRING PIC X(9).
01 IDX-IN PIC 9.
01 IDX-OUT PIC 9.
MOVE 9 TO IDX-IN.
PERFORM MOVE-A-CHAR (could also do an inline PERFORM)
VARYING IDX-OUT FROM 1 BY 1
UNTIL IDX-OUT > 9.
MOVE-A-CHAR.
MOVE CHAR(IDX-IN) TO OUT-STRING(IDX-OUT).
SUBTRACT 1 FROM IDX-IN.
MOVE-A-CHAR-EXIT.
EXIT.
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
What are different data types in cobol?
What is an in line perform? When would you use it? Anything else you wish to say about it.
There are 5 fields and 1000 records in a file. Unload it into an array. Write the syntax for declaration and how will you unload it.
explain sorting techniques in cobol program?
I have File 1 occurs 5 times with Employee-ID,Employee-Name,Employee-Dept (EEE and MECH). I have File 2 occurs 10 times with Employee-ID,Employee-Name,Employee-Dept (EEE,CIVIL,CHEMICAL and MECH). In FIle 1 and FIle 2 , for matching Employee-DEPT (Only MECH) , we need to move entire records from file1 to file 2. We should not use 2D array. Your help is needed here.
I have a program with an Array of 5000 occurences which is being passed from 5 sub levels to the front end screen. Thess 5 programs using each 5*2 = 10 different arrays with size as 5000. This is causing the transaction to utilize more storage consupmtion. I am looking to reduce the storage consumption. As part of that initially i thought Dynamic array may solve my problem. After viewing the comments given i see its same as normal array. IS there any other way we can resolve this issue?
Can you please let me know the centre name of INS certification in Kolkata.
What is the use of intialize verb?
What is the usage of comp fields in cobol?
how do you reference the variable block file formats from cobol programs
What happens when we move a comp-3 field to an edited (say z (9). Zz-)?
What are all the divisions of a COBOL program?
What is the default value(s) for an initialize and what keyword allows for an override of the default?
Have you used comp and comp-3 in your project? And how?
Explain how will you differentiate between an internal and an external sort, the pros and cons, internal sort syntax etc