RMcobol Extensions

RMcobol standard System Calls

These are available on virtualy all systems.

SYSTEM

RENAME

DELETE

RAND

SRAND

Roadtech extensions for use with Roadrunner

Available as a library module for RMcobol 7xx, or integrated with the runtime for RMcobol 6.xx

Roadtech RMcobol extensions {core}

These have generaly been ported to AIX 3.2.5, 4.1.x, 4.2.x, 4.3.x, SCO ?

GETENV

Returns the value of an environment variable. If the variable is undfined returned string will be spaces.
        03      ENV_NAME        pic X(n)
        03      ENV_VAL         pic X(n)

        call GETENV using ENV_NAME ENV_VAL

FTEST

Checks type ahead buffer to see if any keys have been pressed.

DELAY

Suspends process for a delay of WAIT seconds, or until and event occures.
        03      WAIT            pic 9(4) comp-1.

        call DELAY using WAIT.

UIDS

Returns the efective, real, saved and login UID's of the current process.
        03      UID_E           pic 9(4) comp-1.
        03      UID_R           pic 9(4) comp-1.
        03      UID_S           pic 9(4) comp-1.
        03      UID_L           pic 9(4) comp-1.

        Call UIDS using UID_E UID_R UID_S UID_L

UTOUCH

attempts to create the file "NAME". The file is created using the current REAL rather than the current EFECTIVE UID. This means that a user would still have access rights to this file after exiting from roadrunner. This is usefull for generating output files for use with other packages.
        03      NAME            pic X(n).
        03      ERR             pic 9(4) comp-1.

        call UTOUCH using NAME ERR.

ROWCOL

Prototype workround for bug in Version 6.00 beta runtime. To obtain new screen dimensions following a screen type switch {SET 132-COLUMNS to TRUE}, {SET 80-COLUMNS to TRUE}. Please call via RRSCRDIM.PRC, as it will then be easy to take account of any changes when Liant catch up with this bugget.
        03      M-ROW            pic 9(4) comp-1.
        03      M-COL            pic 9(4) comp-1.

        call ROWCOL using M-ROW, M-COL.

MDELAY

Suspends process for a delay of WAIT mili-seconds, or until and event occures. The higher the number the lower the priority.
        03      WAIT            pic 9(4) comp-1.
        call DELAY using WAIT.

GETPRI

Returns the current schedualing priority of the current process.
        03      PRI            pic 9(4) comp-1.
        call GETPRI using PRI.

SETPRI

Sets the current schedualing priority of the current process. Note you cannot increase your priority this way. Only select a new absolute value of lower or equal priority.
        03      PRI            pic 9(4) comp-1.
        call SETPRI using PRI.

NICE

Reduces the schedualing priority of the calling process by an amount "PRI".
        03      PRI            pic 9(4) comp-1.
        call NICE using PRI.

PUTENV

Adds a new entery to the environment, or replaces an existing entery.

Caution when replacing an entery the memory used for the previous entry is not reclaimed. Under no circumstances may programs make repeated changes to environment variables.

        call PUTENV    using ENV_NAME ENV_VALUE;
                ON EXCEPTION MOVE "PUTENV not supported" TO ENV-VAL.

PID

Returns the PID of the current process.

On AIX 3.1, 3.2, 4.1, 4.2 pid is a 32bit number. From AIX 4.3 onwards it may be a 64bit number depending on the setup.

        03      PID_VALUE            pic 9(18) comp-4.
        call PID    using PID_VALUE;
                ON EXCEPTION MOVE "PID not supported" TO ENV-VAL.

Roadtech RMcobol extentions {EDI}

These provide access from cobol to the EDI functions provided by
  • rredi
  • edid

They use the following variables for there calls.

        03   NAME                     pic X(256).

        03   TAG.
             05     TAG_Dataset       pic X.
             05     TAG_Company       pic X.

        03   EDI-LINE.
             05 line-type.
                 07 line-basetype       pic X(3).
                 07 line-subtype       pic X .
             05 line-ver               pic 9(2).
             05 line-data.
                 07     Filler          pic X(1018).

        03   FILE    pic X(256).

        03   HOST              PIC X(40).

        03      IP      pic X(15).

        03      ERR     pic 9(4) comp-1.
                88      NOFILE  value   100.
                88      NOHOST  value   200.
                88      NOIP    value   201.
                88      NOROUTE value   202.
                88      NOPORT    value   203.
                88      NOSOCKET  value   204.
                88      NOCONNECT value   205.
                88      NOPEER    value   206.
                88      EDI_WRITE value   207.
                88      TAGERR  value   300.

