Differenciate between Prod and Test

Is there some command to see whether I am running in Test or in Prod? We need to put different FTP parameters into the FTP controlcards depending which environment the program is running from.

Thank You!!!

You can use USR0010N to determine which environment you are using. Here is a sample of how to tell:

0170 DEFINE DATA                                               
0180 PARAMETER                                                 
0190 1 #PDA-DBIDNAME        (A12)                              
0200 1 #PDA-DBID            (N3)                               
0210 LOCAL                                                     
0220 1 USR0010L                                                
0230   2 OUTPUTS                                               
0240     3 FILENAME       (A12/1:50)    /* System File Name    
0250     3 DBID           (P03/1:50)    /* DBID                
0260     3 FNR            (P03/1:50)    /* File Number         
0270     3 DBNAME         (A07/1:50)    /* DB Type             
0280     3 AMOUNT         (P04)         /* Number of Entries   
0290 **                                                        
0300 1 #CT                (P5)                                 
0310 END-DEFINE                                                
0320 **********************************************************
0330 CALLNAT 'USR0010N' USR0010L                               
0340 FOR #CT = 1 TO AMOUNT                                     
0350   IF FILENAME (#CT) = 'FNAT'                              
0360     MOVE DBID (#CT) TO #PDA-DBID                          
0370     ESCAPE BOTTOM                                                 
0380   END-IF                                                          
0390 END-FOR                                                           
0400 **                                                                
0410 DECIDE ON FIRST VALUE OF #PDA-DBID                                
0420   VALUE 010  MOVE 'DEVELOPMENT' TO #PDA-DBIDNAME /* Global Vista  
0430   VALUE 030  MOVE 'Q/A        ' TO #PDA-DBIDNAME /* Global Vista  
0440   VALUE 050  MOVE 'TRAINING   ' TO #PDA-DBIDNAME /* Global Vista  
0450   VALUE 070  MOVE 'PRODUCTION ' TO #PDA-DBIDNAME /* Global Vista  
0460   VALUE 100  MOVE 'DEVELOPMENT' TO #PDA-DBIDNAME                  
0470   VALUE 110  MOVE 'Q/A-Q      ' TO #PDA-DBIDNAME                  
0480   VALUE 111  MOVE 'Q/A-R      ' TO #PDA-DBIDNAME                  
0490   VALUE 112  MOVE 'SIT        ' TO #PDA-DBIDNAME                  
0500   VALUE 115  MOVE 'ADAJOE     ' TO #PDA-DBIDNAME                  
0510   VALUE 120  MOVE 'PRODUCTION ' TO #PDA-DBIDNAME                  
0520   VALUE 125  MOVE 'DWD        ' TO #PDA-DBIDNAME                  
0530   VALUE 130  MOVE 'BLUE       ' TO #PDA-DBIDNAME                  
0540   VALUE 135  MOVE 'DWP        ' TO #PDA-DBIDNAME                  
0550   VALUE 140  MOVE 'TRAINING   ' TO #PDA-DBIDNAME                  
0560   VALUE 200  MOVE 'DEVELOPMENT' TO #PDA-DBIDNAME                  
0570   VALUE 210  MOVE 'Q/A-Q      ' TO #PDA-DBIDNAME             
0580   VALUE 211  MOVE 'Q/A-R      ' TO #PDA-DBIDNAME             
0590   VALUE 212  MOVE 'SIT        ' TO #PDA-DBIDNAME             
0600   VALUE 220  MOVE 'PRODUCTION ' TO #PDA-DBIDNAME             
0610   VALUE 240  MOVE 'TRAINING   ' TO #PDA-DBIDNAME             
0630 END-DECIDE                                                   
0640 *                                                            
0650 END   

You will need to customize for your purposes, but using the DBID associated with the location of the FNAT works for us as each environment has its own FNAT.



Thank you for the quick reply.
I tried to run your exact code.
First of all it doesn’t recognize the word PARAMETER so I just used Local for everything.
Second of all I don’t know where program USR0010N would be. In any case it’s not in my library and I wouldn’t know how to link to it.
Thank you again,


Regarding not recognizing DEFINE DATA PARAMETER, the sample was a subprogram (use SET TYPE N in your editor command line to ensure you save this as a subprogram) that accepts two parameters that this will pass back to the calling program, environment name and dbid where the FNAT resides. Making this a subprogram will allow this module to be called from any program in your environment that needs this functionality, which also leads to the suggestion that you put this subprogram in an application steplib (e.g., SYSTEM on FUSER or any others your DBA set up in your shop for such purposes). You will also need to modify lines 420-610 to customize for your environment (may need to have the DBA provide this for you as I have the impression you are a programmer).

As for finding USR0010N (or any USR* routine), these are supplied in SYSEXT library (in FNAT). Your DBA should copy USR0010N (or all USR* routines preferably) to SYSTEM (on FUSER) or some other steplib or make SYSEXT (in FNAT) a steplib to all your application libraries (in FUSER).

Hope this helps!


I have checked all the system functions before I asked this question. I don’t see any for DBIDNAME and DBID.
I have not done anything involving the system or the environment before.

Hi Carol,

Yeah, that’s why this routine is your best bet. It will return what your Natural environment is configured with as defined by parameter settings. In our shop we have unique FNATs for each environment but sometimes share FUSERs so we look for the setting on the FNAT to pull the associated dbid, from which we infer what the environment is.

I recommend you print out this discussion thread and meet with your DBA to see if the same thing holds true in your shop and to get a list of all your environments with associated FNAT dbids.

Development dbid 10
QA dbid 20

Such a list will allow you to make the needed changes in lines 420-610.

If it turns out you share FNATs but perhaps FUSER is unique, you will have to change the condition on line 350 accordingly.

Your DBA will also need to take some action as previously described to make USR0010N available to you, and then you can place a customized version of this subprogram in your application steplib.

Best of luck!