You are on page 1of 48

Product specification and design SAP - External Sales and Use Tax System Interface Overview for the

SAP System
For internal use only \INTFSD_E.DOC Version : 1.0 Date : 02/26/96

SAP AG

Neurottstr. 16

D-69190 Walldorf

Fehler! Formatvorlage nicht definiert. Copyright

SAP AG

Copyright
Copyright 1996 SAP AG. All rights reserved. No part of this description of functions may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, WINDOWS and EXCEL and SQL-Server are registered trademarks of Microsoft Corporation. IBM, OS/2, DB2/6000 and AIX are a registered trademark of IBM Corporation. OSF/Motif is a registered trademark of Open Software Foundation. ORACLE is a registered trademark of ORACLE Corporation, California, USA. INFORMIX-OnLine for SAP is a registered trademark of Informix Software Incorporated. UNIX is a registered trademark of SCO Santa Cruz Operation. ADABAS is a registered trademark of Software AG. SAP, R/2, R/3, RIVA, ABAP/4, SAPoffice, SAPmail, SAPaccess, SAPEDI, SAP ArchiveLink, InterSAP, SAP Business Workflow, are registered trademarks of SAP AG.

All rights reserved.

Order information

ii

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface Contents

Contents
Chapter 1: Specification............................................................................................... 1 A.1 Administration....................................................................................................... 1 A.1.1 Author, Date, Status, Version .......................................................................... 1 A.1.2 Project Team................................................................................................... 1 A.1.3 Development requests / customer requirements .............................................. 1 A.1.4 Intended usage for this document / target group .............................................. 2 A.2 Development information /news .......................................................................... 2 A.2.1 Background ..................................................................................................... 2 A.2.2 Graphical Overview......................................................................................... 3 A.2.3 Negative list, possible enhancements ............................................................ 3 A.3 Requirements ........................................................................................................ 4 A.3.1 Functional requirements .................................................................................. 4 A.3.2 Technical requirements ................................................................................... 4 A.3.3 Customizing .................................................................................................... 4 Chapter 2: Design......................................................................................................... 1 B.1 Master Data Maintenance ..................................................................................... 1 B.2 Tax Calculation ..................................................................................................... 3 B.3 External Tax System Update ................................................................................ 4 B.4 Additional functions/Reports ............................................................................... 5 B.5 RFC function modules.......................................................................................... 6 B.5.1 Function module for tax jurisdiction code determination .................................. 6 B.5.2 Function module for tax calculation ................................................................. 6 B.6 Tables / Interfaces to External Systems .............................................................. 6 B.6.1 COM_ERR - SAP link area for the error message handling ............................. 7 B.6.2 COM_ERR - SAP link area for the tax jurisdiction code determination............. 8 B.6.3 COM_TAX - SAP link area for the tax calculation function............................... 9

January 29, 1996

iii

SAP AG

SAP - External Sales and Use Tax System Interface

Chapter 1: Specification
A.1 Administration
A.1.1 Author, Date, Status, Version
Author: Date: Status: Version: Gert Bizer 02/26/96 draft 1.0

A.1.2 Project Team


Greg Tedesco Jrg Wiederspohn Kemal Kksal Gert Bizer

A.1.3 Development requests / customer requirements


The design of the interface is based on development request no. 204420/1994. Many U.S. businesses are accustomed to using a software package to keep abreast of these tax rules and rates. There is essentially no competitive or strategic advantage for a company to maintain its own sales and use tax data: tax collection, remittance and reporting is a requirement and is a cost of doing business. However, failure to comply with the state tax regulations can result in penalties. By utilizing an external sales tax service, customers may be able to minimize these costs while more effectively collecting and reporting for the taxing jurisdictions. Companies which use a standard tax collection and reporting package with which an auditor is familiar may actually lessen the burden of such an audit as the auditor will probably be familiar (and hopefully comfortable) with the method used for tax collection and reporting. Because of the above scenarios, and the fact that maintaining large amounts of tax data within SAP is a cumbersome task, many customers with a significant portion of transactions (especially sales transactions) subject to tax have requested that SAP make an interface available to an external sales and use tax software system. These software packages generally provide tax rate data, tax rule processing logic, and a sales and use tax reporting mechanism. In order to be viable, a tax interface should ideally remove from SAP all tax decisions, maintenance, and processing logic. This information should reside with the tax software; thereby maintaining transaction data within SAP and tax information within the tax package. If this separation can be accomplished there should be no need for maintenance

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

to the SAP system in the event of tax changes so long as the tax software and rates are kept current. The best solution combining both rate and rule processing would be to link from SAP to the vendor package giving the tax software all required line item data. The package can then determine tax based upon its complete system of rates and processing logic and return the tax data to SAP. SAP can then move the tax amounts into the line item as manual condition records for inclusion into the appropriate document.

A.1.4 Intended usage for this document / target group


This document is intended to be used by partners. It contains the necessary information which enables the partners to create the non-SAP part of the SALESTAX interface.

A.2 Development information /news


A.2.1 Background
It is possible for each individual state, county, city and local taxing municipality (e.g. transit authority, water district, etc.) within the U.S. to have applicable sales and use tax on a given transaction. Whether a transaction is applicable to one or more of these taxing jurisdictions and the resultant amount of the tax depends upon many factors. These include some combination (depending upon the controlling taxing jurisdiction) of ship-to and ship-from locations or (less frequently) point of order origin and point of order acceptance locations; customer state tax exemptions, product category, customer's nexus or presence within a state, specific intra-state maximum tax rules, and so on. The taxable status of a transaction therefore depends upon the applicable tax rates and the rules associated with the controlling taxing jurisdictions. SAP supports U.S. sales and use tax processing through a combination of tax / jurisdiction tables and condition processing. Theoretically, it would be possible to account for each specific tax rate and rule within the SAP system. In fact, the R/3 system has enhancements made in the area of taxation which permit maintenance of tax rate data for each state, county and city via user-defined jurisdiction codes within the system. In practice, this could potentially require storing up to the currently more than 55,000 taxing jurisdictions within the U.S. (number supplied by tax software vendor) within the jurisdiction code table. Additionally, taxing jurisdictions will occasionally change their rates or rules regarding the tax consequences sales transactions. This requires that someone be responsible for keeping the tax data current across these jurisdictions. It should be noted that the process allows for capture and application of tax rates, but does not include processing for many of the special tax rules which may also be included within a particular transaction. These could potentially be coded as well, if one is aware of how these rules are to be applied.

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

A.2.2 Graphical Overview

SAP delivery and maintenance

Partner delivery and maintenance

SAP application programs (R/3 FI,MM,SD)

SALESTAX Tax-API (SAP-part) RFC SAP Tax Link Area

SALESTAX Tax-API (Partner-part)

Partner application programs

Partner link area

- fill SAP link area - initiate RFC communication - receive SAP link area - Error handling

- accept SAP link area - map to Partner link area - call Partners programs - map to SAP link area - prepare error handling

Fig. 1: General process overview of the sales tax interface


From R/3 Release 3.0B on SAP delivers a standard interface for sales and use tax calculation. From SAP standard functions (i.e. order entry) the tax interface is called as a background function. Transaction data is collected and transferred to an external tax system using the SAP Tax Link Area. An external system has to accept the data, execute the necessary calculations and pass the results back to SAP using the SAP Tax Link Area. This data is then used by the SAP standard functions. The external system has therefore to supply a C program which works with the standard SAP RFC library. This program must be able to handle the SAP data and initiate the necessary processes of the external tax system. The certified tax software vendors deliver both, their software (referred to as Partner application program in the graphic above) plus the communication program (referred to as SALESTAX Tax-API).

A.2.3 Negative list, possible enhancements


Negativ list (List of functions not contained that could be expected), outlook

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

A.3 Requirements
A.3.1 Functional requirements
There are three critical points where an interface between SAP and a sales and use tax software package must occur: A) Master data maintenance: the interface is required here so that the proper keys to the tax software can be stored on the SAP customer, plant, asset, cost center, internal order, and vendor master file record(s) so that the two systems can successfully link. Note: For assets and internal orders there is no automatic jurisdiction code determination possible because these objects do not carry address information. B) Tax calculation: access the tax software to move the appropriate tax amounts to the SAP document. C) External tax system update: update the databases of the external tax system for later audit and/or tax return reporting.

A.3.2 Technical requirements A.3.3 Customizing

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

Chapter 2: Design
The design is based on the above mentioned requirements (A, B, C).

B.1 Master Data Maintenance


In order for SAP to later ensure a valid read against the appropriate tax rate file, SAP will call the external tax system during master data maintenance to store matching data on the SAP master file. In the event that there are multiple possibilities for the tax jurisdiction, a pop-up window will prompt the person entering the data to select from the possible entries (this generally happens when a city or zip code is in more than one county). By synchronizing the tax jurisdiction data at this point, there should be no situations where a jurisdiction is not found during time of rate calculation. The external tax system is called in an online mode. The result is shown immediately after a successful return from the external tax system.
SAP master Data maintenance Address entry - customer - vendor - cost center - plant SD order entry - change ship-to partner SAP-Vertex Tax-API RFC Server of external tax system External tax system

RFC SAP link area (COM_JUR) Ext. communication area

Fig. 2: Process of external tax jurisdiction determination


Within the master data transactions mentioned in figure 2, the function module DETERMINE_TXJCD_EXTERNALLY is called. This function module collects the necessary data for the determination of a tax jurisdiction code and calls function module RFC_DETERMINE_JURISDICTION. This function module is responsible for the external data transfer. The external determination of the tax jurisdiction code occurs during master data maintenance, using the address data of the master record. The minimum information to be passed to the external system is the state and zip code. The following entities are supported for external tax jurisdiction code determination: Customer master Vendor master

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

Cost center master (time-dependent data) Plant

The external determination of a tax jurisdiction code is also performed at change of the ship-to address during order entry.

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

Note:
For other master data (project WBS element, Internal order, Fixed Asset), the external determination of the tax jurisdiction code is not possible, since these elements do not carry appropriate address data. In those elements, the tax jurisdiction code can either be entered manually or can be defaulted from the responsible cost center.

B.2 Tax Calculation


Taxes are calculated in the following areas: SD: Quotations, Sales Orders, Billing documents. MM: Purchase Orders, Invoice Verification FI: A/P, A/R, G/L Each line item within a document can potentially have different properties which affect the taxable status of that line item. Therefore, taxes must be calculated at a line item level. As in the jurisdiction interface, SAP will call the tax system via RFC to extract the appropriate tax rates and amounts (rates are used for display only). This call will be performed by exiting pricing via a formula routine specified in the tax calculation procedure and the SD pricing procedure. Taxes are calculated on a line item basis in SD and MM (purchasing only). In MM Invoice Verification and FI the data is accumulated based on tax code and jurisdiction code (at the end of document processing, taxes are calculated for the each level of tax code and jurisdiction). At the point of tax calculation, the necessary data (i.e. ship-from jurisdiction code, ship-to jurisdiction code, point of order acceptance jurisdiction code, point of order origin jurisdiction code, tax base amount, tax date, etc.) is gathered and stored in the tax link area (COM_TAX). The external tax system is called in an online mode. The result is shown immediately after a successful return from the external tax system.

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

SAP document processing - SD - MM - FI

SAP-Vertex Tax-API

RFC Server of external tax system

External tax system

RFC SAP link area (COM_TAX) Ext. communication area

Fig. 3: Process of external tax calculation determination


Within the transactions mentioned in figure 3, the a formula (FV64A300) is called through condition technique. This formula handles the data, which is necessary for the calculation of sales and use taxes and calls function module RFC_CALCULATE_TAXES. This function module is responsible for the external data transfer. The tax link area contains all of the information the tax system requires to calculate jurisdiction and the appropriate tax rates and amounts. Once the tax call is complete, rates and amounts are returned to SAP at state, county, city and local taxing jurisdiction levels. The tax amounts and rates are then inserted into the individual line item. Amounts are used because in some instances (i.e. maximum tax), tax rules make the actual amount different than if calculated directly from the rate. The rates are inserted into the line items for display and reporting purposes only. For example, some states have a maximum line item tax. Assume customer XYZ purchases 100 units of product A1234 for $100.00 each. The applicable state sales tax is 6% but there is a maximum tax of $500.00 on a line item in that state. If the calculated amount were based on the rate (6%) then the result would be $600.00, but in this case the external system will calculate and return an amount of $500.00 and a rate of 6%. This illustrates why it is important to use the tax amounts from the tax interface rather than the tax rates. The interface currently provides for ten levels per line item. Currently, only six of tehm are used. These are: state, county, city and three local jurisdictions (e.g. transit or municipal service designations).

B.3 External Tax System Update


The 3rd party tax packages provide customers with services including tax audit reporting and tax returns. These external tax packages require information from the SAP R/3 system in order to provide these services. The external tax packages currently do not support dynamic transaction backout for all of their databases. Therefore, SAP has chosen not to update these packages realtime. SAP uses a 3 step procedure for updating the external tax packages.

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

Step 1: at time of document creation, the tax calculation details are stored in the internal memory of the tax calculation modules. As soon as the document is posted into FI, the data is removed from the internal memory and stored into a table (TTXY). This table contains all COM_TAX data by document number and item number. This allows to have more detailed information available, especially for SD documents. Step 2: at time of FI document posting a special index (TTXI) is updated for all tax relevant documents. Step 3: SAP provides 2 programs (RFYTXD00 and RFYTXU00) which use the index (TTXI,TTXY), along with the document tax information (BSET), to update the external tax package. The index is then updated with status information (i.e. update successful or not successful).

B.4 Additional functions/Reports


To allow better handling with the SALESTAX interface, the following additional functions are available: Display utility for the update functionality index table (TTXI). This tool allows to monitor the actual status of the update of the external tax systems databases including error message handling. It is also possible, to initiate a forced update procedure (Report RFYTXF00) for records which are not updateing automatically. The name of the display utility is RFYTXD00. Forced update utility to update the external tax systems register/audit databases. In some cases, the external recalculation of a document leads to other values than those which are stored in the FI document. In this case the automatic update of the external tax systems fails. For these cases the forced update can be initiated thru the display utility (Report RFYTXD00). The name of the display utility is RFYTXF00. Master data conversion utility (RFYTXM00). This report allows to determine new tax jurisdiction codes for the customer master, vendor master, cost center and plant in a mass data run. Actually (Release 3.0C), an update of these data elements is not realized, but will be available in a later version. Global mass conversion tool. This tool will allow to perform all redeterminations of the tax jurisdiction code including the master data tables (Report RFYTXM00). It will also allow for redetermination of the tax jurisdiction code in purchase orders.

Following additional features are planned for later versions:

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

B.5 RFC function modules


B.5.1 Function module for tax jurisdiction code determination
The function module RFC_DETERMINE_JURISDICTION is used for the external determination of a tax jurisdiction code. It contains no special logic. This function module is called from function module DETERMINE_TXJCD_EXTERNALLY. Parameters for that function module are: --> Input Structure COM_JUR --> Output Structure COM_ERR --> Tables Structure COM_JUR Note: For the output of resutlts, structure COM_TAX is returned in table format, since multiple results are possible.

B.5.2 Function module for tax calculation


The function module RFC_CALCULATE_TAXES is used for the external calculation of taxes. It contains no special logic.This function module is called from Program SAPLV61A (Form FV64A300). Parameters for that function module are:

--> Input Structure COM_TAX --> Output Structure COM_TAX --> Structure COM_ERR

B.6 Tables / Interfaces to External Systems


The following interface structures are used to exchange data with external systems: COM_ERR - defines the SAP link area for the error message handling COM_JUR - defines the SAP link area for the tax jurisdiction code determination

COM_TAX - defines the SAP link area for the tax calculation function

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

B.6.1 COM_ERR - SAP link area for the error message handling
The structure COM_ERR defines the SAP link area for the error message handling. An explanation of the possible field types is given at the end of this section. SAP Field Name RETCODE Length char01 Field Type C Input Output X Comment Return code (note: '0' = determination successful, other values = determination not successful) Application specific error code (to be displayed in SAP online error message) Application specific error message (to be displayed in SAP online error message)

ERRCODE

char04

ERRMSG

char72

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

B.6.2 COM_ERR - SAP link area for the tax jurisdiction code determination
The structure COM_JUR defines the SAP link area for the tax jurisdiction code determination. An explanation of the possible field types is given at the end of this section. SAP Field Name COUNTRY STATE COUNTY CITY ZIPCODE TXJCD_L1 Length char03 char03 char35 char35 char10 char02 Field Type C C C C C C Input X X X X X X X X X X Output Comment Country key (ISO code to be expected) State code County name City name Zipcode Length of first structure element of the Tax Jurisdiction Code (usually used for the state code) Length of second structure element ot the tax jurisdiction code (used for state or Zipcode) Length of third structure element of the tax jurisdiction code (used for Geocode or Citycode) Length of fourth structure element of the tax jurisdiction code (probably used for the city in/out indicator) X Tax jurisdiction code (note: SAP expects the full tax jurisdiction code, i.e. state/county/city/.. or state/zipcode/geocode in this field) Indicator: location is out of city

TXJCD_L2

char02

TXJCD_L3

char02

TXJCD_L4

char02

TXJCD

char15

OUTOF_CITY

char01

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

B.6.3 COM_TAX - SAP link area for the tax calculation function
The structure COM_TAX defines the SAP link area for the tax calculation function. An explanation of the possible field types is given at the end of this section. SAP Field Name CLIENT Length char03 Field Type C Input X Output Comment SAP Client (note: this field might be used for sepparation of audit file records, if a company uses more than one SAP client with the external tax interface Company code (note: this field will be filled always by the SAP company code) Division Code (note: this field will be filled with the actual SAP business area when available) country key (ISO code to be expected) Document number of the financial or sales document (No. of financial doc document / No. of SD billing document), used for updating the audit file/sales tax register Item number of the financial or sales document (No. of financial doc document / No. of SD billing document), used for updating the audit file/sales tax register Customer (A/R) or vendor (A/P) account number Customer (A/R) or vendor (A/P) account class (note: this field is currently not supported by SAP, it can be filled in an SAP User-Exit by the customer)

COMP_CODE

char04

DIVISION

char04

COUNTRY DOC_NUMBER

char03 char10

C C

X X

POS_NO

char06

ACCNT_NO ACCNT_CLS

char16 char10

C C

X X

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

SAP Field Name TAX_DATE TXJCD_ST TXJCD_SF TXJCD_POA

Length char08 char15 char15 char15

Field Type D C C C

Input X X X X

Output

Comment Date for tax calculation Tax Jurisdiction Code of the shipto Tax Jurisdiction Code of the shipfrom "Tax Jurisdiction Code of the point of order acceptance (note: this field is currently not supported by SAP, it can be filled in an SAP User-Exit by the customer; if not specified by the customer, this field is defaulted from the shipfrom)" "Tax Jurisdiction Code of the point of order origin (note: this field is currently not supported by SAP, it can be filled in an SAP User-Exit by the customerr; if not specified by the customer, this field is defaulted from the shipto)"

TXJCD_POO

char15

TXJCD_IND

char01

"Indicates which tax jurisdiction code is used(note: values: '1' = ST, '2' = SF, '3' = POA, '4' = POO; this field is currently not supported by SAP, it can be filled in an SAP User-Exit by the customer)" "Indicates which Jurisdiction is the Point of Title Passage(note: values: '0' = ST, '1' = SF; this field is currently not supported by SAP, it can be filled in an User-Exit by the customer) " "Indicates, whether the actual transaction is an accounts payable or an accounts receivable transaction. The value is filled

PTP_IND

char01

APAR_IND

char01

10

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

SAP Field Name

Length

Field Type

Input

Output

Comment from SAP T007A; values: 'A' = accounts receivable, 'V' = accounts payable)"

TXJCD_L1

char02

Length of first structure element of the Tax Jurisdiction Code (usually used for the state code) Length of second structure element ot the tax jurisdiction code (used for state or Zipcode) Length of third structure element of the tax jurisdiction code (used for Geocode or Citycode) Length of fourth structure element of the tax jurisdiction code (probably used for the city in/out indicator) X Type of tax -sales/use/service/ lease/... (note: values:' ' or '0' = Sales Tax, '1' = Consumer Use Tax, '2' = Service Tax, '3' = Rental/Lease Tax, other values could be later defined) Material number Product code (from SAP-table TTXP - user defined) Item quantity (note: this value is not available for all SAP transactions i.e. not for financial documents) Unit of item quantity (note: this value is not available for all SAP transactions i.e. not for financial documents) Gross Amount Document currency (note: ISO

TXJCD_L2

char02

TXJCD_L3

char02

TXJCD_L4

char02

TAX_TYPE

char01

MATNR PROD_CODE QUANTITY

char18 char10 char13

C C Q

X X X

UNIT

char03

AMOUNT CURRENCY

char15 char05

A C

X X

February 1996

11

SAP - External Sales and Use Tax System Interface

SAP AG

SAP Field Name

Length

Field Type C

Input X

Output

Comment currency code to be expected)

CURR_DEC

char03

Number of decimals used for the currency in the SAP-system (note: value comes out of TCURXCURRDEC) Freight Amount (note: this field is currently not used by SAP) Tax exempt amount (note: this field is currently not used by SAP) "Tax exempt indicator (note: values: ' ' or '0' = decision about taxability always external, '1' = transaction is taxable, '2' = transaction is non-taxable;this field is currently not used by SAP,SAP defaults '0')" "Indicates whether the transaction is doing a tax credit or tax debit (note: this is used for the update of the sales tax register/audit file; values: ' ' or '0' = debit, '1' = credit) " Update indicator (note: 'X' = update, ' ' = no update to sales tax register/audit file) "Overwrite indicator (note: 'X' = overwrite, ' ' = no overwrite; G78 this indicator tells the external tax systems not to recalculate the taxes but to use the given amounts and rates; this is used for the update of the sales tax register/audit file only) " X "Federal tax percentage (note: Within SAP only used for display purposes; currently not used by

FREIGHT_AM EXEMPT_AMT EXEMPT_IND

char15 char15 char01

A A C

X X X

CREDIT_IND

char01

UPDATE_IND

char01

OVRWRT_IND

char01

TAXPCT0

char15

12

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

SAP Field Name

Length

Field Type P

Input X

Output X

Comment SAP)"

TAXPCT1

char15

State tax percentage (note: Within SAP only used for display purposes) County tax percentage (note: Within SAP only used for display purposes) City/local tax percentage (note: Within SAP only used for display purposes) District/secondary county tax percentage (note: Within SAP only used for display purposes) Secondary city tax percentage (note: Within SAP only used for display purposes) Other tax percentage (note: Within SAP only used for display purposes) "Other tax percentage (note: Within SAP only used for display purposes; currently not used by SAP)" "Other tax percentage (note: Within SAP only used for display purposes; currently not used by SAP)" "Other tax percentage (note: Within SAP only used for display purposes; currently not used by SAP)" Overall combined tax percentage (note: currently not used by SAP) Federal tax amount (note: currently not used by SAP)

TAXPCT2

char15

TAXPCT3

char15

TAXPCT4

char15

TAXPCT5

char15

TAXPCT6

char15

TAXPCT7

char15

TAXPCT8

char15

TAXPCT9

char15

TAXPCOV TAXAMT0

char15 char15

P A

X X

X X

February 1996

13

SAP - External Sales and Use Tax System Interface

SAP AG

SAP Field Name TAXAMT1 TAXAMT2 TAXAMT3 TAXAMT4 TAXAMT5 TAXAMT6 TAXAMT7 TAXAMT8 TAXAMT9 TAXAMOV TAXBAS0

Length char15 char15 char15 char15 char15 char15 char15 char15 char15 char15 char15

Field Type A A A A A A A A A A A

Input X X X X X X X X X X X

Output X X X X X X X X X X X

Comment State tax amount County tax amount City/local tax amount District/secondary county tax amount Secondary city tax amount Other tax amount Other tax amount (note: currently not used by SAP) Other tax amount (note: currently not used by SAP) Other tax amount (note: currently not used by SAP) Overall tax amount (note: currently not used by SAP) "Federal tax base amount (note: Within SAP only used for display purposes; currently not used by SAP; only to be filled if different from AMOUNT field)" "State tax base amount (note: Within SAP only used for display purposes; only to be filled if different from AMOUNT field)" "County tax base amount (note: Within SAP only used for display purposes; only to be filled if different from AMOUNT field)" "City/local tax base amount (note: Within SAP only used for display purposes; only to be filled if different from AMOUNT field)" "District/secondary county base

TAXBAS1

char15

TAXBAS2

char15

TAXBAS3

char15

TAXBAS4

char15

14

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

SAP Field Name

Length

Field Type

Input

Output

Comment amount (note: Within SAP only used for display purposes; only to be filled if different from AMOUNT field)"

