Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SELECT DISTINCT with JOIN

Former Member
0 Kudos

Hi,

how Do I write this select in rigth way in ABAP

SELECT ska1ktopl AS ktopl ska1saknr AS saknr

t370k_t~eartx AS eartx

INTO TABLE lt_ska1 FROM ska1

JOIN (SELECT DISTINCT damage_gl FROM zzpm_cost_elem ) ON ska1saknr = zzpm_cost_elemdamage_gl.

The problem with the select "SELECT DISTINCT damage_gl FROM zzpm_cost_elem " which I have to put table name instead of it

What should I do ?

Thx

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Friend ,

Please see this example how you can use the select DISTINCT statement



DATA: ITAB TYPE STANDARD TABLE OF SPFLI,
      WA LIKE LINE OF ITAB.

DATA: LINE(72) TYPE C,
      LIST LIKE TABLE OF LINE(72).

LINE = ' CITYFROM CITYTO '.
APPEND LINE TO LIST.

SELECT DISTINCT (LIST)
       INTO CORRESPONDING FIELDS OF TABLE ITAB
       FROM SPFLI.

IF SY-SUBRC EQ 0.
  LOOP AT ITAB INTO WA.
    WRITE: / WA-CITYFROM, WA-CITYTO.
  ENDLOOP.
ENDIF.

Regards,

1 REPLY 1

Former Member
0 Kudos

Hi Friend ,

Please see this example how you can use the select DISTINCT statement



DATA: ITAB TYPE STANDARD TABLE OF SPFLI,
      WA LIKE LINE OF ITAB.

DATA: LINE(72) TYPE C,
      LIST LIKE TABLE OF LINE(72).

LINE = ' CITYFROM CITYTO '.
APPEND LINE TO LIST.

SELECT DISTINCT (LIST)
       INTO CORRESPONDING FIELDS OF TABLE ITAB
       FROM SPFLI.

IF SY-SUBRC EQ 0.
  LOOP AT ITAB INTO WA.
    WRITE: / WA-CITYFROM, WA-CITYTO.
  ENDLOOP.
ENDIF.

Regards,