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
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.
What is the utilization of copybook in cobol?
What are the different rules to perform a Search?
Are you comfortable in cobol or jcl?
What is inspect in cobol ?
What is the local-storage section?
How to find out the closest prime number of an input number? I believe it has something to do with SEARCH and COBOL Linear Array.
What are the different rules for performing sort operation?
How to get the last record in vsam file in cluster? And how can you get the ksds file records into cobol program?
What is the compute verb? How is it used?
How to remove the spaces at the end of each record in the output file of variable length, via cobol program?
here is my requirement A1 is alphanumeric with value 'A1B2C3D4' as defined below 05 A1 PIC X(8) VALUE IS 'A1B2C3D4' but i need to have A2,A3 as ABCD & 1234 repectively...... A2 = ABCD A3 = 1234 Can you please explain me what are the different ways to do it?
What is the difference between external and global variables in COBOL?
What is the problem of ordered sequential files access?
What is the difference between PIC 9.99 and PIC9v99?