BAPI to get customer company?

750 Views Asked by At

Customer company is stored in KNB1 table.

I tried with BAPI_CUSTOMER_GETDETAIL2, seems it does not expose company code. Instead of it, company code is the bapi input.

I am looking for a BAPI that can give company code from given customer number. Is there any bapi existed?

1

There are 1 best solutions below

0
On

There is no BAPI for that, because what you want to do does not make sense on a conceptual level. A customer does not have a company code. A customer can have company code specific data for any number of company codes. When there is a n..1 relationship between customers and company codes in your system, then that's something unique to how your organization uses it. On a technical level, the relationship is n..m.

But if you want a table of all company codes (BUKRS) which have data for a specific customer (KUNNR), you can do that with a simple SQL statement:

SELECT bukrs FROM knb1 INTO TABLE @lt_bukrs WHERE kunnr = @lv_kunnr.