SARSAM

The SARSAM routine provides an alternate, centralized method for calling the subroutines supported by the SARSAM access method. The SARSAM routine itself simply invokes the appropriate subroutine.
view
The SARSAM routine provides an alternate, centralized method for calling the subroutines supported by the SARSAM access method. The SARSAM routine itself simply invokes the appropriate subroutine.
Calling Parameters
Address of request type:
  • SAMOPEN - Open database
  • SAMCLOSE - Close database
  • SAMGET - Get index record
  • SAMINVL- Invalidate buffers
  • SAMMSG - Return error message
  • SAMSOPN - Open subfile
  • SAMSGET - Get subfile record
  • SAMSCLS - Close subfile
  • SAMAOPN - Open auxiliary subfile
  • SAMAGET - Get auxiliary subfile record
  • SAMACLS - Close auxiliary subfile
  • SAMDFMT - Format date
  • SAMTFMT - Format time
The parameter list consists of the address of the request type followed by the parameters required by the routine. As an example, SAMOPEN supports two calling parameters: the address of a 17-byte database identifier, and the address of an OPEN type. These two calling parameter addresses must follow the address of the character string SAMOPEN.
Return Codes
Output return codes are dependent on the routine being requested.
For more information about return codes, see the appropriate routine.
Calling Example: Assembler
The following is an example using assembler:
. . . CALL SARSAM,(OPENREQ,DATABASE),VL OPEN DATABASE LTR R15,R15 CHECK RETURN CODE BN2 ERROR . . . MVC GREC(16),=CL16'' BEGIN WITH FIRST GCR * GET NEXT RECORD GETREC CALL SARSAM,(GETREQ,GREC,GRECL,GTYPE,GRETL),VL CH R15,=H'4' BE EOF BH ERROR . . Process GCR record . B GETREC ERROR CALL SARSAM,(MSGREQ,MSG,MSGL),VL GET MESSAGE . . PRINT ERROR MESSAGE . EOF CALL SARSAM,(CLOSEREQ),VL CLOSE DATABASE . . Terminate Processing . OPENREQ DC C'SAMOPEN' OPEN REQUEST ROUTINE NAME GETREQ DC C'SAMGET' GET REQUEST ROUTINE NAME MSGREQ DC C'SAMMSG' MESSAGE REQUEST ROUTINE NAME CLOSEREQ DC C'SAMCLOSE' CLOSE REQUEST ROUTINE NAME DATABASE DC CL17'VIEW.SYSTEM1' DATABASE NAME GREC DS CL(GCRLEN) STORAGE FOR GCR GRECL DC Y(GCRLEN) LENGTH OF GCR GRETL DS H RETURN LENGTH OF GCR GTYPE DC C'GT' GET GREATER THAN MSG DS CL100 MESSAGE AREA MSGL DC H'100' LENGTH OF MESSAGE AREA
Calling Example: COBOL
The following is an example using COBOL:
. . . 77 RTNCODE PIC S9(8) COMP. 77 OPENREC PIC X(7) VALUE 'SAMOPEN'. 77 GETREQ PIC X(6) VALUE 'SAMGET'. 77 MSGREQ PIC X(6) VALUE 'SAMMSG'. 77 CLOSEREQ PIC X(8) VALUE 'SAMCLOSE'. 77 DATABASE PIC X(17) VALUE 'VIEW.SYSTEM1'. 77 GRECL PIC S9(4) VALUE +248. 77 GRETL PIC S9(4) COMP. 77 GTYPE PIC X(2) VALUE 'GT'. 77 MSG PIC X(100) VALUE SPACES. 77 MSGL PIC S9(4) COMP VALUE +100. 01 GREC. 05 GREC-KEY PIC X(16). 05 GREC-DATA PIC X(232). . . . CALL 'SARSAM' USING OPENREQ, DATABASE. MOVE RETURN-CODE TO RTNCODE. IF RTNCODE NOT = 0 GO TO ERROR. . . . MOVE SPACE TO GREC-KEY. GETREC. CALL 'SARSAM' USING GETREQ, GREC, GRECL, GTYPE, GRETL. MOVE RETURN-CODE TO RTNCODE. IF RTNCODE > 4 GO TO ERROR. IF RTNCODE = 4 GO TO EOF. . . Process GCR record . GO TO GETREC. GETREC. CALL 'SARSAM' USING MSGREQ, MSG, MSGL. . . Print Message . EOF. CALL 'SARSAM' USING CLOSEREQ. . . Final Processing . STOP RUN.