QSNDDTAQ API – Send (Write) to data Queue
Okay, so far we’ve learnt the basics. Now here’s an example which will clarify the things. In this example, we are sending some entry to the data queue using a data structure.
Why Data Structure?
Data structure makes it easier to send multiple types of data at a time to a data queue. In this example we are trying to send an alphanumeric and numeric data type values to the data queue. However, do remember that everything is passed as a character field only.
Required Vs. Optional Parms
API QSNDDTAQ takes four sets of parameters. First set of parameter is required. It is the name of the data queue, name of the library in which the data queue exists, numeric 5,0 variable to indicate the length of data and lastly the actual data.
Please note that any extra information in the ‘data’ variable is truncated to the length specified as the third parameter.
Example of QSNDDTAQ in RPG ILE:-
Prerequisite:-
This example uses a data queue long enough to hold 22 characters named TEST to be present in the library list.
*
D @DataQ S 10A Inz('TEST')
D @Library S 10A Inz('*LIBL')
D @Data DS
D @Website 1 20
D @Age 21 22 0
D @DataLength S 5 0 Inz(22)
C Eval @Website = 'tutorialindia.com'
C Eval @Age = 1
C Call 'QSNDDTAQ'
C Parm @DataQ
C Parm @Library
C Parm @DataLength
C Parm @Data
C Return
In the above example, we’ve used the required parameters (of the API) only. Apart from the required parameters, we can pass two sets of optional parameters.
To know more about these parameters and their defitions please refer IBM documentation at http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/index.jsp?topic=...
Now that we’ve written to the data queue, how do we verify that records were written correctly? There are two ways to do that, one of them is using QRCVDTAQ. I will discuss this API in the next chapter.
- 3636 reads
