OpenVMS Source Code Demos

WCSM_SUBMIT_TO_BATCH.FUN

	!+
	!0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
	!1         2         3         4         5         6         7         8         9         0         1         2         3
	!=========================================================================================================================
	! Title  : wcsm_submit_to_batch
	! Author : Neil Rieck
	! Created: 94.02.28
	! History:
	! ver who when   what
	! --- --- ------ ---------------------------------------------------------------------------------------------------------
	! 100 NSR 940228 1. original work
	!     NSR 940314 2. added EDIT$ to parameters
	!     NSR 940315 3. removed EDIT$ from parameters and now pass double quotes with xtra space
	!     NSR 940420 4. changed the map size from 40 to 15
	!     NSR 000502 5. added trace code to find a potential OpenVMS 7.2 problem					bf_trace
	!		 6. changed mapped string lengths from 255 to 80
	!		    (this will reduce the run-time memory requirements of this function by 2100 bytes)
	!     NSR 040528 7. changed mapped string lengths from 80 to 132 (we're on Alpha now so this is no big deal)
	!     NSR 061117 8. changed trace file directory from csmis$msg: to csmis$dat:
	!     NSR 070709 9. changed mapped string lengths from 132 to 255 (the 132-character limit was tuncating the
	!			mailing address list in EXPRESSVU PUBLIC VIEWING)
	!=========================================================================================================================
	!-
	function long wcsm_submit_to_batch( string	queue_name$	,&
							file_spec$	,&
							log_spec$	,&
							user_name$	,&
							p1$		,&
							p2$		,&
							p3$		,&
							p4$		,&
							p5$		,&
							p6$		,&
							p7$		,&
							p8$		)
	!
	option type=explicit							!
	!
    %if %Variant < 99% %then							! production
	%include "[.inc]VMS_Externals.inc"					! the name says it all
    %else									! development
	%include "[-.inc]VMS_Externals.inc"					! the name says it all
    %end %if
	!
	declare SysItems	SjcBuf(15)					! 0-15
	!
	declare IosbRec		SjcIosb						! our SndJbc iosb
	!
	map(wcsm_submit_to_batch_map)		 &
		string	queue_name	= 255	,&
			user_name	= 255	,&
			file_spec	= 255	,&
			log_spec	= 255	,&
			parameter_1	= 255	,&
			parameter_2	= 255	,&
			parameter_3	= 255	,&
			parameter_4	= 255	,&
			parameter_5	= 255	,&
			parameter_6	= 255	,&
			parameter_7	= 255	,&
			parameter_8	= 255	,&
			queue_name_copy	= 255	,&
		long	entry_num%		,&
			sys_rc%			,&
			i%
	!
	queue_name	= queue_name$						! xfer dynamic strings to fixed
	queue_name_copy	= queue_name$						!					bf_trace
	user_name	= user_name$						!
	file_spec	= file_spec$						!
	log_spec	= log_spec$						!
	!
	declare string constant dquote = '34'C					! double quote
	!
	! notes:
	! 1. we must quote the data so we can pass certain kinds of punctuation to the batch job
	! 2. when we pass a blank field DCL will dump the double quotes so we must always include a space
	!
	parameter_1	= dquote + p1$ + " " + dquote
	parameter_2	= dquote + p2$ + " " + dquote
	parameter_3	= dquote + p3$ + " " + dquote
	parameter_4	= dquote + p4$ + " " + dquote
	parameter_5	= dquote + p5$ + " " + dquote
	parameter_6	= dquote + p6$ + " " + dquote
	parameter_7	= dquote + p7$ + " " + dquote
	parameter_8	= dquote + p8$ + " " + dquote
	!
	SjcBuf( 0%)::BuffLen	= len( edit$(queue_name, 128%) )		! pass the desired queue name length
	SjcBuf( 0%)::ItemCode	= Sjc$_queue					!
	SjcBuf( 0%)::BuffAddr	= LOC( queue_name )				! pass the desired queue name address
	SjcBuf( 0%)::RtnLenAdr	= 0%						!
	!
	SjcBuf( 1%)::BuffLen	= len( edit$(file_spec, 128%) )			! pass the desired file name length
	SjcBuf( 1%)::ItemCode	= Sjc$_File_Specification			!
	SjcBuf( 1%)::BuffAddr	= LOC( file_spec )				! pass the desired file name address
	SjcBuf( 1%)::RtnLenAdr	= 0%						!
	!
	if len( edit$(log_spec,128%) ) <> 0% then				! if a log file was spec'd...
		SjcBuf( 2%)::BuffLen	= len( edit$(log_spec,128%) )		! log file name
		SjcBuf( 2%)::ItemCode	= Sjc$_Log_Specification		! log file
		SjcBuf( 2%)::BuffAddr	= LOC( log_spec )			!
		SjcBuf( 2%)::RtnLenAdr	= 0%					!
	else
		SjcBuf( 2%)::BuffLen	= 0%					!
		SjcBuf( 2%)::ItemCode	= Sjc$_No_Log_Specification		! NO log file
		SjcBuf( 2%)::BuffAddr	= 0%					!
		SjcBuf( 2%)::RtnLenAdr	= 0%					!
	end if
	!
	SjcBuf( 3%)::BuffLen	= 0%						! we do NOT want a printed log (ever)
	SjcBuf( 3%)::ItemCode	= sjc$_No_Log_Spool				!
	SjcBuf( 3%)::BuffAddr	= 0%						!
	SjcBuf( 3%)::RtnLenAdr	= 0%						!
	!
	SjcBuf( 4%)::BuffLen	= len( edit$(Parameter_1,128%)	)		!
	SjcBuf( 4%)::ItemCode	= sjc$_Parameter_1				!
	SjcBuf( 4%)::BuffAddr	= loc( Parameter_1 )				!
	SjcBuf( 4%)::RtnLenAdr	= 0%						!
	!
	SjcBuf( 5%)::BuffLen	= len( edit$(Parameter_2,128%) )		!
	SjcBuf( 5%)::ItemCode	= sjc$_Parameter_2				!
	SjcBuf( 5%)::BuffAddr	= loc( Parameter_2 )				!
	SjcBuf( 5%)::RtnLenAdr	= 0%						!
	!
	SjcBuf( 6%)::BuffLen	= len( edit$(Parameter_3,128%) )		!
	SjcBuf( 6%)::ItemCode	= sjc$_Parameter_3				!
	SjcBuf( 6%)::BuffAddr	= loc( Parameter_3 )				!
	SjcBuf( 6%)::RtnLenAdr	= 0%						!
	!
	SjcBuf( 7%)::BuffLen	= len( edit$(Parameter_4,128%) )		!
	SjcBuf( 7%)::ItemCode	= sjc$_Parameter_4				!
	SjcBuf( 7%)::BuffAddr	= loc( Parameter_4 )				!
	SjcBuf( 7%)::RtnLenAdr	= 0%						!
	!
	SjcBuf( 8%)::BuffLen	= len( edit$(Parameter_5,128%) )		!
	SjcBuf( 8%)::ItemCode	= sjc$_Parameter_5				!
	SjcBuf( 8%)::BuffAddr	= loc( Parameter_5 )				!
	SjcBuf( 8%)::RtnLenAdr	= 0%						!
	!
	SjcBuf( 9%)::BuffLen	= len( edit$(Parameter_6,128%) )		!
	SjcBuf( 9%)::ItemCode	= sjc$_Parameter_6				!
	SjcBuf( 9%)::BuffAddr	= loc( Parameter_6 )				!
	SjcBuf( 9%)::RtnLenAdr	= 0%						!
	!
	SjcBuf(10%)::BuffLen	= len( edit$(Parameter_7,128%) )		!
	SjcBuf(10%)::ItemCode	= sjc$_Parameter_7				!
	SjcBuf(10%)::BuffAddr	= loc( Parameter_7 )				!
	SjcBuf(10%)::RtnLenAdr	= 0%						!
	!
	SjcBuf(11%)::BuffLen	= len( edit$(Parameter_8,128%) )		!
	SjcBuf(11%)::ItemCode	= sjc$_Parameter_8				!
	SjcBuf(11%)::BuffAddr	= loc( Parameter_8 )				!
	SjcBuf(11%)::RtnLenAdr	= 0%						!
	i% = 11%								! i% now points to last used subscript
	!
	if len( edit$(user_name,128%) ) <> 0% then				! if a USER NAME was spec'd...
		i% = i% + 1%							! advance subscript
		SjcBuf( i%)::BuffLen	= len( edit$(user_name,128%) )		! length of username string
		SjcBuf( i%)::ItemCode	= Sjc$_Username				!
		SjcBuf( i%)::BuffAddr	= LOC( user_name )			! address of username string
		SjcBuf( i%)::RtnLenAdr	= 0%					!
	end if
	!
!~~~	i% = i% + 1%								x advance subscript
!~~~	SjcBuf( i%)::BuffLen	= 4%						x variable 'entry_num%' is 4 bytes (long)
!~~~	SjcBuf( i%)::ItemCode	= Sjc$_Entry_Number_Output			x we want the job entry number
!~~~	SjcBuf( i%)::BuffAddr	= LOC( entry_num% )				x pass the address of 'entry_num%'
!~~~	SjcBuf( i%)::RtnLenAdr	= 0%						x we don't care how many bytes were returned
	!
	i% = i% + 1%								! advance subscript
	SjcBuf( i%)::LIST_TERMINATOR	= 0%					! end of list...
	!
	sys_rc% = sys$sndjbcw(						,	! submit and WAIT				&
				sjc$_Enter_File				,	! function					&
				 					,	!						&
				SjcBuf()				,	!						&
				SjcIosb::quad_0				,	!						&
				 					,	!						&
				 					)
	!
	declare string junk$						!						bf_trace
	junk$ = ""							!						bf_trace
	if (sys_rc% and 1%) <> 1% then					! if an error during submit...
	    wcsm_submit_to_batch	= sys_rc%			! then pass back that RC
	    junk$ = "> trace 98-rc "+ str$(sys_rc%)	+"<>"+		!						bf_trace &
		queue_name$	+"<>"+	&
		file_spec$	+"<>"+	&
		log_spec$	+"<>"+	&
		user_name$	+"<->"+	&
		p1$		+"<>"+	&
		p2$		+"<>"+	&
		p3$		+"<>"+	&
		p4$		+"<>"+	&
		p5$		+"<>"+	&
		p6$		+"<>"+	&
		p7$		+"<>"+	&
		p8$
	else								! else submit was ok...
	    if (SjcIosb::job_status and 1%) <> 1% then			! so now test the job status
		wcsm_submit_to_batch	= SjcIosb::job_status		!
		junk$ = "> trace 99-js "+str$(SjcIosb::job_status)+">"+	!						bf_trace &
			queue_name$			+"<>"+		! view incoming variables				&
			file_spec$			+"<>"+		! ''							&
			log_spec$			+"<>"+		! ''							&
			user_name$			+"<->"+		! ''							&
			edit$(queue_name,128%)		+"<>"+		! view internal variables				&
			edit$(file_spec ,128%)		+"<>"+		! ''							&
			edit$(log_spec  ,128%)		+"<>"+		! ''							&
			edit$(user_name ,128%)		+"<->"+		! ''							&
			edit$(queue_name_copy,128%)	+"<"		! is the system call clobering the original?
	    else							!
		wcsm_submit_to_batch	= 1%				! VMS success (-s-)
	    end if							!
	end if								!
	!
	if junk$ <> "" then						! could this be an OpenVMS-7.2 problem ?	bf_trace
	    when error in						!
		open "csmis$dat:zzz_neil_submit_trace.txt" as #109, access append, allow modify
		margin #109, 130					!
		print #109, "wcsm_submit_to_batch: ";junk$		!
	    use								!
	    end when							!
	    close #109							!
	end if								!
	!
	end function							!

Back to Home
Neil Rieck
Waterloo, Ontario, Canada.