Thiru
Thiru

Reputation: 251

How to increase the process performance by reducing following codes?

I have written a program using progress 4GL. The syntax is correct but don't know how to reduce the codes..We are the company working for seats and using progress 4gl..we have one table called shift maintenance which has shift time for every hours.Let explain with an example.

DEFINE VARIABLE FistshiftStartHour AS INTEGER NO-UNDO.
DEFINE VARIABLE FistShiftEnddHour AS INTEGER NO-UNDO.
DEFINE VARIABLE SecshiftStartHour AS INTEGER NO-UNDO.
DEFINE VARIABLE SecShiftEnddHour AS INTEGER NO-UNDO.

FIND FIRST shift WHERE shift.shiftsequence = 1 NO-LOCK NO-ERROR.
ASSIGN
        FistshiftStartHour = shift.starthour
        FistShiftEnddHour = shift.endhour.

FIND FIRST shift WHERE shift.shiftsequence = 2 NO-LOCK NO-ERROR.
ASSIGN
        SecshiftStartHour = shift.starthour
        SecShiftEnddHour = shift.endhour.

Like this i need to write a query for every shift hours and assign to two variables for 21 shift sequence.Is there any chance for reducing so much queries?(Note-I must to assign start and end time to individual variables).

Upvotes: 0

Views: 157

Answers (1)

Robert Timothy
Robert Timothy

Reputation: 86

You can handle the shift time with array variable and assign it when doing loop in your table / temp-table:

DEFINE VARIABLE sSeq AS INTEGER EXTENT 21 NO-UNDO. /* start hour */
DEFINE VARIABLE eSeq AS INTEGER EXTENT 21 NO-UNDO. /* end hour */

FOR EACH shift WHERE shift.shiftsequence LE 21 NO-LOCK BY shift.shiftsequence:
    sSeq[shift.shiftsequence] = shift.starthour.
    eSeq[shift.shiftsequence] = shift.endhour.
    DISP sSeq[shift.shiftsequence] eSeq[shift.shiftsequence].
END.

Upvotes: 1

Related Questions