How to sort an array in descending in RPG
Answers were Sorted based on User's Feedback
Answer / tahir
sorta is an array opcode to do the sorting ..
of records can used in all array type like-
1.run time
2.compile time
3.pre run time
and example of it can be.....
we use ipe specification for creating an array,there is a
parameter in ipe spec. SEQUENCE ENTRY ____________
write___A(ascending)
D(decending)
E arr1 1 4 2 0 arr2 3
C z-add 1 x 20
C do 12
C sortaarr1
C arr1,x dsply arr2,x
C add 1 x
C enddo
C seton lr
**
12dec
01jan
04apr
09sep
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / surya siram
While declaring the array in the rpgle program, use the key word "DESCEND" and then use the bif SORTA (Sort array) to sort the array in descending order.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / ravi kumar
DARR1 S 3S 0 DIM(5) DESCEND
C
C EVAL Arr1(1) = 100
C EVAL Arr1(2) = 500
C EVAL Arr1(3) = 300
C EVAL Arr1(4) = 400
C EVAL Arr1(5) = 250
C sorta arr1
C ARR1(1) DSPLY
C ARR1(2) DSPLY
C ARR1(3) DSPLY
C ARR1(4) DSPLY
C ARR1(5) DSPLY
C SETON lR
OUTPUT:
500
400
300
250
100
| Is This Answer Correct ? | 1 Yes | 1 No |
1. Which Built-In-Function will you use to achieve the following functionality? CLONO1NO2NO3 Factorl÷÷+OpcdeFactor2++÷ResultLenDHHiLoEq C QTY IFLT *ZERO C QTY MULT -1 QTY C ENDIF a) %ABS b) %TRIM c) %TRIMS d) %UNS
what is the necessary keyword needed to scroll subfile records?
In a particular program one file is used where override command is applied to a file, now this program calls another program where we want to use the same file but without override.How it can be done?
what is use of sflnxtchg and use of MDT(modify data tag).both r same r not and can we use these on dspf and subfile.
what is decimal data error? when it will come and how to achieve(rectify) this error please give me solution as well as code
How can we know running job is batch or interactive?
what is importance of 'MAPFLD' IN OPNQRYF FILE ?
I have a RPG program of 100 Lines and first line is to SETON indicator LR. Will the program execute rest of the 99 Lines?
When will DUMP & DEBUG be ignored?
what built in function can be used with SETLL.If you want to check whether the search argument is successful or not? Please give me answer with example?
how to convert date format from one format to another i think in CL/400 its CVTDAT,Please tell in RPG/400 sir not in RPGILE
What is the difference between copybooks and subprocedures in as400?