EDIGNFILE

Returns the name of the file where rredid is storing incoming messages and, trips a name change so that future messages are routed to a new file. MOVE "ZA" to tag MOVE 0 to ERR. MOVE SPACES to ENV-VAL. call EDIGNFILE using NAME TAG ERR; ON EXCEPTION MOVE "EDIGNFILE not supported" TO ENV-VAL.

EDIL2HOST

As per rredi but from cobol.
           Move "editest.roadrunner.uk.com" to HOST
           MOVE "ZA" to tag
           MOVE SPACES to  EDI-LINE.
           Move "TEST" to  line-type.
           Move 00 to  line-ver.
           Move "Test message" to  line-data.

           MOVE SPACES to ENV-VAL.
           MOVE 0 to ERR.

           CALL "EDIL2HOST" USING EDI-LINE, TAG, HOST, ERR;
                ON EXCEPTION MOVE "EDIL2HOST not supported" TO ENV-VAL.


EDIL2IP

As per rredi but from cobol.
        call EDIL2IP   using LINE TAG IP ERR;
                ON EXCEPTION MOVE "EDIL2IP not supported" TO ENV-VAL.

EDIF2HOST

As per rredi but from cobol.
        call EDIF2HOST using FILE TAG HOST ERR;
                ON EXCEPTION MOVE "EDIF2HOST not supported" TO ENV-VAL.

EDIF2IP

As per rredi but from cobol.
        call EDIF2IP   using FILE TAG IP ERR;
                ON EXCEPTION MOVE "EDIF2IP not supported" TO ENV-VAL.

File bits for paul

Example call arguments.

        03   PATH              PIC X(400).

        03   PERM           PIC 9(4) comp-1.

        03      ERR     pic 9(4) comp-1.
                88      NOFILE    value   100.
                88      NOHOST    value   200.
                88      NOIP      value   201.
                88      NOROUTE   value   202.
                88      NOPORT    value   203.
                88      NOSOCKET  value   204.
                88      NOCONNECT value   205.
                88      NOPEER    value   206.
                88      EDI_WRITE value   207.
                88      TCP_CLOSE value   208.
                88      EDI_READ  value   209.
                88      TIME_OUT  value   210.
                88      TAGERR    value   300.

	03   Buffer		PIC x(4000).

	03   size	pic 9(4) comp -1.

Call set works with a single connection. Close the connection before attempting to open another.

FileCreate

Creates and opens a file.

        move 0 to ERR.
        move "/var/www/pub/someware/pic.png" to PATH.
        move 0 to PERM.
	call FileCreate useing PATH, PERM, ERR;
                ON EXCEPTION MOVE "FileCreate not supported" TO ENV-VAL.

FileRead

Attempt to read block of bytes from link. Size is the amount we wish to read, it may not exceed the size of the call stucture.

size=0 implies read upto the size of the Buffer.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

On return size idecates the number of bytes actualy read.

	move 0 to ERR.
	call FileRead useing Buffer, ERR, size;       
                ON EXCEPTION MOVE "FileRead not supported" TO ENV-VAL.

	DISPLAY Buffer.

or alternatively

	move 30 to grace.
	move 0 to ERR.
	move 20 to size.
	call FileRead useing Buffer, ERR, size, grace;       
                ON EXCEPTION MOVE "FileRead not supported" TO ENV-VAL.

	DISPLAY Buffer.
This is not quite right if timer expires we may only have read a partial block.

FileReadln

Read bytes from link upto the next LF on the input streem, or upto the size of the buffer if no LF reached before buffer is full.
  • Time limit
  • Size of Structure provided
  • Line feed.
Return, Structure {space filled?}, bytes read, and status.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

	move 0 to ERR.
	call FileReadln useing Buffer, ERR;       
                ON EXCEPTION MOVE "FileReadln not supported" TO ENV-VAL.

	DISPLAY Buffer.

or alternatively

	move 30 to grace.
	move 0 to ERR.
	call FileReadln useing USER, ERR, grace;       
                ON EXCEPTION MOVE "FileReadln not supported" TO ENV-VAL.
	DISPLAY Buffer.

