Supplier Relationship Management Adapter For SAP R/3: User's Guide
Supplier Relationship Management Adapter For SAP R/3: User's Guide
SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.
SAS Publishing provides a complete selection of books and electronic products to help customers use SAS software
to its fullest potential. For more information about our e-books, e-learning products, CDs, and hard-copy books, visit
the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228.
®
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS
Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are trademarks of their respective companies.
Contents
PREFACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .vii
1 Data Extraction
For convenience, the extraction of SAP table data is split into several different job steps. As a result, if only a
partial extraction is required, then data extraction for a particular table or set of tables can be run in isolation,
thus saving extraction time.
Also, to save space and extraction time, the number of columns that are extracted from SAP for each table is
limited to only those columns that are deemed to be relevant to SAS Supplier Relationship Management. For
a complete list of extracted columns by SAP table name, see Appendix E.
Job Dependencies
To ensure accurate results from running the SAS/Warehouse Administrator suite of jobs, the jobs should be
run in the correct sequence.
A list of all the jobs and their dependencies is available in Chapter 3, “Job Details,” on page 10 or in
summary form in Appendix B.
Libraries
Several libraries are defined when the adapter is started, for use within the SAS/Warehouse Administrator
environment. Each main library and its purpose are detailed in Appendix C.
2
C H A P T E R
The SAP R/3 system stores reference information (such as texts, descriptions, and names)
in separate SAP tables.
The SAS Supplier Relationship Management Adapter for SAP R/3 uses the Format
Generation Control add-in to create SAS formats and informats from the extracted data.
See Appendix A for details about extracted tables and created formats.
Date formats are also set up for data that is not stored in SAP R/3. These formats convert
dates into month and quarter text, depending on the language setting that is used.
• $QTRTXT. converts specified quarter number to quarter text.
• $MTHQTR. converts specified month number to quarter text.
• $MTHTXT. converts specified month number to month text.
Format Creation
The Format Generation utility stores metadata that describes which formats need to be
created. The formats are all based on tables, most of which are extracted from SAP,
although some are also provided with the adapter. The formats can be modified to add
local language descriptions. The metadata for all formats is kept in a single table called
PUBSPEC.FMTCNTL.
Although the adapter ships with pre-generated code, the format metadata might need to
be modified. Possible reasons for modifying the format metadata include the following:
• The solution has expanded.
• The strategy of removing duplicates of a particular format has changed. This strategy
is performed if an error message about a repeated range appears when generating the
formats.
4 SAS Supplier Relationship Management Adapter for SAP R/3: User’s Guide
title 'SAS';
The following is an example of the format definitions for Cost Center. Note that for Cost
Center, format and informat areas are created, where
format type C = character format
format type J = character informat.
The input table is R3DATA.CSKT, which is an extracted copy of the R/3 table CSKT.
The format is defined as mapping the concatenation KOKRS || KOSTL onto the
concatenation KOKRS || KOSTL || KTEXT, using a hyphen ( - ) as a label separator.
Sort vars
Label Dup removal for Dup
Format char. Output format Where clause strategy- removal
name separator library for input dsn FIRST/LAST
FIRST/LAST
In the example CSKT extract (Display 2.1), a format is created called COSTC, which
maps 10000000000600 onto 1000-0000000600-Plant/Branc2, etc. and so on.
In the second part of the format metadata, the output format library is specified in
LIBRARY.FMT&lang. For example, for English language formats, the formats are
created in LIBRARY.FMTE.
This method enables you to create formats for all languages that are maintained in the
R/3 system. In addition, the WHERE clause SPRAS="&LANG" is used to extract only
English language descriptions.
The last two metadata information fields specify a duplicate removal strategy of L, and
specify DATBI as the sort variable for duplicate removal. In the CSKT table contents, the
value for DATBI is usually the R/3 maximum date, 31DEC9999. Consequently, the
descriptions are valid until the year 9999. It is possible that multiple records can indicate
multiple descriptions for the same cost center, in which case they would be distinguished
by a different DATBI value.
In this case, to get the latest description, perform a sort by both START (start label) and
DATBI (sort variables for duplicate removal), and then take the LAST.DATBI row as
shown in the following code:
%put Duplicate removal strategy = L;
proc sort data=work._fmt;
by start DATBI;
run;
data work._fmt;
set work._fmt;
by start DATBI;
if LAST.start;
run;
The format creation job step must be included early in the job flow, because most if not
all of the subsequent processes use formats. Doing so enables new features that use
formats to assume correct and available formats.
The actual code is created by the Format Generation add-in utility to SAS/ACCESS
Interface to R/3.
6
C H A P T E R
3 Executing SAS/Warehouse
Administrator Jobs
2. Using the navigation tree, navigate to the desired Operational Data Definition (ODD). Right-click the
desired ODD and select Process. The Process Editor window opens.
3. In the Process Editor window, select View → Job Hierarchy to show the job hierarchy in the
navigation tree.
To submit jobs manually, see the following section. To submit multiple jobs in a batch, see “Submitting
Multiple Jobs” on page 5.
An example of submitting a single SAS/Warehouse Administrator job follows. This process must be
repeated for every job in the adapter suite (Appendix A).
Chapter 3: Executing SAS/Warehouse Administrator Jobs 9
1. In the Job List or Job Hierarchy tree of the Process Editor, right-click the desired job name and select
Run. The Load Generation/Execution Properties dialog box opens (Display 3.2).
A SAS/Warehouse Administrator add-in enables you to execute more than one job in a single command. The
add-in is automatically installed as part of the adapter installation.
1. In the Job List or Job Hierarchy tree of the Process Editor, right-click any job name and select Add-Ins.
A list of add-ins appears (Display 3.3).
10 SAS Supplier Relationship Management Adapter for SAP R/3: User’s Guide
2. Select Publish Multiple Jobs Source Code from the list and click OK. The Publish Multiple Jobs Source
Code dialog box opens (Display 3.4).
3. To select individual jobs, select a job group in the Jobgroups list, then select the jobs to execute in the
Jobs list. Click the right arrow button to add these jobs to the Selected Jobs list. Repeat for another job
group if desired. To select all jobs, click Select All Jobs.
4. Select the Include Master Job check box and click OK.
When the processing has completed, a dialog box opens, indicating the number of jobs that were processed.
Also, the output source code that is produced is stored in the catalog that is specified in the Source Catalog
field of the Publish Multiple Jobs Source Code dialog box.
You should check the SAS log for any errors that occurred during processing.
Tip: The output source code can be stored in a permanent SAS catalog or external file by changing the
specifications in the Generation Options box of the Publish Multiple Jobs Source Code dialog box. You can
then submit, or schedule the submission of, any number of SAS/Warehouse Administrator jobs, without
having to initiate SAS/Warehouse Administrator or the adapter. Submit these jobs by using the SAS
Explorer to navigate to the appropriate catalog; right-click the _MASTERJOB_.SOURCE entry and select
Run.
12
C H A P T E R
4 Job Details
The following details are valid for the initially provided software. Any site-specific changes that are made to
the adapter will affect the accuracy of this information.
G/L Account
Dependencies: None
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Extracts the following SAP R/3 tables:
• SKA1 G/L Account Master (Chart of Accounts)
• SKAT G/L Account Master Record (Chart of Accounts:
Description).
Material Data
Dependencies: None
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Extracts the SAP R/3 table MARA General Material Data.
Purchasing Document
Dependencies: None
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Extracts the following SAP R/3 tables:
• EKKO Purchasing Document Header
• EKPO Purchasing Document Item.
16 SAS Supplier Relationship Management Adapter for SAP R/3: User’s Guide
Trading Contract
Dependencies: None
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Extracts the following SAP R/3 tables:
• WBHI Trading Contract: Item Data
• WBHK Trading Contract: Header Data.
Vendor Master
Dependencies: None
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Extracts the SAP R/3 table LFA1 Vendor Master.
Format Creation
Dependencies: Table Extracts for Formats
Details: This job executes a user-written mapping. However, this is a not a mapping
program but source code to create the formats.
Source member is FMTCNTL.GENFMT.SOURCE.
The data that is extracted from the job Formats is used to create SAS
formats, as detailed in Appendix A.
SAS formats are also created for output of month and quarter descriptions.
Account Assignment
Dependencies: Format Creation
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Joins tables SKA1 and SKAT, extracted in the job G/L Account.
The variables that are used for the join are MANDT, KTOPL, and SAKNR.
The macro variable &SPRAS is used to subset the table SKAT to the correct
language descriptions.
Output from this job is Account Assignment
(SRMDATA.ACCOUNT_ASSIGNMENT).
Note: The output from the job Account Assignment is currently not used
in the remainder of the adapter process. This data extraction is included
for future expansion or for additional reporting requirements. Therefore,
if there are no requirements for this information, then this job can be
removed from the job suite.
Chapter 4: Job Details 17
Cost Centers
Dependencies: Format Creation
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Joins the tables CSKS and CSKT, extracted in the jobs Cost Center Master
Data and Formats, respectively.
The variables that are used for the join are MANDT, KOKRS, KOSTL, and
DATBI.
The macro variable &SPRAS is used to subset the table CSKT to the
correct language descriptions.
Output from this job is Cost Centers (SRMDATA.COST_CENTRES).
Note: The output from the job Cost Centers is currently not used in the
remainder of the adapter process. This data extraction is included for
future expansion or for additional reporting requirements. Therefore, if
there are no requirements for this information, then this job can be
removed from the job suite.
Invoice
Dependencies: Format Creation
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Concatenates the tables BSAK and BSIK to create an intermediate table
called Vendors Secondary Index (INTERM.CONCAT).
This intermediate table is the joined with the tables BKPF and BSEG.
The variables that are used for the join are MANDT, BUKRS, GJAHR, and
BELNR from all three tables, and BUZEI from BSEG/concat.
Output from this job is Invoice (SRMDATA.INVOICE).
A simple index (SUPPLIER_NUMBER) is created for this data set for use
in later job steps.
Item Master
Dependencies: Format Creation
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Straight assignment from the table Material Data.
Output from this job is Item Master (SRMDATA.ITEM_MASTER).
18 SAS Supplier Relationship Management Adapter for SAP R/3: User’s Guide
Profit Centers
Dependencies: Format Creation
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Joins the tables CEPC and CEPCT, extracted in the job Profit Center
Master Data.
The variables that are used for the join are MANDT, PRCTR, DATBI, and
KOKRS.
The macro variable &SPRAS is used to subset the table CEPCT to the
correct language descriptions.
Output from this job is Profit Centers (SRMDATA.PROFIT_CENTRES).
Note: The output from the job Profit Centers is currently not used in the
remainder of the adapter process. This data extraction is included for
future expansion or for additional reporting requirements. Therefore, if
there are no requirements for this information, then this job can be
removed from the job suite.
Purchase Order
Dependencies: Format Creation
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Joins the tables EKKO, EKKN, and EKPO, extracted in the jobs
Purchasing Document and Account Assignment in Purchasing Docum.
The variables that are used for the join are MANDT and EBELN from
EKKO/EKPO and EBELN and EBELP from EKPO/EKKN.
Output from this job is Purchase Order
(SRMDATA.PURCHASE_ORDER).
Supplier Master
Dependencies: Format Creation
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Straight assignment from table LFA1 Vendor Master.
Output from this job is Supplier Master
(SRMDATA.SUPPLIER_MASTER).
Accounting Document
Dependencies: Format Creation
Details: This job executes a user-written mapping.
Source member is SRMR3SRC.ADDDELTA.SOURCE.
Updates Accounting Document data with delta extracted data from
BKPF/BSEG Accounting Document.
Output from this job is an updated Accounting Document
(R3DATA.ACCDOC).
Transformed Data
Dependencies: • Invoice
• Item Master
• Purchase Order
• Supplier Master
Details: This job executes user-written mappings.
Join_POI.SOURCE; left-joins the tables Purchase Order and Item Master to
create an intermediate table called Joined: PO & Item
(INTERM.JOIN_POI).
Join_INV_PO_SUPP.SOURCE; left-joins the tables Invoice, intermediate
table Joined: PO & Item and Supplier Master.
Output from this job is Transformed Data
(SRMDATA.CAPABILITIES_TRANSFORMED).
Summary Tables
Dependencies: Transformed Data
Details: This job uses only source code that is generated by SAS/Warehouse
Administrator.
Creates an OLAP Nway table.
Class columns:
CUS_SYSTEM1_CODE DB_DUNS
DB_HQPAR_DUNS DB_DOM_DUNS
DB_GLBL_DUNS DB_UNSPSC2_CODE
DB_UNSPSC4_CODE DB_UNSPSC6_CODE
DB_UNSPSC8_CODE SAS_YEAR
SAS_QUARTER SAS_MONTH
SAS_SIC2_CODE SAS_SIC4_CODE
SAS_SIC6_CODE SAS_SIC8_CODE
VAR_MATRL1_CODE VAR_MATRL2_CODE
VAR_ORG1_CODE VAR_ORG2_CODE
VAR_GENHIER1_LEV1_CODE VAR_GENHIER1_LEV2_CODE
VAR_GENHIER1_LEV3_CODE VAR_GENHIER2_LEV1_CODE
VAR_GENHIER3_LEV1_CODE
Statistic columns:
CUS_SPEND (Stat=Sum)
SAS_TRANSACTIONS (Stat=Sum)
CAR_XTRA_NUM (Stat=Sum)
Output from this job is Nway (SRMDATA.NWAY).
20
A P P E N D I X
C Defined Libraries
ENRICH !r3droot\Enrichment
Library intended to contain any user- or externally provided enrichment
data, such as Dun & Bradstreet data
INTERM !r3droot\Intermediate
Stores intermediate working data sets that are used for temporary table
joins
LIBRARY !root\formats
SAS format library
NONR3D !r3droot\nonr3data
Data sets that contain data that has not been sourced from SAP
R3DATA !r3droot\r3data
Data sets that contain data that has been extracted from SAP
R3LIB !root\srm\dd\r3lib
Data dictionary metadata on SAP tables
R3VIEW !root\srm\dd\r3view
Catalog for all R/3 descriptors
SASERP !r3droot\r3addins\programs
Source library for R3 add-ins
SRMDATA !r3droot\SRMdata
Detail tables that are produced as output from the adapter process.
Includes the final summary Nway table.
SRMR3SRC !r3droot\r3source
Source catalogs for all user-written source code and format control
source code
26
A P P E N D I X
2. From the selection list of SAS/Warehouse Administrator add-ins, select Reverse Impact
Analysis and click OK (Display D.2).
30 SAS Supplier Relationship Management Adapter for SAP R/3: User’s Guide
3. In the Reverse Impact Analysis dialog box (Display D.3), select Detailed (Tables and
processes) and click OK. A new reverse impact analysis diagram is displayed (Display D.4).
You can view, save or print this diagram.
T001W – Plants/Branches
MANDT Client
WERKS Plant
NAME1 Name
BWKEY Valuation area
KUNNR Customer number of plant
LIFNR Vendor number of plant
FABKL Factory calendar key
NAME2 Name 2
STRAS House number and street
PFACH P.O. Box
PSTLZ Postal code
ORT01 City
LAND1 Country key
REGIO Region (state, province, county)
SPRAS Language key
In all other cases the Initial Load NOT Required set of jobs should be run.
The reason for this is that the initial load will do a complete extraction of the data from the BKPF and BSEG
tables (depending on the date setting in the autoexec.sas file), whereas the subsequent loads will extract only
delta changes that have been made to those tables, resulting in significant savings in extraction time.
The tables BKPF and BSEG are the main tables that are used for storing financial transactions in SAP R/3.
BKPF is the heading table and BSEG contains line item detail.
BSEG is often one of the largest individual tables in an SAP R/3 system. Because of the way BSEG is
indexed in SAP, there is a different process to do this initial load compared to subsequent updates.
This job must be run by using the Batch RFC Server, which is the default server for the adapter extractions.
Execution times in excess of 12 hours can be expected.
42 SAS Supplier Relationship Management Adapter for SAP R/3: User’s Guide
The extraction is split into logical sections, by looking up all the relevant company codes and then splitting
the data into financial years. The process uses the macro variable &_START, which must be set in the
autoexec.sas file. All data that has a date greater than or equal to &_START will be extracted.
The macro variable &OVERLAP_DAYS, which is set in autoexec.sas, is used to subtract a number of days
from the date that is stored in NONR3D.DELTACTL. This prevents the loss of data that was not in the
system when the previous extraction was done.
BSEG has no date or time stamps that can be used, so the adapter must identify the new and changed records
in the heading table BKPF and extract the matching items from BSEG.
The extraction of the changed records in BKPF is therefore quite simple, but the extraction of BSEG is not.
Extraction of BSEG is done by using a server-side join. The SAP server selects all relevant BKPF records
and then does a “nested select” to get the matching BSEG records.
Appendix F: Loading the BKPF and BSEG Tables 43
The Advanced Business Application Program (ABAP) function Z_SAS_READ_TABLE _JOIN is called as
follows:
%callrfc(
Z_SAS_READ_TABLE_JOIN
EXPORTING data_file = &data_fileref
metadata_file = &field_fileref
destination = &sasrfcex_destination
IMPORTING return = rc
INTABLES parameter = work.table_parameter
TABLES s = work.program
);
However, the ABAP function is called by the SAS/ACCESS Interface to R/3 software Business Application
Programming Interface (BAPI) connector (%CALLRFC macro), a component of SAS/ACCESS Interface to
R/3 software. This connector submits code as an interactive process on the SAP R/3 server. For this reason, it
is possible to experience the time-out problems that are associated with interactive processes.
The ABAP code takes as parameters an initial table name, columns in that table, and an associated WHERE
clause. Additional lines in the parameters specify an additional table that is joined by a nested select (SAP
R/3 does not allow standard SQL join syntax to extract from the BSEG cluster table).
To prevent potential memory problems in SAP R/3, the extraction is split logically into financial years. No
splitting is done on the BUKRS company code column, but it might make sense to add logic to split the
extraction into date ranges (instead of simply getting all data with dates greater than the previous extraction).
However, if extractions are done frequently enough, then this should not be a problem.
In addition, ensure that the RFC destination that calls the program SASRFCEX is on the same server that is
running the extraction. The SAP gateway must be set correctly in the destination if the server load balancing
is done on the SAP system.
The following description is adapted from the comment at the head of the macro
%BKPF_BSEG_JOIN_PARAMETERS, which is used to define the input table (server-side query
definition) of the ABAP function Z_SAS_READ_TABLE_JOIN:
The input table has only one column called LINE. The length
of the column should not exceed 72 characters.
Each table is identified by the keyword TABLE, followed by the table name.
The next line contains the keyword FIELD, followed by the first field to extract. The next lines
contain the keyword FIELD, followed by a field name, or only the field name without the keyword.
Each field must be identified in a separate line. The keyword AS can be used to rename a field—for
example, FIELD OBJECTID AS OBJECTID1. A list of field names is required. An asterisk (*) is not
accepted. All fields that are used in one of the WHERE conditions must be listed in the field list.
44 SAS Supplier Relationship Management Adapter for SAP R/3: User’s Guide
The next line contains the keyword WHERE, followed by the WHERE condition for the table. The
WHERE condition can be continued on the next line (as long as it does not start with one of the
keywords). If, while generating input tables, the possibility exists that the next line will start with one
of the keywords, then insert the keyword WHERE at the beginning of the line.
The example below joins the tables CDHDR and CDPOS. A nested SELECT statement will be
generated to join the two tables. Simplified, the generated ABAP statement will look like the
following:
ENDSELECT.
ENDSELECT.
data work.table_parameter;
length line $ 72;
line = 'TABLE BKPF'; output;
line = 'FIELD MANDT'; output;
line = ' BUKRS as BKPF_BUKRS'; output;
line = ' BELNR as BKPF_BELNR'; output;
line = ' CPUDT'; output;
line = ' AEDAT'; output;
line = ' BUDAT'; output;
line = ' MONAT'; output;
line = ' WAERS'; output;
line = ' UPDDT'; output;
line = "WHERE GJAHR = &gjahr"; output;
line = " AND ( CPUDT GE &cutdateq"; output;
line = " OR AEDAT GE &cutdateq"; output;
line = " OR UPDDT GE &cutdateq ) "; output;
line = 'TABLE BSEG'; output;
line = 'FIELD BUKRS'; output;
line = ' BELNR'; output;
line = ' GJAHR'; output;
line = ' BUZEI'; output;
line = ' BSCHL'; output;
line = ' KOART'; output;
line = ' GSBER'; output;
line = ' DMBTR'; output;
line = ' WRBTR'; output;
line = ' PSWBT'; output;
line = ' PSWSL'; output;
Appendix F: Loading the BKPF and BSEG Tables 45
The statements in bold are used for subsetting. If you must modify the logic—for example, to extract
changes for a single date only—then the expression could be changed to use the EQ operator instead of GE.
(Note that as the query is being executed on SAP, valid ABAP expression syntax must be used.)
It is possible to add columns. Valid names can be found via the SAS/ACCESS to R/3 List of Tables
program.
The job calls the macros %START_LISTENER and %KILL_LISTENER to start and stop communication
with SAP through an SAP destination. The %START_LISTENER macro in turn calls a CMD script (for
Windows) or a shell script (for UNIX) that starts the listening program.
The CMD script SAS_RFCEXEC.CMD (or shell script sas_rfcexec) must be modified to fit your local SAP
system. The script must also use a destination that refers back to the machine on which SAS is running.
When the server-side join of BKPF and BSEG is complete, the result is joined to R3DATA.T001 in order to
include the local currency columns.
Accounting Document
This job takes the output from the job BKPF/BSEG Accounting Document and updates the previously
extracted R3DATA.ACCDOC with the delta-change information. This new data is not appended because the
changed data must be updated.
46
A P P E N D I X
G Recommended Reading
Recommended Reading
Here is the recommended reading list for this title:
For a complete list of SAS publications, see the current SAS Publishing Catalog. To order the
most current publications or to receive a free copy of the catalog, contact a SAS
representative at
Customers outside the United States should contact their local SAS office.
48
Your Turn