TAXBAS5

char15

"Secondary city tax base amount (note: Within SAP only used for display ; only to be filled if different from AMOUNT field)" "Other tax base amount (note: Within SAP only used for display purposes; only to be filled if different from AMOUNT field)" "Other tax base amount (note: Within SAP only used for display purposes; currently not used by SAP; only to be filled if different from AMOUNT field)" "Other tax base amount (note: Within SAP only used for display purposes; currently not used by SAP; only to be filled if different from AMOUNT field)" "Other tax base amount (note: Within SAP only used for display purposes; currently not used by SAP; only to be filled if different from AMOUNT field)" Product exemption flag (note: only output parameter, indicates material exemption reason, currently not used by SAP) Customer exemption flag (note: only output parameter, indicates material exemption reason, currently not used by SAP) Federal exempt amount (note:

TAXBAS6

char15

TAXBAS7

char15

TAXBAS8

char15

TAXBAS9

char15

EXMATFLG

char02

EXCUSFLG

char02

EXAMT0

char15

February 1996

15

SAP - External Sales and Use Tax System Interface

SAP AG

SAP Field Name

Length

Field Type A A A A

Input

Output X X X X

Comment currently not used by SAP)

EXAMT1 EXAMT2 EXAMT3 EXAMT4

char15 char15 char15 char15

State exempt amount (note: currently not used by SAP) County exempt amount (note: currently not used by SAP) City/local exempt amount (note: currently not used by SAP) District/secondary county exempt amount (note: currently not used by SAP) Secondary city exempt amount (note: currently not used by SAP) Other exempt amount (note: currently not used by SAP) Other exempt amount (note: currently not used by SAP) Other exempt amount (note: currently not used by SAP) Other exempt amount (note: currently not used by SAP) Federal exempt code (note: currently not used by SAP) State exempt code (note: currently not used by SAP) County exempt code (note: currently not used by SAP) City/local exempt code (note: currently not used by SAP) District/secondary county exempt code (note: currently not used by SAP) Secondary city exempt code (note:

EXAMT5 EXAMT6 EXAMT7 EXAMT8 EXAMT9 EXCODE0 EXCODE1 EXCODE2 EXCODE3 EXCODE4

char15 char15 char15 char15 char15 char02 char02 char02 char02 char02

A A A A A C C C C C

X X X X X X X X X X

EXCODE5

char02

16

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

SAP Field Name

Length

Field Type C C C C C

Input

Output X X X X

Comment currently not used by SAP)

EXCODE6 EXCODE7 EXCODE8 EXCODE9 EXCERTIF

char02 char02 char02 char02 char25

Other exempt code (note: currently not used by SAP) Other exempt code (note: currently not used by SAP) Other exempt code (note: currently not used by SAP) Other exempt code (note: currently not used by SAP) Number of tax exemption certificate (note: forseen for later use) Reason for tax exemption (note: forseen for later use) User defined field (for reporting purposes)

EXREASON USER_DATA

char02 char50

C C X

February 1996

17

SAP - External Sales and Use Tax System Interface

SAP AG

Possible Field Types : Field Type A Field Description Amount fields Comment Amount fields are right justified, left filled with spaces. The number of digits after the decimal point is variable. The structure field CURR_DEC contans the number of decimal places after the decimal point. If the CURR_DEC field is empty, two (2) decimals have to be assumed. Example1: Currency = US$, decimals of US$ = 2, content of field CURR_DEC = 002 --> 100.00 US$ is passed over in the tax link area as _10000 Example2: Currency = LIT, decimals of LIT = 0, content of field CURR_DEC = 000 --> 100 Lit is passed over in the tax link area as ___100 Negative values have a minus sign (-) at the last digit of the field. Example: A negative amount of minus 100.00 US$ is passed over in the tax link area amount field as 10000-. C D P Character fields Date fields Percent fields Character fields are all left justified, right filled with spaces. Date fields are in the format character(8) completely filled. Structure: YYYYMMDD. Percent fields are right justified, left filled with spaces. They are assumed to have three (3) digits after the decimal point within SAP. In the communication structure, no decimal point is used. Example: If SAP displays a percentage as 10.000 the percentage field in the tax link area is filled as _10000. Negative values have a minus sign (-) at the last digit of the field. Example: If a percentage is negative 10.000-the percentage field in the tax link area is filled as 10000-. Q Quantity fields Quantity fiels are similar to percentage fields. Negative values are not allowed.

18

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

Chapter 3: Implementation
C.1 RFC Server Example Program
C.1.1 Header File - saprfcsr.h
/* -----------------------------------------------------------------------------SAP AG - R/3 Remote Function Call Interface Generation RFC_ANSIC_SR_EXP E 30C 02-09-1996 12:44 Complete ANSI C server example saprfcsr.h -----------------------------------------------------------------------------*/ #include #include #include #include #include #include <memory.h> <stdio.h> <stdlib.h> <string.h> "saprfc.h" "sapitab.h"

/* -----------------------------------------------------------------------------Called function RFC_DETERMINE_JURISDICTION importing LOCATION_DATA structure COM_JUR length 110 number of fields 11 exporting LOCATION_ERR structure COM_ERR length 77 number of fields 3 tables LOCATION_RESULTS structure COM_JUR length 110 number of fields 11 exceptions -----------------------------------------------------------------------------*/ /* structure type definition */ #ifndef SAP_ST_COM_JUR #define SAP_ST_COM_JUR typedef struct { RFC_CHAR Country[3]; RFC_CHAR State[3]; RFC_CHAR County[35]; RFC_CHAR City[35]; RFC_CHAR Zipcode[10]; RFC_NUM TxjcdL1[2]; RFC_NUM TxjcdL2[2]; RFC_NUM TxjcdL3[2]; RFC_NUM TxjcdL4[2]; RFC_CHAR Txjcd[15]; RFC_CHAR OutofCity[1]; } COM_JUR; #endif #ifndef SAP_ST_COM_ERR #define SAP_ST_COM_ERR typedef struct { RFC_CHAR Retcode[1]; RFC_NUM Errcode[4]; RFC_CHAR Errmsg[72]; } COM_ERR; #endif /* ------------------------------------------------------------------------------

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

Called function RFC_CALCULATE_TAXES importing TAX_DATA structure COM_TAX length 968 number of fields 91 exporting TAX_ERR structure COM_ERR length 77 number of fields 3 TAX_RESULT structure COM_TAX length 968 number of fields 91 tables exceptions -----------------------------------------------------------------------------*/ /* structure type definition */ #ifndef SAP_ST_COM_TAX #define SAP_ST_COM_TAX typedef struct { RFC_CHAR Client[3]; RFC_CHAR CompCode[4]; RFC_CHAR Division[4]; RFC_CHAR Country[3]; RFC_CHAR DocNumber[10]; RFC_NUM PosNo[6]; RFC_CHAR AccntNo[16]; RFC_CHAR AccntCls[10]; RFC_CHAR TaxDate[8]; RFC_CHAR TxjcdSt[15]; RFC_CHAR TxjcdSf[15]; RFC_CHAR TxjcdPoa[15]; RFC_CHAR TxjcdPoo[15]; RFC_CHAR TxjcdInd[1]; RFC_CHAR PtpInd[1]; RFC_CHAR AparInd[1]; RFC_NUM TxjcdL1[2]; RFC_NUM TxjcdL2[2]; RFC_NUM TxjcdL3[2]; RFC_NUM TxjcdL4[2]; RFC_CHAR TaxType[1]; RFC_CHAR Matnr[18]; RFC_CHAR ProdCode[10]; RFC_CHAR Quantity[13]; RFC_CHAR Unit[3]; RFC_CHAR Amount[15]; RFC_CHAR Currency[5]; RFC_CHAR CurrDec[3]; RFC_CHAR FreightAm[15]; RFC_CHAR ExemptAmt[15]; RFC_CHAR ExemptInd[1]; RFC_CHAR CreditInd[1]; RFC_CHAR UpdateInd[1]; RFC_CHAR OvwrtInd[1]; RFC_CHAR Taxpct0[15]; RFC_CHAR Taxpct1[15]; RFC_CHAR Taxpct2[15]; RFC_CHAR Taxpct3[15]; RFC_CHAR Taxpct4[15]; RFC_CHAR Taxpct5[15]; RFC_CHAR Taxpct6[15]; RFC_CHAR Taxpct7[15]; RFC_CHAR Taxpct8[15]; RFC_CHAR Taxpct9[15]; RFC_CHAR Taxpcov[15]; RFC_CHAR Taxamt0[15]; RFC_CHAR Taxamt1[15]; RFC_CHAR Taxamt2[15]; RFC_CHAR Taxamt3[15]; RFC_CHAR Taxamt4[15]; RFC_CHAR Taxamt5[15]; RFC_CHAR Taxamt6[15]; RFC_CHAR Taxamt7[15]; RFC_CHAR Taxamt8[15]; RFC_CHAR Taxamt9[15];

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR RFC_CHAR #endif

Taxamov[15]; Taxbas0[15]; Taxbas1[15]; Taxbas2[15]; Taxbas3[15]; Taxbas4[15]; Taxbas5[15]; Taxbas6[15]; Taxbas7[15]; Taxbas8[15]; Taxbas9[15]; Exmatflg[2]; Excusflg[2]; Examt0[15]; Examt1[15]; Examt2[15]; Examt3[15]; Examt4[15]; Examt5[15]; Examt6[15]; Examt7[15]; Examt8[15]; Examt9[15]; Excode0[2]; Excode1[2]; Excode2[2]; Excode3[2]; Excode4[2]; Excode5[2]; Excode6[2]; Excode7[2]; Excode8[2]; Excode9[2]; Excertif[25]; Exreason[2]; UserData[50]; } COM_TAX;

#ifndef SAP_ST_COM_ERR #define SAP_ST_COM_ERR typedef struct { RFC_CHAR Retcode[1]; RFC_NUM Errcode[4]; RFC_CHAR Errmsg[72]; } COM_ERR; #endif

C.1.2 Main Program - saprfcsr.c


/* -----------------------------------------------------------------------------SAP AG - R/3 Remote Function Call Interface Generation RFC_ANSIC_SR_EXP E 30C 02-09-1996 12:44 Complete ANSI C server example saprfcsr.c -----------------------------------------------------------------------------*/ #include "saprfcsr.h" #ifdef SAPonWINDOWS #include <io.h> #endif #if !defined(SAPonWINDOWS) && !defined(SAPonNT) #define __min(a,b) (((a)<(b))?(a):(b)) #endif static char gh; static FILE *infile,*outfile,*logfile; void LOG(const RFC_HANDLE hRfc, const char *text,const char *str)

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

{ if (logfile!=NULL) { fprintf(logfile,"%d %s %s\n",hRfc,text,str); fflush(logfile); } } #define OUT(text,pos) printf("%*.0s",pos,text); printf("%s\n",text); if (outfile!=NULL) fprintf(outfile,"=%s\n",text) #define NL printf("\n") typedef void (* RFC_HELP)(const char *topic, const char *subtopic, const char *text); static RFC_HELP rfc_help; void WIN_DLL_EXPORT_FLAGS hlp_rfc_determine_jurisdiction(const char *topic, const char *subtopic, const char *text); void WIN_DLL_EXPORT_FLAGS hlp_rfc_calculate_taxes(const char *topic, const char *subtopic, const char *text); void help(const char *topic, const char *subtopic, const char *text) { /* general help */ if (strcmp(topic,"h")==0) { OUT("This is a server example programm for SAP Remote Function Call.",6); OUT("The program was generated by the R/3 RFC Interface Generator.",6); OUT("For further information about the example see saprfcsr.txt.",6); OUT("To get help using the example, answer '?' on any item.",6); OUT("The example has been generated for function module:",6); NL; OUT("- RFC_DETERMINE_JURISDICTION",8); OUT(" Ermittlung des Jurisdictioncodes durch ein externes System.",8); NL; } /* program arguments help */ if (strcmp(topic,"s")==0) { OUT("Starting the generated external server you can use the following",6); OUT("additional program arguments:",6); NL; OUT("-i <filename> input from file",8); OUT("-o <filename> output to file",8); OUT("-log <filename> log events file",8); OUT("-? this text",8); NL; } /* input help */ if (strcmp(topic,"i")==0) { OUT("To input function module parameters, answer 'y' and type in",6); OUT("parameter values and append table rows if necessary.",6); NL; } if ((strcmp(topic,"isi")==0)||(strcmp(topic,"esi")==0)) { OUT("To fill in the structure, answer 'y' and type in structure fields.",10); NL; } if ((strcmp(topic,"iso")==0)||(strcmp(topic,"eso")==0)) { OUT("To display the structure fields, answer 'y'.",10); NL; } if (strcmp(topic,"ti")==0) { OUT("To append a table row, answer 'y' and type in table row fields.",10); NL; } if (strcmp(topic,"to")==0) { OUT("To get the table row and display the row fields, answer 'y' or '*' for all rows.",10); NL; } if (strcmp(topic,"xi")==0) { OUT("Terminates the function. To raise the exception, answer 'y'.",10); NL; } if (strcmp(topic,"xo")==0) { OUT("Terminated the called function.",10); NL; } if (strcmp(topic,"c")==0) { OUT("To call the function module, answer 'y'.",6); NL; } if (strcmp(topic,"a")==0) { OUT("To call the function module again, answer 'y'.",6); NL; } /* end info */ if (strcmp(topic,"end")==0) { OUT("Thank you for using the SAP Business Application Programming Interface",2); OUT("and SAP Remote Function Call. For further information please call us at:",2); OUT("SAP America Inc. Western Regional Office 950 Towerlane Foster City",2); OUT("CA 94404-2127, Phone (+1) 415 637 1655 FAX (+1) 415 637 9592 or",2); OUT("SAP AG Basisvertrieb Postbox 1461 D-69185 Walldorf Germany,",2);

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

