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



This is my Physical file 'EMPS' existing in library "TAMIL1" and its record fo..

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

This is my Physical file 'EMPS' existing in library "TAMIL1" and its record fo..

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

This is my Physical file 'EMPS' existing in library "TAMIL1" and its record fo..

Answer / roshan


the %WLDCRD keyword is case sensitive,

Your are entering the 'S' with capital latter in %WLDCRD
keyword and records present in file are start with
samll 's', becouse of that records are not selected in open
query command.

Thanks
Roshan

Is This Answer Correct ?    2 Yes 0 No

This is my Physical file 'EMPS' existing in library "TAMIL1" and its record fo..

Answer / vicky

BRO ITS CL PROGRAM NOT RPG

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More RPG400 Interview Questions

Difference between RESET and CLEAR

1 Answers   TCS,


suppose if we want to update the data in cl what we will do?

9 Answers  


What is the difference Return and InLr?

3 Answers  


what is plat file?

6 Answers   Indian Infotech,


What would be the effect on the field where reverse image, underline and high intensity?

7 Answers   IBM,






Why there is invention of RPG if we can do insert update delete in CL through SQL.Why the rise of RPG?

1 Answers   Infogain,


what is the procedure and explain about real time scenario.

0 Answers   Adhoc Technologies, Hanuman Automation, HSBC, IBM,


I want my simple Green screen should refersh every 1 min ,How can I do it..? Please share the logic

2 Answers  


HOW TO DEBUG A BATCH JOB WHEN IT IS IN MESSAGEWAIT(MSWG) STATUS.I KNOW THE STEPS FOR BATCH DEBUGGING,BUT IM CONFUSING WITH WHEN WE SUBMIT ANY JOB FOR BATCH DEBUG WE PUT IN HELD STATE.SO HERE ALSO DO SAME THING OR ANY OTHER WAY,PLEASE HELP ME....

1 Answers   HCL, Mind Tree,


Why we cannot call a service program? If I add a PEP can i call the service program?

1 Answers   DELL,


How can read PF in reverse order (end to start) in CL pgm..

8 Answers   TCS,


how to retrieve particular field records from a physical file,say i have a physical file called 'employee' in it i have to retrieve the records of a field 'admin' present in pf 'employee' using rpg,but i should not use logical file or openquery file.

3 Answers   iGate, Wipro,


Categories