This is my Physical file 'EMPS' existing in library "TAMIL1"
and its record format is 'EMPRCD"
a)its source is
R EMPRCD
ENO 4 0
ENAME 10
EADD 10
b)The records present in EMPS are as follows
ENO ENAME EADD
0001 tamil coimbatore
0002 kumar bangalore
0003 sunder bangalore
0004 arunkumar chennai
0005 pandi hyderabad
0006 santhosh hyderabad
0007 sasi salem
0008 kalai chennai
0009 suresh hyderabad
0010 vijay bangalore
0011 Arul chennai
0012 velu chennai
0013 khan bangalore
0014 praba chennai
0015 praba.p coimbatore
0016 anand ooty
0017 raja erode
0018 sankar erode
0019 vadivel namakkal
0020 anbu chennai
0021 Ajith mumabi
c)now i want to select the 'ENAME' field records starting
with 'S'
for that i have created a RPG program
its source code is
PGM
DCLF FILE(TAMIL1/EMPS)
DCL VAR(&MYENO) TYPE(*CHAR) LEN(4)
OVRDBF FILE(EMPS) SHARE(*YES)
OPNQRYF FILE((TAMIL1/EMPS)) QRYSLT('ENAME *EQ
%WLDCRD("S *")')
READ: RCVF RCDFMT(EMPRCD)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
CHGVAR VAR(&MYENO) VALUE(&ENO)
SNDUSRMSG MSG(&MYENO)
SNDUSRMSG MSG(&ENAME)
SNDUSRMSG MSG(&EADD)
GOTO READ
END: CLOF OPNID(EMPS)
DLTOVR FILE(EMPS)
ENDPGM
Is this coding correct sir,the program gets compiled,and if
i call it it says query running but records are not
displayed.please help me out
Answers were Sorted based on User's Feedback
Answer / katiyar
Looks like your answer is correct, Just little modification
as per my understanding and as per your requirement.
--------------------------------------------------------
PGM
DCLF FILE(TAMIL1/EMPS)
OVRDBF FILE(TAMIL1/EMPS) SHAR(*YES)
OPNQRYF FILE((TAMIL1/EMPS)) QRYSLT('ENAME *EQ + %WLDCRD
("S*")')
/*--To See the result in file, Use following commands--*/
CPYFRMQRYF FROMOPNID(TAMIL1/EMPS) TOFILE(TAMIL1/TESTPF1) +
MBROPT(*REPLACE) CRTFILE(*YES)
RUNQRY QRYFILE((TAMIL1/TESTPF1))
READ: RCVF RCDFMT(EMPRCD)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
/*---To See the result, Use following commands----*/
SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&ENAME) +
TOPGMQ(*EXT)
SNDUSRMSG MSG(&ENAME) TOUSR(&USERNAME)
****Provide your User Profile Name in TOUSR = &USERNAME
/*-------------------------------------------------*/
SNDUSRMSG MSG(&ENAME)
GOTO READ
END: CLOF OPNID(EMPS)
DLTOVR FILE(EMPS)
ENDPGM
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
I am sure, this will help you.
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / katiyar
Your Answer is totally correct. Just little modification.
Add Commented Code as same mentioned below in above code.
--------------------------------------------------------
PGM
DCLF FILE(TAMIL1/EMPS)
OVRDBF FILE(TAMIL1/EMPS) SHAR(*YES)
OPNQRYF FILE((TAMIL1/EMPS)) QRYSLT('ENAME *EQ + %WLDCRD
("S*")')
/*--To See the result, Use following commented commands--*/
/* CPYFRMQRYF FROMOPNID(TESTPF) TOFILE(KATIYAR1/TESTPF1) +
MBROPT(*REPLACE) */
/* RUNQRY QRYFILE((TESTPF1)) */
/*------------------------------------------------------*/
READ: RCVF RCDFMT(EMPRCD)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
/*---------------------------------------------------*/
SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&ENAME) +
TOPGMQ(*EXT)
SNDUSRMSG MSG(&EMPNM) TOUSR(&USERNAME)
****Provide your User Profile Name in TOUSR = &USERNAME
/*-------------------------------------------------*/
SNDUSRMSG MSG(&ENAME)
GOTO READ
END: CLOF OPNID(EMPS)
DLTOVR FILE(EMPS)
ENDPGM
Hope this helps you.
Is This Answer Correct ? | 4 Yes | 0 No |
Suppose we have 10 records with same name and we are reading using READE,after 4 record i have to use CHAIN what is the output
Why did we give STRSRVJOB while debugging batch program
Can we create 300 logical files based on a single physical file using the CRTLF command only once?.
how can we can we the data decimal error?how can we open such file in support
how to find whether a date format is valid or not in RPG400 not in RPGILE.Can you please write the coding for this sir,i'm new to AS400.Please help.
Assume my file has 100 records and I want to see only first 10 records. Is this possible through lf?
Hi, I am getting the error in RPG (All Record Formats for externally-described file ABCD ignored or dropped due to error; file ignored.) Please suggest any
what is a rpg?
can i use unique key in LF
How do I link an existing logical file to it's Physical File without recompiling?
Hi guys, anybody know How RPG/400 code can be converted to RPG IV code with a single command?
how do I preserve and clean the array?