declare

IBM i, AS400 Tutorial, iSeries, System i - Flat File Processing in RPG program - Create Flat Files



Sharing buttons:

welcome to this channel I'm Emma classes

today in this video we're going to tell

you how we can process a flat file how

we can create a flat file what is flat

file and how it is should so they start

and responded RPG actually so the start

first create a flat file so we'll be

creating a flat fighting this command

create if so take a poll here suppose I

have taken a name of flat file s flat 5

1 in every I have in my class 1 now what

is the important thing here is in this

case we don't have the Judea source so

we're not going to provide any I hear so

sky layer also supply being here so what

I do we need to provide the record

length if no duteous case there is no

DIDS file source file and we need to

provide a record and suppose I will be

giving here India to Gordon so I am

creating a file named flat file 1 which

is a flat file action which is having no

radius and having a record length of 100

ok so I'm pressing it and pressing enter

here so 5 that 5 1 Peter in Liberia in

my plasma work object IPMI class 1 /

flat 5 1 okay so what is the difference

between a flat file it have to give is

that the flat file has the record format

of the flat file is same with the flat

file that file and the field name is

also same with that record format name

and the file so indirectly we can say or

Die T we can say that PI rename record

format name and the female is saying in

case of flat file but this is not in

case of a PF so when you create a PF we

hat we have the filing the fielding the

record format name I defend so gypsy I

like to start wrong IPMI + 1 / flat 5 1

so this is the flat file when viewed

here whose length is hundred characters

there is no data right now let's insult

this is the test data the speed is only

two I'm going to add one flat file

values so this is at any time now we

have inserted two reports here we'll see

these are the two recalls each gets

inserted come out of this tsk now we'll

see DSP of the information flat find one

come to bottom we can see that the

record format flat is flat five and so

we can say that the plat the file name

and the record format theme seem right

you know so now we'll see that we will

name the spec 50 black 5 1 3 down so the

field name is also flat for you in so

the file name record format me and the

filly named are same in case of flat

file so we have inserted to record so

let's stop them we have already created

one example so first of all will show

your own example that how we can not

process a flat file what are the main

points which needs to be considered

while processing a flat file you know

RPG program so I show you the wrong

example first so this is a example which

will not come pie actually this is

source code which will not compile I

have declared here the flat file

input mode you can see that the input

mode we have declared the flag file okay

this file will not have any key so I

have not written K here

so now we have declared a variable local

variable whose length is also hundred

characters so now I have read the file

from star start now first record flat 5

1 settle on that file and read that file

then check the condition till not

personal at a file using it this file ok

and loop the value now we have evaluated

at flat file 1 we read into this local

variable then at last we have said that

last according the data and large so now

if we are going to create the program

for this let us compile this using

option 14 yeah so we'll be getting that

compilation error compilation stop

severity 40 added found in the program

let's do the job

so do work job here and for then P is on

on you can actually take chapter six

here did five on the last one right now

we can come to bottom by taking taken be

in the center you know so we can see

them Co 80-48 found in the program so P

job here so what are those errors those

errors are first error is all record

formats for externally described filing

or dropped it to the end so what I have

all what i what i should do there we

need to rename the recall format need

okay so for removing this error we need

to rename that record format knee and

other thing is this one expression

contains you know print that is not

defined so that for feeling that flat

five one is not defined here so we need

to be perfect that you name either so we

need to rename the evening and also the

record format name so then only we will

be able to create the program for this

example so let's come up Oh what we can

do there you can do really don't see

that example there that correct what we

will do you take a foot here and add it

more now the first thing we'll do we'll

rename that record format name flat file

one two flat file one at the rate okay

now combine here this file this tape is

a compiled here take option 14 now that

forty error has been gone now to a t-38

only left do work jobs and

over than shift of six come to bottom

but I can be press ENTER then we joke

so we can see that the left types of the

right the type of the right hand left

hand side do not match in they were

operation so cannot define name as a

field since it has already defined the

specification is ignored so now we need

to rename that 11 then we'll be able to

remove this arrow so in that incorrect

example come out once and let you know

please know that this was the correct

example and this was wrong example so I

have corrected I have renamed the record

format and I mean the fuel-air not not

in this example so that's that's why I

was calling this as a wrong example I am

correcting this wrong example right now

which will be the are replica flat fight

we Jim to seem a flat fine medium so I

allude here think I hear enough respects

you know when I will rename that

[Music]

prefects okay so I'll fix it with tea so

now what will happen here wave comes

back T so T fell flat five one so you

have been chained now no file this now

compile this a captain please down

because it with the star source so that

we can debug this program now program

this plays in I agree this so this

program have been compiled you can see

this one has been so this was the same

program which was corrected on here but

I have shown you that incorrect why we

have corrected the errors in the

incorrect program while recompiling them

again in a game so by this you will get

to the errors which come if we are not

renaming the record formats or if you

are not even in the P which is the clay

which is there in the flat file we are

not going to given definition for a for

a flat file thing so that was one thing

so now let's say debug this program is

to your DVD gratified to PG o flat by 2

P geom star us use IBM I class

okay the rain was our core correct fi 2

P Geum enter in and the pic point is at

line one

now call this program flat f i2 p Geum

no percept in here so the record will be

fine find the record has been found here

this is the test data that was the first

Accord which has been no evaluated to a

local variable this is the test data the

textual here then obtained game so again

this is fine sitting recorder safe 11

this is the second dieter okay which has

been evaluated to local variable no

there will be no more recalls there in

the file flat file so it will come out

of loop automatically in the third eye

attrition no the last according

indicator has been set to on state the

program will end so we have seen that

how we can process a flat file how to

create a plan fine actually

we don't need to give the definition in

the flat file and the file name the

record format name and fuse name is

seeming case of flat file which is

different form of PF but black eye is up

to you is a physical file it's just

having no DDS which is having no field

definition just having the same regard

format name the same field in the same

file name but you need to provide a

requirement for that and when we are

using that to that file we are

processing that flat file in my PG

program we need to we need to remove the

required format name there if we all

know we are not renaming those then we

are getting the security 40 error that

all the record formats and programs are

good ok and if we are not renaming the

field name by using prefix keyword so

if you are not doing this has this this

has when we are getting the severity

Tierra that this field is not defined so

we need to read prefix that field as

well so once we are renaming that record

format prefix of that field of the flat

file we are able to compile our program

we are able to run our program so we

have learned in this video that how we

can process a flat file so in / PG

program so this was a very basic example

which I have shown you what we can do we

can take a flat file we can take a flat

file of any record length okay we can

take a flat file of say 50 record length

and we have saved those on first ten

places we have saved the library name on

the second ten places we have saved file

on the third places we have saved the

type of the object and and so on so if

you want to take those into the data's

chain over program so we can cook like

that we can code we can take that

variable value add that variable to a

dataset chip which are based on these

five feeds in first 10 position then

second 10 to 20 position then 30 and 32

based on your requirements so we we have

learned the basics of the flag file that

how we can process them so this is all

in this video so thank you for watching

my video please don't forget to

subscribe my channel and also press the

bell button so that you can get all my

we using future that I will be uploading

in my channel thank you and have a nice

time