Transfer Object/library to other server using save file and SAVLIB command in AS400

How to Transfer Object/library to other server using save file and SAVLIB command

Use case:
1. In case we need to transfer program or physical file from UAT server to production server.
2. In case we need to transfer source physical file from UAT to production to compare code or to move code from UAT to production.
3. In case we need to transfer single member from source physical file to move to production and compile in production.
4. In case we need to transfer whole library having all type of objects, i.e. PGM, PF, LF, CMD etc.

Transfer of objects and libraries can be done from one server to other using SAVOBJ and SAVLIB command, to transfer a object we use SAVOBJ and to transfer library we use SAVLIB, but to avoid this ambiguity we can use SAVLIB command as simple approach to perform both operations. Many times developers finds it difficult which command and process to use to transfer objects and library from one server to another server.
Usually we get request to move source from UAT from one of the library to any specific library in production server, We can learn this following below steps:
To make it very simple and smooth process, we will suggest to create same libraries in UAT and production server and use those libraries every time, in case if user is transferring it for first time please avoid library creation steps.
Steps :
1. Please create libraries at UAT and production server, below is the command to create test libraries, we will copy all the objects which we need to transfer in this particular library and then transfer whole library there, Please type below command on command line and press F4. Please note that there is no need to create libraries every time, you can use existing libraries as well.

Please type the name of library which you want to create, take *TEST parameter value as library type, optional text as description, Press Enter.


You will get below successful message after library creation.

2. After creation of libraries at both the server please create a save file using SAVF command from command line on both servers, Please note that there is no need to create save file every time, you can use existing save file as well. Type SAVF and press F4 from command line.

Mention save file name under “Save File” parameter, we have taken ‘SAVF’ as save file name and mention library which we have created above ‘TFRSAVF’ as library parameter.

After successful creation of save file you will get below message:

3. Using WRKOBJPDM command you can check all the objects of the library, currently we have one object SAVF as save file in our library, Type WRKOBJPDM and press F4. Mention library name which we have created and press enter.

4. Please copy objects which you want to transfer to other server in TFRSAVF library however you want and options available at your end, we have used command CRTDUPOBJ or option ‘3’ from menu, in more simple terms use WRKOBJPDM or WRKOBJ command with library name from where you want to tranfer objects and from the list of available object simply use ‘3’ option and mention your save file library name ‘TFRSAVF’ as ‘To Library’ Parameter, We have copied TST file as sample. For transferring source physical simply copy your source physical file, for transferring a single program source, create a source physical file and copy member in this source physical file which is under ‘TFRSAVF’ library. In below sample we are transferring one source physical file name QLBLSRC having one member as program source code and one PF named ‘TST’.


5. Use SAVLIB command from command line to save library to save file first, Mention library name ‘TFRSAVF’ as Library parameter value , ‘*SAVF’ as Device parameter value, Press Enter, system will prompt for two more parameter, type ‘SAVF’ as Save file parameter value, ‘TFRSAVF’ as Save file library parameter value. Press Enter.
In case first time you are using SAVLIB command in created library then you will get below respose, else you will get below confirmation screen in case there is already data in SAVF, simple use option ‘G’ and press enter, you will get confirmation message on command line in both the cases.

6. Now go to destination server(production) and use FTP command to get/transfer the saved library from Source server (UAT).
Type FTP on command line and press F4, Mention server IP and press Enter (Source server from where we want to copy saved library, i.e. UAT server as per this example)

You will get below screen once you are in FTP mode, System will ask to enter USERID and PASSWORD, please enter your UAT user profile name and password to connect with Source server (UAT server), now use BIN and press enter to set binary image representation.

After this please use below command to get the library from source to destination server, it might take few seconds, depends on network and size of library, here GET is the FTP command, first TFRSAVF/SAVF denotes address of source server save file, second TFRSAVF/SAVF denotes address of destination server save file, here at both ends we have same name, ‘(R’ is to replace existing date if any at destination server.

After successful transfer use QUIT command and press enter.

7. Now we need to restore library from save file which we have transferred from source server to destination server, use command RSTLIB on command line and press F4, system will prompt value for ‘Saved Library’ and ‘Device’ parameter, type ‘TFRSAVF’ as saved library and ‘*SAVF’ as device parameter value, press enter and system will prompt to enter Save file name and save file library name, again type ‘SAVF’ as save file name and ‘TFRSAVF’ as save file library name, press enter, after successful operation you will get below message.

*Note : Kindly delete source physical file from destination server library before restoring the library using SAVLIB command, else system by default won’t replace source physical file and you will not be able to see the changes.

8. You can use WRKOBJPDM and WRKMBRPDM commands to check the restored objects from save file and can further copy or compare to your actual application source libraries.

Leave a Comment