![]() However, don’t forget the YAGNI principle. Either way you get less duplicated source code, and your routine can adapt more easily to organizational changes. Whatever you decide, the result will probably work fine. To write a wrapper or not, to explicitly or implicitly describe the data, these are not life-or-death questions. The sixth parameter, error code, supports various formats, and the caller loads the bytes-provided subfield of a data structure to specify how to handle an exception. That’s not the only explicit parameter definition in that API. If new data formats are needed someday, IBM will have no trouble adding them. The caller uses the third parameter to tell the API which format to use - OBJD0100, OBJD0200, OBJD0300, or OBJD0400. The Retrieve Object Description API (QUSROJBD) can return data in four formats. For an example of an explicit definition, I once again turn to IBM APIs. In the last example, the parameter format was implicit. Both methods are valid, and I don’t consider one any better than the other. Explicit means that the caller must tell the called routine what the parameter looks like. Will the parameter format be implicit or explicit? Implicit means that the called routine itself determines how the parameter is formatted. If you decide not to use a wrapper, you come to. IBM had not yet given us the MONITOR op code, so I used something, probably the TESTB opcode, to figure out which type of data I had. dcl-ds CustomerParm qualified based(P1) Īnd that’s what I did those many years ago. Instead, you can make CUS004R receive a customer account number in either packed or decimal format. If you use the Display Program (DSPPGM) command to view information about QSYRTVFI, you’ll find procedure QsyRetrieveFunctionInformation inside service program QSYFNUSG.īut you may prefer not to use a wrapper. In other words, you can access the same routine as a program call or a subprocedure call. I understand that in many (most? all?) cases, the short name is a program wrapper over a procedure of the longer name. An example is QSYRTVFI/QsyRetrieveFunctionInformation. If you look through the alphabetic list of APIs in the API Finder, you’ll often see two names - a short one in all caps and a longer one in mixed case - for an API. Using a wrapper is a perfectly good programming technique. Voilà! CUS006R calls CUS004R indirectly using wrapper CUS005R. (I don’t have access to a system with the S/36 environment at present, so I use RPG III instead.) I DS If there were input-output (updateable) or output-only parameters, wrapper program CUS005R would have reformat them from packed to zoned decimal before returning to caller CUS006R.įinally, here’s caller program CUS006R, which passes zoned-decimal parameters. In this the case, the parameter is passed as input only. **freeĬUS005 receives the customer number in zoned decimal format, reformats the value into packed decimal, and calls CUS004R. Here are the salient pieces of wrapper program CUS005R, which bridges the gap between the two. I need to call this program from an RPG II program, which cannot pass packed-decimal parameters. Here’s part of program CUS004R, which accepts a seven-digit customer account number as packed decimal. I’ll stick to the same example to illustrate. A wrapper is a routine that stands between a caller and another, incompatible routine. When faced with the need for more than one interface into a routine (program or subprocedure), the first choice you must make is whether or not to use a wrapper. Through the years, I’ve had to provide interface alternatives from time to time. Such was my introduction to flexible interfaces, and it was only an introduction. I ended up changing the called program to accept the parameter in either packed decimal or zoned decimal format. I could have changed the called program and the native callers to use data structures to define the parameter as zoned decimal, but the idea didn’t thrill me. The called program defined the parameter as packed decimal. S/36 programs passed numeric parameters in zoned decimal format, whereas native RPG and CL programs used packed decimal. The problem I ran into was rooted in a numeric parameter. I needed to call a program that had been written in the latest version of RPG from both S/36 RPG II and native RPG III (a.k.a. I was working on an AS/400 that ran a mixture of System/36 and native applications. The details are murky, it’s been eons ago.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |