How to sort an array in descending in RPG

Answers were Sorted based on User's Feedback



How to sort an array in descending in RPG..

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

How to sort an array in descending in RPG..

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

How to sort an array in descending in RPG..

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

Post New Answer

More RPG400 Interview Questions

list down and describe the sub systems vailable

5 Answers   IBM,


1. What is bound-by-call and bound-by-reference? 2. Where and why is *Nomain used? 3. What are the difficulties faced by programmers when using service programs? 4. Explain the different ways of parsing and compiling XML in iSeries.

2 Answers  


How I can reread the physical file in CL program once the end of file reached in same CL program.

20 Answers   IBM,


How to sort an array in descending in RPG

3 Answers   Google, TCS,


1.How to read a subfile in out put mode? 2.what are the keywords used to share same file? 3.using composite key which rpg code used?

3 Answers   HSBC,






what is ment by "MDT"

2 Answers   TCS,


How can i keyed a flat file in RPGLE

5 Answers   IBM, Wipro,


How to write record if no field or the field are different in physical file in rpgle ?

0 Answers  


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?

6 Answers  


what is data area and how it is used in rpg program ?

0 Answers   IBM,


HI,1: What is the function of 'SETON LR' AND '*INLR=*ON ? 2:Can we used "seton lr" OR "*INLR = *ON" in between the program code ? 3:if yes then according to there function the code which is written acter seton lr/ *inlr should not be execute . Can any one tell me why those code get executed ?

2 Answers  


what is an online rpg?

0 Answers   IBM,


Categories