Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

how to run only 10 modules of existing N modules in service program in RPGILE ?

3 Answers   Wipro,


How to declare the dynamic(run time) array in rpgle? can you please give example

2 Answers   Polaris,


how to convert date format from one format to another i think in CL/400 its CVTDAT,Please tell in RPG/400 sir not in RPGILE

3 Answers   iGate,


1.Load an runtime array of length 99 from the pf and you want to handle all the possible errors?

1 Answers   HCL,


How to find d key field of a pf that doesn’t have source physical file?

2 Answers  


wat is scan and check ? give me real time scenarios where we used these keywords in ur projects?

2 Answers   Four soft,


How do I link an existing logical file to it's Physical File without recompiling?

2 Answers  


What does Implicit Open means with respect to a file ? What about the Explicit Open?..what are the major differences between these two?

1 Answers   IBM,


steps involved in debugging and types of debugging modes?

1 Answers  


without logical file we cannot access the data in physical file.but we specify physical file in the program(ie:- Ffile IF E k disk).how can it be accessed?

3 Answers   HSBC, TCS,


Hi,Please give me complete code with this logic. The question is how to read the records from a file with load an array of size with error condition? (The logic is Z-Add 0 IDX *LOVAL SETLL FILE READ FILE 99 *IN9 DOWEQ *OFF IDX ANDLT 99 ADD 1 IDX MOVE FIELD ARR,IDX READ FILE 99 ENDDO)please give me complete code with explanation?

1 Answers  


How to read data from Nth member of a physical file containing some X number of members in it? "Provided member names are unknown"

4 Answers  


Categories