Calling API

50 pts.
IBM iSeries
Hi all, Does anyone knows how to call API program in interactive mode? How are the rules to call API? Let say I want to put CALL QEZSNDMG in WRKJOBSCDE, what do I have to put in the command, cause when I try CALL QEZSNDMG parm(''N' 'Y' ' ' 'Testing' 'User1'') its not working. It says that error found on *N command. And when I try ==> Call PGM(QEZSNDMG) PARM(N Y TESTING1 User1), it says Parameters passed on CALL do not match those required. Anyone please help.

Answer Wiki

Thanks. We'll let you know when a new response is added.

When calling an API the same set of rules generally apply whether the call is done interactively or in batch. One rule is that API parameters are passed in groups (required, optional group 1, optional group 2, etc). In the case of QEZSNDMG there are nine parameters in the first group where you are passing only five. In addition, QEZSNDMG documents that if you call the API in batch then paramter 10 must be passed and must be set to a value of ‘N’. As parameter 10 is in optional parameter group 2 then you must pass all of optional group 1 and all of optional group 2.

With this information, then:

ADDJOBSCDE JOB(QEZSNDMG) CMD(CALL PGM(QEZSNDMG) PARM('*INFO' '*NORMAL' 'Testing' X'00000007' 'USER1' X'00000001' X'00000000' X'00000000' X'00000000' 'N' ' ' '*USR'))

will send the message ‘Testing’ to user USER1.

A couple of items:

  1. Some of the parameters are defined as being Binary(4). As command analyzer will treat any numeric parameter as packed decimal you need to specify the Binary(4) parameters using hex. So x’00000001′ means pass a 4-byte field which will look like a 1 when viewed as a binary number (the number of users). x’00000007′ means pass a 4-byte field which looks like a 7 (the length of your message).
  2. Two of the parameters are outputs from the API. You need to pass “something” for these (I use x’00000000′) but you will not be able to determine what values were returned (when using a command line like approach).
  3. For the Error code parameter I used x’00000000′. This appears to the API as if I had specified a Bytes Provided within the Error code structure of 0, so errors will be returned as exceptions.

Bruce Vining

Discuss This Question:  

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: