× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: copy file member using SEPT calls
  • From: Leif Svalgaard <l.svalgaard@xxxxxxxxxxxxx>
  • Date: Tue, 22 Feb 2000 14:42:50 -0600

Another example (maybe a bit more easy to follow) of
how to use the low-level SEPT calls to do I/O.
The following (not so itty-bitty) program copies
a member of a file to another member of the file.
It is straightforward to extend it to use other files
in different libraries.

/* CALL THISPGM PARM(FROM-FILE FROM-MBR TO-MBR); */

DCL SPCPTR .PARM1 PARM;
    DCL DD PARM-FROM-FILE CHAR(10) BAS(.PARM1);

DCL SPCPTR .PARM2 PARM;
    DCL DD PARM-FROM-MBR  CHAR(10) BAS(.PARM2);

DCL SPCPTR .PARM3 PARM;
    DCL DD PARM-TO-MBR    CHAR(10) BAS(.PARM3);

DCL OL PARAMETERS(.PARM1, .PARM2, .PARM3) EXT PARM MIN(3);

ENTRY * (PARAMETERS) EXT;
    CPYBLAP    FROM-FILE-NAME, PARM-FROM-FILE, " ";
    CPYBLAP    FROM-MBR-NAME , PARM-FROM-MBR , " ";
    CPYBLAP    TO-MBR-NAME   , PARM-TO-MBR   , " ";

    CALLI      OPEN-FROM-MBR, *, .OPEN-FROM-MBR;
    CALLI      OPEN-TO-MBR  , *, .OPEN-TO-MBR;
COPY-NEXT-RECORD:
    CALLI      READ-FROM-RECORD, *, .READ-FROM-RECORD;
    CPYBLA     TO-DATA, FROM-DATA;
    CALLI      WRITE-TO-RECORD,  *, .WRITE-TO-RECORD;
    B          COPY-NEXT-RECORD;

END-OF-FILE:
    CALLI      CLOSE-FROM-MBR, *, .CLOSE-FROM-MBR;
    CALLI      CLOSE-TO-MBR,   *, .CLOSE-TO-MBR;
    RTX        *;

/************* COMMON FILE HANDLING ****************/

DCL SYSPTR .SEPT(6440) BAS(@SEPT);
DCL DD PCO CHAR(16) BASPCO;
   DCL SPCPTR @SEPT  DEF(PCO) POS( 1);

DCL CON CLOSE-ENTRY BIN(2) INIT(11);
DCL CON OPEN-ENTRY  BIN(2) INIT(12);
DCL CON *LIBL       BIN(2) INIT(-75);
DCL CON *FIRST      BIN(2) INIT(-71);
DCL CON LIB-ID      BIN(2) INIT(72);
DCL CON MBR-ID      BIN(2) INIT(73);
DCL SPCPTR .NULL;

DCL SPCPTR .ODP-ROOT;
DCL SPC     ODP-ROOT  BAS(.ODP-ROOT);
    DCL DD ODP-STATUS       CHAR(4)   DIR;
    DCL DD ODP-DEV-LENGTH   BIN(4)    DIR;
    DCL DD ODP-OPEN-SIZE    BIN(4)    DIR;
    DCL DD ODP.OPEN-FEEDBCK BIN(4)    DIR;
    DCL DD ODP.DEV-NAMELIST BIN(4)    DIR;
    DCL DD ODP....MORE....  CHAR(1)   DIR;

DCL SPCPTR .DEV-CONTROL-BLOCK;
DCL SPC     DEV-CONTROL-BLOCK  BAS(.DEV-CONTROL-BLOCK);
    DCL DD  DCB-MAX-NBR-OF-DEVICES   BIN( 2) DIR;
    DCL DD  DCB-DEVICES-IN-THE-ODP   BIN( 2) DIR;
    DCL DD  DCB-DEVICE-NAME         CHAR(10) DIR;
    DCL DD  DCB-OFFSET-TO-FM-WORK    BIN( 4) DIR;
    DCL DD  DCB-LENGTH-OF-FM-WORK    BIN( 4) DIR;
    DCL DD  DCB-INDEX-FOR-LUD-PTR    BIN( 2) DIR;
    DCL DD  DCB-GET                  BIN( 2) DIR;
    DCL DD  DCB-GET-BY-RRN           BIN( 2) DIR;
    DCL DD  DCB-GET-BY-KEY           BIN( 2) DIR;
    DCL DD  *                        BIN( 2) DIR;
    DCL DD  DCB-PUT                  BIN( 2) DIR;
    DCL DD  DCB-PUT-GET              BIN( 2) DIR;
    DCL DD  DCB-UPDATE               BIN( 2) DIR;
    DCL DD  DCB-DELETE               BIN( 2) DIR;
    DCL DD  DCB-FORCE-EOD            BIN( 2) DIR;
    DCL DD  DCB-FORCE-EOV            BIN( 2) DIR;
    DCL DD  *                        BIN( 2) DIR;
    DCL DD  *                        BIN( 2) DIR;
    DCL DD  DCB-FREE-REC-LOCK        BIN( 2) DIR;
    DCL DD  *                        BIN( 2) DIR;
    DCL DD  *                        BIN( 2) DIR;
    DCL DD  *                        BIN( 2) DIR;
    DCL DD  DCB-CLOSE                BIN( 2) DIR;
    DCL DD  DCB-OPEN                 BIN( 2) DIR;
    DCL DD  DCB-SPTB                 BIN( 2) DIR;

/************* INPUT FILE HANDLING ****************/

DCL DD FROM-FILE-NAME CHAR(10);
DCL DD FROM-MBR-NAME  CHAR(10);
DCL DD FROM-RECORD-LENGTH BIN(2) INIT(92);

DCL SPCPTR .IBUF;
DCL DD FROM-RECORD CHAR(92) BAS(.IBUF);
    DCL DD FROM-DATA CHAR(80) DEF(FROM-RECORD) POS(13);

/* INPUT FILE CONTROL BLOCK */
DCL SPCPTR .IFCB INIT(IFCB);
DCL DD      IFCB CHAR(214) BDRY(16);
    DCL SPCPTR .IFCB-ODP               DEF(IFCB) POS(  1);
    DCL SPCPTR .IFCB-INBUF             DEF(IFCB) POS( 17);
    DCL SPCPTR .IFCB-OUTBUF            DEF(IFCB) POS( 33);
    DCL SPCPTR .IFCB-OPEN-FEEDBACK     DEF(IFCB) POS( 49);
    DCL SPCPTR .IFCB-IO-FEEDBACK       DEF(IFCB) POS( 65);
    DCL SPCPTR .IFCB-NEXT-UFCB         DEF(IFCB) POS( 81);

    DCL DD *                  CHAR(32) DEF(IFCB) POS( 97);
    DCL DD IFCB-FILE          CHAR(10) DEF(IFCB) POS(129);
    DCL DD IFCB-LIB-ID        BIN(2)   DEF(IFCB) POS(139);
    DCL DD IFCB-LIBRARY       CHAR(10) DEF(IFCB) POS(141);
    DCL DD IFCB-MBR-ID        BIN(2)   DEF(IFCB) POS(151);
    DCL DD IFCB-MEMBER        CHAR(10) DEF(IFCB) POS(153);

    DCL DD IFCB-DEVICE-NAME   CHAR(10) DEF(IFCB) POS(163);
    DCL DD IFCB-DEVICE-INDEX  BIN(2)   DEF(IFCB) POS(173);

    DCL DD IFCB-FLAGS-1       CHAR(1)  DEF(IFCB) POS(175) INIT(X'80');
    DCL DD IFCB-FLAGS-2       CHAR(1)  DEF(IFCB) POS(176) INIT(X'20');

    DCL DD IFCB-REL-VERSION   CHAR(4)  DEF(IFCB) POS(177);
    DCL DD IFCB-INV-MK-COUNT  BIN (4)  DEF(IFCB) POS(181);
    DCL DD IFCB-MORE-FLAGS    CHAR(1)  DEF(IFCB) POS(185);
    DCL DD *                  CHAR(23) DEF(IFCB) POS(186);

    DCL DD IFCB-RECORD-ID     BIN (2)  DEF(IFCB) POS(209) INIT(1);
    DCL DD IFCB-RECORD-LENGTH BIN (2)  DEF(IFCB) POS(211);
    DCL DD IFCB-NO-MORE-PARMS BIN (2)  DEF(IFCB) POS(213) INIT(32767);

