× 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.




    D QWCCVTDT        PR                  ExtPgm('QWCCVTDT')
    D  inFmt                        10A   Const OPTIONS(*VARSIZE)
    D  inDate                       64A   Const OPTIONS(*VARSIZE)
    D  outFmt                       10A   Const OPTIONS(*VARSIZE)
    D  outDate                      64A   OPTIONS(*VARSIZE)
    D  api_error                          LikeDS(QUSEC)
    D                                     OPTIONS(*VARSIZE)

The problem with this prototype is all of the OPTIONS(*VARSIZE) all over the place. Can I suggest that you remove them from all but the outDate and api_error parameters?

The way you have this coded, you can't use literals unless they're the exact length of the parameter.

For example, for the "input format", the API is expecting to receive a CHAR(10) field. Always. If you use the above prototype and code

      callp QWCCVTDT( '*MDY' . . . )

The prototype will only pass 4 bytes to the API, in spite of the fact that the API expects 10. So now you're forcing the caller to always put his formats in variables to make sure that all 10 chars are passed, and that makes the API more awkward to use.

Worse, depending on what happens to be in memory, there's a good chance that you could call the API (the way it's coded above) and have it work MOST of the time, since the memory after the literal might happen to be blank or x'00'. That means that it'd just fail occasionally, likely in production, and the bug may never be found.

Prototypes are supposed to protect you from these things, but they won't if you're disabling that protection by using OPTIONS(*VARSIZE) everywhere.

So my suggestion is to code the prototype like this:

     D QWCCVTDT        PR                  ExtPgm('QWCCVTDT')
     D  inFmt                        10A   Const
     D  inDate                       20A   Const
     D  outFmt                       10A   Const
     D  outDate                      20A   OPTIONS(*VARSIZE)
     D  api_error                          LikeDS(QUSEC)
     D                                     OPTIONS(*VARSIZE)



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.