360 likes | 559 Views
Introduction ABAP Dates. Lecture Overview. I go into more depth than your book about how currency and quantity values work. Introduction (Dates). If you come from a .NET or most worlds, dates are treated much differently from what you are used to
E N D
Lecture Overview • I go into more depth than your book about how currency and quantity values work
Introduction (Dates) • If you come from a .NET or most worlds, dates are treated much differently from what you are used to • In SAP, dates are not numerical. They are just a special character type • Arithmetic operations are performed by SAP converting data internally for you
Dates (Data Type) • We have a couple of ways to deal with dates • The primary date data type • System fields for date and time that come from the SYST struct
The Date (D) Data Type (1) • It’s just an 8 character string
The Date (D) Data Type (2) • The internal format is YYYYMMDD • There are ABAP dictionary fields for dates • sy-datum gets the value of the system date • Example to print the current date
The Date (D) Data Type (3) • We can perform arithmetic on dates • Add 30 days to the current date
The Date (D) Data Type (4) • We extract parts using positional params • +n denotes the starting position (offset specification) • (n) denotes the number of characters to get
Manipulating Date Parts • When subtracting two dates, you get the number of elapsed days • Adding an integral value adds days to a date
The Time (T) Data Type • The Time (T) data type stores the time as a character string HHMMSS • ABAP dictionary types store timestamps in UTC format • TIMESTAMP (YYYMMMDDDhhmmss) • TIMESTAMPL (YYYMMDDhhmmssmmmuuun) • sy-uzeit gets the system time
The Time (T) Data Type (Example) • Declare a time variable and store the current time in it
The Time (T) Data Type (Example) • Get the time parts (hour, minute, second)
Introduction to Reference Fields • Quantity and currency amounts use reference fields • Quantities work with UNIT (units) • Currency fields work with (a currency key) CUKY • The reference table contains a field with the currency key (CUKY) Or unit of measure UNIT
Introduction to Reference Fields • From help.sap.com
Quantity and Currency Fields • They are not primary data types • They are components of a structure in the ABAP dictionary
Currency Fields • They are used to convert amounts from one currency to another • They are really packed (P) BCD numbers • A currency must also have currency key, which designates the currency • CUKY type • Use of the CURR data type is discouraged
Currency Tables • TCURC currency codes • TCURF conversion factors • TCURR exchange rate
Currency (Example) • Using the table ZEKEDAHLTEST • PRICE is of type CURR
Currency (Example) • Reference table is TCURL (Leading Currency)
Currency (Example) • The TCURL Table (Edit using IMG)
Currency (Example) • And finally the leading currency in an exchange quotation
Currency (Configuring) • Exchange ratios are maintained using transaction code OBBS • Exchange rates are maintained using OB08 • Transactions are cleared between company codes
Currency (Configuring Exchange Ratios) • OBBS – Translation ratios define the unit ration between the from and to currencies
Currency (Configuring Exchange Rates) • OB08 – Note that ratios and rates are keyed by the exchange rate type
Steps in Currency Configuration 1. Check Currency Codes - OBY3 2. Set Decimal Places for Currencies - OBY4 3. Check Exchange Rate Types - OB07 4. Enter Exchange Rates - OB08 5. Define Translation Ratios for Currency Translation - OBBS 6. Define Additional Local Currencies - OB22 7. Define Accounts for Exchange Rate Differences - OB09
It’s About Units of Measure • There are four “units of measure” for “things” • Base unit of measure is used for all material stocks • All quantities entered in other units are “converted” to the base unit of measure • Basic view of the material definition • Sales unit of measure allows materials to be sold in different units • Material master sales view
It’s About Units of Measure • Purchase unit of measure is used for “purchasing increments” • Material master, purchasing view • Unit of issue is the quantity issued from the warehouse • Material master, work scheduling view • Alternate unit of measure is defined in table MARM
Creating a Unit of Measure • Define / use a dimension • The seven base dimensions are length, weight, time, electrical current, temperature, molecular mass, brightness • We rarely need to create these • Create units of measure for the dimension • CUNI is the transaction code
Unit of Measure (Example) • Let’s use time • First, Check Units of Measurement from IMG
Unit of Measure (Example) • Look at the Units of measure for time
Unit of Measure (Example) Everything is measured relative to seconds
Unit of Measure (Example) • The conversion factor for minutes. There are 60 seconds in a minute
Unit of Measure (Example) • The conversion factor for months