07-19-2021 11:53 AM
Hello,
I need to select a field from knb1 where kunnr from knb1 is equal to kunnr in likp and assign it to field KART_KLIENT1. For a reason I can't warp my head around, it says that neither table knb1 nor likp have a column kunnr... Which both of them do.
I don't know where to look for a problem, both knb1 and likp are predefined database tables in SAP and kunnr column is there by default.
I am working in SQ02, adding the code to one of the fields.
Thank you for your time.
TYPES: BEGIN OF ty_knb,
tlfns TYPE knb1,
END OF ty_knb.
DATA: wa_knb TYPE ty_knb.
SELECT SINGLE TLFNS
INTO wa_knb
FROM knb1
WHERE knb1-kunnr = likp-kunnr.
KART_KLIENT1 = wa_knb-tlfns
07-19-2021 3:55 PM
Question answered here: sql - Existing column considered non-existent during Select - Stack Overflow
07-19-2021 6:49 PM
That is a link to my question and I am afraid it's not answered yet. :<
07-20-2021 6:13 AM
Hello,
A couple of things that do not look quite right in the snippet you posted.
a) in the TYPES: BEGIN OF... declaration why is the TLFNS field typed like the whole KNB1 structure, should it be TLFNS TYPE KNB1-TLFNS or TLFNS TYPE TLFNS(i.e. the data element TLFNS)
b) in where clause why is it WHERE knb1-kunnr = likp-kunnr, should it simply not be WHERE kunnr = likp-kunnr( since the select statement has FROM knb1 )
c) KNB1 contains the customer information at the company code level. So shouldn't the where clause also have had a AND BUKRS = <some other field in the program/code containing the company code value>
Regards,
Nikhil
07-20-2021 9:34 AM
Thank you for the time and input, Nikhil.
I implemented the changes you suggested, including the BUKRS part (5000 here, I was made to know), but there is still no result. 😕
It feels like I already managed to exhaust all possible solutions and all I am left with is possibly something being wrong outside of the code.
The infoset is quering VTTK mainly and I thought that perhaps I should "Join" KNB1 and LIKP there… but they have no connection to VTTK. So I thought I might join VTTP to VTTK and then I can link LIKP to VTTP by vbeln and then I can link KNB1 to LIKP by kunnr… But there are other "additional fields" in this query already, they are using LIKP-KUNNR without it being added in the "Join" at all, so I am at a loss why isn't my select working.
Regards,
Bartosz
07-23-2021 11:18 AM
The issue's resolved. Turned out it was the matter of the ordering in the end. I can't provide the specifics, because I don't really understand why it works. I just moved the code from one section to another (previously I copied all existing code from the section to which I returned eventually in order to have all the code within a single field)… and it just started working. So I either just don't know something about SAP's inner workings or perhaps there is some sort of a veiled relations between different sections of the code that required my newly introduced code to be precisely in that very field (due to the ordering, I suppose).