DCL OL  OPEN-I(.IFCB);
DCL OL CLOSE-I(.IFCB);

DCL SPCPTR .GET-PARM INIT(GET-PARM);
DCL DD      GET-PARM BIN(4) INIT(H'03000001');
DCL OL GET-I(.IFCB, .GET-PARM, .NULL);
DCL DD GET-ENTRY BIN(2);

DCL EXCM * EXCID(H'5001') BP(END-OF-FILE) CV("CPF") IMD;

DCL INSPTR .OPEN-FROM-MBR;
ENTRY       OPEN-FROM-MBR INT;
    CPYBWP    .NULL, *;    /* .NULL CANNOT BE INIT(*) */
    CPYNV      IFCB-LIB-ID,  *LIBL; /* DEFAULT */
    CPYBLAP    IFCB-LIBRARY,"*LIBL", " ";

    CPYNV      IFCB-RECORD-LENGTH, FROM-RECORD-LENGTH;
    CPYBLA     IFCB-FILE,   FROM-FILE-NAME;
    CPYNV      IFCB-MBR-ID, MBR-ID;
    CPYBLA     IFCB-MEMBER, FROM-MBR-NAME;

    CALLX     .SEPT(OPEN-ENTRY), OPEN-I, *;
    CPYBWP    .IBUF,     .IFCB-INBUF;
    CPYBWP    .ODP-ROOT, .IFCB-ODP;
    ADDSPP    .DEV-CONTROL-BLOCK, .ODP-ROOT, ODP.DEV-NAMELIST;
    CPYNV(B)   GET-ENTRY, DCB-GET/POS(.OPEN-FROM-MBR);

DCL INSPTR .READ-FROM-RECORD;
ENTRY       READ-FROM-RECORD INT;
    CALLX     .SEPT(GET-ENTRY), GET-I, *;
    B         .READ-FROM-RECORD;

DCL INSPTR .CLOSE-FROM-MBR;
ENTRY       CLOSE-FROM-MBR INT;
    CALLX     .SEPT(CLOSE-ENTRY), CLOSE-I, *;
    B         .CLOSE-FROM-MBR;

/************* OUTPUT FILE HANDLING ****************/

DCL DD TO-FILE-NAME CHAR(10);
DCL DD TO-MBR-NAME  CHAR(10);
DCL DD TO-RECORD-LENGTH BIN(2) INIT(92);

DCL SPCPTR .OBUF;
DCL DD TO-RECORD CHAR(92) BAS(.OBUF);
    DCL DD TO-DATA  CHAR(80) DEF(TO-RECORD) POS(13);

