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: 

Any records exist for given VENDOR NUMBER and COMPANY CODE

Former Member
0 Kudos

Hi Experts,

Need help in checking if there are any records exist for given VENDOR NUMBER and COMPANY CODE.

in LFB1 table and if result is 0 then giving out error like COMPANY CODE DO NOT EXIST FOR THIS VENDOR NUMBER.

Thanks for all your help.

-Chris.

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

hi,

most effective is to use SELECT COUNT:

SELECT COUNT( * )
FROM LFB1
WHERE lifnr EQ ...
AND bukrs EQ ...

IF sy-subrc EQ 0.
=> there is a vendor for that company code
ELSE.
=> there is no ...
ENDIF.

hope this helps

ec

6 REPLIES 6

Former Member
0 Kudos

Hi

Records are different in companys.U have 2 check ur company.

All comopanys are having diffent vendor and different company code.

Regards:

Prabu

Former Member
0 Kudos

Hi ,

You can use the following function .

SUPO_GET_VENDORID_COMPANYCODE

Former Member
0 Kudos

hi

if i am getting it right then u can write like :

select single * from LFB1 where lifnr = <vendor no.> and burks = <comp. code>.

if sy-subrc NE 0.

// write ERROR.

endif.

Regards

Sachin

Former Member
0 Kudos

Hi,

In LFB1 table vendor and company code are primary keys, so the records exist for this combination only.

If the result is 0 then it does not mean that the company does not exist. the combination of the record is not existed in the table.

Regards,

Raju.

JozsefSzikszai
Active Contributor
0 Kudos

hi,

most effective is to use SELECT COUNT:

SELECT COUNT( * )
FROM LFB1
WHERE lifnr EQ ...
AND bukrs EQ ...

IF sy-subrc EQ 0.
=> there is a vendor for that company code
ELSE.
=> there is no ...
ENDIF.

hope this helps

ec

0 Kudos

Thanks Eric, your code is working. given your points as well.