FileWrite

BlockWrite of a datastructure to the tcp link. When called Size should indecate how much of the structure is to be sent.

  • size <= 0, send whole structure.
  • size > structure size, send structure size bytes.
  • other wise, send size bytes.

On exit size is teh number of bytes actualy sent.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

	move 0 to ERR.
        move "What ever we like."to Buffer.
        move 18 to size. 
	call FileWrite useing Buffer, ERR, size;       
                ON EXCEPTION MOVE "FileWrite not supported" TO ENV-VAL.

or alternatively

	move 30 to grace.
	move 0 to ERR.
        move "What ever we like."to Buffer.
        move 18 to size. 
	call FileWrite useing Buffer, ERR, size, grace;       
                ON EXCEPTION MOVE "FileWrite not supported" TO ENV-VAL.
This is not quite right should be able to write a partial structure, and return the amount written.

FileWriteln

Writes a text variable or stucture to the socket appending a line feed.

If stucture contains a null this will terminate the line.

Trailing space is removed, remaining line is sent.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

	move 0 to ERR.
        move "What ever we like.         " to Buffer.
	call FileWriteln useing Buffer, ERR;       
                ON EXCEPTION MOVE "FileWriteln not supported" TO ENV-VAL.

or alternatively

	move 30 to grace.
	move 0 to ERR.
        move "What ever we like.         " to Buffer.
	call FileWriteln useing Buffer, ERR, grace;       
                ON EXCEPTION MOVE "FileWriteln not supported" TO ENV-VAL.

FileClose

Close's open tcp socket.

	move 0 to ERR.
	call FileClose using ERR;
                ON EXCEPTION MOVE "FileClose not supported" TO ENV-VAL.

TCP/IP bits for paul

Example call arguments.

        03   HOST              PIC X(40).

        03   SERVICE           PIC X(10).

        03      IP      pic X(15).

        03      ERR     pic 9(4) comp-1.
                88      NOFILE    value   100.
                88      NOHOST    value   200.
                88      NOIP      value   201.
                88      NOROUTE   value   202.
                88      NOPORT    value   203.
                88      NOSOCKET  value   204.
                88      NOCONNECT value   205.
                88      NOPEER    value   206.
                88      EDI_WRITE value   207.
                88      TCP_CLOSE value   208.
                88      EDI_READ  value   209.
                88      TIME_OUT  value   210.
                88      TAGERR    value   300.

	03   Buffer		PIC x(40).

	03   size	pic 9(4) comp -1.

Call set works with a single connection. Close the connection before attempting to open another.

TCPOPEN2HOST

Given a host name atempts to open connection to server.

        move 0 to ERR.
        move "pop3.roadrunner.uk.com" to HOST.
        move "pop3" to SERVICE.
	call TcpOpen2Host useing HOST, SERVICE, ERR;
                ON EXCEPTION MOVE "TcpOpen2Host not supported" TO ENV-VAL.

TcpRead

Attempt to read block of bytes from link. Size is the amount we wish to read, it may not exceed the size of the call stucture.

size=0 implies read upto the size of the Buffer.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

On return size idecates the number of bytes actualy read.

	move 0 to ERR.
	call TcpRead useing Buffer, ERR, size;       
                ON EXCEPTION MOVE "TcpRead not supported" TO ENV-VAL.

	DISPLAY Buffer.

or alternatively

	move 30 to grace.
	move 0 to ERR.
	move 20 to size.
	call TcpRead useing Buffer, ERR, size, grace;       
                ON EXCEPTION MOVE "TcpRead not supported" TO ENV-VAL.

	DISPLAY Buffer.
This is not quite right if timer expires we may only have read a partial block.

TcpReadln

Read bytes from link upto the next LF on the input streem, or upto the size of the buffer if no LF reached before buffer is full.
  • Time limit
  • Size of Structure provided
  • Line feed.
Return, Structure {space filled?}, bytes read, and status.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

	move 0 to ERR.
	call TcpReadln useing Buffer, ERR;       
                ON EXCEPTION MOVE "TcpReadln not supported" TO ENV-VAL.

	DISPLAY Buffer.

or alternatively

	move 30 to grace.
	move 0 to ERR.
	call TcpReadln useing USER, ERR, grace;       
                ON EXCEPTION MOVE "TcpReadln not supported" TO ENV-VAL.
	DISPLAY Buffer.

