Saturday, June 29, 2013

A Display File in CL program.

Using A Display File in CL program.
I just designed one screen which has one input capable field while rest is screen constant .
Have a look at below screenshot:


So this screen has one input where you can enter any of the option.
Let us discuss how this is being called with in a CL program.
In this program we do not need to define opt variable as it will be picked from display file.
Let’s understand the code of the program one by one.
First line PGM shows start of the program.
2nd line DCLF – it stands for declare file which has the screen name. (Basically it is used to declare Display file, also the variables defined in this screen will be accessible to this CL program).
3rd line SNDRCVF --The Send/Receive File (SNDRCVF) command is used by a control language (CL) program to send data to and receive data from a device that is being used interactively by a user. 
(Basically it handles entering your response on screen and passes it to CL program).
4th and 5th line has IF condition whatever condition will be true on screen expected output will be processed as expected.
(like the above program has either F3 pressed or you enter choice 1 as option, on pressing F3 it will close the program and on taking option 1 it will call the program STMLE)

6th line is used to tell the program ends here.

Tuesday, June 25, 2013

Control Language Basic Part 1

Control Language:
Control language also knows as CL. CL is a language which is used in AS400 for controlling purpose. It is basically a well organized language as its basic is commands with different parameter.
Let’s study an example to study how CL works.
Steps to create a CL program:
1.    WRKMBRPDM
2.    Press F6
3.    Give the object name
4.    Type parameter should have value as CLP.






Press Enter
You will get a blank screen.
We will study a program which will display User Profile.
1-    PGM
2-    DCL        VAR(&USER) TYPE(*CHAR) LEN(10)
3-    DCL        VAR(&MSG) TYPE(*CHAR) LEN(40)
4-    RTVUSRPRF  RTNUSRPRF(&USER)
5-    CHGVAR     VAR(&MSG) VALUE(&USER)
6-    SNDPGMMSG  MSG(&MSG)
7-    ENDPGM
Let’s see what each line will do in this program’
1st line show start of the program
2nd and 3rd line we declare two variable named User and Msg.
4th line shows a command which is used to retrieve user profile.
5th line moves value of user profile to msg variable.
6th line sends the user name to program message which is basically appears upon the bottom.
7th line shows how to end a CL program.
So If we try to understand basic structure of any CL Program:
ü  Start
ü  Declare variables
ü  Declare files
ü  Use calculation or assignment
ü  End program.
Just one more thing here, whenever we write any program its developer responsibility to add meaning full comments to programs. So in CL  /* */ are used to do comment.

/* This Program will send User Profile*/