Powered by

Integrative Systems Logo

Star of the day

Kavin Wilkinson

Top answerers

  • Kavin Wilkinson

    0 Answers Master
  • Jason Morrison

    0 Answers Master

All Questions

Filter by

  • No answers
  • No accepted answers

Sorted by

  • No answers
  • No accepted answers

Tagged with

  • No answers
  • No accepted answers

Ibrahim AHMED BELTAGI

Open

Sudoku Solver using Recursion

2021-09-11 10:47:17 | Category: - | 0 answers

--------------------------------------------------------------------------
PUB400.COM
------------
User : USER0047
Password : KHIBAHBE1
-------------------------------------------------------------
 DCL-F MYFILE PRINTER(132) INFDS(PRTFBK);

   DCL-DS PRTFBK;
     CUR_LINE      INT(5)     POS(367);    // Current line num
     CUR_PAGE      INT(10)    POS(369);    // Current page cnt
     // If the first bit of PRT_FLAGS is on, the spooled file has been
     // deleted.  Use TESTB X'80' or TESTB '0' to test this bit.
     PRT_FLAGS     CHAR(1)    POS(373);    // Print Flags
     PRT_MAJOR     CHAR(2)    POS(401);    // Major ret code
     PRT_MINOR     CHAR(2)    POS(403);    // Minor ret code
   END-DS;

DCL-F MYFILE DISK(*EXT) INFDS(DBFBK);

   DCL-DS DBFBK;
     FDBK_SIZE     INT(10)    POS(367);    // Current line num
     JOIN_BITS     INT(10)    POS(371);    // JFILE bits
     LOCK_RCDS     INT(5)     POS(377);    // Nbr locked rcds
     POS_BITS      CHAR(1)    POS(385);    // File pos bits
     DLT_BITS      CHAR(1)    POS(384);    // Rcd deleted bits
     NUM_KEYS      INT(5)     POS(387);    // Num keys (bin)
     KEY_LEN       INT(5)     POS(393);    // Key length
     MBR_NUM       INT(5)     POS(395);    // Member number
     DB_RRN        INT(10)    POS(397);    // Relative-rcd-num
     KEY           CHAR(2000) POS(401);    // Key value (max size 2000)
   END-DS;

DCL-F MYFILE WORKSTN(*EXT) INFDS(DSPFBK);

   DCL-DS DSPFBK;
     DSP_FLAG1     CHAR(2)    POS(367);    // Display flags
     DSP_AID       CHAR(1)    POS(369);    // AID byte
     CURSOR        CHAR(2)    POS(370);    // Cursor location
     DATA_LEN      INT(10)    POS(372);    // Actual data len
     SF_RRN        INT(5)     POS(376);    // Subfile rrn
     MIN_RRN       INT(5)     POS(378);    // Subfile min rrn
     NUM_RCDS      INT(5)     POS(380);    // Subfile num rcds
     ACT_CURS      CHAR(2)    POS(382);    // Active window cursor location
     DSP_MAJOR     CHAR(2)    POS(401);    // Major ret code
     DSP_MINOR     CHAR(2)    POS(403);    // Minor ret code
   END-DS;


----------------------------------Reading By Logical Key ----------------------------
FARACUST   IF   E             DISK
     FARBSHIPA  IF   E           K DISK
     D custkeyDS     e ds                  extname(aracustd:*key)

      *
      *   read all records from the customer file it is non-keyed
      *   use the logical file over the customer file (aracustd) which
      *   is keyed by the sold to number.  use the %kds which again is
      *   sold to number and read all the shipto associated.
      *
      /free

        read ARACUST;
          dow not%eof(ARACUST);
           setll %kds(CustKeyDs) ARBSHIPA;
           reade %kds(CustKeyDs) ARBSHIPA;

             dow not%eof(ARBSHIPA);
               //
               //  do something with the shipto's
               //
               reade %kds(CustKeyDs) ARBSHIPA;
             enddo;

           read ARACUST;
          enddo;
        *inlr = *on;
      /End-Free