TcpWrite

BlockWrite of a datastructure to the tcp link. When called Size should indecate how much of the structure is to be sent.

  • size <= 0, send whole structure.
  • size > structure size, send structure size bytes.
  • other wise, send size bytes.

On exit size is teh number of bytes actualy sent.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

	move 0 to ERR.
        move "What ever we like."to Buffer.
        move 18 to size. 
	call TcpWrite useing Buffer, ERR, size;       
                ON EXCEPTION MOVE "TcpWrite not supported" TO ENV-VAL.

or alternatively

	move 30 to grace.
	move 0 to ERR.
        move "What ever we like."to Buffer.
        move 18 to size. 
	call TcpWrite useing Buffer, ERR, size, grace;       
                ON EXCEPTION MOVE "TcpWrite not supported" TO ENV-VAL.
This is not quite right should be able to write a partial structure, and return the amount written.

TcpWriteln

Writes a text variable or stucture to the socket appending a line feed.

If stucture contains a null this will terminate the line.

Trailing space is removed, remaining line is sent.

If specified grace is the maximum amount of time to block, if not specified a default value of 30 seconds is used..

	move 0 to ERR.
        move "What ever we like.         " to Buffer.
	call TcpWriteln useing Buffer, ERR;       
                ON EXCEPTION MOVE "TcpWriteln not supported" TO ENV-VAL.

or alternatively

	move 30 to grace.
	move 0 to ERR.
        move "What ever we like.         " to Buffer.
	call TcpWriteln useing Buffer, ERR, grace;       
                ON EXCEPTION MOVE "TcpWriteln not supported" TO ENV-VAL.

TcpClose

Close's open tcp socket.

	move 0 to ERR.
	call TcpClose using ERR;
                ON EXCEPTION MOVE "TcpClose not supported" TO ENV-VAL.

TCPOPEN2IP

HTTP

These HTTP methods provide a simplefied interface for opening, HTTP connections. One opened used the read, write, close calls to transfer the page.

	03 HTTP_version pic X(20).
        03 HTTP_status pic 9(4) comp-1.
        03 HTTP_server_message pic X(80).
	03 HTTP_realm  pic X(20).
	03 HTTP_userid pic X(10).
	03 HTTP_passwd pic X(10).
  • HTTP_version Version ID returned from the server.
  • HTTP_status Numeric status code from server.
  • HTTP_server_message Short message coresponding to status.
  • HTTP_realm Identifer returned when Basic Authentication is requiered.

HttpHead

HttpGet

Negoceate http get method with server.

Question what information if any from the servers headers do we want to return to the calling program.

        move "www.ooo.xxx" to host.
        move "faq/rmcalls.html" to url.
	move 0 to ERR.
	call HttpGet using host, url, ERR, user, passwd,
                HTTP_version,
                HTTP_status,
                HTTP_server_message;
                ON EXCEPTION MOVE "HttpGet not supported" TO ENV-VAL.

On exit ERR is non zero if a problem prevents the request from beeing made.

HTTP_version is inialized the to server ID string.

HTTP_Status is set to the server status for the request {200 successfull, 403 Access denied, ...}

HTTP_server_message is initalized to the status message from the server.

If successfull the datalink is initalized at the start of the content block. Successive calls to ______Read may be made to read the contents of the "file".

HttpPut

Put New or Replacement file to server.

HttpPost

?

HttpReadHeader

Read one line from the set of headers returned on the last Get, Head, ...
	move 0 to ERR.
	call HttpReadHeader using header, ERR;
                ON EXCEPTION MOVE "HttpReadHeader not supported" TO ENV-VAL.

Dangerouse goods functions for Patrick

This is a draft so do not take as gosple.

Draft routines are done as RMcobol 7.xx extension library.

All cobol calls are to start "DG_" so as to avoide clashes with outer modules.

READDGSHIPING

The user at Patrick's is expected to provide the base UN number, Each UN number can apply to more than one item, and form of packing.

Think of Parafin, it can be shipped as bulk liquid, 40Gal drums, or 4.5 liter plastic bottles in cardboard cartons.

So we need to read the shipping description database to identify the exact item and form of packing.

