Sample Code:: Output: Shouhil, Fazal, Syeduzm

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

EVAL:

It is used to evaluate any kind of expression.


Sample code:
DA
S
10A INZ('SHOUHIL')
DB
S
10A INZ('FAZALLL')
DC
S
10A INZ('SYEDUZMA')
DD
S
10A INZ('
')
DE
S
10A INZ('
')
DF
S
10A INZ('
')
/FREE
EVAL D=A;
EVAL E=B;
EVAL F=C;
DSPLY D;
DSPLY E;
DSPLY F;
*INLR=*ON;
/END-FREE
Output : SHOUHIL,FAZAL,SYEDUZM

EVALR:
It is used to evaluate any kind of expression.
Sample code:
Dfld1
s
10a inz('shouhil')
C fld1
dsply
C
eval
fld1='shouhil'
C fld1
dsply
C
evalr fld1='shouhil'
C fld1
dsply
C
seton
lr
Output

: SHOUHIL,
SHOUHIL
SHOUHIL

MOVE:
The MOVE operation transfers characters from factor 2 to the result field.
Sample code:
FPHS
IF E
K DISK
FE
CF E
WORKSTN
/FREE
READ PHS;
EVAL DID=EMPID;
EVAL DNAM=EMPNAM;
EVAL DADD=EMPADD;
EXFMT DEPREC;
*INLR=*ON;
/END-FREE
Output : 100
fazal
syeduzma

DOW:
DOW means program could never perform the loop (If the
condition is false). .
Sample code:
FPHS
IF E
K DISK
/FREE
DOW not %eof(phs);
READ PHS;
DSPLY EMPID;
ENDDO;
*INLR=*ON;
/END-FREE
**********************************************
Output

: 100,200,300,400

DOU:
With DOU, program will perform the loop at least once.
Sample code:
FPHS
IF E
/FREE
DOU %eof;
READ PHS;
DSPLY EMPID;
ENDDO;
*INLR=*ON;
/END-FREE

K DISK

**********************************************
Output

: 100

FOR:
Sample code:
DCOUNT
S
2P 0 INZ(2)
C
FOR
COUNT=1 TO 6 BY 2
C
COUNT
DSPLY
C
ENDFOR
C
SETON
LR
**********************************************
Output

: 1
3
5

DIM(similar to occur)
Sample code:
DA
S
10P 0 DIM(10)
DRES
S
10P 0
/FREE
RES=1;
DSPLY RES;
*INLR=*ON;
/END-FREE
**********************************************
Output

: 1

DATE:
It will convert date, to another format.
Sample code:
Ddate
s
10a
Dres
s
d
/free
date='990302';
res=%date(date:*ymd0);
dsply res;
*inlr=*on;
/end-free
**********************************************
Output

: 1999-03-02

TIME:
It will convert time to another format.
Sample code:
Dtime
s
10a
Dres
s
t
/free
time='1134';
res=%time(time:*iso0);
dsply res;
*inlr=*on;
/end-free
**********************************************
Output

: 11.34.00

OCCUR
OCCUR sets the current position of a multiple-occurrence data structure..
Only one occurrence can be used at a time. First we need to set a pointer
and we can set the data and retrieve data from multi occurrence data
structure.
Sample code:
D mds
ds
D mn
s
/free
%occur(mds)=1;
mn=1;
dsply mn;
%occur(mds)=2;
mn=2;
dsply mn;
*inlr=*on;
/end-free

occurs(10)
10p 0

**********************************************
Output

SECOND (ADDING A SECOND):


It gives the number in correct format and it will add.
Sample code:
Dsec
s
t inz(t'10.12.15')
Dres
s
t
/free
res=sec+%seconds(2);
dsply res;
*inlr=*on;
/end-free
**********************************************
Output

: 10.12.15

SECOND(SUBSTRACTING):
It gives the number of seconds in correct format and it will substract.
Sample code:
Dsec
s
t inz(t'10.12.15')
Dres
s
t
/free
res=sec+%seconds(-2);
dsply res;
*inlr=*on;
/end-free
**********************************************
Output

: 10.12.14

MINUTES(ADDING):
It gives the number of minutes in correct format.
Sample code:
D sec
s
D res
s
/free
res=sec+%hours(2);
dsply res;
*inlr=*on;
/end-free

t inz(t'10.12.15')
t

**********************************************
Output

: 10.15.15

MINUTES(SUBSTRACTING):
It gives the number of minutes, and will be subtract.
Sample code:
D sec
s
t inz (t'10.12.15')
D res
s
t
/free
res=sec+%hours(-2);
dsply res;
*inlr=*on;
/end-free
**********************************************
Output

: 10.15.15

HOURS(ADDING):
It gives the number of hours in correct format.
Sample code:
D sec
s
t inz(t'10.12.15')
D res
s
t
/free
res=sec+%seconds(2);
dsply res;
*inlr=*on;
/end-free
**********************************************
Output

: 13.12.15

HOURS(SUBSRACTING):
It gives the number of hours in correct format and it will be substract.
Sample code:
D sec
s
t inz(t'10.12.15')
D res
s
t
/free
res=sec+%seconds(-2);
dsply res;
*inlr=*on;
/end-free
**********************************************
Output

: 13.12.15

DATA AREA WITH LOCK:


Retrieving the data area in data structure with lock.
Sample code:
DDATA
UDS
DTAARA('DTS')
DF1
1 50A
C *LOCK
IN
DATA
C F1
DSPLY
C
OUT
DATA
C
UNLOCK DATA
C
SETON
Output

: INDIA IS MY COUNTRY

DATA AREA FOR GROUPING:


Retrieving the data area in data structure with lock.
Sample code:
DFLD1
D yy
Dfl
D mm
Df2
D dd
/free
yy ='2012';
mm='12';
dd ='04';
dsply fld1;
*inlr=*on;
/end-free
Output

DS
4a
1a inz('-')
2a
1a inz('-')
2a

: 2012-12-04

You might also like