--------------------
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 1
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 100 CTL-OPT datFmt(*MDY) main(Main_Proc) dftactgrp(*no); 09/04/21
 101 Dcl-f SuDoKurep Printer(*ext) OflInd(Overflow); 09/04/21
 103 Dcl-f SUDOKUSCR Workstn(*ext) sfile(Record:Rrn) 09/04/21
 104 INDDS(WkstnInd); 09/03/21
 105 //--------------Indicators Data Structure --------- 09/04/21
 106 Dcl-DS WkstnInd ; 09/01/21
 107 Exit ind pos(03); 09/01/21
 108 Cancel ind pos(12); 09/01/21
 109 SflEnd ind pos(90); 09/03/21
 110 Sflclr ind pos(75); 09/03/21
 111 SflDSp ind pos(95); 09/03/21
 112 SfldspCtl ind pos(85); 09/03/21
 113 Protect ind pos(99); 09/04/21
 114 End-DS; 09/01/21
 115 //--------------Prototype Parameters -------------- 09/04/21
 400 DCL-Pr Snd_Parm_F ind ; 09/01/21
 500 Snd_parm_i int(3) ; 08/25/21
 501 Snd_parm_j int(3) ; 08/25/21
 503 END-Pr; 08/31/21
 504 //---------End Prototype Parameters -------------- 09/04/21
 505 // 09/04/21
 506 //-------------Y Array contains value , Status , and possibles- 09/04/21
 507 DCL-ds y dim(9) Qualified; 08/31/21
 508 Value Zoned(1:0) inz(0) ; 08/27/21
 509 Status Char(1) inz(' ') ; 08/27/21
 510 Possiples Zoned(1:0) dim(9) inz(0); 08/27/21
 511 End-DS; 08/27/21
 512 //-------------X Array contains 9 Y's-------------- 09/04/21
 513 Dcl-ds X dim(9) Qualified ; 08/27/21
 514 Y likeds(y) dim(9); 08/27/21
 515 End-DS; 08/27/21
 516 Dcl-s xb int(3) ; //for x direction of blocks 08/27/21
 517 Dcl-s yb int(3) ; //for y direction of blocks 08/27/21
 518 Dcl-s zx int(3) ; //for x direction of blocks 08/27/21
 519 Dcl-s zy int(3) ; //for y direction of blocks 08/27/21
 520 Dcl-s Rcv_Parm_F ind ; // Receive Indicator 09/04/21
 521 Dcl-S RRN int(3) ; // SFL record no 09/04/21
 522 09/04/21
 525 //------------- Main Procedure ------------- 09/10/21
 526 // 09/10/21
 600 DCL-Proc Main_Proc ; 08/25/21
 700 dcl-s InputDate date inz(*Job); 08/06/21
 800 dcl-s DayNumber zoned(1 : 0); 08/06/21
 801 dcl-s DayName2 char(9); 08/07/21
 900 06/13/21
 901 //9012345-------Like --------------- 08/25/21
 902 Dcl-s i int(3) ; //for X direction 08/25/21
 903 Dcl-s j int(3) ; //for Y direction 08/25/21
 904 Dcl-s k int(3) ; //for possiplites 08/25/21
 905 Dcl-s z int(3) inz(1); 08/25/21
 911 Dcl-s Number int(3) ; 08/25/21
 913 Dcl-s Flag ind ; 08/25/21
 914 Dcl-s Flag2 ind inz('1'); 09/04/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 2
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 915 //--------------Array Data Structure------------------- 08/25/21
 916 //Dcl-s Data zoned(1 :0) dim(81) CTDATA PERRCD(9) ; 08/25/21
 917 Dcl-s Data zoned(1 :0) dim(81) inz(0) ; 08/25/21
 931 //---------------------------------------------- 08/25/21
 1101 Exsr First ; //Inizialization subroutine 09/10/21
 1102 i=1; 08/25/21
 1103 j=1; 08/25/21
 1104 Flag ='0' ; 08/27/21
 1105 Flag=Recursion(i:j); 09/01/21
 1106 // --------------- End Part of the Program ----- 09/10/21
 1107 Exsr Printing; 09/04/21
 1108 IF Flag=*ON and Flag2=*ON; 09/04/21
 1109 Result= 'CongratulationĂº'; 09/04/21
 1110 Else; 09/04/21
 1111 Result= 'Some thing goes Wrong'; 09/04/21
 1112 EndIF; 09/04/21
 1113 //--------- Display the final Results in Subfile ---- 09/10/21
 1114 Protect= *on; 09/10/21
 1116 Clear RRN; 09/04/21
 1117 Sflclr =*On; 09/04/21
 1118 SflDsp=*Off; 09/04/21
 1119 SflDspCtl=*Off; 09/04/21
 1120 write Control; 09/04/21
 1121 EXSR From_Array_To_SCR; 09/04/21
 1133 Sflclr =*Off; 09/04/21
 1134 SflDsp=*On ; 09/04/21
 1135 SflDspCtl=*On ; 09/04/21
 1136 EXFMT Control; 09/10/21
 1137 close SuDoKurep; 09/04/21
 1138 *InLR ='1'; 08/25/21
 1139 //---------- End of Every thing Godby ---- 09/10/21
 1140 // 09/10/21
 1201 //-------------load data and initializations ---------- 08/25/21
 1202 BEGSR First ; 08/25/21
 1204 write RCD001; 09/04/21
 1205 //---------------Prepare SubFile ------------- 09/04/21
 1213 SflEnd =*On; 09/03/21
 1215 Clear RRN; 09/03/21
 1216 For i =1 to 9; 09/03/21
 1220 RRN +=1; 09/03/21
 1221 Write Record; 09/03/21
 1222 Endfor; 09/03/21
 1223 //---------------Dsplay SubFile ------------- 09/04/21
 1224 SflDsp=*On; 09/04/21
 1225 SflDspCtl=*On; 09/03/21
 1226 EXFMT Control; 09/03/21
 1227 EXSR From_SCR_To_Array; 09/04/21
 1262 //-----Putting Mark For Given Cells & fill all the possiple solutions 09/10/21
 1263 For i =1 to 9; 08/25/21
 1264 For j =1 to 9; 08/25/21
 1265 IF X(i).Y(j).value<> 0 ; 09/07/21
 1266 X(i).Y(j).status='A' ; // Given cells 09/10/21
 1267 Endif; 08/25/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 3
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 1268 For k =1 to 9 ; 09/03/21
 1269 X(i).Y(j).Possiples(k)= k; // all Possibles values 09/10/21
 1270 EndFor; 09/03/21
 1271 Endfor; 08/25/21
 1272 Endfor; 09/01/21
 1273 EndSr; 08/25/21
 1274 //-----------------------Move data from Screen to Array ----- 09/10/21
 1275 BegSr From_SCR_To_Array; 09/07/21
 1276 I=1; 09/07/21
 1277 DOW %EOF=*Off; 09/07/21
 1278 Readc Record; 09/04/21
 1279 Dow i< RRn; 09/08/21
 1280 x(i).Y(1).value = 0 ; 09/08/21
 1282 x(i).Y(2).value = 0 ; 09/08/21
 1284 x(i).Y(3).value = 0 ; 09/08/21
 1285 x(i).Y(4).value = 0 ; 09/08/21
 1286 x(i).Y(5).value = 0 ; 09/08/21
 1287 x(i).Y(6).value = 0 ; 09/08/21
 1288 x(i).Y(7).value = 0 ; 09/08/21
 1289 x(i).Y(8).value = 0 ; 09/08/21
 1290 x(i).Y(9).value = 0 ; 09/08/21
 1291 i+=1 ; 09/08/21
 1292 Enddo; 09/08/21
 1293 If RRn=i; 09/07/21
 1294 x(i).Y(1).value = A1; 09/04/21
 1295 x(i).Y(2).value = A2; 09/04/21
 1296 x(i).Y(3).value = A3; 09/04/21
 1297 x(i).Y(4).value = A4; 09/04/21
 1298 x(i).Y(5).value = A5; 09/04/21
 1299 x(i).Y(6).value = A6; 09/04/21
 1300 x(i).Y(7).value = A7; 09/04/21
 1301 x(i).Y(8).value = A8; 09/04/21
 1302 x(i).Y(9).value = A9; 09/04/21
 1303 i +=1; 09/08/21
 1304 EndIf; 09/07/21
 1305 EndDo ; 09/07/21
 1306 EndSr; 09/07/21
 1307 //----------------------Move data from Array to Screen - 09/10/21
 1308 BegSr From_Array_To_SCR; 09/04/21
 1309 For i =1 to 9; 09/04/21
 1310 a1= x(i).Y(1).value ; 09/04/21
 1311 a2= x(i).Y(2).value ; 09/04/21
 1312 a3= x(i).Y(3).value ; 09/04/21
 1313 a4= x(i).Y(4).value ; 09/04/21
 1314 a5= x(i).Y(5).value ; 09/04/21
 1315 a6= x(i).Y(6).value ; 09/04/21
 1316 a7= x(i).Y(7).value ; 09/04/21
 1317 a8= x(i).Y(8).value ; 09/04/21
 1318 a9= x(i).Y(9).value ; 09/04/21
 1319 RRn +=1; 09/04/21
 1320 Write Record; 09/04/21
 1321 Endfor; 09/04/21
 1322 EndSr; 09/04/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 4
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 1339 //------------------------Checking & Printing ---- 09/04/21
 1340 BegSr Printing; //checking the results 08/25/21
 1341 k=1; // checking the rows 08/25/21
 1342 //dsply 'Checking the Rows' ; 09/04/21
 1343 //------------------------------ 09/10/21
 1344 For i = 1 to 9 ; 08/25/21
 1345 Number=0; 08/25/21
 1346 For j = 1 to 9; 09/04/21
 1347 data(k) = x(i).y(j).value; 09/04/21
 1348 Number+= data(k); 09/04/21
 1349 k+=1; 09/04/21
 1350 Endfor; 09/04/21
 1351 IF Number <> 45; 09/04/21
 1352 FLAG2= *OFF; 09/04/21
 1353 ENDIF; 09/04/21
 1354 //dsply Number; 09/04/21
 1355 EndFor; 08/25/21
 1356 //----------------------------------------- 08/25/21
 1357 //dsply 'Checking the Coulmans'; 09/04/21
 1358 //------------------------------ 09/10/21
 1359 For j = 1 to 9 ; 08/25/21
 1360 Number=0; 08/25/21
 1361 For i = 1 to 9; 08/25/21
 1362 Number = Number + x(i).y(j).value; 08/25/21
 1363 endfor; 08/25/21
 1364 IF Number <> 45; 09/04/21
 1365 FLAG2= *OFF; 09/04/21
 1366 ENDIF; 09/04/21
 1367 //dsply Number; 09/04/21
 1368 EndFor; 08/25/21
 1369 //----------------------------------------- 08/25/21
 1370 //dsply 'Checking the Blocks ' ; 09/10/21
 1371 //------------------------------ 09/10/21
 1372 For ZX= 1 to 7 by 3 ; 08/25/21
 1373 For ZY= 1 to 7 by 3 ; 08/25/21
 1374 Number=0; 08/25/21
 1375 For i = ZX to zx+2 ; 08/25/21
 1376 For j = ZY to zy+2 ; 08/25/21
 1377 Number = Number + x(i).y(j).value; 08/25/21
 1378 Endfor; 08/25/21
 1379 Endfor; 08/25/21
 1380 // dsply Number; 09/04/21
 1381 IF Number <> 45; 09/04/21
 1382 FLAG2= *OFF; 09/04/21
 1383 ENDIF; 09/04/21
 1384 Endfor; 08/25/21
 1385 Endfor; 08/25/21
 1386 EndSr; 08/25/21
 1387 //------------------------------ 08/25/21
 1388 End-proc Main_Proc ; 09/10/21
 1389 // 09/04/21
 4100 //----------------RECURSION------------------------------ 08/27/21
 4101 // 09/10/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 5
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 4102 DCL-proc Recursion; 08/27/21
 4103 DCL-S Nxt_Parm_i int(3) ; 08/25/21
 4104 DCL-S Nxt_Parm_j int(3) ; 08/25/21
 4105 DCL-S Nxt_Parm_F ind ; 08/25/21
 4106 DCL-S Check_X ind ; 08/27/21
 4107 DCL-S Check_Y ind ; 08/27/21
 4108 DCL-S Check_B ind ; 08/27/21
 4109 DCL-S KK int(3) ; 08/27/21
 4110 DCL-S K int(3) ; //Posiplites 08/27/21
 4111 DCL-PI Recursion ind; 09/01/21
 4112 Rcv_Parm_i int(3) ; 09/01/21
 4113 Rcv_Parm_j int(3) ; 09/01/21
 4114 // Rcv_Parm_F ind ; 09/01/21
 4115 END-PI; 08/25/21
 4116 //-----logic ---------------------- 08/25/21
 4119 DoW Rcv_Parm_F = '0' ; 08/27/21
 4120 //--(1)------ check if the next cell is Given Number ---- 08/30/21
 4121 //-------------------------------------------------------- 09/10/21
 4122 Dow X(Rcv_Parm_i).Y(Rcv_Parm_j).Status = 'A' ; 08/30/21
 4123 Rcv_Parm_j = Rcv_Parm_j +1; 08/30/21
 4124 IF Rcv_Parm_j > 9 ; 08/30/21
 4125 Rcv_Parm_j =1; 08/30/21
 4126 Rcv_Parm_i = Rcv_Parm_i + 1; 08/31/21
 4127 endif; 08/30/21
 4128 IF Rcv_Parm_i > 9; 08/31/21
 4129 Rcv_Parm_F = *ON; 08/31/21
 4130 Return *ON; 08/31/21
 4131 endif; 08/30/21
 4132 EndDo; 08/30/21
 4134 //--(2)-----------DoW The cell is not Given ---- 09/10/21
 4135 //-------------------------------------------------------- 09/10/21
 4136 IF X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =' ' ;// Empty Cell 09/10/21
 4137 K = 1; // First posiple # 09/10/21
 4141 EndIf; 08/27/21
 4142 //--(3)---Check Number is Valid -------------------------- 09/10/21
 4143 DoW K <= 9; 08/30/21
 4144 Exsr #Check_X; //Check X validity 09/10/21
 4145 Exsr #Check_Y; //Check Y validity 09/10/21
 4146 Exsr #Check_B; //Check B validity 09/10/21
 4147 //--(4)---If The stting # is valid then get next cell --- 09/10/21
 4149 IF Check_X = '1' and Check_Y = '1' and Check_B ='1' ; 08/27/21
 4150 X(Rcv_Parm_i).Y(Rcv_Parm_j).value =K ; 08/28/21
 4151 X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =%char(k); 08/28/21
 4152 Name = ' NEW '; 08/29/21
 4153 Exsr #Write_Rec; 08/30/21
 4155 Exsr Next; 08/27/21
 4168 //--(5)------ Call next Cell------------------------- 09/10/21
 4169 Nxt_Parm_F = Recursion(Nxt_Parm_i:Nxt_Parm_j); 09/01/21
 4171 IF Rcv_Parm_F = '1'; 08/31/21
 4172 Leave ; 08/31/21
 4173 EndIF; 08/31/21
 4174 //--(6)------ If Received flag ='0' Take the next possible # -- 09/10/21
 4175 // and cancel its selected value ------------------- 09/10/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 6
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 4176 X(Rcv_Parm_i).Y(Rcv_Parm_j).value =0 ; 08/30/21
 4177 X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =' ' ; 08/30/21
 4178 Name='Back'; 08/30/21
 4179 Exsr #Write_Rec; 08/30/21
 4180 K+=1; 08/30/21
 4181 Else ; 08/30/21
 4182 K+=1; 08/30/21
 4183 EndIf; 08/25/21
 4184 EndDo; 08/27/21
 4185 //---(7) If all possibles not valid Return False and cancel valus- 09/10/21
 4186 IF K > 9; 08/27/21
 4187 X(Rcv_Parm_i).Y(Rcv_Parm_j).value =0 ; 08/27/21
 4188 X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =' ' ; 08/27/21
 4189 k=0; 08/28/21
 4190 Return *Off; 08/31/21
 4191 EndIf; 08/25/21
 4193 EndDo; 08/27/21
 4194 // --(8 ) Return True ----------------- 09/10/21
 4195 Rcv_Parm_F ='1' ; 08/31/21
 4196 Return *ON; 08/31/21
 4197 //------------Next Cell --------------------------------- 09/10/21
 4198 BegSr Next; 08/25/21
 4199 Nxt_Parm_i =Rcv_Parm_i ; 08/25/21
 4200 Nxt_Parm_j =Rcv_Parm_j + 1 ; 08/25/21
 4201 if Nxt_parm_j > 9 ; 08/25/21
 4202 Nxt_parm_j = 1 ; 08/25/21
 4203 Nxt_parm_i = Rcv_Parm_i + 1 ; 08/25/21
 4204 If Nxt_parm_i > 9 ; 08/25/21
 4205 // Dsply 'End of Program' ; 08/27/21
 4206 Rcv_parm_F = '1' ; 08/31/21
 4207 Return *ON; 08/31/21
 4208 endif; 08/25/21
 4211 Endif; 08/25/21
 4212 EndSr; 08/25/21
 4213 //------------Check # with X access --------------------- 09/10/21
 4214 BegSr #Check_X ; 08/27/21
 4215 Check_X='1'; 08/27/21
 4216 For kk =1 to 9; 08/27/21
 4217 If kk <> Rcv_Parm_j; 08/27/21
 4218 If X(Rcv_Parm_i).Y(KK).value = K ; 08/27/21
 4219 Check_X='0'; 08/28/21
 4220 LeaveSr; 08/28/21
 4221 EndIF; 08/27/21
 4222 Endif; 08/27/21
 4223 EndFor; 08/27/21
 4224 EndSr ; 08/27/21
 4225 //------------Check # with Y access --------------------- 09/10/21
 4227 BegSr #Check_Y ; 08/27/21
 4228 Check_Y='1'; 08/27/21
 4229 For kk =1 to 9; 08/27/21
 4230 If kk <> Rcv_Parm_i; 08/27/21
 4231 If X(kk).Y(Rcv_Parm_j).value = K ; 08/28/21
 4232 Check_Y='0'; 08/28/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 7
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 4233 LeaveSr; 08/28/21
 4234 EndIF; 08/27/21
 4235 Endif; 08/27/21
 4236 EndFor; 08/27/21
 4237 EndSr ; 08/27/21
 4238 //------------Check # with Blocks --------------------------- 09/10/21
 4240 BegSr #Check_B ; 08/27/21
 4241 Check_B='1'; 08/27/21
 4242 xb =%Int((Rcv_Parm_i - 1)/3) * 3 + 1; 08/30/21
 4243 yb =%Int((Rcv_Parm_j - 1)/3) * 3 + 1; 08/30/21
 4244 For zx=xb to xb+2; 08/27/21
 4245 For zy=yb to yb+2; 08/27/21
 4246 If zx <> Rcv_Parm_i and zy <> Rcv_Parm_j ; 08/27/21
 4247 If X(zx).Y(zy).value = K ; 08/27/21
 4248 Check_B='0'; 08/28/21
 4249 LeaveSr; 08/28/21
 4250 EndIF; 08/27/21
 4251 Endif; 08/27/21
 4252 endfor; 08/27/21
 4253 Endfor; 08/27/21
 4254 EndSr ; 08/27/21
 4255 //------------Print Data in Printer file----------------- 09/10/21
 4256 BegSr #Write_Rec; 08/30/21
 4257 //Dsply (%char(Rcv_Parm_i)+ ' R E '+ %char(Rcv_Parm_j)+ ' K='+%char(K)); 08/30/21
 4258 PARM_I =Rcv_Parm_i; 08/30/21
 4259 PARM_J =Rcv_Parm_j; 08/30/21
 4260 K_NO =K ; 08/30/21
 4261 Number = X(Rcv_Parm_i).Y(Rcv_Parm_j).value ; 08/30/21
 4262 STATUS = X(Rcv_Parm_i).Y(Rcv_Parm_j).Status ; 08/30/21
 4263 Ser +=1; 09/04/21
 4264 // write RCD002; 09/07/21
 4265 EndSr ; 08/30/21
 4266 End-Proc Recursion; 08/25/21
 4267 //------------------------------Input data -------------- 08/25/21
 * * * * E N D O F S O U R C E * * * *

View the topic

Ibrahim AHMED BELTAGI

Open

Solving Sudoku Game by Recursion algorithm

2021-09-10 19:43:46 | Category: - | 0 answers

Below is the source program for Sudoku solver 

SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 100 CTL-OPT datFmt(*MDY) main(Main_Proc) dftactgrp(*no); 09/04/21
 101 Dcl-f SuDoKurep Printer(*ext) OflInd(Overflow); 09/04/21
 103 Dcl-f SUDOKUSCR Workstn(*ext) sfile(Record:Rrn) 09/04/21
 104 INDDS(WkstnInd); 09/03/21
 105 //--------------Indicators Data Structure --------- 09/04/21
 106 Dcl-DS WkstnInd ; 09/01/21
 107 Exit ind pos(03); 09/01/21
 108 Cancel ind pos(12); 09/01/21
 109 SflEnd ind pos(90); 09/03/21
 110 Sflclr ind pos(75); 09/03/21
 111 SflDSp ind pos(95); 09/03/21
 112 SfldspCtl ind pos(85); 09/03/21
 113 Protect ind pos(99); 09/04/21
 114 End-DS; 09/01/21
 115 //--------------Prototype Parameters -------------- 09/04/21
 400 DCL-Pr Snd_Parm_F ind ; 09/01/21
 500 Snd_parm_i int(3) ; 08/25/21
 501 Snd_parm_j int(3) ; 08/25/21
 503 END-Pr; 08/31/21
 504 //---------End Prototype Parameters -------------- 09/04/21
 505 // 09/04/21
 506 //-------------Y Array contains value , Status , and possibles- 09/04/21
 507 DCL-ds y dim(9) Qualified; 08/31/21
 508 Value Zoned(1:0) inz(0) ; 08/27/21
 509 Status Char(1) inz(' ') ; 08/27/21
 510 Possiples Zoned(1:0) dim(9) inz(0); 08/27/21
 511 End-DS; 08/27/21
 512 //-------------X Array contains 9 Y's-------------- 09/04/21
 513 Dcl-ds X dim(9) Qualified ; 08/27/21
 514 Y likeds(y) dim(9); 08/27/21
 515 End-DS; 08/27/21
 516 Dcl-s xb int(3) ; //for x direction of blocks 08/27/21
 517 Dcl-s yb int(3) ; //for y direction of blocks 08/27/21
 518 Dcl-s zx int(3) ; //for x direction of blocks 08/27/21
 519 Dcl-s zy int(3) ; //for y direction of blocks 08/27/21
 520 Dcl-s Rcv_Parm_F ind ; // Receive Indicator 09/04/21
 521 Dcl-S RRN int(3) ; // SFL record no 09/04/21
 522 09/04/21
 525 //------------- Main Procedure ------------- 09/10/21
 526 // 09/10/21
 600 DCL-Proc Main_Proc ; 08/25/21
 700 dcl-s InputDate date inz(*Job); 08/06/21
 800 dcl-s DayNumber zoned(1 : 0); 08/06/21
 801 dcl-s DayName2 char(9); 08/07/21
 900 06/13/21
 901 //9012345-------Like --------------- 08/25/21
 902 Dcl-s i int(3) ; //for X direction 08/25/21
 903 Dcl-s j int(3) ; //for Y direction 08/25/21
 904 Dcl-s k int(3) ; //for possiplites 08/25/21
 905 Dcl-s z int(3) inz(1); 08/25/21
 911 Dcl-s Number int(3) ; 08/25/21
 913 Dcl-s Flag ind ; 08/25/21
 914 Dcl-s Flag2 ind inz('1'); 09/04/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 2
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 915 //--------------Array Data Structure------------------- 08/25/21
 916 //Dcl-s Data zoned(1 :0) dim(81) CTDATA PERRCD(9) ; 08/25/21
 917 Dcl-s Data zoned(1 :0) dim(81) inz(0) ; 08/25/21
 931 //---------------------------------------------- 08/25/21
 1101 Exsr First ; //Inizialization subroutine 09/10/21
 1102 i=1; 08/25/21
 1103 j=1; 08/25/21
 1104 Flag ='0' ; 08/27/21
 1105 Flag=Recursion(i:j); 09/01/21
 1106 // --------------- End Part of the Program ----- 09/10/21
 1107 Exsr Printing; 09/04/21
 1108 IF Flag=*ON and Flag2=*ON; 09/04/21
 1109 Result= 'CongratulationĂº'; 09/04/21
 1110 Else; 09/04/21
 1111 Result= 'Some thing goes Wrong'; 09/04/21
 1112 EndIF; 09/04/21
 1113 //--------- Display the final Results in Subfile ---- 09/10/21
 1114 Protect= *on; 09/10/21
 1116 Clear RRN; 09/04/21
 1117 Sflclr =*On; 09/04/21
 1118 SflDsp=*Off; 09/04/21
 1119 SflDspCtl=*Off; 09/04/21
 1120 write Control; 09/04/21
 1121 EXSR From_Array_To_SCR; 09/04/21
 1133 Sflclr =*Off; 09/04/21
 1134 SflDsp=*On ; 09/04/21
 1135 SflDspCtl=*On ; 09/04/21
 1136 EXFMT Control; 09/10/21
 1137 close SuDoKurep; 09/04/21
 1138 *InLR ='1'; 08/25/21
 1139 //---------- End of Every thing Godby ---- 09/10/21
 1140 // 09/10/21
 1201 //-------------load data and initializations ---------- 08/25/21
 1202 BEGSR First ; 08/25/21
 1204 write RCD001; 09/04/21
 1205 //---------------Prepare SubFile ------------- 09/04/21
 1213 SflEnd =*On; 09/03/21
 1215 Clear RRN; 09/03/21
 1216 For i =1 to 9; 09/03/21
 1220 RRN +=1; 09/03/21
 1221 Write Record; 09/03/21
 1222 Endfor; 09/03/21
 1223 //---------------Dsplay SubFile ------------- 09/04/21
 1224 SflDsp=*On; 09/04/21
 1225 SflDspCtl=*On; 09/03/21
 1226 EXFMT Control; 09/03/21
 1227 EXSR From_SCR_To_Array; 09/04/21
 1262 //-----Putting Mark For Given Cells & fill all the possiple solutions 09/10/21
 1263 For i =1 to 9; 08/25/21
 1264 For j =1 to 9; 08/25/21
 1265 IF X(i).Y(j).value<> 0 ; 09/07/21
 1266 X(i).Y(j).status='A' ; // Given cells 09/10/21
 1267 Endif; 08/25/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 3
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 1268 For k =1 to 9 ; 09/03/21
 1269 X(i).Y(j).Possiples(k)= k; // all Possibles values 09/10/21
 1270 EndFor; 09/03/21
 1271 Endfor; 08/25/21
 1272 Endfor; 09/01/21
 1273 EndSr; 08/25/21
 1274 //-----------------------Move data from Screen to Array ----- 09/10/21
 1275 BegSr From_SCR_To_Array; 09/07/21
 1276 I=1; 09/07/21
 1277 DOW %EOF=*Off; 09/07/21
 1278 Readc Record; 09/04/21
 1279 Dow i< RRn; 09/08/21
 1280 x(i).Y(1).value = 0 ; 09/08/21
 1282 x(i).Y(2).value = 0 ; 09/08/21
 1284 x(i).Y(3).value = 0 ; 09/08/21
 1285 x(i).Y(4).value = 0 ; 09/08/21
 1286 x(i).Y(5).value = 0 ; 09/08/21
 1287 x(i).Y(6).value = 0 ; 09/08/21
 1288 x(i).Y(7).value = 0 ; 09/08/21
 1289 x(i).Y(8).value = 0 ; 09/08/21
 1290 x(i).Y(9).value = 0 ; 09/08/21
 1291 i+=1 ; 09/08/21
 1292 Enddo; 09/08/21
 1293 If RRn=i; 09/07/21
 1294 x(i).Y(1).value = A1; 09/04/21
 1295 x(i).Y(2).value = A2; 09/04/21
 1296 x(i).Y(3).value = A3; 09/04/21
 1297 x(i).Y(4).value = A4; 09/04/21
 1298 x(i).Y(5).value = A5; 09/04/21
 1299 x(i).Y(6).value = A6; 09/04/21
 1300 x(i).Y(7).value = A7; 09/04/21
 1301 x(i).Y(8).value = A8; 09/04/21
 1302 x(i).Y(9).value = A9; 09/04/21
 1303 i +=1; 09/08/21
 1304 EndIf; 09/07/21
 1305 EndDo ; 09/07/21
 1306 EndSr; 09/07/21
 1307 //----------------------Move data from Array to Screen - 09/10/21
 1308 BegSr From_Array_To_SCR; 09/04/21
 1309 For i =1 to 9; 09/04/21
 1310 a1= x(i).Y(1).value ; 09/04/21
 1311 a2= x(i).Y(2).value ; 09/04/21
 1312 a3= x(i).Y(3).value ; 09/04/21
 1313 a4= x(i).Y(4).value ; 09/04/21
 1314 a5= x(i).Y(5).value ; 09/04/21
 1315 a6= x(i).Y(6).value ; 09/04/21
 1316 a7= x(i).Y(7).value ; 09/04/21
 1317 a8= x(i).Y(8).value ; 09/04/21
 1318 a9= x(i).Y(9).value ; 09/04/21
 1319 RRn +=1; 09/04/21
 1320 Write Record; 09/04/21
 1321 Endfor; 09/04/21
 1322 EndSr; 09/04/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 4
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 1339 //------------------------Checking & Printing ---- 09/04/21
 1340 BegSr Printing; //checking the results 08/25/21
 1341 k=1; // checking the rows 08/25/21
 1342 //dsply 'Checking the Rows' ; 09/04/21
 1343 //------------------------------ 09/10/21
 1344 For i = 1 to 9 ; 08/25/21
 1345 Number=0; 08/25/21
 1346 For j = 1 to 9; 09/04/21
 1347 data(k) = x(i).y(j).value; 09/04/21
 1348 Number+= data(k); 09/04/21
 1349 k+=1; 09/04/21
 1350 Endfor; 09/04/21
 1351 IF Number <> 45; 09/04/21
 1352 FLAG2= *OFF; 09/04/21
 1353 ENDIF; 09/04/21
 1354 //dsply Number; 09/04/21
 1355 EndFor; 08/25/21
 1356 //----------------------------------------- 08/25/21
 1357 //dsply 'Checking the Coulmans'; 09/04/21
 1358 //------------------------------ 09/10/21
 1359 For j = 1 to 9 ; 08/25/21
 1360 Number=0; 08/25/21
 1361 For i = 1 to 9; 08/25/21
 1362 Number = Number + x(i).y(j).value; 08/25/21
 1363 endfor; 08/25/21
 1364 IF Number <> 45; 09/04/21
 1365 FLAG2= *OFF; 09/04/21
 1366 ENDIF; 09/04/21
 1367 //dsply Number; 09/04/21
 1368 EndFor; 08/25/21
 1369 //----------------------------------------- 08/25/21
 1370 //dsply 'Checking the Blocks ' ; 09/10/21
 1371 //------------------------------ 09/10/21
 1372 For ZX= 1 to 7 by 3 ; 08/25/21
 1373 For ZY= 1 to 7 by 3 ; 08/25/21
 1374 Number=0; 08/25/21
 1375 For i = ZX to zx+2 ; 08/25/21
 1376 For j = ZY to zy+2 ; 08/25/21
 1377 Number = Number + x(i).y(j).value; 08/25/21
 1378 Endfor; 08/25/21
 1379 Endfor; 08/25/21
 1380 // dsply Number; 09/04/21
 1381 IF Number <> 45; 09/04/21
 1382 FLAG2= *OFF; 09/04/21
 1383 ENDIF; 09/04/21
 1384 Endfor; 08/25/21
 1385 Endfor; 08/25/21
 1386 EndSr; 08/25/21
 1387 //------------------------------ 08/25/21
 1388 End-proc Main_Proc ; 09/10/21
 1389 // 09/04/21
 4100 //----------------RECURSION------------------------------ 08/27/21
 4101 // 09/10/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 5
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 4102 DCL-proc Recursion; 08/27/21
 4103 DCL-S Nxt_Parm_i int(3) ; 08/25/21
 4104 DCL-S Nxt_Parm_j int(3) ; 08/25/21
 4105 DCL-S Nxt_Parm_F ind ; 08/25/21
 4106 DCL-S Check_X ind ; 08/27/21
 4107 DCL-S Check_Y ind ; 08/27/21
 4108 DCL-S Check_B ind ; 08/27/21
 4109 DCL-S KK int(3) ; 08/27/21
 4110 DCL-S K int(3) ; //Posiplites 08/27/21
 4111 DCL-PI Recursion ind; 09/01/21
 4112 Rcv_Parm_i int(3) ; 09/01/21
 4113 Rcv_Parm_j int(3) ; 09/01/21
 4114 // Rcv_Parm_F ind ; 09/01/21
 4115 END-PI; 08/25/21
 4116 //-----logic ---------------------- 08/25/21
 4119 DoW Rcv_Parm_F = '0' ; 08/27/21
 4120 //--(1)------ check if the next cell is Given Number ---- 08/30/21
 4121 //-------------------------------------------------------- 09/10/21
 4122 Dow X(Rcv_Parm_i).Y(Rcv_Parm_j).Status = 'A' ; 08/30/21
 4123 Rcv_Parm_j = Rcv_Parm_j +1; 08/30/21
 4124 IF Rcv_Parm_j > 9 ; 08/30/21
 4125 Rcv_Parm_j =1; 08/30/21
 4126 Rcv_Parm_i = Rcv_Parm_i + 1; 08/31/21
 4127 endif; 08/30/21
 4128 IF Rcv_Parm_i > 9; 08/31/21
 4129 Rcv_Parm_F = *ON; 08/31/21
 4130 Return *ON; 08/31/21
 4131 endif; 08/30/21
 4132 EndDo; 08/30/21
 4134 //--(2)-----------DoW The cell is not Given ---- 09/10/21
 4135 //-------------------------------------------------------- 09/10/21
 4136 IF X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =' ' ;// Empty Cell 09/10/21
 4137 K = 1; // First posiple # 09/10/21
 4141 EndIf; 08/27/21
 4142 //--(3)---Check Number is Valid -------------------------- 09/10/21
 4143 DoW K <= 9; 08/30/21
 4144 Exsr #Check_X; //Check X validity 09/10/21
 4145 Exsr #Check_Y; //Check Y validity 09/10/21
 4146 Exsr #Check_B; //Check B validity 09/10/21
 4147 //--(4)---If The stting # is valid then get next cell --- 09/10/21
 4149 IF Check_X = '1' and Check_Y = '1' and Check_B ='1' ; 08/27/21
 4150 X(Rcv_Parm_i).Y(Rcv_Parm_j).value =K ; 08/28/21
 4151 X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =%char(k); 08/28/21
 4152 Name = ' NEW '; 08/29/21
 4153 Exsr #Write_Rec; 08/30/21
 4155 Exsr Next; 08/27/21
 4168 //--(5)------ Call next Cell------------------------- 09/10/21
 4169 Nxt_Parm_F = Recursion(Nxt_Parm_i:Nxt_Parm_j); 09/01/21
 4171 IF Rcv_Parm_F = '1'; 08/31/21
 4172 Leave ; 08/31/21
 4173 EndIF; 08/31/21
 4174 //--(6)------ If Received flag ='0' Take the next possible # -- 09/10/21
 4175 // and cancel its selected value ------------------- 09/10/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 6
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 4176 X(Rcv_Parm_i).Y(Rcv_Parm_j).value =0 ; 08/30/21
 4177 X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =' ' ; 08/30/21
 4178 Name='Back'; 08/30/21
 4179 Exsr #Write_Rec; 08/30/21
 4180 K+=1; 08/30/21
 4181 Else ; 08/30/21
 4182 K+=1; 08/30/21
 4183 EndIf; 08/25/21
 4184 EndDo; 08/27/21
 4185 //---(7) If all possibles not valid Return False and cancel valus- 09/10/21
 4186 IF K > 9; 08/27/21
 4187 X(Rcv_Parm_i).Y(Rcv_Parm_j).value =0 ; 08/27/21
 4188 X(Rcv_Parm_i).Y(Rcv_Parm_j).Status =' ' ; 08/27/21
 4189 k=0; 08/28/21
 4190 Return *Off; 08/31/21
 4191 EndIf; 08/25/21
 4193 EndDo; 08/27/21
 4194 // --(8 ) Return True ----------------- 09/10/21
 4195 Rcv_Parm_F ='1' ; 08/31/21
 4196 Return *ON; 08/31/21
 4197 //------------Next Cell --------------------------------- 09/10/21
 4198 BegSr Next; 08/25/21
 4199 Nxt_Parm_i =Rcv_Parm_i ; 08/25/21
 4200 Nxt_Parm_j =Rcv_Parm_j + 1 ; 08/25/21
 4201 if Nxt_parm_j > 9 ; 08/25/21
 4202 Nxt_parm_j = 1 ; 08/25/21
 4203 Nxt_parm_i = Rcv_Parm_i + 1 ; 08/25/21
 4204 If Nxt_parm_i > 9 ; 08/25/21
 4205 // Dsply 'End of Program' ; 08/27/21
 4206 Rcv_parm_F = '1' ; 08/31/21
 4207 Return *ON; 08/31/21
 4208 endif; 08/25/21
 4211 Endif; 08/25/21
 4212 EndSr; 08/25/21
 4213 //------------Check # with X access --------------------- 09/10/21
 4214 BegSr #Check_X ; 08/27/21
 4215 Check_X='1'; 08/27/21
 4216 For kk =1 to 9; 08/27/21
 4217 If kk <> Rcv_Parm_j; 08/27/21
 4218 If X(Rcv_Parm_i).Y(KK).value = K ; 08/27/21
 4219 Check_X='0'; 08/28/21
 4220 LeaveSr; 08/28/21
 4221 EndIF; 08/27/21
 4222 Endif; 08/27/21
 4223 EndFor; 08/27/21
 4224 EndSr ; 08/27/21
 4225 //------------Check # with Y access --------------------- 09/10/21
 4227 BegSr #Check_Y ; 08/27/21
 4228 Check_Y='1'; 08/27/21
 4229 For kk =1 to 9; 08/27/21
 4230 If kk <> Rcv_Parm_i; 08/27/21
 4231 If X(kk).Y(Rcv_Parm_j).value = K ; 08/28/21
 4232 Check_Y='0'; 08/28/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 18:46:28 PUB400 PAGE 7
 SOURCE FILE . . . . . . . USER00471/QRPGLESRC
 MEMBER . . . . . . . . . SUDOKU5
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 4233 LeaveSr; 08/28/21
 4234 EndIF; 08/27/21
 4235 Endif; 08/27/21
 4236 EndFor; 08/27/21
 4237 EndSr ; 08/27/21
 4238 //------------Check # with Blocks --------------------------- 09/10/21
 4240 BegSr #Check_B ; 08/27/21
 4241 Check_B='1'; 08/27/21
 4242 xb =%Int((Rcv_Parm_i - 1)/3) * 3 + 1; 08/30/21
 4243 yb =%Int((Rcv_Parm_j - 1)/3) * 3 + 1; 08/30/21
 4244 For zx=xb to xb+2; 08/27/21
 4245 For zy=yb to yb+2; 08/27/21
 4246 If zx <> Rcv_Parm_i and zy <> Rcv_Parm_j ; 08/27/21
 4247 If X(zx).Y(zy).value = K ; 08/27/21
 4248 Check_B='0'; 08/28/21
 4249 LeaveSr; 08/28/21
 4250 EndIF; 08/27/21
 4251 Endif; 08/27/21
 4252 endfor; 08/27/21
 4253 Endfor; 08/27/21
 4254 EndSr ; 08/27/21
 4255 //------------Print Data in Printer file----------------- 09/10/21
 4256 BegSr #Write_Rec; 08/30/21
 4257 //Dsply (%char(Rcv_Parm_i)+ ' R E '+ %char(Rcv_Parm_j)+ ' K='+%char(K)); 08/30/21
 4258 PARM_I =Rcv_Parm_i; 08/30/21
 4259 PARM_J =Rcv_Parm_j; 08/30/21
 4260 K_NO =K ; 08/30/21
 4261 Number = X(Rcv_Parm_i).Y(Rcv_Parm_j).value ; 08/30/21
 4262 STATUS = X(Rcv_Parm_i).Y(Rcv_Parm_j).Status ; 08/30/21
 4263 Ser +=1; 09/04/21
 4264 // write RCD002; 09/07/21
 4265 EndSr ; 08/30/21
 4266 End-Proc Recursion; 08/25/21
  * * * * E N D O F S O U R C E * * * *

Below The Display file source file

MEMBER . . . . . . . . . SUDOKUSCR
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 10 A*%%TS SD 20210904 173116 USER0047 REL-V7R4M0 5770-WDS 09/04/21
 20 A*%%EC 09/04/21
 30 A DSPSIZ(24 80 *DS3) 09/04/21
 40 A REF(*LIBL/ITEM_PF) 09/04/21
 1210 R RECORD SFL 09/03/21
 1220 A A1 1Y 0B 7 5EDTCDE(4) 09/03/21
 1230 A 99 COLOR(RED) 09/04/21
 1240 A A2 1Y 0B 7 9EDTCDE(4) 09/03/21
 1250 A 99 COLOR(RED) 09/04/21
 1260 A A3 1Y 0B 7 13EDTCDE(4) 09/03/21
 1270 A 99 COLOR(RED) 09/04/21
 1280 A A4 1Y 0B 7 19EDTCDE(4) 09/03/21
 1290 A 99 COLOR(RED) 09/04/21
 1300 A A5 1Y 0B 7 23EDTCDE(4) 09/03/21
 1310 A 99 COLOR(RED) 09/04/21
 1320 A A6 1Y 0B 7 27EDTCDE(4) 09/03/21
 1330 A 99 COLOR(RED) 09/04/21
 1340 A A7 1Y 0B 7 33EDTCDE(4) 09/03/21
 1350 A 99 COLOR(RED) 09/04/21
 1360 A A8 1Y 0B 7 37EDTCDE(4) 09/03/21
 1370 A 99 COLOR(RED) 09/04/21
 1380 A A9 1Y 0B 7 41EDTCDE(4) 09/03/21
 1390 A 99 COLOR(RED) 09/04/21
 1400 09/03/21
 1410 A R CONTROL SFLCTL(RECORD) 09/04/21
 1420 A*%%TS SD 20210904 173116 USER0047 REL-V7R4M0 5770-WDS 09/04/21
 1430 A SFLSIZ(0010) 09/04/21
 1440 A SFLPAG(0009) 09/04/21
 1450 A 85 SFLDSPCTL 09/04/21
 1460 A 95 SFLDSP 09/04/21
 1470 A 75 SFLCLR 09/04/21
 1480 A 90 SFLEND(*MORE) 09/04/21
 1490 A OVERLAY 09/04/21
 1500 A RESULT 22A O 6 51 09/04/21
 1510 A 5 5'==================================- 09/04/21
 1520 A ==' 09/04/21
 1530 A 3 15'S' 09/04/21
 1540 A 3 17'U' 09/04/21
 1550 A 3 19'D' 09/04/21
 1560 A 3 21'O' 09/04/21
 1570 A 3 23'K' 09/04/21
 1580 A 3 25'U' 09/04/21
 * * * * E N D O F S O U R C E * * * *