OUT("Phone (+49) 6227 34 1763 FAX (+49) 6227 34 1880.",2); NL; } if (rfc_help!=NULL) rfc_help(topic, subtopic, text); } void INS(const char *topic,const char *subtopic,const char *text,const unsigned pos,const unsigned len,char *str) { int c=0; do { printf("%*.0s",pos,text); printf("%-*s : ",len,text); if (infile!=NULL) { /* read from input file comparing input event (text) */ do { c=getc(infile); if (c==EOF) { OUT("error reading input file",0); exit(1); } fgets(str,256,infile); *(str+strlen(str)-1) = '\0'; } while ((c!='=')||(strcmp(text,str)!=0)); c=getc(infile); if (c==EOF) { OUT("error reading input file",0); exit(1); } fgets(str,256,infile); *(str+strlen(str)-1) = '\0'; printf("%s\n",str); } /* cut CR/LF and stdout */ else gets(str); /* read from stdin */ if (outfile!=NULL) fprintf(outfile,"=%s\n<%s\n",text,str); /* write output file */ if (str[0]=='?') help(topic,subtopic,text); } while (str[0]=='?'); return; } void OUTS(const char *text,const unsigned pos,const unsigned len,char *str) { printf("%*.0s",pos,text); printf("%-*s : %s\n",len,text,str); if (outfile!=NULL) fprintf(outfile,"=%s\n>%s\n",text,str); return; } #define SETCHAR(var,str) memcpy(var,str,__min(strlen(str),sizeof(var))); \ if (sizeof(var)>strlen(str)) memset(var+strlen(str),' ',sizeof(var)-strlen(str)) #define GETCHAR(var,str) sprintf(str,"%.*s",sizeof(var),var) #define SETDATE(var,str) memcpy(var,str,__min(strlen(str),sizeof(var))); \ if (sizeof(var)>strlen(str)) memset(var+strlen(str),'0',sizeof(var)-strlen(str)) #define GETDATE(var,str) sprintf(str,"%.*s",sizeof(var),var) #define SETFLOAT(var,str) *var=atof(str); #define GETFLOAT(var,str) sprintf(str,"%f",var); #define SETINT(var,str) *var=atol(str); #define GETINT(var,str) sprintf(str,"%ld",var); #define SETNUM(var,str) memcpy(var+(sizeof(var)__min(strlen(str),sizeof(var))),str,__min(strlen(str),sizeof(var))); \ if (sizeof(var)>strlen(str)) memset(var,'0',sizeof(var)strlen(str)) #define GETNUM(var,str) sprintf(str,"%.*s",sizeof(var),var) #define SETTIME(var,str) memcpy(var,str,__min(strlen(str),sizeof(var))); \ if (sizeof(var)>strlen(str)) memset(var+strlen(str),'0',sizeof(var)-strlen(str)) #define GETTIME(var,str) sprintf(str,"%.*s",sizeof(var),var) #define SETINT1(var,str) *var=atoi(str); #define GETINT1(var,str) sprintf(str,"%hu",var); #define SETINT2(var,str) *var=atoi(str); #define GETINT2(var,str) sprintf(str,"%d",var); void WIN_DLL_EXPORT_FLAGS rfc_error(char *operation) { #ifdef SAPonNT char s[16]; #endif RFC_ERROR_INFO RfcErrorInfo;

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

OUT("RFC error",0); OUTS("operation/code",0,15,operation); memset(&RfcErrorInfo,0,sizeof(RfcErrorInfo)); RfcLastError(&RfcErrorInfo); OUTS("key",0,15,RfcErrorInfo.key); OUTS("status",0,15,RfcErrorInfo.status); OUTS("message",0,15,RfcErrorInfo.message); OUTS("internal status",0,15,RfcErrorInfo.intstat); NL; RfcClose (RFC_HANDLE_NULL); #ifdef SAPonNT INS("","","Quit? [y]",4,24,s); #endif exit(1); } /* -----------------------------------------------------------------------------Called function RFC_DETERMINE_JURISDICTION importing LOCATION_DATA structure COM_JUR length 110 number of fields 11 exporting LOCATION_ERR structure COM_ERR length 77 number of fields 3 tables LOCATION_RESULTS structure COM_JUR length 110 number of fields 11 exceptions -----------------------------------------------------------------------------*/ RFC_RC WIN_DLL_EXPORT_FLAGS rfc_determine_jurisdiction(RFC_HANDLE hRfc ,COM_JUR *iLocationData ,COM_ERR *eLocationErr ,ITAB_H thLocationResults ,char *xException) { /* --------------------------------------------------begin of example code replace the example code with your code --------------------------------------------------*/ /* table row variables */ COM_JUR *tLocationResults; unsigned crow; char t; char s[256]; if (!gh) { gh=1; do { INS("h","","Help? ?/[n]",4,24,s); } while (s[0]=='?'); NL; } rfc_help = hlp_rfc_determine_jurisdiction; help("f","",""); /* display importing parameters */ OUT("importing",6); OUT("LOCATION_DATA",8); NL; INS("iso","LOCATION_DATA","Display structure? [y]/n",4,24,s); NL; if ((s[0] != 'n')&&(s[0] != 'N')) { GETCHAR(iLocationData->Country,s); OUTS("COUNTRY",10,30,s); GETCHAR(iLocationData->State,s); OUTS("STATE",10,30,s); GETCHAR(iLocationData->County,s); OUTS("COUNTY",10,30,s); GETCHAR(iLocationData->City,s); OUTS("CITY",10,30,s); GETCHAR(iLocationData->Zipcode,s); OUTS("ZIPCODE",10,30,s); GETNUM(iLocationData->TxjcdL1,s); OUTS("TXJCD_L1",10,30,s); GETNUM(iLocationData->TxjcdL2,s); OUTS("TXJCD_L2",10,30,s); GETNUM(iLocationData->TxjcdL3,s); OUTS("TXJCD_L3",10,30,s); GETNUM(iLocationData->TxjcdL4,s); OUTS("TXJCD_L4",10,30,s); GETCHAR(iLocationData->Txjcd,s); OUTS("TXJCD",10,30,s); GETCHAR(iLocationData->OutofCity,s); OUTS("OUTOF_CITY",10,30,s); OUT("LOCATION_DATA",8); NL; }

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

