OK - It's happening early on, so I'm not going to upload the whole shebang. I've included some modified code to show what's going on.
I've added a routine to display the character count of an environment variable and display it.
To properly execute the bach file, a text file named varname.txt must already exist and I created it this way...
copy con varname.txt
set req_num=^Z (press ENTER)
The ^Z occurs when I press the F6 key. I then pressed ENTER to save the file. If you look at the start of the main batch file, I was going to include the code to delete varname.txt and recreate it by adding the following line...
echo set req_num=>varname.txt
I ended up remming it out because (and this may somehow tie into the issue) if I create it this way, when the main batch file builds the set_reqnum.cmd batch file, I end up with two lines like so...
C:\test>type set_reqnum.cmd
set req_num=
req00001
It should be: set req_num.cmd=req00001 (no space at the end

)
The character counting routine shows that %req_num% has a length of 8, which is correct if you enter req00001 (no space) as the input. Once the batch file is finished, if I call up req_var.txt into Notepad and hit the END key, the cursor is right next to the last character of the string - there is no space. So it does not appear to be occurring during when the following line is executed...
echo %req_num%>req_var.txt
I can't reconcile the fact that echoing to varname.txt (example above) seems to produce a carriage return, yet echoing %req_num%>req_var.txt does not... unless the character counting routine does not count carriage returns as a character. I frankly don't understand how the character counting routine does what it does.
Notice that in the main batch file I've added a line which calls the batch file that was built (named set_reqnum.cmd) and this line is remmed out initially.
rem call set_reqnum.cmd
If you remove the "rem" and save the batch file (I call it test.cmd) and then run it again, you will see the length of the string variable is now 9. So something seems to be happening when it builds set_reqnum.cmd
It's either then or during the echo %req_num%>req_var.txt
Anyway... I'm confused... maybe I should take up drinking...
By the way, thanks for everyones help!
@echo off
del req_var.txt >nul
del set_reqnum.cmd>nul
rem del varname.txt>nul
rem echo set req_num=>varname.txt
:start
cls
:get_req_num
set req_num=''
cls
echo Don't forget to create varname.txt before hand
echo copy con varname.txt
echo set req_num=
echo Then press F6 and the ENTER
echo.
echo Specify the Request ID Number as: req#####
echo.
set /p req_num=Please enter the Request ID:
if (%req_num%)==() goto get_req_num
echo.
echo You entered: %req_num%
echo.
echo %req_num%>req_var.txt
pause
copy varname.txt+req_var.txt set_reqnum.cmd>nul
rem Modified Routine to show the length of the string variable
rem Un-rem the next line to see the change in length of req_num
rem call set_reqnum.cmd
echo.
@echo off & setlocal enableextensions
set testString_=%req_num%
call :GetLength "%testString_%" length_
rem echo 123456789 123456789 123456789
echo.%testString_%
echo.
echo Length = %length_%
goto :EOF
endlocal & goto :EOF
::
::===============================================================
:: Subroutine: Return the length of a string
:GetLength string count
setlocal enableextensions enabledelayedexpansion
if "%~1"=="" (endlocal & set "%2=0" & goto :EOF)
set s=%~1
for /L %%c in (0,1,255) do (
set si=!s:~%%c,1!
if defined si set charCount=%%c
)
set /a charCount+=1
endlocal & set "%2=%charCount%" & goto :EOF