I have an sqlrpg program which is supposed to generate warehouse locations, 8 positions, in a loop so that we will have rows, aisles,bins, as: but code is only producing the first row below, and is in a 'never ending loop. Now this below code is the entire, but perhaps you can see is it incrementing correctly? I am try to isolate as to where exactly this is not working. If you can alert me please what part is not incrementing towards the desired locations result:
AA01A01
AA01A02
AA01B01
AA01B02
AA01C01
AA01C02
AA01D01
H DFTACTGRP(*NO)
FLOCtest O E K DISK rename(LOCATION:REC1)
F prefix(w_)
D @1Position s 1
D @2Position s 1
D @34Position s 2
D @5Position s 1
D @67Position s 2
D @Location s 10a
D @Location1 s 1a
D @Location2 s 1a
D @Location3 s 2a
D @Location4 s 1a
D @Location5 s 2a
D w_STRSEL s 1000a inz(*blanks)
D w_STRSEL1 s 1000a inz(*blanks)
D w_STRSEL2 s 1000a inz(*blanks)
D w_STRSEL3 s 1000a inz(*blanks)
D w_STRWHERE s 1000a inz(*blanks)
D w_STRSQL s 1000a inz(*blanks)
D intVal s 10 0
D yesNo s 1
D w_APOS c const(x'7D')
D getValue PR 10A
D p_file 10A CONST
D getDetails PR
D p_field 20A CONST
D p_file 20A CONST
C EXSR MAINR
C EXSR EXITR
C MAINR BEGSR
C* EXSR getValPos
C EXSR genValue
C ENDSR
C getValPos BEGSR
/free
@1Position = getValue('POSITION1');
@2Position = getValue('POSITION2');
@34Position= getValue('POSITION34');
@5Position = getValue('POSITION5');
@67Position= getValue('POSITION67');
/end-free
C ENDSR
C upd67a BEGSR
/free
Exec SQL
Update Position67 set SixSeven = 1
Where SixSevenPosition =: @Location5;
/end-free
C ENDSR
C upd67b BEGSR
/free
Exec SQL
Update Position67 set SixSeven = 0;
/end-free
C ENDSR
C upd5a BEGSR
/free
Exec SQL
Update Position5 set FifthFlag = 1
Where FIFTH00001 =: @Location4;
/end-free
C ENDSR
C upd5b BEGSR
/free
Exec SQL
Update Position5 set FIFTHFLAG = 0;
/end-free
C ENDSR
C upd34a BEGSR
/free
Exec SQL
Update Position34 set THIRD00002= 1
Where THIRD00001 =: @Location3;
/end-free
C ENDSR
C upd34b BEGSR
/free
Exec SQL
Update Position34 set THIRD00002= 0;
/end-free
C ENDSR
C upd2a BEGSR
/free
Exec SQL
Update Position2 set SECONDFLAG= 1
Where SECON00001 =: @Location2;
/end-free
C ENDSR
C upd2b BEGSR
/free
Exec SQL
Update Position2 set SECONDFLAG= 0;
/end-free
C ENDSR
C del1a BEGSR
/free
Exec SQL
delete from Position1
Where FIRST00001 =:@Location1;
/end-free
C ENDSR
C writeLoc BEGSR
C eval @Location = *blanks
C eval @Location = @Location1 +
C @Location2 + @Location3 +
C @LocatioN4 + @Location5
C eval w_Location = @Location
C write rec1
C ENDSR
C genValue BEGSR
/free
@1Position = getValue('POSITION1');
DOW @1Position = '1';
w_STRSEL3 = ' order by FirstPosition';
getDetails('FirstPosition':'Position1');
@Location1 = %trim(@Location);
W_STRWHERE = ' where SECONDFLAG=0';
@2Position= getValue('POSITION2');
DOW @2Position = '1';
w_STRSEL2 = ' where SecondFlag=0';
w_STRSEL3 = ' order by SecondPosition';
getDetails('SecondPosition':'Position2');
@Location2 = %trim(@Location);
W_STRWHERE = ' where THIRD00002=0';
@34Position=
getValue('POSITION34');
DOW @34Position = '1';
w_STRSEL2 = ' where ThirdFourthFlag=0';
w_STRSEL3 = ' order by ThirdFourthPosition';
getDetails('ThirdFourthPosition':'Position34');
@Location3 = %trim(@Location);
W_STRWHERE = ' where FifthFlag= 0';
@5Position= getValue('POSITION5');
DOW @5Position = '1';
w_STRSEL2 = ' where FifthFlag=0';
w_STRSEL3 = ' order by FifthPosition';
getDetails('FifthPosition':'Position5');
@Location4 = %trim(@Location);
W_STRWHERE = ' where SixSeven = 0';
@67Position= getValue('POSITION67');
DOW @67Position = '1';
w_STRSEL2 = ' where SixSeven=0';
w_STRSEL3 = ' order by SixSevenPosition';
getDetails('SixSevenPosition':'Position67');
@Location5 = %trim(@Location);
/end-free
C EXSR writeLoc
C EXSR upd67a
/free
W_STRWHERE = ' where SixSeven = 0';
@67Position= getValue('POSITION67');
/end-free
C* ENDSR
C ENDDO
C EXSR upd67b
C EXSR upd5a
/free
W_STRWHERE = ' where FifthFlag= 0';
@5Position= getValue('POSITION5');
/end-free
C ENDDO
C EXSR upd5b
C EXSR upd34a
/free
W_STRWHERE = ' where THIRD00002=0';
@34Position= getValue('POSITION34');
/end-free
C ENDDO
C EXSR upd34b
C EXSR upd2a
/free
W_STRWHERE = ' where SECONDFLAG=0';
@2Position= getValue('POSITION2');
/end-free
C ENDDO
C EXSR upd2b
C EXSR del1a
/free
W_STRWHERE = ' where FIRSTFLAG=0';
@1Position= getValue('POSITION1');
/end-free
C ENDDO
C ENDSR
C EXITR BEGSR
C EVAL *INLR = *ON
C ENDSR
P getValue b
D getValue pi 10A
D p_file 10A CONST
D x_val1 s 10a
D x_val2 s 9s 0
/free
yesNo = '0';
w_STRSEL = 'SELECT * FROM ' + p_file;
w_STRSQL = %trimr(w_STRSEL) + %trimr(W_STRWHERE);
Exec SQL PREPARE S1 FROM :w_STRSQL;
Exec SQL DECLARE C1 CURSOR FOR S1;
Exec SQL OPEN C1;
Exec SQL Fetch C1 Into :x_val1, :x_val2;
if SQLCOD = 0;
yesNo = '1';
endif;
Exec SQL CLOSE C1;
return yesNo;
/end-free
P getValue E
P getDetails b
D getDetails pi
D p_field 20A CONST
D p_file 20A CONST
D x_val1 s 10a
/FREE
@Location = *blanks;
w_STRSEL = 'SELECT ' + p_field;
w_STRSEL1= ' FROM ' + p_file;
w_STRSQL = %trimr(w_STRSEL) + %trimr(w_STRSEL1) +
%trimr(w_STRSEL2) + %trimr(w_STRSEL3);
Exec SQL PREPARE S1a FROM :w_STRSQL;
Exec SQL DECLARE C1a CURSOR FOR S1a;
Exec SQL OPEN C1a;
Exec SQL Fetch C1a Into :x_val1;
if SQLCOD = 0;
@Location = %trim(x_val1);
endif;
Exec SQL CLOSE C1a;
w_STRSEL = *blanks;
w_STRSEL1 = *blanks;
w_STRSEL2 = *blanks;
w_STRSEL3 = *blanks;
w_STRSQL = *blanks;
/end-free
P getDetails E