Including custom and hang-off entities in the API template

The standard APIs can be extended to provide information from the custom or hang-off tables. A tool specifically provided for generating the template XML's, templateXmlGen.xml is located in the <runtime_sandbox>/bin directory.

About this task

To include custom and hang-off entities in the API template:

Procedure

  1. Run the template XML generation tool from your <runtime_sandbox> directory by using the following command:
    sci_ant.sh -Dtable=TABLE_NAME -f bin/templateXmlGen.xml
  2. Once the command is run, the sample XML files are placed in the <runtime_sandbox>/extn/sampleXML directory as TABLE_NAME_sample.xml.

    For example, consider HF_Order_Header is a hang-off of YFS_Order_Header table. The generated HF_Order_Header_sample.xml is as follows:

    <HFOrderHeader Createprogid=" " Description=" " DocumentType=" " EnterpriseKey=" " OrderHeaderKey=" " OrderName=" " OrderNo=" " .... > </HFOrderHeader>

  3. A sample XML for including the above attributes in a standard API can be generated by passing the YFS table that has a relationship with the hang-off table you are interested in.

    For example, assume HF_Order_Header is a hang-off table with a relationship to the YFS_Order_Header table. The XML template generated by the tool when TABLE_NAME=YFS_Order_Header is passed:

    <Order>
      <OrderLines>
         <OrderLine ........>
           <Extn extended attributes >
             <HFOrderHeaderList>
               <HFOrderHeader Createprogid=" " Description=" " .........>
               </HFOrderHeader>
             </HFOrderHeaderList>
           </Extn>
         </OrderLine>
      </OrderLines> 
    </Order>
    Note: You can modify the attributes only within your custom or hang-off element.

    You can prune this sample XML to include your custom attributes in an API template, such as getOrderDetails output template. However, you cannot modify any of the YFS elements or attributes.

    Note: The sample XMLs are also automatically generated when you create the database extension jar file, and are posted in the <runtime_sandbox>/xapidocs/sampleXML directory. However, if you need to create a sample template, you must run the template XML generation tool separately by specifying the corresponding YFS table name.
  4. A hang-off table can be deleted by passing an Operation attribute in the change or modify APIs. For example, HF_Order_Header element can be deleted in a changeOrder API as:
    <Order>
      <OrderLines>
        <OrderLine ........>
            <Extn extended attributes >
               <HFOrderHeaderList>
                 <HFOrderHeader Operation="Delete" Createprogid=" " ....... >
                 </HFOrderHeader>
               </HFOrderHeaderList>
            </Extn>
         </OrderLine>
      </OrderLines> 
    </Order>

    The operations such as Create and Modify are run by default. If an entry for that element exists, the API modifies the entries with the recent value. In the case where that element does not exist it creates a new entry.

  5. The records in a hang-off table can be reset by assigning the value of “true” to the Reset attribute at the list level element of the XML. When the records are reset, all existing records for that hang off table that correspond to the parent table are deleted and all elements included under the list element are inserted. For example, hang off records in the HF_Order_Header_list element can be reset by using the following:
    <Order>
       <OrderLines>
         <OrderLine ........>
             <Extn extended attributes >
                <HFOrderHeaderList Reset="true">
                   <HFOrderHeader>
                   </HFOrderHeader>
                </HFOrderHeaderList>
             </Extn>
         </OrderLine>
       </OrderLines> 
     </Order>
  6. Build and deploy your extensions.