30 pts.
 SUBFILE
IF I HAVE AN EMPTY DATABASE FILE WITH NO RECORDS. HOW WILL I CODE IN RPGLE WITHOUT LETTING THE PROGRAM CRASH?

Software/Hardware used:
AS400
ASKED: Jan 2, 2012  10:21 AM GMT
UPDATED: March 17, 2012  6:03:35 AM GMT
3,355 pts.
  Help
 Approved Answer - Chosen by HOPPER5089 (Question Asker)

Generally, If records are present in a subfile, You will be switching ON the Subfile Display & Subfile Control Display Indicators.
If, There were no records in a PF(for writing into Subfile), In this case, The program will crash if we follow the normal procedure. You will need to Switch OFF the Subfile Display Indicator.
Which means, If no records are present for displaying, We will Switch ON only 'Subfile Control Display' indicator and will write Subfile Control Format.
For better appearance, You can have another Record format which says "No Records are present to display" and write it before displaying the subfile.
You should be very careful with the OVERLAY indicator when no records are present,

Pradeep.
ANSWERED:  Jan 2, 2012  10:35 AM (GMT)  by Deepu9321   3,355 pts.

 
Other Answers:
Set off the SFLDSP indicator and seton the SFLDSPCTL indicator
Last Wiki Answer Submitted:  Jan 3, 2012  4:26 AM (GMT)  by  Renjithgr   285 pts.
Latest Answer Wiki Contributors:  Deepu9321   3,355 pts.
To see other answers submitted to the Answer Wiki View Answer History.
Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _




 

Or you could create 1 subfile record with the message “No Records exist” in the first text field.
Phil

 36,420 pts.

 

set indicator in subfile display, subfile display control..

eval *in35=*on -> ON subfile display control indicator
exfmt subctl -> subfile control record format name
and switch off subfile display and subfile display control indicator
after you getting empty subfile….

 3,665 pts.

 

thanx every1.deepu and sathish that exactly is the answer i was looking for.

 30 pts.

 

what exactly is the scenario if we use MONMSG to capture the error. is it possible??

 30 pts.

 

You cannot have the MONMSG Command in RPGLE.
Why would you like to use MONMSG, Main use of having MONMSG is for error handling.
You can follow the above suggested procedure for avoiding the Program Crash.
If Records > 0 ;
Switch Display & Display Control Indicators
Else
Switch Display Control Indicator Only
EndIF
Write Control Format

Pradeep.

 3,355 pts.

 

use MONMSG to capture the error. is it possible??

Possible, yes (monitor message is a CL process but there are RPG ways to capture errors/exceptions) that might work in this case, however, these seem totally inappropriate. The program has to compute the subfile RRN to write subfile records so it a staight forward process to use Pradeep recommendion. Pradeep’s recommendation it is the standard practice for handling this case.
Phil

 36,420 pts.

 

Firstly.. during CLRSFL : eval dspctl = *off
eval clear = *on
write sflctl
eval dspctl =*on
eval clear = *off

after reading PF:

Only switch on SFLDSP if RRN > 0
in else do as
Philpl1jb suggested .

 130 pts.

 

rebekahalkhalifa@yahoo.com
Hello…
I wish you best Compliment of the season,with hope that you are physically and healthly alright,l do believe that this mail will reach in good condition. My name is Rebekah i saw your profile in www.itknowledgeexchange.techtarget.com and admire it, i think we can make it together, please i would like you to contact me through my email address:( rebekahalkhalifa@yahoo.com ) i will tell you more about myself, also send you my photo,as soon as you contact me back, hopping for your lovely reply soonest,
Rebekah….

 3,500 pts.