Application Development and Automation 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: 
Read only

EXEC SQL join in ABAP program

Former Member
0 Likes
2,064

Hi All,

I am using EXEC SQL join in my ABAP report,but it is giving dump.could you please correct my following code?

START-OF-SELECTION.

CONCATENATE '%' pa_match '%' INTO tp_match.

EXEC SQL.

OPEN dbcur FOR

SELECT kunnr,name1, banks

FROM kna1 as a inner join

knbk as b

on akunnr = bkunnr

WHERE a.kunnr = b.kunnr and

upper(a~name1) LIKE :tp_match

ENDEXEC.

DO.

EXEC SQL.

FETCH NEXT dbcur INTO :wa_name1

ENDEXEC.

IF sy-subrc <> 0.

EXIT.

ENDIF.

APPEND wa_name1 TO ta_name1.

COLLECT wa_name1 INTO ta_name1.

ENDDO.

EXEC SQL.

CLOSE dbcur

ENDEXEC.

1 ACCEPTED SOLUTION
Read only

former_member222860
Active Contributor
0 Likes
885

Remove the 'As' from the statement

EXEC SQL.
  OPEN dbcur FOR
  SELECT kunnr,name1, banks
  FROM kna1 a inner join        "Delete 'AS' here
  knbk b
  on a~kunnr = b~kunnr
  WHERE a.kunnr = b.kunnr and
  upper(a~name1) LIKE :tp_match
ENDEXEC.

3 REPLIES 3
Read only

Former Member
0 Likes
885

why are u using EXEC SQL???

Read only

0 Likes
885

"why are u using EXEC SQL???"

Because he needs NAME1 in uppercase when doing the select... something ABAP SQL doesn't support.

Edited by: Matt Sprague on Oct 14, 2009 2:54 PM

Read only

former_member222860
Active Contributor
0 Likes
887

Remove the 'As' from the statement

EXEC SQL.
  OPEN dbcur FOR
  SELECT kunnr,name1, banks
  FROM kna1 a inner join        "Delete 'AS' here
  knbk b
  on a~kunnr = b~kunnr
  WHERE a.kunnr = b.kunnr and
  upper(a~name1) LIKE :tp_match
ENDEXEC.