Question

  Asked: Feb 26 2008   7:03 AM GMT
  Asked by: TG


Calling API


AS/400, iSeries, OS/400, i5, WRKJOBSCDE, QEZSNDMG

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.
Any one please help

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



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'))
FRQ(*ONCE))

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
http://www.brucevining.com/
  • AddThis Social Bookmark Button

Browse more Questions and Answers on AS/400.

Looking for relevant AS/400 Whitepapers? Visit the Search400.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register