Topic
  • 2 replies
  • Latest Post - ‏2014-06-27T07:38:16Z by MathiasLanglet
MathiasLanglet
MathiasLanglet
6 Posts

Pinned topic Calling QliChgLL with RPG Free

‏2014-06-26T15:40:16Z |

Hello fellow devs,

 

I'm fairly new to RPG and today I tried my first API call and I failed miserably.

Here is the code I'm running: http://pastebin.com/RJYR8vf3

Here is the API specification: http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qlichgll.htm?lang=en

I've tried to debug the program but the API return parameter always comes back blank and I can't seem to step-into the API.

 

Any help is greatly appreciated!

 

Kind Regards,

Mathias

  • barbara_morris
    barbara_morris
    393 Posts

    Re: Calling QliChgLL with RPG Free

    ‏2014-06-26T16:11:44Z  

    Hi Mathias, the name of the API is case-sensitive. It should be 'QLICHGLL'.

    Your error-code parameter is not valid. It is accidentally working ok because the first four bytes of the initial value for the varying length string is x'0000', but that is not a good way to code it. It should be a data structure with at least two int(10) subfields. The first subfield indicates how long the structure is, but a value of zero for the first subfield says that the API should signal an exception if an error occurs. (I almost always set the value to zero and use CALLP(E) like you did, especially when developing my API call, because it's much easier to read the error message in the joblog.)

    Here's how I would handle the error code parameter:

             ... 
             pStdApiErr   Likeds(ApiErrMsg);      
          end-pr; 

          dcl-c GIVE_EXCEPTION_IF_ERROR 0;
          dcl-ds ApiErrMsg Qualified;
             BytesProvided Int(10) Inz(GIVE
    _EXCEPTION_IF_ERROR);
             BytesAvailable Int(10);
             ExceptionId Char(7);
             Reserved Char(1);
          end-ds;

    Updated on 2014-06-26T16:12:17Z at 2014-06-26T16:12:17Z by barbara_morris
  • MathiasLanglet
    MathiasLanglet
    6 Posts

    Re: Calling QliChgLL with RPG Free

    ‏2014-06-27T07:38:16Z  

    Hi Mathias, the name of the API is case-sensitive. It should be 'QLICHGLL'.

    Your error-code parameter is not valid. It is accidentally working ok because the first four bytes of the initial value for the varying length string is x'0000', but that is not a good way to code it. It should be a data structure with at least two int(10) subfields. The first subfield indicates how long the structure is, but a value of zero for the first subfield says that the API should signal an exception if an error occurs. (I almost always set the value to zero and use CALLP(E) like you did, especially when developing my API call, because it's much easier to read the error message in the joblog.)

    Here's how I would handle the error code parameter:

             ... 
             pStdApiErr   Likeds(ApiErrMsg);      
          end-pr; 

          dcl-c GIVE_EXCEPTION_IF_ERROR 0;
          dcl-ds ApiErrMsg Qualified;
             BytesProvided Int(10) Inz(GIVE
    _EXCEPTION_IF_ERROR);
             BytesAvailable Int(10);
             ExceptionId Char(7);
             Reserved Char(1);
          end-ds;

    Hi Barbara!

    Thanks for the reply! The API call is working now.

    Cheers,

    Mathias