Below is the Report File

A*%%*********************************************************************** 09/05/21
 2 A*%%TS RD 20210905 191433 USER0047 REL-V7R4M0 5770-WDS 09/05/21
 3 A*%%FI+10660100000000000000000000000000000000000000000000000000 09/05/21
 4 A*%%FI 0000000000000000000000000000000000000000000000000 09/05/21
 5 A*%%*********************************************************************** 09/05/21
 6 A R RCD001 09/05/21
 7 A*%%*********************************************************************** 09/05/21
 8 A*%%RI 00000 09/05/21
 9 A*%%*********************************************************************** 09/05/21
 10 A 2 09/05/21
 11 A ' SER' 09/05/21
 12 A 13 09/05/21
 13 A ' I' 09/05/21
 14 A 21 09/05/21
 15 A ' J' 09/05/21
 16 A 30 09/05/21
 17 A 'VALU' 09/05/21
 18 A 34 09/05/21
 19 A 'E' 09/05/21
 20 A 37 09/05/21
 21 A 'K' 09/05/21
 22 A 40 09/05/21
 23 A 'STA' 09/05/21
 24 A 43 09/05/21
 25 A 'TUS' 09/05/21
 26 A 50 09/05/21
 27 A 'NAME' 09/05/21
 28 A*%%*********************************************************************** 09/05/21
 29 A*%%SS 09/05/21
 30 A*%%*********************************************************************** 09/05/21
 31 A R RCD002 09/05/21
 32 A*%%*********************************************************************** 09/05/21
 33 A*%%RI 00000 09/05/21
 34 A*%%*********************************************************************** 09/05/21
 35 A SPACEB(001) 09/05/21
 36 A SER 8S 0O 3 09/05/21
 37 A EDTCDE(4) 09/05/21
 38 A PARM_I 4S 0O 13 09/05/21
 39 A EDTCDE(L) 09/05/21
 40 A PARM_J 4S 0O 21 09/05/21
 41 A EDTCDE(L) 09/05/21
 42 A NUMBER 4S 0O 30 09/05/21
 43 A EDTCDE(L) 09/05/21
 44 A K_NO 1S 0O 37 09/05/21
 45 A EDTCDE(L) 09/05/21
 46 A STATUS 1A O 42 09/05/21
 47 A NAME 29A O 50 09/05/21
 48 A*%%*********************************************************************** 09/05/21
 49 A*%%SS 09/05/21
 50 A*%%SN NUMBER 9999 09/05/21
 51 A*%%SN K_NO 9 09/05/21
 52 A*%%SN NAME xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 09/05/21
 53 A*%%CP+999CRTPRTF 09/05/21
 -=* http://pub400.com *=- 
 5770WDS V7R4M0 190419 SEU SOURCE LISTING 09/10/21 19:18:37 PUB400 PAGE 2
 SOURCE FILE . . . . . . . USER00471/QDDSSRC
 MEMBER . . . . . . . . . SUDOKUREP
 SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
 54 A*%%CP+ FILE(USER00471/TEST) 09/05/21
 55 A*%%CP+ DEVTYPE(*SCS) 09/05/21
 56 A*%%CP PAGESIZE(*N 132 *N ) 09/05/21
 57 A*%%*********************************************************************** 09/05/21
 58 DDDDD 09/05/21
 * * * * E N D O F S O U R C E * * * *