/* display tables */ OUT("tables",6); sprintf(s,"%d lines",ItFill(thLocationResults)); OUTS("LOCATION_RESULTS",8,32,s); NL; t=0; for (crow = 1;crow <= ItFill(thLocationResults); crow++) { if (t!='*') { INS("to","LOCATION_RESULTS","Get table row? [y]/n",4,24,s); t=s[0]; NL; } if ((s[0] == 'n')||(s[0] == 'N')) break; tLocationResults = ItGetLine(thLocationResults,crow); if (tLocationResults == NULL) rfc_error("ItGetLine LOCATION_RESULTS"); GETCHAR(tLocationResults->Country,s); OUTS("COUNTRY",10,30,s); GETCHAR(tLocationResults->State,s); OUTS("STATE",10,30,s); GETCHAR(tLocationResults->County,s); OUTS("COUNTY",10,30,s); GETCHAR(tLocationResults->City,s); OUTS("CITY",10,30,s); GETCHAR(tLocationResults->Zipcode,s); OUTS("ZIPCODE",10,30,s); GETNUM(tLocationResults->TxjcdL1,s); OUTS("TXJCD_L1",10,30,s); GETNUM(tLocationResults->TxjcdL2,s); OUTS("TXJCD_L2",10,30,s); GETNUM(tLocationResults->TxjcdL3,s); OUTS("TXJCD_L3",10,30,s); GETNUM(tLocationResults->TxjcdL4,s); OUTS("TXJCD_L4",10,30,s); GETCHAR(tLocationResults->Txjcd,s); OUTS("TXJCD",10,30,s); GETCHAR(tLocationResults->OutofCity,s); OUTS("OUTOF_CITY",10,30,s); sprintf(s,"%d of %d lines",crow,ItFill(thLocationResults)); OUTS("LOCATION_RESULTS",8,32,s); NL; } INS("i","","Input? [y]/n",4,24,s); NL; if ((s[0]!='n') && (s[0]!='N')) { /* input export parameters */ OUT("exporting",6); OUT("LOCATION_ERR",8); NL; do { INS("esi","LOCATION_ERR","Fill structure? y/n",4,24,s); } while (s[0]==0); NL; if ((s[0]=='y')||(s[0]=='Y')) { INS("esfi","LOCATION_ERR","RETCODE",10,30,s); SETCHAR(eLocationErr>Retcode,s); INS("esfi","LOCATION_ERR","ERRCODE",10,30,s); SETNUM(eLocationErr>Errcode,s); INS("esfi","LOCATION_ERR","ERRMSG",10,30,s); SETCHAR(eLocationErr>Errmsg,s); OUT("LOCATION_ERR",8); NL; } /* input table rows */ OUT("tables",6); while ("you want") { sprintf(s,"%d lines",ItFill(thLocationResults)); OUTS("LOCATION_RESULTS",8,32,s); NL; do { INS("ti","LOCATION_RESULTS","Append table row? y/n",4,24,s); } while (s[0]==0); NL; if ((s[0] != 'y')&&(s[0] != 'Y')) break; tLocationResults = ItAppLine(thLocationResults); if (tLocationResults == NULL) rfc_error("ItAppLine LOCATION_RESULTS"); INS("tfi","LOCATION_RESULTS","COUNTRY",10,30,s); SETCHAR(tLocationResults>Country,s); INS("tfi","LOCATION_RESULTS","STATE",10,30,s); SETCHAR(tLocationResults>State,s); INS("tfi","LOCATION_RESULTS","COUNTY",10,30,s); SETCHAR(tLocationResults>County,s); INS("tfi","LOCATION_RESULTS","CITY",10,30,s); SETCHAR(tLocationResults>City,s); INS("tfi","LOCATION_RESULTS","ZIPCODE",10,30,s); SETCHAR(tLocationResults>Zipcode,s); INS("tfi","LOCATION_RESULTS","TXJCD_L1",10,30,s); SETNUM(tLocationResults>TxjcdL1,s); INS("tfi","LOCATION_RESULTS","TXJCD_L2",10,30,s); SETNUM(tLocationResults>TxjcdL2,s); INS("tfi","LOCATION_RESULTS","TXJCD_L3",10,30,s); SETNUM(tLocationResults>TxjcdL3,s); INS("tfi","LOCATION_RESULTS","TXJCD_L4",10,30,s); SETNUM(tLocationResults>TxjcdL4,s); INS("tfi","LOCATION_RESULTS","TXJCD",10,30,s); SETCHAR(tLocationResults>Txjcd,s);

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

INS("tfi","LOCATION_RESULTS","OUTOF_CITY",10,30,s); SETCHAR(tLocationResults->OutofCity,s); } } OUT("Returning...",4); NL; /* --------------------------------------------------end of example code --------------------------------------------------*/ return RFC_OK; } RFC_RC WIN_DLL_EXPORT_FLAGS srv_rfc_determine_jurisdiction(RFC_HANDLE hRfc) { /* RFC variables */ RFC_PARAMETER Importing[2]; RFC_PARAMETER Exporting[2]; RFC_TABLE Tables[2]; RFC_RC RfcRc; /* param variables */ COM_JUR iLocationData; COM_ERR eLocationErr; ITAB_H thLocationResults = ITAB_NULL; char xException[256]; /* init export parameters */ SETCHAR(eLocationErr.Retcode,""); SETNUM(eLocationErr.Errcode,""); SETCHAR(eLocationErr.Errmsg,""); /* define import params */ Importing[0].name Importing[0].nlen Importing[0].type Importing[0].leng Importing[0].addr = = = = = "LOCATION_DATA"; 13; TYPC; sizeof(COM_JUR); &iLocationData;

Importing[1].name = NULL; /* define internal tables */ Tables[0].name Tables[0].nlen Tables[0].type Tables[0].leng Tables[0].itmode = = = = = "LOCATION_RESULTS"; 16; TYPC; sizeof(COM_JUR); RFC_ITMODE_BYREFERENCE;

Tables[1].name = NULL; if (RfcGetData(hRfc,Importing,Tables) != RFC_OK) return RfcRc; thLocationResults = Tables[0].ithandle; /* call RFC function */ RfcRc = rfc_determine_jurisdiction(hRfc ,&iLocationData ,&eLocationErr ,thLocationResults ,xException); if (RfcRc == RFC_EXCEPTION) { RfcRaise(hRfc,xException); RfcListen(hRfc); return RfcRc; } /* define export params */ Exporting[0].name = "LOCATION_ERR";

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

Exporting[0].nlen Exporting[0].type Exporting[0].leng Exporting[0].addr

= = = =

12; TYPC; sizeof(COM_ERR); &eLocationErr;

Exporting[1].name = NULL; if (RfcRc == RFC_OK) RfcRc = RfcSendData(hRfc, Exporting, Tables); return RfcRc; } void hlp_rfc_determine_jurisdiction(const char *topic, const char *subtopic, const char *text) { if (strcmp(topic,"f")==0) { OUT("Called function RFC_DETERMINE_JURISDICTION",2); OUT("importing",6); OUT("LOCATION_DATA",8); OUT("exporting",6); OUT("LOCATION_ERR",8); OUT("tables",6); OUT("LOCATION_RESULTS",8); NL; } /* import param help */ if (strcmp(topic,"eso")==0) { if (strcmp(subtopic,"LOCATION_ERR")==0) { OUT("structure COM_ERR",10); OUT("length 77 number of fields 3",10); NL; } } /* export param help */ if (strcmp(topic,"efi")==0) { } if (strcmp(topic,"esi")==0) { if (strcmp(subtopic,"LOCATION_ERR")==0) { OUT("structure COM_ERR",10); OUT("length 77 number of fields 3",10); NL; } } if (strcmp(topic,"esfi")==0) { if (strcmp(subtopic,"LOCATION_ERR")==0) { if (strcmp(text,"RETCODE")==0) { OUT("like COM_ERR-RETCODE",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"ERRCODE")==0) { OUT("like COM_ERR-ERRCODE",12); OUT("type RFC_NUM length 4 init '0'",12); NL; } if (strcmp(text,"ERRMSG")==0) { OUT("like COM_ERR-ERRMSG",12); OUT("type RFC_CHAR length 72 init ' '",12); NL; } } } /* table help */ if ((strcmp(topic,"to")==0)||(strcmp(topic,"ti")==0)) { if (strcmp(subtopic,"LOCATION_RESULTS")==0) { OUT("structure COM_JUR",10); OUT("length 110 number of fields 11",10); NL; } } if (strcmp(topic,"tfi")==0) { if (strcmp(subtopic,"LOCATION_RESULTS")==0) { if (strcmp(text,"COUNTRY")==0) { OUT("like COM_JUR-COUNTRY",12); OUT("type RFC_CHAR length 3 init ' '",12); NL; } if (strcmp(text,"STATE")==0) { OUT("like COM_JUR-STATE",12); OUT("type RFC_CHAR length 3 init ' '",12); NL; } if (strcmp(text,"COUNTY")==0) { OUT("like COM_JUR-COUNTY",12); OUT("type RFC_CHAR length 35 init ' '",12); NL; } if (strcmp(text,"CITY")==0) { OUT("like COM_JUR-CITY",12); OUT("type RFC_CHAR length 35 init ' '",12); NL; } if (strcmp(text,"ZIPCODE")==0) { OUT("like COM_JUR-ZIPCODE",12); OUT("type RFC_CHAR length 10 init ' '",12); NL; } if (strcmp(text,"TXJCD_L1")==0) {

February 1996

SAP - External Sales and Use Tax System Interface

SAP AG

OUT("like COM_JUR-TXJCD_L1",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TXJCD_L2")==0) { OUT("like COM_JUR-TXJCD_L2",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TXJCD_L3")==0) { OUT("like COM_JUR-TXJCD_L3",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TXJCD_L4")==0) { OUT("like COM_JUR-TXJCD_L4",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TXJCD")==0) { OUT("like COM_JUR-TXJCD",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"OUTOF_CITY")==0) { OUT("like COM_JUR-OUTOF_CITY",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } } } return; } /* -----------------------------------------------------------------------------Called function RFC_CALCULATE_TAXES importing TAX_DATA structure COM_TAX length 968 number of fields 91 exporting TAX_ERR structure COM_ERR length 77 number of fields 3 TAX_RESULT structure COM_TAX length 968 number of fields 91 tables exceptions -----------------------------------------------------------------------------*/ RFC_RC WIN_DLL_EXPORT_FLAGS rfc_calculate_taxes(RFC_HANDLE hRfc ,COM_TAX *iTaxData ,COM_ERR *eTaxErr ,COM_TAX *eTaxResult ,char *xException) { /* --------------------------------------------------begin of example code replace the example code with your code --------------------------------------------------*/ char s[256]; if (!gh) { gh=1; do { INS("h","","Help? ?/[n]",4,24,s); } while (s[0]=='?'); NL; } rfc_help = hlp_rfc_calculate_taxes; help("f","",""); /* display importing parameters */ OUT("importing",6); OUT("TAX_DATA",8); NL; INS("iso","TAX_DATA","Display structure? [y]/n",4,24,s); NL; if ((s[0] != 'n')&&(s[0] != 'N')) { GETCHAR(iTaxData->Client,s); OUTS("CLIENT",10,30,s); GETCHAR(iTaxData->CompCode,s); OUTS("COMP_CODE",10,30,s); GETCHAR(iTaxData->Division,s); OUTS("DIVISION",10,30,s); GETCHAR(iTaxData->Country,s); OUTS("COUNTRY",10,30,s); GETCHAR(iTaxData->DocNumber,s); OUTS("DOC_NUMBER",10,30,s); GETNUM(iTaxData->PosNo,s); OUTS("POS_NO",10,30,s); GETCHAR(iTaxData->AccntNo,s); OUTS("ACCNT_NO",10,30,s); GETCHAR(iTaxData->AccntCls,s); OUTS("ACCNT_CLS",10,30,s); GETCHAR(iTaxData->TaxDate,s); OUTS("TAX_DATE",10,30,s); GETCHAR(iTaxData->TxjcdSt,s); OUTS("TXJCD_ST",10,30,s); GETCHAR(iTaxData->TxjcdSf,s); OUTS("TXJCD_SF",10,30,s);

10

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

GETCHAR(iTaxData->TxjcdPoa,s); OUTS("TXJCD_POA",10,30,s); GETCHAR(iTaxData->TxjcdPoo,s); OUTS("TXJCD_POO",10,30,s); GETCHAR(iTaxData->TxjcdInd,s); OUTS("TXJCD_IND",10,30,s); GETCHAR(iTaxData->PtpInd,s); OUTS("PTP_IND",10,30,s); GETCHAR(iTaxData->AparInd,s); OUTS("APAR_IND",10,30,s); GETNUM(iTaxData->TxjcdL1,s); OUTS("TXJCD_L1",10,30,s); GETNUM(iTaxData->TxjcdL2,s); OUTS("TXJCD_L2",10,30,s); GETNUM(iTaxData->TxjcdL3,s); OUTS("TXJCD_L3",10,30,s); GETNUM(iTaxData->TxjcdL4,s); OUTS("TXJCD_L4",10,30,s); GETCHAR(iTaxData->TaxType,s); OUTS("TAX_TYPE",10,30,s); GETCHAR(iTaxData->Matnr,s); OUTS("MATNR",10,30,s); GETCHAR(iTaxData->ProdCode,s); OUTS("PROD_CODE",10,30,s); GETCHAR(iTaxData->Quantity,s); OUTS("QUANTITY",10,30,s); GETCHAR(iTaxData->Unit,s); OUTS("UNIT",10,30,s); GETCHAR(iTaxData->Amount,s); OUTS("AMOUNT",10,30,s); GETCHAR(iTaxData->Currency,s); OUTS("CURRENCY",10,30,s); GETCHAR(iTaxData->CurrDec,s); OUTS("CURR_DEC",10,30,s); GETCHAR(iTaxData->FreightAm,s); OUTS("FREIGHT_AM",10,30,s); GETCHAR(iTaxData->ExemptAmt,s); OUTS("EXEMPT_AMT",10,30,s); GETCHAR(iTaxData->ExemptInd,s); OUTS("EXEMPT_IND",10,30,s); GETCHAR(iTaxData->CreditInd,s); OUTS("CREDIT_IND",10,30,s); GETCHAR(iTaxData->UpdateInd,s); OUTS("UPDATE_IND",10,30,s); GETCHAR(iTaxData->OvwrtInd,s); OUTS("OVWRT_IND",10,30,s); GETCHAR(iTaxData->Taxpct0,s); OUTS("TAXPCT0",10,30,s); GETCHAR(iTaxData->Taxpct1,s); OUTS("TAXPCT1",10,30,s); GETCHAR(iTaxData->Taxpct2,s); OUTS("TAXPCT2",10,30,s); GETCHAR(iTaxData->Taxpct3,s); OUTS("TAXPCT3",10,30,s); GETCHAR(iTaxData->Taxpct4,s); OUTS("TAXPCT4",10,30,s); GETCHAR(iTaxData->Taxpct5,s); OUTS("TAXPCT5",10,30,s); GETCHAR(iTaxData->Taxpct6,s); OUTS("TAXPCT6",10,30,s); GETCHAR(iTaxData->Taxpct7,s); OUTS("TAXPCT7",10,30,s); GETCHAR(iTaxData->Taxpct8,s); OUTS("TAXPCT8",10,30,s); GETCHAR(iTaxData->Taxpct9,s); OUTS("TAXPCT9",10,30,s); GETCHAR(iTaxData->Taxpcov,s); OUTS("TAXPCOV",10,30,s); GETCHAR(iTaxData->Taxamt0,s); OUTS("TAXAMT0",10,30,s); GETCHAR(iTaxData->Taxamt1,s); OUTS("TAXAMT1",10,30,s); GETCHAR(iTaxData->Taxamt2,s); OUTS("TAXAMT2",10,30,s); GETCHAR(iTaxData->Taxamt3,s); OUTS("TAXAMT3",10,30,s); GETCHAR(iTaxData->Taxamt4,s); OUTS("TAXAMT4",10,30,s); GETCHAR(iTaxData->Taxamt5,s); OUTS("TAXAMT5",10,30,s); GETCHAR(iTaxData->Taxamt6,s); OUTS("TAXAMT6",10,30,s); GETCHAR(iTaxData->Taxamt7,s); OUTS("TAXAMT7",10,30,s); GETCHAR(iTaxData->Taxamt8,s); OUTS("TAXAMT8",10,30,s); GETCHAR(iTaxData->Taxamt9,s); OUTS("TAXAMT9",10,30,s); GETCHAR(iTaxData->Taxamov,s); OUTS("TAXAMOV",10,30,s); GETCHAR(iTaxData->Taxbas0,s); OUTS("TAXBAS0",10,30,s); GETCHAR(iTaxData->Taxbas1,s); OUTS("TAXBAS1",10,30,s); GETCHAR(iTaxData->Taxbas2,s); OUTS("TAXBAS2",10,30,s); GETCHAR(iTaxData->Taxbas3,s); OUTS("TAXBAS3",10,30,s); GETCHAR(iTaxData->Taxbas4,s); OUTS("TAXBAS4",10,30,s); GETCHAR(iTaxData->Taxbas5,s); OUTS("TAXBAS5",10,30,s); GETCHAR(iTaxData->Taxbas6,s); OUTS("TAXBAS6",10,30,s); GETCHAR(iTaxData->Taxbas7,s); OUTS("TAXBAS7",10,30,s); GETCHAR(iTaxData->Taxbas8,s); OUTS("TAXBAS8",10,30,s); GETCHAR(iTaxData->Taxbas9,s); OUTS("TAXBAS9",10,30,s); GETCHAR(iTaxData->Exmatflg,s); OUTS("EXMATFLG",10,30,s); GETCHAR(iTaxData->Excusflg,s); OUTS("EXCUSFLG",10,30,s); GETCHAR(iTaxData->Examt0,s); OUTS("EXAMT0",10,30,s); GETCHAR(iTaxData->Examt1,s); OUTS("EXAMT1",10,30,s); GETCHAR(iTaxData->Examt2,s); OUTS("EXAMT2",10,30,s); GETCHAR(iTaxData->Examt3,s); OUTS("EXAMT3",10,30,s); GETCHAR(iTaxData->Examt4,s); OUTS("EXAMT4",10,30,s); GETCHAR(iTaxData->Examt5,s); OUTS("EXAMT5",10,30,s); GETCHAR(iTaxData->Examt6,s); OUTS("EXAMT6",10,30,s); GETCHAR(iTaxData->Examt7,s); OUTS("EXAMT7",10,30,s); GETCHAR(iTaxData->Examt8,s); OUTS("EXAMT8",10,30,s); GETCHAR(iTaxData->Examt9,s); OUTS("EXAMT9",10,30,s); GETCHAR(iTaxData->Excode0,s); OUTS("EXCODE0",10,30,s); GETCHAR(iTaxData->Excode1,s); OUTS("EXCODE1",10,30,s); GETCHAR(iTaxData->Excode2,s); OUTS("EXCODE2",10,30,s); GETCHAR(iTaxData->Excode3,s); OUTS("EXCODE3",10,30,s); GETCHAR(iTaxData->Excode4,s); OUTS("EXCODE4",10,30,s);

February 1996

11

SAP - External Sales and Use Tax System Interface

SAP AG

GETCHAR(iTaxData->Excode5,s); OUTS("EXCODE5",10,30,s); GETCHAR(iTaxData->Excode6,s); OUTS("EXCODE6",10,30,s); GETCHAR(iTaxData->Excode7,s); OUTS("EXCODE7",10,30,s); GETCHAR(iTaxData->Excode8,s); OUTS("EXCODE8",10,30,s); GETCHAR(iTaxData->Excode9,s); OUTS("EXCODE9",10,30,s); GETCHAR(iTaxData->Excertif,s); OUTS("EXCERTIF",10,30,s); GETCHAR(iTaxData->Exreason,s); OUTS("EXREASON",10,30,s); GETCHAR(iTaxData->UserData,s); OUTS("USER_DATA",10,30,s); OUT("TAX_DATA",8); NL; } INS("i","","Input? [y]/n",4,24,s); NL; if ((s[0]!='n') && (s[0]!='N')) { /* input export parameters */ OUT("exporting",6); OUT("TAX_ERR",8); NL; do { INS("esi","TAX_ERR","Fill structure? y/n",4,24,s); } while (s[0]==0); NL; if ((s[0]=='y')||(s[0]=='Y')) { INS("esfi","TAX_ERR","RETCODE",10,30,s); SETCHAR(eTaxErr->Retcode,s); INS("esfi","TAX_ERR","ERRCODE",10,30,s); SETNUM(eTaxErr->Errcode,s); INS("esfi","TAX_ERR","ERRMSG",10,30,s); SETCHAR(eTaxErr->Errmsg,s); OUT("TAX_ERR",8); NL; } OUT("TAX_RESULT",8); NL; do { INS("esi","TAX_RESULT","Fill structure? y/n",4,24,s); } while (s[0]==0); NL; if ((s[0]=='y')||(s[0]=='Y')) { INS("esfi","TAX_RESULT","CLIENT",10,30,s); SETCHAR(eTaxResult->Client,s); INS("esfi","TAX_RESULT","COMP_CODE",10,30,s); SETCHAR(eTaxResult>CompCode,s); INS("esfi","TAX_RESULT","DIVISION",10,30,s); SETCHAR(eTaxResult>Division,s); INS("esfi","TAX_RESULT","COUNTRY",10,30,s); SETCHAR(eTaxResult->Country,s); INS("esfi","TAX_RESULT","DOC_NUMBER",10,30,s); SETCHAR(eTaxResult>DocNumber,s); INS("esfi","TAX_RESULT","POS_NO",10,30,s); SETNUM(eTaxResult->PosNo,s); INS("esfi","TAX_RESULT","ACCNT_NO",10,30,s); SETCHAR(eTaxResult->AccntNo,s); INS("esfi","TAX_RESULT","ACCNT_CLS",10,30,s); SETCHAR(eTaxResult>AccntCls,s); INS("esfi","TAX_RESULT","TAX_DATE",10,30,s); SETCHAR(eTaxResult->TaxDate,s); INS("esfi","TAX_RESULT","TXJCD_ST",10,30,s); SETCHAR(eTaxResult->TxjcdSt,s); INS("esfi","TAX_RESULT","TXJCD_SF",10,30,s); SETCHAR(eTaxResult->TxjcdSf,s); INS("esfi","TAX_RESULT","TXJCD_POA",10,30,s); SETCHAR(eTaxResult>TxjcdPoa,s); INS("esfi","TAX_RESULT","TXJCD_POO",10,30,s); SETCHAR(eTaxResult>TxjcdPoo,s); INS("esfi","TAX_RESULT","TXJCD_IND",10,30,s); SETCHAR(eTaxResult>TxjcdInd,s); INS("esfi","TAX_RESULT","PTP_IND",10,30,s); SETCHAR(eTaxResult->PtpInd,s); INS("esfi","TAX_RESULT","APAR_IND",10,30,s); SETCHAR(eTaxResult->AparInd,s); INS("esfi","TAX_RESULT","TXJCD_L1",10,30,s); SETNUM(eTaxResult->TxjcdL1,s); INS("esfi","TAX_RESULT","TXJCD_L2",10,30,s); SETNUM(eTaxResult->TxjcdL2,s); INS("esfi","TAX_RESULT","TXJCD_L3",10,30,s); SETNUM(eTaxResult->TxjcdL3,s); INS("esfi","TAX_RESULT","TXJCD_L4",10,30,s); SETNUM(eTaxResult->TxjcdL4,s); INS("esfi","TAX_RESULT","TAX_TYPE",10,30,s); SETCHAR(eTaxResult->TaxType,s); INS("esfi","TAX_RESULT","MATNR",10,30,s); SETCHAR(eTaxResult->Matnr,s); INS("esfi","TAX_RESULT","PROD_CODE",10,30,s); SETCHAR(eTaxResult>ProdCode,s); INS("esfi","TAX_RESULT","QUANTITY",10,30,s); SETCHAR(eTaxResult>Quantity,s); INS("esfi","TAX_RESULT","UNIT",10,30,s); SETCHAR(eTaxResult->Unit,s); INS("esfi","TAX_RESULT","AMOUNT",10,30,s); SETCHAR(eTaxResult->Amount,s); INS("esfi","TAX_RESULT","CURRENCY",10,30,s); SETCHAR(eTaxResult>Currency,s); INS("esfi","TAX_RESULT","CURR_DEC",10,30,s); SETCHAR(eTaxResult->CurrDec,s); INS("esfi","TAX_RESULT","FREIGHT_AM",10,30,s); SETCHAR(eTaxResult>FreightAm,s); INS("esfi","TAX_RESULT","EXEMPT_AMT",10,30,s); SETCHAR(eTaxResult>ExemptAmt,s); INS("esfi","TAX_RESULT","EXEMPT_IND",10,30,s); SETCHAR(eTaxResult>ExemptInd,s); INS("esfi","TAX_RESULT","CREDIT_IND",10,30,s); SETCHAR(eTaxResult>CreditInd,s);

12

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

INS("esfi","TAX_RESULT","UPDATE_IND",10,30,s); SETCHAR(eTaxResult>UpdateInd,s); INS("esfi","TAX_RESULT","OVWRT_IND",10,30,s); SETCHAR(eTaxResult>OvwrtInd,s); INS("esfi","TAX_RESULT","TAXPCT0",10,30,s); SETCHAR(eTaxResult->Taxpct0,s); INS("esfi","TAX_RESULT","TAXPCT1",10,30,s); SETCHAR(eTaxResult->Taxpct1,s); INS("esfi","TAX_RESULT","TAXPCT2",10,30,s); SETCHAR(eTaxResult->Taxpct2,s); INS("esfi","TAX_RESULT","TAXPCT3",10,30,s); SETCHAR(eTaxResult->Taxpct3,s); INS("esfi","TAX_RESULT","TAXPCT4",10,30,s); SETCHAR(eTaxResult->Taxpct4,s); INS("esfi","TAX_RESULT","TAXPCT5",10,30,s); SETCHAR(eTaxResult->Taxpct5,s); INS("esfi","TAX_RESULT","TAXPCT6",10,30,s); SETCHAR(eTaxResult->Taxpct6,s); INS("esfi","TAX_RESULT","TAXPCT7",10,30,s); SETCHAR(eTaxResult->Taxpct7,s); INS("esfi","TAX_RESULT","TAXPCT8",10,30,s); SETCHAR(eTaxResult->Taxpct8,s); INS("esfi","TAX_RESULT","TAXPCT9",10,30,s); SETCHAR(eTaxResult->Taxpct9,s); INS("esfi","TAX_RESULT","TAXPCOV",10,30,s); SETCHAR(eTaxResult->Taxpcov,s); INS("esfi","TAX_RESULT","TAXAMT0",10,30,s); SETCHAR(eTaxResult->Taxamt0,s); INS("esfi","TAX_RESULT","TAXAMT1",10,30,s); SETCHAR(eTaxResult->Taxamt1,s); INS("esfi","TAX_RESULT","TAXAMT2",10,30,s); SETCHAR(eTaxResult->Taxamt2,s); INS("esfi","TAX_RESULT","TAXAMT3",10,30,s); SETCHAR(eTaxResult->Taxamt3,s); INS("esfi","TAX_RESULT","TAXAMT4",10,30,s); SETCHAR(eTaxResult->Taxamt4,s); INS("esfi","TAX_RESULT","TAXAMT5",10,30,s); SETCHAR(eTaxResult->Taxamt5,s); INS("esfi","TAX_RESULT","TAXAMT6",10,30,s); SETCHAR(eTaxResult->Taxamt6,s); INS("esfi","TAX_RESULT","TAXAMT7",10,30,s); SETCHAR(eTaxResult->Taxamt7,s); INS("esfi","TAX_RESULT","TAXAMT8",10,30,s); SETCHAR(eTaxResult->Taxamt8,s); INS("esfi","TAX_RESULT","TAXAMT9",10,30,s); SETCHAR(eTaxResult->Taxamt9,s); INS("esfi","TAX_RESULT","TAXAMOV",10,30,s); SETCHAR(eTaxResult->Taxamov,s); INS("esfi","TAX_RESULT","TAXBAS0",10,30,s); SETCHAR(eTaxResult->Taxbas0,s); INS("esfi","TAX_RESULT","TAXBAS1",10,30,s); SETCHAR(eTaxResult->Taxbas1,s); INS("esfi","TAX_RESULT","TAXBAS2",10,30,s); SETCHAR(eTaxResult->Taxbas2,s); INS("esfi","TAX_RESULT","TAXBAS3",10,30,s); SETCHAR(eTaxResult->Taxbas3,s); INS("esfi","TAX_RESULT","TAXBAS4",10,30,s); SETCHAR(eTaxResult->Taxbas4,s); INS("esfi","TAX_RESULT","TAXBAS5",10,30,s); SETCHAR(eTaxResult->Taxbas5,s); INS("esfi","TAX_RESULT","TAXBAS6",10,30,s); SETCHAR(eTaxResult->Taxbas6,s); INS("esfi","TAX_RESULT","TAXBAS7",10,30,s); SETCHAR(eTaxResult->Taxbas7,s); INS("esfi","TAX_RESULT","TAXBAS8",10,30,s); SETCHAR(eTaxResult->Taxbas8,s); INS("esfi","TAX_RESULT","TAXBAS9",10,30,s); SETCHAR(eTaxResult->Taxbas9,s); INS("esfi","TAX_RESULT","EXMATFLG",10,30,s); SETCHAR(eTaxResult>Exmatflg,s); INS("esfi","TAX_RESULT","EXCUSFLG",10,30,s); SETCHAR(eTaxResult>Excusflg,s); INS("esfi","TAX_RESULT","EXAMT0",10,30,s); SETCHAR(eTaxResult->Examt0,s); INS("esfi","TAX_RESULT","EXAMT1",10,30,s); SETCHAR(eTaxResult->Examt1,s); INS("esfi","TAX_RESULT","EXAMT2",10,30,s); SETCHAR(eTaxResult->Examt2,s); INS("esfi","TAX_RESULT","EXAMT3",10,30,s); SETCHAR(eTaxResult->Examt3,s); INS("esfi","TAX_RESULT","EXAMT4",10,30,s); SETCHAR(eTaxResult->Examt4,s); INS("esfi","TAX_RESULT","EXAMT5",10,30,s); SETCHAR(eTaxResult->Examt5,s); INS("esfi","TAX_RESULT","EXAMT6",10,30,s); SETCHAR(eTaxResult->Examt6,s); INS("esfi","TAX_RESULT","EXAMT7",10,30,s); SETCHAR(eTaxResult->Examt7,s); INS("esfi","TAX_RESULT","EXAMT8",10,30,s); SETCHAR(eTaxResult->Examt8,s); INS("esfi","TAX_RESULT","EXAMT9",10,30,s); SETCHAR(eTaxResult->Examt9,s); INS("esfi","TAX_RESULT","EXCODE0",10,30,s); SETCHAR(eTaxResult->Excode0,s); INS("esfi","TAX_RESULT","EXCODE1",10,30,s); SETCHAR(eTaxResult->Excode1,s); INS("esfi","TAX_RESULT","EXCODE2",10,30,s); SETCHAR(eTaxResult->Excode2,s); INS("esfi","TAX_RESULT","EXCODE3",10,30,s); SETCHAR(eTaxResult->Excode3,s); INS("esfi","TAX_RESULT","EXCODE4",10,30,s); SETCHAR(eTaxResult->Excode4,s); INS("esfi","TAX_RESULT","EXCODE5",10,30,s); SETCHAR(eTaxResult->Excode5,s); INS("esfi","TAX_RESULT","EXCODE6",10,30,s); SETCHAR(eTaxResult->Excode6,s); INS("esfi","TAX_RESULT","EXCODE7",10,30,s); SETCHAR(eTaxResult->Excode7,s); INS("esfi","TAX_RESULT","EXCODE8",10,30,s); SETCHAR(eTaxResult->Excode8,s); INS("esfi","TAX_RESULT","EXCODE9",10,30,s); SETCHAR(eTaxResult->Excode9,s); INS("esfi","TAX_RESULT","EXCERTIF",10,30,s); SETCHAR(eTaxResult>Excertif,s); INS("esfi","TAX_RESULT","EXREASON",10,30,s); SETCHAR(eTaxResult>Exreason,s); INS("esfi","TAX_RESULT","USER_DATA",10,30,s); SETCHAR(eTaxResult>UserData,s); OUT("TAX_RESULT",8); NL; } } OUT("Returning...",4); NL;

February 1996

13

SAP - External Sales and Use Tax System Interface

SAP AG

/* --------------------------------------------------end of example code --------------------------------------------------*/ return RFC_OK; } RFC_RC WIN_DLL_EXPORT_FLAGS srv_rfc_calculate_taxes(RFC_HANDLE hRfc) { /* RFC variables */ RFC_PARAMETER Importing[2]; RFC_PARAMETER Exporting[3]; RFC_TABLE Tables[1]; RFC_RC RfcRc; /* param variables */ COM_TAX iTaxData; COM_ERR eTaxErr; COM_TAX eTaxResult; char xException[256]; /* init export parameters */ SETCHAR(eTaxErr.Retcode,""); SETNUM(eTaxErr.Errcode,""); SETCHAR(eTaxErr.Errmsg,""); SETCHAR(eTaxResult.Client,""); SETCHAR(eTaxResult.CompCode,""); SETCHAR(eTaxResult.Division,""); SETCHAR(eTaxResult.Country,""); SETCHAR(eTaxResult.DocNumber,""); SETNUM(eTaxResult.PosNo,""); SETCHAR(eTaxResult.AccntNo,""); SETCHAR(eTaxResult.AccntCls,""); SETCHAR(eTaxResult.TaxDate,""); SETCHAR(eTaxResult.TxjcdSt,""); SETCHAR(eTaxResult.TxjcdSf,""); SETCHAR(eTaxResult.TxjcdPoa,""); SETCHAR(eTaxResult.TxjcdPoo,""); SETCHAR(eTaxResult.TxjcdInd,""); SETCHAR(eTaxResult.PtpInd,""); SETCHAR(eTaxResult.AparInd,""); SETNUM(eTaxResult.TxjcdL1,""); SETNUM(eTaxResult.TxjcdL2,""); SETNUM(eTaxResult.TxjcdL3,""); SETNUM(eTaxResult.TxjcdL4,""); SETCHAR(eTaxResult.TaxType,""); SETCHAR(eTaxResult.Matnr,""); SETCHAR(eTaxResult.ProdCode,""); SETCHAR(eTaxResult.Quantity,""); SETCHAR(eTaxResult.Unit,""); SETCHAR(eTaxResult.Amount,""); SETCHAR(eTaxResult.Currency,""); SETCHAR(eTaxResult.CurrDec,""); SETCHAR(eTaxResult.FreightAm,""); SETCHAR(eTaxResult.ExemptAmt,""); SETCHAR(eTaxResult.ExemptInd,""); SETCHAR(eTaxResult.CreditInd,""); SETCHAR(eTaxResult.UpdateInd,""); SETCHAR(eTaxResult.OvwrtInd,""); SETCHAR(eTaxResult.Taxpct0,""); SETCHAR(eTaxResult.Taxpct1,""); SETCHAR(eTaxResult.Taxpct2,""); SETCHAR(eTaxResult.Taxpct3,""); SETCHAR(eTaxResult.Taxpct4,""); SETCHAR(eTaxResult.Taxpct5,""); SETCHAR(eTaxResult.Taxpct6,""); SETCHAR(eTaxResult.Taxpct7,""); SETCHAR(eTaxResult.Taxpct8,""); SETCHAR(eTaxResult.Taxpct9,"");

14

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

SETCHAR(eTaxResult.Taxpcov,""); SETCHAR(eTaxResult.Taxamt0,""); SETCHAR(eTaxResult.Taxamt1,""); SETCHAR(eTaxResult.Taxamt2,""); SETCHAR(eTaxResult.Taxamt3,""); SETCHAR(eTaxResult.Taxamt4,""); SETCHAR(eTaxResult.Taxamt5,""); SETCHAR(eTaxResult.Taxamt6,""); SETCHAR(eTaxResult.Taxamt7,""); SETCHAR(eTaxResult.Taxamt8,""); SETCHAR(eTaxResult.Taxamt9,""); SETCHAR(eTaxResult.Taxamov,""); SETCHAR(eTaxResult.Taxbas0,""); SETCHAR(eTaxResult.Taxbas1,""); SETCHAR(eTaxResult.Taxbas2,""); SETCHAR(eTaxResult.Taxbas3,""); SETCHAR(eTaxResult.Taxbas4,""); SETCHAR(eTaxResult.Taxbas5,""); SETCHAR(eTaxResult.Taxbas6,""); SETCHAR(eTaxResult.Taxbas7,""); SETCHAR(eTaxResult.Taxbas8,""); SETCHAR(eTaxResult.Taxbas9,""); SETCHAR(eTaxResult.Exmatflg,""); SETCHAR(eTaxResult.Excusflg,""); SETCHAR(eTaxResult.Examt0,""); SETCHAR(eTaxResult.Examt1,""); SETCHAR(eTaxResult.Examt2,""); SETCHAR(eTaxResult.Examt3,""); SETCHAR(eTaxResult.Examt4,""); SETCHAR(eTaxResult.Examt5,""); SETCHAR(eTaxResult.Examt6,""); SETCHAR(eTaxResult.Examt7,""); SETCHAR(eTaxResult.Examt8,""); SETCHAR(eTaxResult.Examt9,""); SETCHAR(eTaxResult.Excode0,""); SETCHAR(eTaxResult.Excode1,""); SETCHAR(eTaxResult.Excode2,""); SETCHAR(eTaxResult.Excode3,""); SETCHAR(eTaxResult.Excode4,""); SETCHAR(eTaxResult.Excode5,""); SETCHAR(eTaxResult.Excode6,""); SETCHAR(eTaxResult.Excode7,""); SETCHAR(eTaxResult.Excode8,""); SETCHAR(eTaxResult.Excode9,""); SETCHAR(eTaxResult.Excertif,""); SETCHAR(eTaxResult.Exreason,""); SETCHAR(eTaxResult.UserData,""); /* define import params */ Importing[0].name Importing[0].nlen Importing[0].type Importing[0].leng Importing[0].addr = = = = = "TAX_DATA"; 8; TYPC; sizeof(COM_TAX); &iTaxData;

Importing[1].name = NULL; Tables[0].name = NULL; if (RfcGetData(hRfc,Importing,Tables) != RFC_OK) return RfcRc; /* call RFC function */ RfcRc = rfc_calculate_taxes(hRfc ,&iTaxData ,&eTaxErr ,&eTaxResult ,xException); if (RfcRc == RFC_EXCEPTION) { RfcRaise(hRfc,xException); RfcListen(hRfc); return RfcRc; }

February 1996

15

SAP - External Sales and Use Tax System Interface

SAP AG

/* define export params */ Exporting[0].name Exporting[0].nlen Exporting[0].type Exporting[0].leng Exporting[0].addr Exporting[1].name Exporting[1].nlen Exporting[1].type Exporting[1].leng Exporting[1].addr = = = = = = = = = = "TAX_ERR"; 7; TYPC; sizeof(COM_ERR); &eTaxErr; "TAX_RESULT"; 10; TYPC; sizeof(COM_TAX); &eTaxResult;

Exporting[2].name = NULL; if (RfcRc == RFC_OK) RfcRc = RfcSendData(hRfc, Exporting, Tables); return RfcRc; } void hlp_rfc_calculate_taxes(const char *topic, const char *subtopic, const char *text) { if (strcmp(topic,"f")==0) { OUT("Called function RFC_CALCULATE_TAXES",2); OUT("importing",6); OUT("TAX_DATA",8); OUT("exporting",6); OUT("TAX_ERR",8); OUT("TAX_RESULT",8); NL; } /* import param help */ if (strcmp(topic,"eso")==0) { if (strcmp(subtopic,"TAX_ERR")==0) { OUT("structure COM_ERR",10); OUT("length 77 number of fields 3",10); NL; } if (strcmp(subtopic,"TAX_RESULT")==0) { OUT("structure COM_TAX",10); OUT("length 968 number of fields 91",10); NL; } } /* export param help */ if (strcmp(topic,"efi")==0) { } if (strcmp(topic,"esi")==0) { if (strcmp(subtopic,"TAX_ERR")==0) { OUT("structure COM_ERR",10); OUT("length 77 number of fields 3",10); NL; } if (strcmp(subtopic,"TAX_RESULT")==0) { OUT("structure COM_TAX",10); OUT("length 968 number of fields 91",10); NL; } } if (strcmp(topic,"esfi")==0) { if (strcmp(subtopic,"TAX_ERR")==0) { if (strcmp(text,"RETCODE")==0) { OUT("like COM_ERR-RETCODE",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"ERRCODE")==0) { OUT("like COM_ERR-ERRCODE",12); OUT("type RFC_NUM length 4 init '0'",12); NL; } if (strcmp(text,"ERRMSG")==0) { OUT("like COM_ERR-ERRMSG",12); OUT("type RFC_CHAR length 72 init ' '",12); NL; } } if (strcmp(subtopic,"TAX_RESULT")==0) { if (strcmp(text,"CLIENT")==0) { OUT("like COM_TAX-CLIENT",12); OUT("type RFC_CHAR length 3 init ' '",12); NL; } if (strcmp(text,"COMP_CODE")==0) { OUT("like COM_TAX-COMP_CODE",12); OUT("type RFC_CHAR length 4 init ' '",12); NL; } if (strcmp(text,"DIVISION")==0) { OUT("like COM_TAX-DIVISION",12); OUT("type RFC_CHAR length 4 init ' '",12); NL; }

16

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

if (strcmp(text,"COUNTRY")==0) { OUT("like COM_TAX-COUNTRY",12); OUT("type RFC_CHAR length 3 init ' '",12); NL; } if (strcmp(text,"DOC_NUMBER")==0) { OUT("like COM_TAX-DOC_NUMBER",12); OUT("type RFC_CHAR length 10 init ' '",12); NL; } if (strcmp(text,"POS_NO")==0) { OUT("like COM_TAX-POS_NO",12); OUT("type RFC_NUM length 6 init '0'",12); NL; } if (strcmp(text,"ACCNT_NO")==0) { OUT("like COM_TAX-ACCNT_NO",12); OUT("type RFC_CHAR length 16 init ' '",12); NL; } if (strcmp(text,"ACCNT_CLS")==0) { OUT("like COM_TAX-ACCNT_CLS",12); OUT("type RFC_CHAR length 10 init ' '",12); NL; } if (strcmp(text,"TAX_DATE")==0) { OUT("like COM_TAX-TAX_DATE",12); OUT("type RFC_CHAR length 8 init ' '",12); NL; } if (strcmp(text,"TXJCD_ST")==0) { OUT("like COM_TAX-TXJCD_ST",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TXJCD_SF")==0) { OUT("like COM_TAX-TXJCD_SF",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TXJCD_POA")==0) { OUT("like COM_TAX-TXJCD_POA",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TXJCD_POO")==0) { OUT("like COM_TAX-TXJCD_POO",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TXJCD_IND")==0) { OUT("like COM_TAX-TXJCD_IND",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"PTP_IND")==0) { OUT("like COM_TAX-PTP_IND",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"APAR_IND")==0) { OUT("like COM_TAX-APAR_IND",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"TXJCD_L1")==0) { OUT("like COM_TAX-TXJCD_L1",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TXJCD_L2")==0) { OUT("like COM_TAX-TXJCD_L2",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TXJCD_L3")==0) { OUT("like COM_TAX-TXJCD_L3",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TXJCD_L4")==0) { OUT("like COM_TAX-TXJCD_L4",12); OUT("type RFC_NUM length 2 init '0'",12); NL; } if (strcmp(text,"TAX_TYPE")==0) { OUT("like COM_TAX-TAX_TYPE",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"MATNR")==0) { OUT("like COM_TAX-MATNR",12); OUT("type RFC_CHAR length 18 init ' '",12); NL; } if (strcmp(text,"PROD_CODE")==0) { OUT("like COM_TAX-PROD_CODE",12); OUT("type RFC_CHAR length 10 init ' '",12); NL; } if (strcmp(text,"QUANTITY")==0) { OUT("like COM_TAX-QUANTITY",12); OUT("type RFC_CHAR length 13 init ' '",12); NL; } if (strcmp(text,"UNIT")==0) { OUT("like COM_TAX-UNIT",12); OUT("type RFC_CHAR length 3 init ' '",12); NL; } if (strcmp(text,"AMOUNT")==0) { OUT("like COM_TAX-AMOUNT",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"CURRENCY")==0) { OUT("like COM_TAX-CURRENCY",12); OUT("type RFC_CHAR length 5 init ' '",12); NL; }

February 1996

17

SAP - External Sales and Use Tax System Interface

SAP AG

if (strcmp(text,"CURR_DEC")==0) { OUT("like COM_TAX-CURR_DEC",12); OUT("type RFC_CHAR length 3 init ' '",12); NL; } if (strcmp(text,"FREIGHT_AM")==0) { OUT("like COM_TAX-FREIGHT_AM",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXEMPT_AMT")==0) { OUT("like COM_TAX-EXEMPT_AMT",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXEMPT_IND")==0) { OUT("like COM_TAX-EXEMPT_IND",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"CREDIT_IND")==0) { OUT("like COM_TAX-CREDIT_IND",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"UPDATE_IND")==0) { OUT("like COM_TAX-UPDATE_IND",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"OVWRT_IND")==0) { OUT("like COM_TAX-OVWRT_IND",12); OUT("type RFC_CHAR length 1 init ' '",12); NL; } if (strcmp(text,"TAXPCT0")==0) { OUT("like COM_TAX-TAXPCT0",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT1")==0) { OUT("like COM_TAX-TAXPCT1",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT2")==0) { OUT("like COM_TAX-TAXPCT2",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT3")==0) { OUT("like COM_TAX-TAXPCT3",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT4")==0) { OUT("like COM_TAX-TAXPCT4",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT5")==0) { OUT("like COM_TAX-TAXPCT5",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT6")==0) { OUT("like COM_TAX-TAXPCT6",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT7")==0) { OUT("like COM_TAX-TAXPCT7",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT8")==0) { OUT("like COM_TAX-TAXPCT8",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCT9")==0) { OUT("like COM_TAX-TAXPCT9",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXPCOV")==0) { OUT("like COM_TAX-TAXPCOV",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT0")==0) { OUT("like COM_TAX-TAXAMT0",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT1")==0) { OUT("like COM_TAX-TAXAMT1",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT2")==0) { OUT("like COM_TAX-TAXAMT2",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT3")==0) { OUT("like COM_TAX-TAXAMT3",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT4")==0) { OUT("like COM_TAX-TAXAMT4",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT5")==0) { OUT("like COM_TAX-TAXAMT5",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; }

18

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

if (strcmp(text,"TAXAMT6")==0) { OUT("like COM_TAX-TAXAMT6",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT7")==0) { OUT("like COM_TAX-TAXAMT7",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT8")==0) { OUT("like COM_TAX-TAXAMT8",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMT9")==0) { OUT("like COM_TAX-TAXAMT9",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXAMOV")==0) { OUT("like COM_TAX-TAXAMOV",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS0")==0) { OUT("like COM_TAX-TAXBAS0",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS1")==0) { OUT("like COM_TAX-TAXBAS1",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS2")==0) { OUT("like COM_TAX-TAXBAS2",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS3")==0) { OUT("like COM_TAX-TAXBAS3",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS4")==0) { OUT("like COM_TAX-TAXBAS4",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS5")==0) { OUT("like COM_TAX-TAXBAS5",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS6")==0) { OUT("like COM_TAX-TAXBAS6",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS7")==0) { OUT("like COM_TAX-TAXBAS7",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS8")==0) { OUT("like COM_TAX-TAXBAS8",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"TAXBAS9")==0) { OUT("like COM_TAX-TAXBAS9",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXMATFLG")==0) { OUT("like COM_TAX-EXMATFLG",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCUSFLG")==0) { OUT("like COM_TAX-EXCUSFLG",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXAMT0")==0) { OUT("like COM_TAX-EXAMT0",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT1")==0) { OUT("like COM_TAX-EXAMT1",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT2")==0) { OUT("like COM_TAX-EXAMT2",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT3")==0) { OUT("like COM_TAX-EXAMT3",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT4")==0) { OUT("like COM_TAX-EXAMT4",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT5")==0) { OUT("like COM_TAX-EXAMT5",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT6")==0) { OUT("like COM_TAX-EXAMT6",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; }

February 1996

19

SAP - External Sales and Use Tax System Interface

SAP AG

if (strcmp(text,"EXAMT7")==0) { OUT("like COM_TAX-EXAMT7",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT8")==0) { OUT("like COM_TAX-EXAMT8",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXAMT9")==0) { OUT("like COM_TAX-EXAMT9",12); OUT("type RFC_CHAR length 15 init ' '",12); NL; } if (strcmp(text,"EXCODE0")==0) { OUT("like COM_TAX-EXCODE0",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE1")==0) { OUT("like COM_TAX-EXCODE1",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE2")==0) { OUT("like COM_TAX-EXCODE2",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE3")==0) { OUT("like COM_TAX-EXCODE3",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE4")==0) { OUT("like COM_TAX-EXCODE4",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE5")==0) { OUT("like COM_TAX-EXCODE5",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE6")==0) { OUT("like COM_TAX-EXCODE6",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE7")==0) { OUT("like COM_TAX-EXCODE7",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE8")==0) { OUT("like COM_TAX-EXCODE8",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCODE9")==0) { OUT("like COM_TAX-EXCODE9",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"EXCERTIF")==0) { OUT("like COM_TAX-EXCERTIF",12); OUT("type RFC_CHAR length 25 init ' '",12); NL; } if (strcmp(text,"EXREASON")==0) { OUT("like COM_TAX-EXREASON",12); OUT("type RFC_CHAR length 2 init ' '",12); NL; } if (strcmp(text,"USER_DATA")==0) { OUT("like COM_TAX-USER_DATA",12); OUT("type RFC_CHAR length 50 init ' '",12); NL; } } } return; } /* -----------------------------------------------------------------------------main program -----------------------------------------------------------------------------*/ main(int argc,char **argv) { /* RFC variables */ static RFC_HANDLE hRfc; static RFC_ENV RfcEnv; static RFC_RC RfcRc; static RFC_FUNCTIONNAME RfcFuncName; char s[16]; int count; /* program arguments */

20

February 1996

SAP AG

SAP - External Sales and Use Tax System Interface

outfile = NULL; infile = NULL; logfile = NULL; for (count=0;count<argc;count++) { if (argv[count][0]=='-') { if (argv[count][1]=='?') { help("h","",""); help("l","",""); help("end","",""); exit(0); } if (argv[count][1]=='i') { if ((infile=fopen(argv[count+1],"r"))==NULL) { OUT("error opening input file",0); exit(1); } } if ((argv[count][1]=='l')&&(argv[count][2]=='o')&&(argv[count][3]=='g')) { if ((logfile=fopen(argv[count+1],"w"))==NULL) { OUT("error opening log file",0); exit(1); } } if (argv[count][1]=='o') { if ((outfile=fopen(argv[count+1],"w"))==NULL) { OUT("error opening output file",0); exit(1); } } } } LOG(hRfc,"program started",*argv); #ifdef SAPonWINDOWS _wsetexit(_WINEXITNOPERSIST); /* close window when program finished */ #endif /* accept connection */ hRfc = RfcAccept(argv); LOG(hRfc,"RfcAccept called",""); if (hRfc == 0) rfc_error("RfcAccept"); RfcEnv.errorhandler = rfc_error; RfcEnvironment(&RfcEnv); /* install function */ RfcRc = RfcInstallFunction("RFC_DETERMINE_JURISDICTION",srv_rfc_determine_jurisdiction , "Ermittlung des Jurisdictioncodes durch ein externes System"); LOG(hRfc,"RfcInstallFunction called","rfc_determine_jurisdiction"); if (RfcRc != RFC_OK) {RfcAbort(hRfc,"RfcInstallFunction"); rfc_error("RfcInstallFunction"); } /* install function */ RfcRc = RfcInstallFunction("RFC_CALCULATE_TAXES",srv_rfc_calculate_taxes, "Berechnung der Steuern durch ein externes System"); LOG(hRfc,"RfcInstallFunction called","rfc_calculate_taxes"); if (RfcRc != RFC_OK) {RfcAbort(hRfc,"RfcInstallFunction"); rfc_error("RfcInstallFunction"); } /* --------------------------------------------------do your initilisation work here --------------------------------------------------*/ OUT("SAP AG, Walldorf - Business Application Programming Interface",0); NL; OUT("External RFC server example program",2); NL; OUT("1 rfc_determine_jurisdiction",6); OUT("2 rfc_calculate_taxes",6); NL; /* wait for calls */ while ((RfcRc == RFC_OK) || (RfcRc == RFC_EXCEPTION)) RfcRc = RfcDispatch(hRfc); /* wait for calls using RfcGetName instead of RfcDispatch. RFC_PING not supported! */ /* while ((RfcRc == RFC_OK) || (RfcRc == RFC_EXCEPTION)) { RfcRc = RfcGetName(hRfc, RfcFuncName); if (RfcRc != RFC_OK) break; if (strcmp(RfcFuncName,"RFC_DETERMINE_JURISDICTION")==0) RfcRc = srv_rfc_determine_jurisdiction(hRfc); } if (strcmp(RfcFuncName,"RFC_CALCULATE_TAXES")==0) RfcRc = srv_rfc_calculate_taxes(hRfc); } */ /* connection close */ if (hRfc!=0) { RfcClose(hRfc); LOG(hRfc,"RfcClose called",""); }

February 1996

21

SAP - External Sales and Use Tax System Interface

SAP AG

/* --------------------------------------------------do your exiting work here --------------------------------------------------*/ help("end","",""); #ifdef SAPonNT INS("","","Quit? [y]",4,24,s); #endif if (outfile!=NULL) fclose(outfile); if (infile!=NULL) fclose(infile); if (logfile!=NULL) fclose(logfile); return RfcRc; }

22

February 1996

You might also like