Calling API

50 pts.
Tags:
AS/400
i5
iSeries
OS/400
QEZSNDMG
WRKJOBSCDE
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

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, <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/QEZSNDMG.htm”>QEZSNDMG</a> 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/

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following