View the topic

Christian

Open

Dynamic SQL schema

2021-08-04 18:29:12 | Category: - | 0 answers

HI,


I'm creating a SQL Function.
In this function, I do a SELECT ... FROM TableA ...
I need to be able to specify a schema where to read the TableA
On a call to this function I may want to read the TableA from SchemaA and on another call read this table from SchemaB

I can't find how to do this :(

Need help,

Thank you,

Christian

View the topic

deepa hase

Open

SQLRPGLE

2021-07-30 14:54:02 | Category: - | 0 answers

If I recompile a PF , will I have to recompile the sqlrpgle program if the file is used only in sql mode only in that program

View the topic

deepa hase

Open

RPGLE/SQL

2021-07-30 14:53:46 | Category: - | 0 answers

I have a table data as follows.
 Saltab
EMpno     Sal   Saltyp
 1        100     C 
 1         20     D
 2      500     C
 2      100     D

Want to write sql query to display result as follows. Please suggest...
EMpno          Difference
1        80
   400 

View the topic

Doyle Hudson

Open

Journal receiver chains

2021-07-01 18:13:39 | Category: - | 0 answers

We are upgrading/migrating to the Power 9 and need to restore our journal receivers. Every time we do, the new machine ends up breaking the receiver chain. This will mess up several jobs we have that currently use the current chain to gather journal information. I know we can change those jobs to look at specific receivers, but that isn't dynamic enough for our purposes. The question is: Does anyone know of a way to restore a receiver chain to a new machine and have it continue with the saved chain?

View the topic

Mithilesh Kumar

Open

Reading Multiple Files in a Directory

2021-07-01 09:56:37 | Category: - | 0 answers

I have a requirement wherein I need to create a program to copy the data from all the files from an IFS folder into a DB2 file. Is there any way that I can read all the files on IFS in a loop and copy data using CPYFRMIMPF command? 

View the topic

deepa hase

Open

CLLE

2021-06-11 06:23:24 | Category: - | 1 answers

Can I validate email id using cl program? 

View the topic

deepa hase

Open

RPGLE/SQL

2021-06-11 06:23:08 | Category: - | 1 answers

Can I validate email id using cl program? 

View the topic

deepa hase

Open

SQLRPGLE

2021-06-11 06:22:41 | Category: - | 1 answers

I Want to display day name of a date specified by user for example, if user inputs date as 11-06-2021 then 'Friday' should be displayed as a day value.

How can I obtain this? 

View the topic