ABAP/4

Dynamic WHERE Clause in ABAP/4

You can apply internal table for create dynamic where clauses.

Example

DATA i_where(100) OCCURS 0 WITH HEADER LINE.
APPEND ’vbeln LIKE ’’%1’’’ to i_where.
APPEND ’matnr LIKE ’’%M’’’ to i_where.

TABLE lips.
DATA i_lips TYPE TABLE OF lips WITH HEADER LINE.
SELECT * FROM lips INTO TABLE i_lips
    WHERE werks = ’1000’
        AND (i_where).

Above Example is look like:


TABLE lips.
DATA i_lips TYPE TABLE OF lips WITH HEADER LINE.
SELECT * FROM lips INTO TABLE i_lips
    WHERE werks = ’1000’
    AND vbeln LIKE ’%1’
        AND matnr LIKE ’%M’.

How to Copy File on Windows by ABAP/4

If you want to copy file on PC windows, you can use function "WS_FILE_COPY".

Example


*&---------------------------------------------------------------------*
*&     Form COPY_FILE
*&---------------------------------------------------------------------*
*      text
*----------------------------------------------------------------------*
*     -->PAR_SOURCE      text
*     -->PAR_DESTINATION text
*----------------------------------------------------------------------*
FORM copy_file USING   par_source
                       par_destination.

How to Display Field Value as Checkbox in ABAP/4

When you want to display value of filed as checkbox in ABAP report, you can use WRITE statement by using option "AS CHECKBOX".

Example


DATA: ch1(1) TYPE C,
ch2(1) TYPE C VALUE ’X’.
WRITE: / ’Checkbox 1 ’, ch1 AS CHECKBOX,
/ ’Checkbox 2 ’, ch2 AS CHECKBOX.

Dynamic Table Name in ABAP/4

In ABAP/4, you can specify table name in SELECT statement by dynamically.

Example


DATA table_name(10) TYPE C.
DATA num_rows TYPE I.
table_name = ’BKPF’.
SELECT COUNT( * ) FROM (table_name) INTO num_rows.
WRITE: ’Table Name ’, table_name, ’have rows ’, num_rows.

Chained Statement in ABAP/4

The statements that same keyword can be chained by colon (:). Between the statements separated by ",". When you apply this method, ensure that the chained statement ended by ".".

Example

Normal Statement

PARAMETERS p1(10) TYPE C.
PARAMETERS p2 TYPE D.

Chained Statement

PARAMETERS: p1(10) TYPE C,
p2 TYPE D.

Normal Statement

WRITE ’First’.
WRITE ’Second’.

Color in ABAP/4


Name Code Color
COL_BACKGROUND 0 depends on GUI
COL_HEADING 1 grayish-blue
COL_NORMAL 2 bright gray
COL_TOTAL 3 yellow
COL_KEY 4 bluish green
COL_POSITIVE 5 green
COL_NEGATIVE 6 red
COL_GROUP 7 violet