Client Specified Select
Client specified clause switches off the automatic client handling by open SQL. If we select the MANDT (client) field then we have to use client specified clause like follows:
SELECT mandt field1 field2 ... fieldn
INTO TABLE internal_table FROM database_table
CLIENT SPECIFIED "MANDT has been selected
"hence client specified is must
WHERE mandt = '800'
AND field1 IN select_option.
INTO TABLE internal_table FROM database_table
CLIENT SPECIFIED "MANDT has been selected
"hence client specified is must
WHERE mandt = '800'
AND field1 IN select_option.
This statement is always mentioned after the FROM clause. If the addition CLIENT SPECIFIED is specified, but the client ID in the WHERE condition is not mentioned, the SELECT statement circumvents the SAP buffering.
REPORT zabap_gui.
TABLES: kna1.
* Local structure for local internal table
* and work area
TYPES:
BEGIN OF ty_kna1,
mandt TYPE kna1-mandt,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
pstlz TYPE kna1-pstlz,
regio TYPE kna1-regio,
END OF ty_kna1.
* Local internal table & work area
DATA:
it_kna1 TYPE TABLE OF ty_kna1,
wa_kna1 TYPE ty_kna1.
* Selection range by select option internal table
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr.
START-OF-SELECTION.
* Selection of the specific fields
SELECT mandt kunnr land1 name1 ort01 pstlz regio
INTO TABLE it_kna1 FROM kna1
CLIENT SPECIFIED "MANDT has been selected
"hence client specified is must
WHERE mandt = '800'
AND kunnr IN s_kunnr.
IF sy-subrc = 0.
WRITE:/ 'Clnt',
5 'Customer No',
14 'Country',
24 'Name',
60 'City',
100 'Postal',
112 'Region'.
ULINE.
SKIP.
LOOP AT it_kna1 INTO wa_kna1.
WRITE:/ wa_kna1-mandt,
5 wa_kna1-kunnr,
14 wa_kna1-land1,
24 wa_kna1-name1,
60 wa_kna1-ort01,
100 wa_kna1-pstlz,
112 wa_kna1-regio.
ENDLOOP.
ENDIF.
TABLES: kna1.
* Local structure for local internal table
* and work area
TYPES:
BEGIN OF ty_kna1,
mandt TYPE kna1-mandt,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
pstlz TYPE kna1-pstlz,
regio TYPE kna1-regio,
END OF ty_kna1.
* Local internal table & work area
DATA:
it_kna1 TYPE TABLE OF ty_kna1,
wa_kna1 TYPE ty_kna1.
* Selection range by select option internal table
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr.
START-OF-SELECTION.
* Selection of the specific fields
SELECT mandt kunnr land1 name1 ort01 pstlz regio
INTO TABLE it_kna1 FROM kna1
CLIENT SPECIFIED "MANDT has been selected
"hence client specified is must
WHERE mandt = '800'
AND kunnr IN s_kunnr.
IF sy-subrc = 0.
WRITE:/ 'Clnt',
5 'Customer No',
14 'Country',
24 'Name',
60 'City',
100 'Postal',
112 'Region'.
ULINE.
SKIP.
LOOP AT it_kna1 INTO wa_kna1.
WRITE:/ wa_kna1-mandt,
5 wa_kna1-kunnr,
14 wa_kna1-land1,
24 wa_kna1-name1,
60 wa_kna1-ort01,
100 wa_kna1-pstlz,
112 wa_kna1-regio.
ENDLOOP.
ENDIF.
Here is the output.