SAP Database

ABAP Programs: Date and Time

Print This Post Email This Post Written by admin on Nov 4th, 2007 | Filed under: ABAP Programs

REPORT ZSOURCE0405.

* Date fields are type d with the fixed length 8 and the internal
* representation YYYYMMDD (year, month, and day).
* The initial value of a date field is 00000000.

DATA TODAY TYPE D.

* The write command formats dates according to personal settings of
* the end user.

TODAY = SY-DATUM.
WRITE (10) TODAY.

* Using date fields to perform computations
DATA ULTIMO TYPE D.
* Set variable to first day of current month.
ULTIMO = SY-DATUM.
ULTIMO+6(2) = ‘01′.
* Set variable to last day of previous month.
SUBTRACT 1 FROM ULTIMO.
WRITE / ULTIMO.

* Time fields are type t with the fixed length 6
* and the format HHMMSS (hours, minutes, and seconds)

DATA MY_TIME TYPE T.
WRITE /(8) MY_TIME.

———————
ABAPer, mail: abap.community@gmail.com http://abaplearner.blogspot.com

If you like this post, you may as well like these too:

  1. ABAP Programs: Converting date fields * Using the built-in calendarDATA: RECEIVING_DATE TYPE D, LAST_ADMISSIBLE_DATE TYPE D. RECEIVING_DATE = ‘19980223′.LAST_ADMISSIBLE_DATE = RECEIVING_DATE + 10.WRITE / LAST_ADMISSIBLE_DATE. RECEIVING_DATE = ‘19980305′.LAST_ADMISSIBLE_DATE = RECEIVING_DATE + 10.WRITE / LAST_ADMISSIBLE_DATE....
  2. ABAP Programs : Using the Basic Layout Formats REPORT ZSOURCE0801. * Simple output containing the current dateWRITE: ‘This is the current date:’, SY-DATUM. * Displaying fields according to their typeDATA: STRING(20), INT TYPE I, PACKED_NUMBER TYPE P...
  3. ABAP Source Code: Syntax of ABAP/4 Programs * Declaration of the program name REPORT ZSOURCE0301. * Displaying the words 'Customer list' on the screen WRITE / 'Customer list'. * Using an addition of the write command...
  4. ABAP Programs: Hexadecimal (or binary) data REPORT CHAP0406. * Hexadecimal (or binary) data is stored in fields of type x.* A type x field of length n contains 2n digits* and its output length is...
  5. ABAP Programs: String Operations REPORT ZSOURCE0708. * Concatenating strings without delimiterDATA: FIRST_NAME(25), MIDDLE_NAME(2), LAST_NAME(25), FULL_NAME(54).FIRST_NAME = ‘John’.MIDDLE_NAME = ‘F.’.LAST_NAME = ‘Kennedy’.CONCATENATE FIRST_NAME MIDDLE_NAME LAST_NAME INTO FULL_NAME.WRITE / FULL_NAME.* Concatenating strings with delimiterDATA: DIRECTORY_1(2),...



Leave a Reply

  • Help Support CRY