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

Are all these RPG/400 Interviewed Questions being asked recently? are current?

1 Answers  


This is my Physical file 'EMPS' existing in library "TAMIL1" and its record format is 'EMPRCD" a)its source is R EMPRCD ENO 4 0 ENAME 10 EADD 10 b)The records present in EMPS are as follows ENO ENAME EADD 0001 tamil coimbatore 0002 kumar bangalore 0003 sunder bangalore 0004 arunkumar chennai 0005 pandi hyderabad 0006 santhosh hyderabad 0007 sasi salem 0008 kalai chennai 0009 suresh hyderabad 0010 vijay bangalore 0011 Arul chennai 0012 velu chennai 0013 khan bangalore 0014 praba chennai 0015 praba.p coimbatore 0016 anand ooty 0017 raja erode 0018 sankar erode 0019 vadivel namakkal 0020 anbu chennai 0021 Ajith mumabi c)now i want to select the 'ENAME' field records starting with 'S' for that i have created a RPG program its source code is PGM DCLF FILE(TAMIL1/EMPS) DCL VAR(&MYENO) TYPE(*CHAR) LEN(4) OVRDBF FILE(EMPS) SHARE(*YES) OPNQRYF FILE((TAMIL1/EMPS)) QRYSLT('ENAME *EQ %WLDCRD("S *")') READ: RCVF RCDFMT(EMPRCD) MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END)) CHGVAR VAR(&MYENO) VALUE(&ENO) SNDUSRMSG MSG(&MYENO) SNDUSRMSG MSG(&ENAME) SNDUSRMSG MSG(&EADD) GOTO READ END: CLOF OPNID(EMPS) DLTOVR FILE(EMPS) ENDPGM Is this coding correct sir,the program gets compiled,and if i call it it says query running but records are not displayed.please help me out

4 Answers   Virtusa,


What is SFLNXTCHG keyword why it has used and where? Briefly explain with Example.

2 Answers   IBM,


Q:Hi all,i want accurate answer with code using in built functions.please sent me code as soon as posible. I have program nmed PGM1 which '' RETRIEVE Current production date''should correctly default the production date for the user who is issuing raw materials to the manufacturing.The production date can be different from the celendra date. However, the program does not make the correct adjustment for all manufacturing plants. there is a parameter which determines the production start time e.g. 07:00 if the system time precedes this,the program subtracts one from the celendra day.This work fine when the celendar day starts after production day as it does in England,the system should be adding one to the celendar day during the overlap. unfortunately the program was desined to assumed the celendar day always starts before the production day. Change required in the program: Change the PROGRAM PGM1 to use the new parrameter to decide whether to add or subtract 1 from the celendar day when determining the production date.

0 Answers   TCS,


How to define data area in RPG program? In which scenario multi occurrence DS is use in AS400?

0 Answers  






Anyone help me for the below question:- If problem/error occur in *PSSR subroutine,how should I handel it in RPG program.

1 Answers  


how do u track msg in cl pgm???

1 Answers   CTS,


thanks mr.Harshad R Suryawaunshi,i'm new to as400 i think you are telling in rpgile i know only rpg400 if possible can you tell in rpg400

0 Answers   iGate,


If record-format name in an externally-described file has already been defined as a file-name.how to solve this?

2 Answers   CTS,


suppose we have 10 members in physical file and i have to use 4 out of 10 so how can we read this in RPG

3 Answers   TCS,


while i am using the dspmsg command on comman line in Mocha am getting error like Not authorized to message queue message my messagequeue Name? can anybody help me how to change my message queue Am anable to see my messages in message queue

1 Answers  


how to retrieve RRN value in RPGLE program

3 Answers  


Categories