AddNextDoc method: Business Interlink class

Syntax

AddNextDoc()

Description

The AddNextDoc method adds a document to one of the following levels:

  • The root level of the input structure for a Business Interlink object. You create a reference to this level with the GetInputDocs method.

  • When a document within the input structure is a list, AddNextDoc adds another document to the list. If you use AddNextDoc on a document that is not a list, AddNextDoc fails and returns an error.

Parameters

None.

Returns

This method returns an integer. The values are:

Value Description

0

eNoError. The method succeeded.

1

eNO_DOCUMENT. The document referenced by this method does not exist.

2

eDOCLIST_OUT_RANGE. You tried to access a document in a list, but the document list is out of range. For example, if a document list contains five documents, and then you call GetDoc/GetOutputDocs once, you can call GetNextDoc four times; the fifth time results in this error.

3

eDOCUMENT_UNINITIALIZED. Internal error.

4

eNOT_DOCUMENTTYPE. You tried to perform an operation upon a parameter that is not a document type.

5

eNOT_LISTTYPE. You tried to perform a GetNextDoc or AddNextDoc upon a document that is not a list.

7

eNOT_BASICTYPE. You tried to perform a GetValue or AddValue upon a parameter that is not of basic type: Integer, Float, String, Time, Date, DateTime.

8

eNO_DATA. You tried to retrieve data from a document that contained no data.

Example

In this example, the input structure for Calculate Cost, or the root level document, is accessed with the GetInputDocs method. The AddNextDoc method adds another BIDocs input document. The Calculate Cost input parameter Account_Info_List is a document, so the AddDoc method adds it to the BIDocs input document. Account_Info_List is also a document list, so AddNextDoc method adds another Account_Info_List document.

Local Interlink &QE_COST; 
Local BIDocs &CalcCostIn; 
Local BIDocs &FromDoc, &ToDoc, &PackageDoc, &AccountDoc; 
Local number &ret, &retinput; 
&QE_COST = GetInterlink(Interlink.QE_COST_EX); 
&CalcCostIn = &QE_COST.GetInputDocs(""); 
For &n = 1 to &number_of_input_sets 
/* Get values for inputs, such as &ORIGIN (code not shown) */ 
   &ret = &CalcCostIn.AddValue("input_param1","value"); 
   &FromDoc = &CalcCostIn.AddDoc("From"); 
   &ret = &FromDoc.AddValue("OriginCountry", "United States"); 
   &ret = &FromDoc.AddValue("OriginPostal_Code", &ORIGIN); 
   &ret = &FromDoc.AddValue("Ship_Date", &SHIPDATE); 
   /* Call AddDoc and AddValue for To and Package_Info 
      (code not shown) */ 
   /* Call AddDoc and AddNextDoc for the AccountDoc document list */ 
   &AccountDoc = &CalcCostIn.AddDoc("Account_Info_List"); 
   For &m = 1 to &number_of_AccountDocs 
      &ret = &AccountDoc.AddValue("Account_Number", &ACCOUNT); 
      &ret = &AccountDoc.AddValue("Meter_Number", &METER); 
      &ret = &AccountDoc.AddValue("Service_Type", &SVCTYPE); 
      &retinput = &AccountDoc.AddNextDoc(); 
   End-For; &retinput = &CalcCostIn.AddNextDoc(); 
 
End-For;
&retinput = &To.AddNextDoc();

The following shows the input structure for this example. It contains five input parameters: input_param1, From, To, Package_Info, and Account_Info_List. From, To, and Package_Info are not lists, so if you try to use AddNextDoc with these parameters, such as the following line of code, AddNextDoc will fail and return an error message.

Example input structure