Saturday, July 22, 2017

Backup your AS400 SAVF in your PC

Hello Friends,

Taking backup is one of the most important thing in project life cycle. When it comes to AS400 we do save our program & data objects into TAPE using SAVOBJBRM commands. But we can also take a copy of our works (program & data objects) and save it in SAVF. And this SAVF can be transferred into your desktop.

This could be useful if you want to transfer any objects from one AS400 to another AS400 but both are not talking to each other. (If both servers are in same network then we can just copy the data using any ways like DDMF or SNDNETF or FTP)

Downloading your SAVF into your PC:

Step 1: Save your objects into SAVF

We are creating a SAVF called BKUP and saving object TESTDATA inside the SAVF

Now before we look on how to transfer this to your desktop, we need understand the IFS representation of an object in AS400.

Now our SAVF object DEVYUS1/BKUP can be viewed/identified as IFS path using below command


In similar fashion we can see all our PF, Programs and other objects. This is important because using this we are going to FTP our BKUP.FILE into our desktop.

Step 2: Download BKUP SAVF into our desktop

When we login the current IFS directory is our home directory (/Home/DEVYUS) then we change that using Change Directory (CD) command as /QSYS.LIB/DEVYUS1.LIB

Then we change our desktop local directory (whatever you wish)

Then we choose BIN (Binary) mode to receive the file (SAVF can be transferred using BIN mode)

Then just GET command will receive the file and store it in your local directory

How to upload the file again to AS400:

Again it is quite simple and instead of GET we need to use PUT command to upload the file. But before that we need to create the SAVF in AS400 server manually.

Let us try to upload this SAVF in another library DEVYUS2

Step 1: Create SAVF


Step 2: Upload using FTP

First we change our Current Directory of AS400 to “/QSYS.LIB/DEVYUS2.LIB”

Then we change our local directory of our desktop

Then changing the transfer mode to BIN (Binary)

Then using PUT command we transfer file back to AS400

So that’s it, hope you got the idea of how to send/receive SAVF from/to your IBM I server.

Have Fun…!!! Happy Coding…!!!

Friday, July 21, 2017

Common Compilation Errors in RPGLE

Hello Friends,

Today we are going to see some of the common errors we come across while compiling the RPGLE code. If you are beginner then this post could be useful if you come across these error messages in your future.

It always give happiness when you compile you code with error code 0 on first time J

Sample code with Error:

Order file:


Basically this program gets Ord_No & Cust_No as input and checks if the order is available in ORDER file. If available then it prints the Order quantity else it writes new record for the customer and order number with other fields (Name & quantity) as default.

After compiling this below is the list of errors:

Let us go one by one and fix it.

RNF7030 à ORD_QTY is not defined

The intention of this line is to display order quantity from file but variable used is Ord_Qty but file contains field as ORDQTY. So compiler is not able to recognize Ord_Qty. Thus we need to remove this underscore

Eval      Msg = 'Order is available '+
                'Qty : ' + Ord_Qty    

RNF7055 à Factor 1 ORD_KEY is not valid for the specified operation.

Ord_Key       Chain     Order

Here we are trying to do chain operation on the file Order but the file specification is not having record access as Key (‘K’)

FOrder     IF   E             Disk  à This should be changed as below
FOrder     IF   E           K Disk

RNF7016 à Display length 100 greater than maximum allowed of 52;

This is because we are trying to display Msg variable using DSPLY function. But the Max length that could be displayed is 52. But Msg variable is having length 100. We need to change this to Max 52.

RNF7416 à The types of the right and left hand side do not match in EVAL operation.

This is most common error you might have already seen it.

Eval      OrdName  = Ord_No     // we are trying to eval char variable with numeric

RNF5196 à File in Factor 2 does not have allowed file type for WRITE

When we need to add new records, the file specification should be defined with File Addition = ‘A’

FOrder     IF A E           K Disk 

Ok now let us quickly make the changes and compile again. 

Now we eliminated all previous errors and ended with new 2 errors. Let us fix these.

RNF7073 à KFLD at sequence number 18 is 4 long. Key field is 5 long.

This is because, our key Ord_Key is formed using Ord_No & Cust_No variables with 4 and 10 length. But the actual files key is ORDNO (5 length) and CUSNO (10 length).

So to fix this, either we can change length of Ord_No from 4 to 5, else we can use Like keyword during 
declaration to ask program to refer data type directly from PF.

RNF7421 à Operands are not compatible with the type of operator.

This is because we are trying to concatenate string and OrdQty in Msg variable. But OrdQty is numeric and thus we need to convert it to %Char before concatenate

So the final code is here.

These are very basic errors and there are more to come when you use Copy book and Procedures and introduce other ILE concepts.

I will try to cover few more in my future posts until then

Have fun..!!! Happy coding..!!!