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

SAP SQL question

Former Member
0 Likes
381

Hi,

in one of the OSS notes it is suggested to use this code:

SELECT * FROM BKPF

WHERE AWTYP = COBK-AWTYP

AND AWKEY = (COBK-REFBN + COBK-AWORG)

AND BUKRS = COBK-REFBK.

It doesn't work with error: Field "(COBK-REFBN + COBK-AWORG)" is unknown.

When I tried to use this: AWKEY CS COBK-REFBN

AND AWKEY CS COBK-AWORG it did not work either.

AWKEY(10) = COBK-REFBN did not work as well.

Do you know any other tricks to solvve this problem?

Thank you,

Vitaly

1 REPLY 1
Read only

Former Member
0 Likes
341

No trickery:

DATA: awkey TYPE bkpf-awkey.

CONCATENATE cobk-refbn cobk-aworg INTO awkey.

SELECT * FROM bkpf
  WHERE awtyp = cobk-awtyp
    AND awkey = awkey
    AND bukrs = cobk-refbk.

I'm not sure of the order of the concatenation. If it doesn't work one way, reverse the concatenation.

Rob