Using customer receiver types

Use the procedure as an example to create a custom receiver type which is the primary contact of the shipment's carrier

Use case:

  • Create a new Document Type SHIPMENT with the required parts (email subject, email body, document file name, and mail from address) and create a new Report Rule for the report whinh443511000 with the required expressions.
  • You create a new receiver type, to send the document to the primary contact of the shipment's carrier.

Complete these steps:

  1. Create a new library tcmcsdomcarr with this content:
    table	ttccom120	|* Buy-from Business Partners
    	table	ttccom140	|* Contacts
    	table	ttcmcs080	|* Carriers/LSP
    
    #include <bic_dom>
    
    function extern long dom.get.destinations(
    		const	string	i.doc.type,
    		const	string	i.receiver.type,
    		const	string	i.custom.receiver.type,
    		const	string	i.receiver.value)
    {
    	FunctionUsage
    	Expl:	Returns the list of destinations
    	Pre:	-
    	Post:	-
    	Input:	i.doc.type		- document type
    		i.receiver.type	- receiver type
    		i.custom.receiver.type	- custom receiver type, if applicable
    		i.receiver.value	- receiver value as defined in the report rule 
    	Output:	-
    	Return: destinations as returned by get.dom.document()
    	EndFunctionUsage
    
    	long	destination
    	domain	tccfrw		carrier
    	domain	tcmail		email
    
    	dom.init()
    
    	carrier = i.receiver.value
    	email = get.email(carrier)
    
    	if not isspace(email) then
    		| send email to the primary contact
    		destination = dom.destination.new(DOM_DESTINATION_TYPE_EMAIL)
    		dom.destination.set.address(destination, email)
    	endif
    
    	return (dom.get.document())
    }
    
    function string get.email(const	string	i.carrier)
    {
    	domain	tcmail	email
    
    	email = ""
    
    	select	tcmcs080.suno
    	from	tcmcs080
    	where	tcmcs080._index1 = { :i.carrier }
    	as set with 1 rows
    	selectdo
    		select	tccom120.ccnt
    		from	tccom120
    		where	tccom120._index1 = { :tcmcs080.suno }
    		as set with 1 rows
    		selectdo
    			select	tccom140.info:email
    			from	tccom140
    			where	tccom140._index1 = { :tccom120.ccnt }
    			as set with 1 rows
    			selectdo
    			endselect
    		endselect
    	endselect
    
    	return (email)
    }
    
  2. Start the Custom Receiver Types (ttrpi2554m000) session and create a new Custom Receiver Type with these properties:
    • Custom Receiver Type: Carrier
    • Description: Carrier
    • Library: tcmcsdomcarr
  3. Start the Document Types (ttrpi2510m000) session and open the details of Document Type SHIPMENT.
  4. Change these properties:
    • Receiver Type: Custom
    • Custom Receiver Type: Carrier
  5. Save the record and click Validate to validate the document type.
  6. Start the Report Rules (ttrpi2520m000) session and open the details for report whinh443511000.
  7. Change the expression of the receiver field variable to:
    table  twhinh430
    select  whinh430.carr
    from    whinh430
    where   whinh430._index1 = {:whinh431.shpm}
    as set with 1 rows
    selectdo
        return (whinh430.carr)
    endselect
    return(“”)
    
  8. Change the expression of the split field variable to: whinh431.shpm
  9. Save the record and click Validate to validate the report rule.
  10. Start the Print Shipping Discrepancies (whinh4435m000) session. Print to the Document Output Management device and view the result.