Quantcast
Channel: Visual COBOL
Viewing all articles
Browse latest Browse all 5819

Wiki Page: Scope of inline usage of IDXFORMAT.

$
0
0
Problem What happens with IDXFORMAT when combining its usages and using it as a compile time directive. as an inline directive. it inside a file handler configuration file. Resolution This is a complex example but hopefully shows how     the IDXFORMAT directive and     the external file handler IDXFORMAT option can be used together. This examples shows A compile directive IDXFORMAT will override a file handler configuration file IDXFORMAT. An inline directive will affect all index files declared below it in the source file. Other coding techniques like copy with the replace statement and piped file input and output. OUTPUT from running doit.sh /home/tonyt/test/2831958idxformat . ./doit.sh java version "1.7.0_13" Java(TM) SE Runtime Environment (build 1.7.0_13-b20) Java HotSpot(TM) Server VM (build 23.7-b01, mixed mode) version @(#)cob.c 2.3.0.72 PRN=KXCRH/AAD:Ao.U4.13.04 PTI=32/64 bit PTI=Micro Focus Visual COBOL Development Hub 2.3 PTI=pkg_106718 PTI=MFInstaller PTI=ES PTI=SOA Configured I see no work (see `cob -?' for help) /home/tonyt/test/2831958idxformat/data001 does exsist removing files /home/tonyt/test/2831958idxformat/data002 does exsist removing files /home/tonyt/test/2831958idxformat/data003 does exsist removing files /home/tonyt/test/2831958idxformat/data004 does exsist removing files /home/tonyt/test/2831958idxformat/data005 does exsist removing files /home/tonyt/test/2831958idxformat/data006 does exsist removing files /home/tonyt/test/2831958idxformat/data007 does exsist removing files /home/tonyt/test/2831958idxformat/data008 does exsist removing files /home/tonyt/test/2831958idxformat/data009 does exsist removing files version @(#)cob.c 2.3.0.72 PRN=KXCRH/AAD:Ao.U4.13.04 PTI=32/64 bit PTI=Micro Focus Visual COBOL Development Hub 2.3 PTI=pkg_106718 PTI=MFInstaller PTI=ES PTI=SOA Configured cob64 -C nolist -xcVv -C list() showdir settings=col copyext(cbl,cpy,SL,FD,WS,DS) dg ans85 preprocess(window1) autoclose endp p(cp) endp execjobstepsub1.cbl * Micro Focus COBOL V2.3 revision 000 Compiler * Copyright (C) Micro Focus 1984-2015. All rights reserved. * Accepted - verbose * Accepted - nolist * Accepted - list() * Accepted - showdir * Accepted - settings(col) * Accepted - copyext(cbl,cpy,SL,FD,WS,DS) * Accepted - dg * Accepted - ans85 * Accepted - preprocess(window1) autoclose * Accepted - p(cp) * Compiling execjobstepsub1.cbl * Total Messages: 0 * Data: 8104 Code: 844 * Micro Focus COBOL Code Generator * Copyright (C) Micro Focus 1984-2015. All rights reserved. * Accepted - verbose * Generating execjobstepsub1 * Data: 7864 Code: 1314 Literals: 128 version @(#)cob.c 2.3.0.72 PRN=KXCRH/AAD:Ao.U4.13.04 PTI=32/64 bit PTI=Micro Focus Visual COBOL Development Hub 2.3 PTI=pkg_106718 PTI=MFInstaller PTI=ES PTI=SOA Configured cob64 -C nolist -xVv -C list() showdir settings=col copyext(cbl,cpy,SL,FD,WS,DS) dg ans85 idxformat(4) preprocess(window1) autoclose endp p(cp) endp execjobstep.cbl execjobstepsub1.o * Micro Focus COBOL V2.3 revision 000 Compiler * Copyright (C) Micro Focus 1984-2015. All rights reserved. * Accepted - verbose * Accepted - nolist * Accepted - list() * Accepted - showdir * Accepted - settings(col) * Accepted - copyext(cbl,cpy,SL,FD,WS,DS) * Accepted - dg * Accepted - ans85 * Accepted - idxformat(4) * Accepted - preprocess(window1) autoclose * Accepted - p(cp) * Compiling execjobstep.cbl * Total Messages: 0 * Data: 18448 Code: 2145 * Micro Focus COBOL Code Generator * Copyright (C) Micro Focus 1984-2015. All rights reserved. * Accepted - verbose * Generating execjobstep * Data: 18208 Code: 3061 Literals: 320 cob64: Entry points defined in module: execjobstep.o *EXECJOBSTEP execjobstep cob64: Entry points defined in module: execjobstepsub1.o EXECJOBSTEPSUB1 execjobstepsub1 execjobstep main Started execjobstepsub1 main Started rebuild $dd_idxfile001 -n | grep -E 'Format |File ' File : Format : IDX-4 rebuild $dd_idxfile002 -n | grep -E 'Format |File ' File : Format : IDX-4 rebuild $dd_idxfile003 -n | grep -E 'Format |File ' File : Format : IDX-8 rebuild $dd_idxfile004 -n | grep -E 'Format |File ' File : Format : IDX-8 rebuild $dd_idxfile005 -n | grep -E 'Format |File ' File : Format : IDX-3 rebuild $dd_idxfile006 -n | grep -E 'Format |File ' File : Format : IDX-3 rebuild $dd_idxfile007 -n | grep -E 'Format |File ' File : Format : IDX-4 rebuild $dd_idxfile008 -n | grep -E 'Format |File ' File : Format : C-ISAM recover1 $dd_idxfile009 junk.log -I -Y | grep Index Indexed File Recovery Utility Indexed File: /home/tonyt/test/2831958idxformat/data009/idxfile009 Number of Index Blocks: 8 Indexed File Recovery Utility Indexed File: /home/tonyt/test/2831958idxformat/data009/idxfile009 main press any key to return   Here is a doit.sh script that will create several files and will show what the IDXFORMAT of the files is set to. This demo is using Visual COBOL using a UNIX platform. To download the doit.sh script, click the link and save as doit.sh then Create a test directory. mkdir testit Cut and paste doit.sh script into this directory You need to change the doit.sh to have the location of your Cobol installation. Then execute the doit.sh script. . ./doit.sh doit.sh script # java -version # COBMODE=64 export COBMODE # vc setup #. /home/products/vcdevhub23_pkg106718/bin/cobsetenv # end vc setup # sx setup #COBDIR=/home/products/sx51ws6 #export COBDIR # #LD_LIBRARY_PATH=$COBDIR/lib:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH # #PATH=$COBDIR/bin:$PATH #export PATH # end sx setup cob -V # # Test IDXFORMAT directive scope # # clean up and create required files export BASE_PWD=$PWD # # create data directories or clean them out. # for i in {1..9} do export istr=$(printf "%03d" $i) if [ ! -d $BASE_PWD/data$istr ] then echo "$BASE_PWD/data$istr does not exsist creating" mkdir $BASE_PWD/data$istr else echo "$BASE_PWD/data$istr does exsist removing files" rm $BASE_PWD/data$istr/* fi export dd_idxfile$istr=$BASE_PWD/data$istr/idxfile$istr done # # execjobstep.cbl is compiled with idxformat it will overide the EXTFH file # execjobstepsub1.cbl is called by execjobstep.cbl and does not use idxformat # so should use the contents of the EXTFH file below. # cat myextfh.cfg EOF [XFH-DEFAULT] IDXFORMAT=1 INDEXCOUNT=32 STRIPSPACE=OFF RUNITLOCKDETECT=OFF [FOLDER:$BASE_PWD/data007] IDXFORMAT=4 [FOLDER:$BASE_PWD/data009] IDXFORMAT=21 EOF # export EXTFH=$BASE_PWD/myextfh.cfg # # lets create the source files # cat execjobstep.cbl EOF identification division. program-id. execjobstep. * * Test IDXFORMAT directive scope * environment division. configuration section. input-output section. file-control. select inputpipe assign to disk ws-inputpipe organization is line sequential file status is file-status. copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile001"== ==(idxfile)== by ==idxfile001==. copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile002"== ==(idxfile)== by ==idxfile002==. \$set idxformat"8" copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile003"== ==(idxfile)== by ==idxfile003==. copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile004"== ==(idxfile)== by ==idxfile004==. \$set idxformat"3" copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile005"== ==(idxfile)== by ==idxfile005==. copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile006"== ==(idxfile)== by ==idxfile006==. data division. file section. fd inputpipe record varying from 1 to 1024 characters depending on inputpipe-line-length. 01 inputpipe-rec pic x(1024). copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile001==. copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile002==. copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile003==. copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile004==. copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile005==. copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile006==. working-storage section. 01 inputpipe-line-length pic 9(4). copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile001== ==(idxfilelength)== by ==idxfile001==. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile002== ==(idxfilelength)== by ==idxfile002==. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile003== ==(idxfilelength)== by ==idxfile003==. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile004== ==(idxfilelength)== by ==idxfile004==. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile005== ==(idxfilelength)== by ==idxfile005==. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile006== ==(idxfilelength)== by ==idxfile006==. 01 ans pic x. 01 file-status. 03 status-key-1 pic x. 03 status-key-2 pic x. 01 abort-flag pic x value "N". 88 not-in-abort value "N". 88 in-abort value "Y". 01 ws-inputpipe pic x(1024) value spaces. 01 i pic 999. procedure division. declaratives. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile001"== ==(idxfile)== by ==idxfile001==. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile002"== ==(idxfile)== by ==idxfile002==. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile003"== ==(idxfile)== by ==idxfile003==. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile004"== ==(idxfile)== by ==idxfile004==. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile005"== ==(idxfile)== by ==idxfile005==. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile006"== ==(idxfile)== by ==idxfile006==. copy "common.DS". end declaratives. main section. main-010. display "execjobstep main Started " set not-in-abort to true open output idxfile001, idxfile002, idxfile003, idxfile004, idxfile005, idxfile006 close idxfile001, idxfile002, idxfile003, idxfile004, idxfile005, idxfile006 call "execjobstepsub1" perform varying i from 1 by 1 until i 9 if i = 9 * RM file number 9 see EXTFH file above * so use the recover1 utility move spaces to ws-inputpipe string " recover1 \$dd_idxfile", i, " junk.log -I -Y | grep Index" into ws-inputpipe else string " rebuild \$dd_idxfile", i, " -n | grep -E 'Format |File '" into ws-inputpipe end-if display ws-inputpipe(1:80) perform idxformat-disp end-perform display "main press any key to return" accept ans . main-090. goback. idxformat-disp section. idxformat-disp-010. open input inputpipe read inputpipe display inputpipe-rec(1:inputpipe-line-length) perform until file-status "00" read inputpipe display inputpipe-rec(1:inputpipe-line-length) end-perform close inputpipe . idxformat-disp-090. exit. end program execjobstep. EOF # # create a sub module not using IDXFORMAT # so this will use the EXTFH file defined above # cat execjobstepsub1.cbl EOF identification division. program-id. execjobstepsub1. * * Test EXTFH * environment division. configuration section. input-output section. file-control. copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile007"== ==(idxfile)== by ==idxfile007==. copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile008"== ==(idxfile)== by ==idxfile008==. copy "idxfile.SL" replacing =="(idxfile)"== by =="idxfile009"== ==(idxfile)== by ==idxfile009==. data division. file section. copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile007==. * using c-isam cant do varying record length, see idxfile.FD fd idxfile008. 01 idxfile008-rec. 03 idxfile008-primary-key. 05 idxfile008-sequence pic 9(9). 05 idxfile008-suffix pic 9. 03 filler pic x(1014). copy "idxfile.FD" replacing ==(idxfile)== by ==idxfile009==. working-storage section. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile007== ==(idxfilelength)== by ==idxfile007==. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile008== ==(idxfilelength)== by ==idxfile008==. copy "idxfile.WS" replacing ==(idxfile)== by ==ws-idxfile009== ==(idxfilelength)== by ==idxfile009==. 01 file-status. 03 status-key-1 pic x. 03 status-key-2 pic x. 01 abort-flag pic x value "N". 88 not-in-abort value "N". 88 in-abort value "Y". procedure division. declaratives. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile007"== ==(idxfile)== by ==idxfile007==. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile008"== ==(idxfile)== by ==idxfile008==. copy "idxfile.DS" replacing =="(idxfile)"== by =="idxfile009"== ==(idxfile)== by ==idxfile009==. copy "common.DS". end declaratives. main section. main-010. display "execjobstepsub1 main Started " set not-in-abort to true open output idxfile007, idxfile008, idxfile009 close idxfile007, idxfile008, idxfile009 . main-090. goback. end program execjobstepsub1. EOF # cat idxfile.WS EOF 01 (idxfilelength)-line-length pic 9(4). 01 (idxfile)-rec. 03 (idxfile)-primary-key. 05 (idxfile)-sequence pic 9(9). 05 (idxfile)-suffix pic 9. 03 filler pic x(1014). EOF # cat idxfile.SL EOF select optional (idxfile) * select (idxfile) assign to disk "(idxfile)" organization is indexed access is dynamic record key is (idxfile)-primary-key file status is file-status. EOF # cat idxfile.FD EOF fd (idxfile) record varying from 10 to 1024 characters depending on (idxfile)-line-length. 01 (idxfile)-rec. 03 (idxfile)-primary-key. 05 (idxfile)-sequence pic 9(9). 05 (idxfile)-suffix pic 9. 03 filler pic x(1014). EOF # cat idxfile.DS EOF decl(idxfile) section. use after standard error procedure on (idxfile). decl(idxfile)-010. display "decl", "(idxfile)", " declarative executing" perform check-file-status . decl(idxfile)-090. exit. EOF # cat common.DS EOF check-file-status. display "check-file-status file-status ", file-status, " " set in-abort to true . EOF # # compile the source files, just put some preprocessors here to show usage # cob -xcVv -C "list() showdir settings=col copyext(cbl,cpy,SL,FD,WS,DS) dg ans85 preprocess(window1) autoclose endp p(cp) endp" execjobstepsub1.cbl # cob -xVv -C "list() showdir settings=col copyext(cbl,cpy,SL,FD,WS,DS) dg ans85 idxformat(4) preprocess(window1) autoclose endp p(cp) endp" execjobstep.cbl execjobstepsub1.o # # lets run the test # ./execjobstep # # end #   Look at the listings after running to see the copy book statements working with the replace statements. Look at the EXTFH config file, to see how to make the C-ISAM file the default, as some old systems use this.

Viewing all articles
Browse latest Browse all 5819

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>