000100IDENTIFICATIONDIVISION.
000200PROGRAM-ID.CARPRG.
000300AUTHOR.RMQB.
000400*---------------------------------------------
000500*OBJECTIVE:WRITEANDREAD-SEQUENTIALFILE
000600*CARSINFORMATION
000700*---------------------------------------------
001700DATADIVISION.
003400WORKING-STORAGESECTION.
00341001REGISTO.
00343005DATESOLDPICX(10).
00344005FILLERPICX(01).
00345005CARBRANDPICX(10).
00345105FILLERPICX(01).
00346005CARMODELPICX(10).
00346105FILLERPICX(01).
00347005REGISTRATIONPICX(09).
00347105FILLERPICX(01).
00348005CLIENTNAMEPICX(10).
00349005CONTACTPIC9(09).
00349105FILLERPICX(01).
00349205PRODUCTIONYEARPIC9(04).
00349305FILLERPICX(01).
00349405MILEAGEPIC9(06).
00349505FILLERPICX(01).
00349605CARPRICEPIC9(05).
00349705FILLERPICX(60).
00349805FILLERPICX(60).
00350001FS-CARPICX(02)VALUESPACES.
00360088FS-CAR-OKVALUE'00'.
00370088FS-CAR-EOFVALUE'10'.
00371001CARNOPIC9(09)COMP-5.
00372001RBASTOPPIC9(09)COMP-5.
00373001READ-RECORDPIC9(09)COMP-5.
00374001SEARCH-RECPIC9(09)COMP-5.
00380001WS-MESSAGEPICX(50).
00390001WS-COMMAREAPICX(10)VALUESPACES.
00400001OPTION-IN.
00410005OPTIONPICX(18).
00420001FILEDATA.
00430005DATA-WRITEPICX(18).
00440005DATA-READPICX(18).
00450001WS-ABSTIMEPICS9(15)COMP-3.
00460001WS-DATEPICX(10).
00470001WS-DAYWEEKPICS9(8)USAGEBINARY.
00480001WS-NAMEDAYPICX(09).
00490001RESPONSEPICS9(08)BINARY.
00570001COUNTERS.
00580005READ-COUNTPIC9(2).
00581005CAR-COUNTPIC9(3).
00590001WS-LENPICS9(4)COMP-3.
00590101WS-KEY-LENPICS9(4)COMP.
00591001WS-STD-REC-KEYPIC9(3).
00592001CH1PICX(01)VALUE'S'.
00593001CH2PICX(01)VALUE'S'.
00594001CH3PICX(01)VALUE'S'.
00595001CH4PICX(01)VALUE'S'.
006000COPYCARMAP.
006001*COPYDFHAID.
006010*COPYDFHBMSCA.
006100LINKAGESECTION.
00620001DFHCOMMAREAPICX(10).
006300*TRANS(ECAR)MAPSET(CARMAP)GROUP(CARPRG)
006400*MAPFIELDSOPTINFOMSGSALEBRANDMODELPLATECLIENT
006410*CONTINUEDPHONECREAT(CREATIONDATE)MILESPRICE
006500PROCEDUREDIVISION.
006600000-MAIN.
006700*MOVEDFHCOMMAREATOWS-COMMAREA.
006800IFEIBCALEN=0THEN
006810MOVEDFHCOMMAREATOWS-COMMAREA
006900PERFORM010-PREPARE
007000MOVE'FIRST'TOWS-COMMAREA
007010MOVESPACESTOREGISTO
007011INITIALIZERESPONSE
007020INITIALIZEREGISTO
007030INITIALIZECARNO
007100INITIALIZEFS-CARREAD-COUNT
007200INITIALIZEWS-LENWS-STD-REC-KEY
007300MOVE1TOCAR-COUNT
007400MOVE99999999TORESPONSE
007600END-IF.
007700*FILLER/SEPARATOR
007800IFEIBCALEN>0THEN
007900PERFORM010-PREPARE
008000END-IF.
009000PERFORM020-CHOICE.
009200EXECCICS
009300RETURN
009400END-EXEC.
009500GOBACK.
009600010-PREPARE.
009900EXECCICS
010000ASKTIME
010100ABSTIME(WS-ABSTIME)
010200END-EXEC.
010300EXECCICS
010400FORMATTIME
010500ABSTIME(WS-ABSTIME)
010600DDMMYYYY(WS-DATE)
010700DATESEP('/')
010800END-EXEC.
010900EXECCICS
011000FORMATTIME
011100ABSTIME(WS-ABSTIME)
011200DAYOFWEEK(WS-DAYWEEK)
011300END-EXEC.
011400EVALUATEWS-DAYWEEK
011500WHEN0
011600MOVE"SUNDAY"TOWS-NAMEDAY
011700WHEN1
011800MOVE"MONDAY"TOWS-NAMEDAY
011900WHEN2
012000MOVE"TUESDAY"TOWS-NAMEDAY
012100WHEN3
012200MOVE"WEDNESDAY"TOWS-NAMEDAY
012300WHEN4
012400MOVE"THURSDAY"TOWS-NAMEDAY
012500WHEN5
012600MOVE"FRIDAY"TOWS-NAMEDAY
012700WHEN6
012800MOVE"SATURDAY"TOWS-NAMEDAY
012900END-EVALUATE.
013000MOVEWS-NAMEDAYTOWS-MESSAGE(1:10).
013100MOVE','TOWS-MESSAGE(11:3).
013200MOVEWS-DATETOWS-MESSAGE(14:10).
013300MOVEWS-MESSAGETOCDAYO.
013500*END-IF.
013600020-CHOICE.
013700*MOVEYITOYOUT.
013701MOVELOW-VALUESTOWS-MESSAGE.
013702MOVELOW-VALUESTOCARMAI.
013751MOVEWS-MESSAGETOMSGO.
013800PERFORMUNTILCH1='N'
013900MOVELOW-VALUESTOCARMAI
014000MOVESPACESTOCDAYI
014100MOVESPACESTOCDAYO
014200*MOVE0TOWCOUNTDUPL.
014400MOVEWS-NAMEDAYTOWS-MESSAGE(1:10)
014500MOVE','TOWS-MESSAGE(11:3)
014600MOVEWS-DATETOWS-MESSAGE(14:10)
014700MOVEWS-MESSAGETOCDAYO
014701MOVE"OPTIONS|0:EXIT/1:NEWRECORD/2:SHOWALL"TOMSGO
014702PERFORM030-SEND-MAP
014703MOVELOW-VALUESTOMSGO
014710MOVE"OPTIONS|3:SEARCHFORARECORD"TOMSGO
014800PERFORM030-SEND-MAP
014900*EXECCICS
015000*SENDMAP('NAMEMA')MAPSET('NAMEMAP')
015100*ERASE
015200*END-EXEC
015300PERFORM040-RECEIVE-MAP
015400*EXECCICS
015500*RECEIVEMAP('NAMEMA')MAPSET('NAMEMAP')
015600*ASIS
015700*END-EXEC
015800MOVEOPTITOOPTION
015900EVALUATEOPTION
016000WHEN1
016100PERFORM050-ADD-RECORD
016110MOVE'N'TOCH1
016200WHEN2
016300PERFORM060-SHOW-RECORDS
016310WHEN3
016320PERFORM070-SEARCH-RECORD
016400WHEN0
016500MOVE'N'TOCH1
016600END-EVALUATE
016610END-PERFORM.
016700030-SEND-MAP.
016800EXECCICS
016900SENDMAP('CARMA')MAPSET('CARMAP')
017000ERASE
017100END-EXEC.
017110030-SEND-MAP-CURSOR.
017120EXECCICS
017130SENDMAP('CARMA')MAPSET('CARMAP')
017140ERASE
017141CURSOR
017150END-EXEC.
017200040-RECEIVE-MAP.
017300EXECCICS
017400RECEIVEMAP('CARMA')MAPSET('CARMAP')
017500ASIS
017600END-EXEC.
017700050-ADD-RECORD.
017800MOVELOW-VALUESTOCARMAI.
017900MOVEWS-NAMEDAYTOWS-MESSAGE(1:10).
018000MOVE','TOWS-MESSAGE(11:3).
018100MOVEWS-DATETOWS-MESSAGE(14:10).
018200MOVEWS-MESSAGETOCDAYO.
018210MOVE0TOCARNO.
018220*MOVEINFOLTOMSGO.
018230*PERFORM030-SEND-MAP.
019600*MOVELOW-VALUESTOCARMAI,CARMAO.
019620MOVE"PLEASEREADTHEFOLLOWINGINSTRUCTIONS"TOMSGO.
019630PERFORM030-SEND-MAP.
019640MOVELOW-VALUESTOMSGO.
019650MOVE"ONLYWRITEINTHEFIELDSATTHEEND"TOMSGO.
019660PERFORM030-SEND-MAP.
019670MOVELOW-VALUESTOMSGO.
019700MOVE"WRITETHEDATEOFSALE(DD-MM-YYYY)"TOMSGO.
019800PERFORM030-SEND-MAP.
019801MOVELOW-VALUESTOMSGO.
019802MOVE"WRITETHECARBRANDINTHEBRANDFIELD"TOMSGO.
019803PERFORM030-SEND-MAP.
019821MOVELOW-VALUESTOMSGO.
019822MOVE"WRITETHECARMODELINTHEMODELFIELD"TOMSGO.
019823PERFORM030-SEND-MAP.
019824MOVELOW-VALUESTOMSGO.
019825MOVE"WRITETHELICENSEPLATEINCARPLATEFIELD"TOMSGO.
019826PERFORM030-SEND-MAP.
019827MOVELOW-VALUESTOMSGO.
019828MOVE"WRITETHENAMEOFTHECLIENTINCLIENTFIELD"TOMSGO.
019829PERFORM030-SEND-MAP.
019830MOVELOW-VALUESTOMSGO.
019840MOVE"WRITETHEPHONEOFCLIENTINTHEPHONEFIELD"TOMSGO.
019841PERFORM030-SEND-MAP.
019842MOVELOW-VALUESTOMSGO.
019843MOVE"WRITETHEYEARTHECARISMADEMADEINFIELD"TOMSGO.
019844PERFORM030-SEND-MAP.
019845MOVELOW-VALUESTOMSGO.
019846MOVE"WRITETHEMILEAGEINTHEMILEAGEFIELD"TOMSGO.
019847PERFORM030-SEND-MAP.
019848MOVELOW-VALUESTOMSGO.
019849MOVE"WRITETHEPRICEOFTHECARINPRICEFIELD"TOMSGO.
019850PERFORM030-SEND-MAP.
019851MOVELOW-VALUESTOMSGO.
019852MOVELOW-VALUESTOWS-MESSAGE.
019853MOVELOW-VALUESTOCARMAI.
019854MOVEWS-NAMEDAYTOWS-MESSAGE(1:10).
019855MOVE','TOWS-MESSAGE(11:3).
019856MOVEWS-DATETOWS-MESSAGE(14:10).
019857MOVEWS-MESSAGETOCDAYO.
019858MOVE-1TOSALEL.
019859MOVE"PLEASEWRITEINFIELDSASINSTRUCTEDABOVE"TOMSGO.
019860PERFORM030-SEND-MAP-CURSOR.
019870PERFORM040-RECEIVE-MAP.
020000MOVESALEITODATESOLD.
020500MOVEBRANDITOCARBRAND.
021000MOVEMODELITOCARMODEL.
021500MOVEPLATEITOREGISTRATION.
022000MOVECLIENTITOCLIENTNAME.
022400MOVEPHONEITOCONTACT.
022800MOVECREATITOPRODUCTIONYEAR.
023200MOVEMILESITOMILEAGE.
023300MOVEPRICEITOCARPRICE.
023700EXECCICSWRITE
023800FILE('CARSDD')
023900FROM(REGISTO)
024010RIDFLD(CARNO)
024100RBA
024200END-EXEC.
024210ADD1TOCAR-COUNT.
024300*CLOSECAR.
024400060-SHOW-RECORDS.
024500*OPENINPUTCAR
024501MOVELOW-VALUESTOWS-MESSAGE.
024502MOVELOW-VALUESTOCARMAI.
024510MOVEWS-MESSAGETOMSGO.
024512MOVEWS-LENTOWS-KEY-LEN.
024520MOVE0TOCARNO.
024600EXECCICSSTARTBR
024700FILE('CARSDD')
024800RIDFLD(CARNO)
024810RBA
024820RESP(RESPONSE)
024900END-EXEC.
024910MOVELOW-VALUESTOWS-MESSAGE.
024920MOVELOW-VALUESTOCARMAI.
024930IFRESPONSENOT=DFHRESP(NORMAL)
024960MOVE'FILEOPERATIONERROR'TOWS-MESSAGE(1:20)
024970MOVE':'TOWS-MESSAGE(21:2)
024980MOVERESPONSETOWS-MESSAGE(24:8)
024991MOVEWS-MESSAGETOMSGO
024992PERFORM030-SEND-MAP
024993END-IF.
024994PERFORMUNTILCH3='N'
024995MOVE0TORESPONSE
025100EXECCICSREADNEXT
025200FILE('CARSDD')
025300INTO(REGISTO)
025320RIDFLD(CARNO)
025330RBA
025340RESP(RESPONSE)
025400END-EXEC
025500MOVELOW-VALUESTOWS-MESSAGE
025600MOVELOW-VALUESTOCARMAI
025601IFRESPONSE=DFHRESP(ENDFILE)
025602MOVELOW-VALUESTOWS-MESSAGE
025603MOVELOW-VALUESTOCARMAI
025604MOVE'ENDOFFILEREACHED'TOWS-MESSAGE(1:19)
025605MOVE':'TOWS-MESSAGE(21:2)
025606MOVERESPONSETOWS-MESSAGE(24:8)
025607MOVEWS-MESSAGETOMSGO
025608PERFORM030-SEND-MAP
025609MOVE'N'TOCH3
025610ELSE
025611IFRESPONSENOT=DFHRESP(NORMAL)
025612MOVELOW-VALUESTOWS-MESSAGE
025613MOVELOW-VALUESTOCARMAI
025620MOVE'FILEOPERATIONERROR'TOWS-MESSAGE(1:20)
025630MOVE':'TOWS-MESSAGE(21:2)
025640MOVERESPONSETOWS-MESSAGE(24:8)
025641MOVEWS-MESSAGETOMSGO
025642PERFORM030-SEND-MAP
025643MOVE'N'TOCH3
025644END-IF
025650END-IF
025660IFRESPONSE=DFHRESP(NORMAL)
026000ADD1TOREAD-COUNT
026001MOVELOW-VALUESTOCARMAI
026002MOVEWS-NAMEDAYTOWS-MESSAGE(1:10)
026003MOVE','TOWS-MESSAGE(11:3)
026004MOVEWS-DATETOWS-MESSAGE(14:10)
026005MOVEWS-MESSAGETOCDAYO
026010MOVE'READINGRECORDSINFILE'TOMSGO
026100MOVEDATESOLDTOSALEO
026200MOVECARBRANDTOBRANDO
026500MOVECARMODELTOMODELO
026600MOVEREGISTRATIONTOPLATEO
026900MOVECLIENTNAMETOCLIENTO
027000MOVECONTACTTOPHONEO
027300MOVEPRODUCTIONYEARTOCREATO
027400MOVEMILEAGETOMILESO
027700MOVECARPRICETOPRICEO
027800PERFORM030-SEND-MAP
027801END-IF
027810END-PERFORM.
027900EXECCICSENDBR
027910FILE('CARSDD')
027920END-EXEC.
028000*CLOSECAR.
028100070-SEARCH-RECORD.
028200MOVE0TOCARNO.
028300EXECCICSSTARTBR
028400FILE('CARSDD')
028500RIDFLD(CARNO)
028600RBA
028700RESP(RESPONSE)
028800END-EXEC.
029100IFRESPONSENOT=DFHRESP(NORMAL)
029110MOVELOW-VALUESTOWS-MESSAGE
029120MOVELOW-VALUESTOCARMAI
029200MOVE'FILEOPERATIONERROR'TOWS-MESSAGE(1:20)
029300MOVE':'TOWS-MESSAGE(21:2)
029400MOVERESPONSETOWS-MESSAGE(24:8)
029500MOVEWS-MESSAGETOMSGO
029600PERFORM030-SEND-MAP
029700END-IF.
029710MOVELOW-VALUESTOWS-MESSAGE.
029720MOVELOW-VALUESTOCARMAI.
029730MOVE"WRITERECORDSEARCHINTHEMADEINFIELD"TOMSGO.
029740PERFORM030-SEND-MAP.
029750MOVELOW-VALUESTOMSGO.
029760MOVE"FOREXAMPLEWRITE0001FORFIRSTRECORD"TOMSGO.
029761MOVE-1TOCREATL.
029770PERFORM030-SEND-MAP-CURSOR.
029780PERFORM040-RECEIVE-MAP.
029790MOVECREATITOREAD-RECORD.
029800PERFORMUNTILCH4='N'
029900MOVE0TORESPONSE
030000EXECCICSREADNEXT
030100FILE('CARSDD')
030200INTO(REGISTO)
030300RIDFLD(CARNO)
030400RBA
030500RESP(RESPONSE)
030600END-EXEC
030900IFRESPONSE=DFHRESP(ENDFILE)
031000MOVELOW-VALUESTOWS-MESSAGE
031100MOVELOW-VALUESTOCARMAI
031200MOVE'ENDOFFILEREACHED'TOWS-MESSAGE(1:19)
031300MOVE':'TOWS-MESSAGE(21:2)
031400MOVERESPONSETOWS-MESSAGE(24:8)
031500MOVEWS-MESSAGETOMSGO
031600PERFORM030-SEND-MAP
031700MOVE'N'TOCH4
031800ELSE
031900IFRESPONSENOT=DFHRESP(NORMAL)
032000MOVELOW-VALUESTOWS-MESSAGE
032100MOVELOW-VALUESTOCARMAI
032200MOVE'FILEOPERATIONERROR'TOWS-MESSAGE(1:20)
032300MOVE':'TOWS-MESSAGE(21:2)
032400MOVERESPONSETOWS-MESSAGE(24:8)
032500MOVEWS-MESSAGETOMSGO
032600PERFORM030-SEND-MAP
032700MOVE'N'TOCH4
032800END-IF
032900END-IF
033000IFRESPONSE=DFHRESP(NORMAL)
033100ADD1TOREAD-COUNT
033110MOVELOW-VALUESTOWS-MESSAGE
033200MOVELOW-VALUESTOCARMAI
033300MOVEWS-NAMEDAYTOWS-MESSAGE(1:10)
033400MOVE','TOWS-MESSAGE(11:3)
033500MOVEWS-DATETOWS-MESSAGE(14:10)
033600MOVEWS-MESSAGETOCDAYO
033700MOVE'READINGRECORDSINFILE'TOMSGO
033800MOVEDATESOLDTOSALEO
033900MOVECARBRANDTOBRANDO
034000MOVECARMODELTOMODELO
034100MOVEREGISTRATIONTOPLATEO
034200MOVECLIENTNAMETOCLIENTO
034300MOVECONTACTTOPHONEO
034400MOVEPRODUCTIONYEARTOCREATO
034500MOVEMILEAGETOMILESO
034600MOVECARPRICETOPRICEO
034700PERFORM030-SEND-MAP
034710MOVECARNOTORBASTOP
034711COMPUTESEARCH-REC=(READ-RECORD-1)*200
034720IFRBASTOP=SEARCH-RECTHEN
034721MOVELOW-VALUESTOMSGO
034723MOVE'YOUGOTTHESEARCHEDRECORD'TOMSGO
034727PERFORM030-SEND-MAP
034730MOVE'N'TOCH4
034740END-IF
034800END-IF
034900END-PERFORM.
035000EXECCICSENDBR
035100FILE('CARSDD')
035200END-EXEC.