READDGSHIPING snag, call returns a linked list. we therefore need two calls 1> Call to initalize the list for a given unno 2> Call to read entery from list We can either return a count on the first call, or a flag indecating more to read on each subsequent call.


 03 unno pic S9(7) usage comp-4.  {NBS2 type 11}
 03 found pic A.        {ABS type 18 J-left}

 move 1203 to unno

 call DG_InitShippingList using unno, found.

 if found == 'N' Then display "unno not found in database"
 if found == 'Y' Then display "unno found in database"
 if found == 'E' Then display "Error accessing un database for unno"

 03 
   05 name pic X(60).   {ANS type 16 J-left, type 17 J-right}
   05 unsub pic X(4).
   05 ununique pic S9(7) usage comp-4. 

 03 more pic A.    {ABS type 18 J-left}

 call DG_ReadShippingList using name, unsub, ununique, more.

 if more == 'E' Then display "Error accessing database or attempt to read past end"

 display name
 display unsub
 display ununique

 if more == 'N' Then display "This is the last record"
 if more == 'Y' Then display "More records exist in the database"


ReadDGMaster

Once the user has identified the product and it packing we can read the master record for the identified

 03 
   05 unno pic S9(7) usage comp-4. 
   05 unsub pic X(4).
   05 ununique pic S9(7) usage comp-4. 

 03 dgdata
   05 shippingName pic X(60).
   05 class     pic X(4). 
   05 classColumn pic S9(7) usage comp-4.
   05 subrisk1  pic X(4).
   05 subrisk1Column pic S9(7) usage comp-4.
   05 subrisk2  pic X(4).
   05 subrisk2Column pic S9(7) usage comp-4.
   05 hazchen   pic X(5).
   05 hazchen   pic X(5).
   05 pkgrp1    pic X(3).
   05 pkgrp2    pic X(3).
   05 pkgrp3    pic X(3).
   05 epg       pic X(8).
   05 wmsgrp    pic X(2).
   05 printMsg	pic X(22).

 03 stat pic A. {ABS type 18 J-left}


  call DG_ReadMaster using unno unsub ununique shippingName class classColumn subrisk1 subrisk1Column subrisk2 subrisk2Column hazchen pkgrp1 pkgrp2 pkgrp3 epg wmsgrp printMsg stat

if stat == 'N' then display "Oops no record for that code"
if stat == 'Y' then display "Details for unique item found"
if stat == 'E' then display "Error accessing database."

*/ /* --------------------------------------------------------------------

DGcomp

We need an interface to call DGcomp to check Class compatibility.

For this we need to assemble an array of from 1 to 16 Class codes.

These are 4byte alphanumberic plus null termination, unused enteries are to be set to ????

17th entery is new class?

The function call returns a 4 character message code :-

                '0001' File access error
                '0010' Invalid Class code in position X1
                '0011' Incompatible Classes in position X1 and X2
                        may not be combined in a shipment
                '0012' No problems found but check on sub risks.
                '1001'-'1008' acknolageable problem.

        int index of first incompatible class code.
        int index of 2nd incompatible entery
        char ERRFLAG {' ', 'E'}

The example program at Patrick's, does not use the new class field.... It erases array to spaces, and then loads the supplied class codes into the class array.

The function is then called repetedly until it returns with ERRFLAG set to E or final is set to Y..... ?????

03 DG-CLassArray
  05 ClassCode pic X(4) occurs 16.

03 DG-StatusCode pic X(4).
03 DG-Index1 pic 9999 comp-1.
03 DG-Index2 pic 9999 comp-1.

call DG_compat_init using DG-CLassArray

call DG_compat_readMessage using DG-StatusCode,
			DG-Index1. DG-Index2, more.

Fatal :-
0001 Call support - Could not read Class table?\n
0010 printf("Class %4.4s is invalid\n", &classArray[err1No-1]);

Error :-
0011 printf("Class %4.4s and %4.4s are not compatible %4.4s\n", &classArray[err1No-1], &classArray[err2No-1], errorCode);

Warning :-
1001 printf("Class %4.4s and %4.4s - Check Note 1\n", &classArray[err1No-1], &classArray[err2No-1]);
1002 "
1003
..
1008
???? printf("Class %4.4s and %4.4s - unknown error 
%4.4s\n", &classArray[err1No-1], &classArray[err2No-1], &errorCode);
                                  printf("Call Support now\n");

??? :-
0012 printf("Compatible but check the sub risks\n");