×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Title: Message
Glad to hear it is working for you!
>What is the preferred method of providing a return code of
the file operation to the calling program ?
I
"throw" an error if something goes wrong in the program. I use the
SNDPGMMSG and RCVPGMMSG api's to put the message on the callstack. Below
are some examples.
/Copy
QSource,PgmBCp
/Copy
QSource,ErrorCp
D error DS
LikeDS(Error_ErrorInfo)
/Free
Monitor;
doSomething(2);
On-Error;
error =
Error_getError();
Select;
When error.code =
'MYCODE0001';
// Number was greater than
zero.
When error.code =
'MYCODE0002';
// Number was not greater
than zero.
EndSl;
EndMon;
*InLR = *On;
/End-Free
/Copy
QSource,ErrorPd
//------------------------------------------
// Give an example of how to
throw an error.
//------------------------------------------
P doSomething B Export
D doSomething PI
D pNbr 10I
0 Value
D pgmName S 30A Inz('PgmBFn_doSomething')
D myCode1 S 10A Inz('MYCODE0001')
D myCode2 S 10A Inz('MYCODE0002')
/Free
If pNbr
> 0;
Error_throwError(myCode1: 100: pgmName: 'nbr is greater than
zero');
Else;
Error_throwError(myCode1: 100: pgmName: 'nbr is not greater than
zero')
EndIf;
Return;
/End-Free
P doSomething E
>Or, just provide a procedure to determine the status
separately ? Like PartIsFound for determining if a part is in the Item
Master.
For
something like this I would use the passbackparm for successful completion
because that is inherent based on the name of the subproc (partIsFound).
That then allows you to do in-line coding:
If
partIsFound(myPartNbr);
EndIf;
>If multiple fields
need to be returned, a data structure is used.
This
is how I do it. I only pass back info in the PI if it needs to be callable
via Java's ServiceProgram object or PCML.
Aaron Bartell
I am beginning to
encapsulate file access in a "Service Orirtented Architecuture" as described in
a previous post by Aaron Bartell. It is working very
well.
What is the
preferred method of providing a return code of the file operation to the calling
program ? Should I provide a return code on every procedure that I write ?
Or, just provide a
procedure to determine the status separately ? Like PartIsFound for
determining if a part is in the Item Master.
Also, I've seen
where others have standardized on always passing data back using the Procudure
interface and never parameters claiming that the parameters should only be used
for input to the procedure. If multiple fields need to be returned, a data
structure is used.
As an Amazon Associate we earn from qualifying purchases.