RPC HELP Tutorial Step 8
Tutorial: Step 8 -- Routine to Retrieve Terminal Types
Now that you have associated an IEN for each record displayed in the list box (Step 7), you can use that IEN to display fields from any terminal type entry in the list box that a user selects. To retrieve the fields for any selected terminal type entry, you should create a second custom RPC. This RPC will need to take an input parameter, the record IEN, to know which record to retrieve.
To create an RPC routine to retrieve individual terminal type records:
1. Choose the data format that your RPC should return. The type of data that you need to return to your client application determines the format of the routine that your RPC will call. In this case, the RPC should, given an IEN, return fields .01, 1, 2, 3, 4, 6, and 7 (Name, Right Margin, Form Feed, Page Length, Back Space, Open Execute, and Close Execute).
- Since this information is constrained and small, a return type of ARRAY would be suitable for this RPC. The return format of the array is arbitrary; for the sake of this application, the routine should return fields .01, 1, 2, 3, and 4 in node 0; field 6 (a 245-character field) in node 1; and field 7 (also a 245-character field) in node 2. This array must be returned in the first parameter to the routine.
2. The routine for this RPC also needs to be able to take an IEN as an input parameter. Any additional input parameters such as one for the IEN must follow the required input parameter in which results are returned.
3. Add a second subroutine to the ZxxxTT routine for the second RPC, similar to the following. This subroutine uses an IEN to retrieve fields for a particular terminal type. It then sets three result nodes, each containing a specified set of fields for the record corresponding to the IEN parameter.
TERMENT(RESULT,IEN) ; retrieve a string of fields for a termtype ; format of results (by field number): ; RESULT(0)=.01^1^2^3^4 ; RESULT(1)=6 ; RESULT(2)=7 ; NEW I,ARRAY NEW IENS SET IENS=IEN_"," SET RESULT(1)="" DO GETS^DIQ(3.2,IENS,".01;1;2;3;4;6;7","","ARRAY") SET RESULT(0)="" IF '$D(DIERR) DO . FOR I=.01,1,2,3,4 DO . . SET RESULT(0)=RESULT(0)_$GET(ARRAY(3.2,IENS,I))_"^" . SET RESULT(1)=$GET(ARRAY(3.2,IENS,6)) . SET RESULT(2)=$GET(ARRAY(3.2,IENS,7)) QUIT ;
4. Test the routine. Call it like the Broker would:
>DO TERMENT^ZxxxTT(.ARRAY,103)
Confirm that the return array contains the specified fields in the following nodes:
ARRAY(0)=C-HINQLINK^80^#,$C(27,91,50,74,27,91,72)^24^$C(8)^ ARRAY(1)=U $I:(0:255::255:512) ARRAY(2)=U $I:(:::::512) C $I
Once you've tested your routine, and confirmed that it returns data correctly, the next step (Step 9) is to create the RPC that will call this routine.