✒️ABAP El formato de salida de los datos
ABAP El formato de salida de los datos
Data Output Format
ABAP provides a set of specially designed statements for generating reports effortlessly. The most popular among these statements is WRITE. The WRITE statement has a specific format as follows:
WRITE: /<offset>(<long>)'<data to display>'.
Example:
WRITE:/1(70) 'Hello World'.
Here, the ':/' represents a line break, offset denotes the starting column for printing, long defines the print length, and data to print is the content displayed on the screen.
Several additional commands complement WRITE for producing specific screen outputs. Some of them include:
- LEFT-JUSTIFIED: Left-justified output.
WRITE:/1(70) 'Hello World' LEFT-JUSTIFIED.
- CENTERED: Centered output.
WRITE:/1(70) 'Hello World' CENTERED.
- RIGHT-JUSTIFIED: Right-justified output.
WRITE:/1(70) 'Hello World' RIGHT-JUSTIFIED.
- NO-ZERO: If the field contains zeros, they are replaced by blanks.
WRITE:/ 'Number without zeros: ', v_number NO-ZERO.
- NO-GAPS: Omits the space after the field to be printed.
DATA: v_text TYPE string.
v_text = 'Hello World'.
CONDENSE v_text NO-GAPS.
WRITE:/ v_text.
- NO-SIGN: The sign does not appear in the output.
WRITE:/ 'Positive number: ', v_positive_number NO-SIGN.
- DECIMALS n: 'n' defines the number of decimal digits.
WRITE:/ 'Amount with 2 decimal places: ', v_amount DECIMALS 2.
- ROUND n: Rounds the output field for type 'p'.
WRITE:/ 'Rounded value: ', v_rounded_value ROUND 2.
- DD/MM/YYYY: Date with separators.
WRITE:/ 'Today''s date is: ', v_date DD/MM/YYYY.
The WRITE statement also allows the use of two useful statements to format data output: SKIP and ULINE.
- SKIP: Prints a blank line on the screen.
SKIP.
- ULINE: Prints a horizontal line on the screen.
ULINE.
Note: To test the SKIP statement, you can execute the standard program DEMO_LIST_SKIP.
Specific events are available for formatting the output of a report, whether on the screen or printer. These events include:
- TOP-OF-PAGE: Used to change the page header.
- END-OF-SELECTION: Used to print data on the screen, separating data processing from printing.
- NO STANDARD PAGE HEADING (To the right of the REPORT statement): Used to remove the default header of a report. It also allows modifying the number of lines and columns displayed in a report using LINE-SIZE (lines) or LINE-COUNT (columns).
*---------------------------------------------------------------------*
TOP-OF-PAGE.
*---------------------------------------------------------------------*
WRITE:/ 'Datos de los alumnos del sistema'.
ULINE.
*---------------------------------------------------------------------*
START-OF-SELECTION.
*---------------------------------------------------------------------*
WRITE:/1(18) 'Nombre del alumno:', v_nombre.
WRITE:/1(16) 'Edad del alumno:', v_edad.
WRITE:/1(14) 'Código Postal:', v_codigo_postal.
*---------------------------------------------------------------------*
END-OF-SELECTION.
*---------------------------------------------------------------------*
WRITE:/ 'Se mostro 1 registro'.
E.g.
REPORT ztest_abap_jega_5 NO STANDARD PAGE HEADING.
DATA: lv_date(8) TYPE c,
lv_formatted_date(10) TYPE c.
TOP-OF-PAGE.
WRITE:/ 'Test Report for Date Formatting' CENTERED.
ULINE.
START-OF-SELECTION.
CLEAR: lv_date, lv_formatted_date.
lv_date = sy-datum.
CONCATENATE lv_date+6(2) lv_date+4(2) lv_date+0(4) INTO lv_formatted_date SEPARATED BY '/'.
WRITE:/ 'Today''s date is: ', lv_formatted_date.
*&---------------------------------------------------------------------*
*& Expected Output:
*&
*& Test Report for Date Formatting
*& ____________________________________________________________________
*&
*& Today's date is: 13/02/2024
*&
*&---------------------------------------------------------------------*
 
 
 
Sobre el autor
Publicación académica de Jaime Eduardo Gomez Arango, en su ámbito de estudios para la Carrera Consultor ABAP.
Jaime Eduardo Gomez Arango
Profesión: Ingeniero de Sistemas y Computación - España - Legajo: SW34C
✒️Autor de: 105 Publicaciones Académicas
🎓Cursando Actualmente: Consultor ABAP Nivel Avanzado
🎓Egresado del módulo:
Disponibilidad Laboral: FullTime
Presentación:
Ingeniero de sistemas y computación con 8 años de experiencia el desarrollo frontend & backend (react/node) y en cloud (aws), actualmente desarrollando habilidades en sap btp, ui5, abap y fiori.
Certificación Académica de Jaime Gomez