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: January 2, 2012  10:21 AM
UPDATED: March 17, 2012  6:03 AM

Answer Wiki:
Set off the SFLDSP indicator and seton the SFLDSPCTL indicator
Last Wiki Answer Submitted:  January 3, 2012  4:26 am  by  deepu9321   3,370 pts.
All Answer Wiki Contributors:  deepu9321   3,370 pts.
To see all 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

 44,190 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,740 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,370 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

 44,190 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.