/* OUTPUT FILE CONTROL BLOCK */
DCL SPCPTR .OFCB INIT(OFCB);
DCL DD      OFCB CHAR(214) BDRY(16);
    DCL SPCPTR .OFCB-ODP               DEF(OFCB) POS(  1);
    DCL SPCPTR .OFCB-INBUF             DEF(OFCB) POS( 17);
    DCL SPCPTR .OFCB-OUTBUF            DEF(OFCB) POS( 33);
    DCL SPCPTR .OFCB-OPEN-FEEDBACK     DEF(OFCB) POS( 49);
    DCL SPCPTR .OFCB-IO-FEEDBACK       DEF(OFCB) POS( 65);
    DCL SPCPTR .OFCB-NEXT-UFCB         DEF(OFCB) POS( 81);

    DCL DD *                  CHAR(32) DEF(OFCB) POS( 97);
    DCL DD OFCB-FILE          CHAR(10) DEF(OFCB) POS(129);
    DCL DD OFCB-LIB-ID        BIN(2)   DEF(OFCB) POS(139);
    DCL DD OFCB-LIBRARY       CHAR(10) DEF(OFCB) POS(141);
    DCL DD OFCB-MBR-ID        BIN(2)   DEF(OFCB) POS(151);
    DCL DD OFCB-MEMBER        CHAR(10) DEF(OFCB) POS(153);

    DCL DD OFCB-DEVICE-NAME   CHAR(10) DEF(OFCB) POS(163);
    DCL DD OFCB-DEVICE-INDEX  BIN(2)   DEF(OFCB) POS(173);

    DCL DD OFCB-FLAGS-1       CHAR(1)  DEF(OFCB) POS(175) INIT(X'80');
    DCL DD OFCB-FLAGS-2       CHAR(1)  DEF(OFCB) POS(176) INIT(X'10');

    DCL DD OFCB-REL-VERSION   CHAR(4)  DEF(OFCB) POS(177);
    DCL DD OFCB-INV-MK-COUNT  BIN (4)  DEF(OFCB) POS(181);
    DCL DD OFCB-MORE-FLAGS    CHAR(1)  DEF(OFCB) POS(185);
    DCL DD *                  CHAR(23) DEF(OFCB) POS(186);

    DCL DD OFCB-RECORD-ID     BIN (2)  DEF(OFCB) POS(209) INIT(1);
    DCL DD OFCB-RECORD-LENGTH BIN (2)  DEF(OFCB) POS(211);
    DCL DD OFCB-NO-MORE-PARMS BIN (2)  DEF(OFCB) POS(213) INIT(32767);

DCL OL  OPEN-O(.OFCB);
DCL OL CLOSE-O(.OFCB);

DCL SPCPTR .PUT-PARM INIT(PUT-PARM);
DCL DD      PUT-PARM BIN(4) INIT(H'10000005');
DCL OL PUT-O(.OFCB, .PUT-PARM, .NULL);
DCL DD PUT-ENTRY BIN(2);

DCL INSPTR .OPEN-TO-MBR;
ENTRY       OPEN-TO-MBR INT;
    CPYBWP    .NULL, *;    /* .NULL CANNOT BE INIT(*) */
    CPYNV      OFCB-LIB-ID,  *LIBL; /* DEFAULT */
    CPYBLAP    OFCB-LIBRARY,"*LIBL", " ";

    CPYNV      OFCB-RECORD-LENGTH, TO-RECORD-LENGTH;
    CPYBLA     OFCB-FILE,   TO-FILE-NAME;
    CPYNV      OFCB-MBR-ID, MBR-ID;
    CPYBLA     OFCB-MEMBER, TO-MBR-NAME;

    CALLX     .SEPT(OPEN-ENTRY), OPEN-O, *;
    CPYBWP    .OBUF,     .OFCB-OUTBUF;
    CPYBWP    .ODP-ROOT, .OFCB-ODP;
    ADDSPP    .DEV-CONTROL-BLOCK, .ODP-ROOT, ODP.DEV-NAMELIST;
    CPYNV(B)   PUT-ENTRY, DCB-PUT/POS(.OPEN-TO-MBR);

DCL INSPTR .WRITE-TO-RECORD;
ENTRY       WRITE-TO-RECORD INT;
    CALLX     .SEPT(PUT-ENTRY), PUT-O, *;
    B         .WRITE-TO-RECORD;

DCL INSPTR .CLOSE-TO-MBR;
ENTRY       CLOSE-TO-MBR INT;
    CALLX     .SEPT(CLOSE-ENTRY), CLOSE-O, *;
    B         .CLOSE-TO-MBR;

PEND;
+---
| This is the MI Programmers Mailing List!
| To submit a new message, send your mail to MI400@midrange.com.
| To subscribe to this list send email to MI400-SUB@midrange.com.
| To unsubscribe from this list send email to MI400-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: dr2@cssas400.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.