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 to remove 2 duplicate records and copy only one using job control language?
Program A (Normal COBBAT) calling a B Program (DB2COBOL, COBBATDB which is using a VSAM file. its a dynamic call. How we will handle VSAM file decleration in our from JCL from where we are running A PGM. And should we have PLAN for A pGM also. if possible can some one post a sample JCL. Thanks for help in advance.
In which area will you utilize 88 level items in cobol?
What are the different open modes available in cobol?
What is amode(31)
What are the different data types in cobol?
which is Best IBM Mainframe Training and Placement Institute in Ameerpet Hyderabad
What is a SSRANGE and NOSSRANGE?
) How do u handle errors in BMS macro?
Explain what you understand by passing by value.
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there
How to use the same COBOL program in Batch and CICS on lines? explain with an example
What is the problem of ordered sequential files access?
Differentiate between structured cobol programming and object-oriented cobol programming.
How to read the 2nd last record of a VSAM file? (The file size is huge and we don't know the key)