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
How you can read the file from bottom?
What kind of error is trapped by on size error option?
) How do u handle errors in BMS macro
How many bytes S(8) comp field occupy and its maximum value?
I have to write to a outfile where the number of records in that file should be the header of that file using IMS.. can anyone help me in this issue
how do you reference the fixed unblock file formats from cobol programs
How to know whether the module is dynamical or statistical?
What are the different rules for performing sort operation?
explain sorting techniques in cobol program?
Which division and paragraphs are mandatory for a COBOL program?
System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..
What are the cobol coding sheets?
How do you get the data to code the BMS macro?
Explain how you can characterize tables in cobol?
What are 77 levels used for?