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: 

Select Query problem

Former Member
0 Kudos

Hi,

My Report is working fine but we want report on basis of sales office wise..means Branch employee can see only own data not of other branches.

My query is on VBRK and picking the Billing document from there. for Sales office wise data, we must goto VBRP table...

I query on VBRP and in selection screen put the Sales office input criteria.

But when i am inserting 1 billing document of AAA Sales office, but in sales office inserting BBB Sales office, then the output shows. It must not show because billing document is of AAA Sales office not BBB.

My Query is..

SELECT * FROM vbrk WHERE vbeln IN vbeln AND ( fkart = 'ZG1' OR fkart = 'ZG2' OR fkart = 'RE' OR fkart = 'ZWCN' OR fkart = 'G2' ) AND rfbsk EQ 'C'.

IF vbrk-fkart = 'ZG1'.

line10 = 'YOUR ACCOUNT WITH US HAS BEEN CREDITED WITH THE AMOUNT AS MENTIONED BELOW FOR PRICE DIFFERENCE AGAINST,'.

ELSEIF vbrk-fkart = 'ZG2'.

line10 = 'YOUR ACCOUNT WITH US HAS BEEN CREDITED WITH THE AMOUNT AS MENTIONED BELOW FOR INCENTIVE AGAINST,'.

ELSEIF vbrk-fkart = 'RE'.

line10 = 'YOUR ACCOUNT WITH US HAS BEEN CREDITED WITH THE AMOUNT AS MENTIONED BELOW CREDIT FOR RETURN AGAINST,'.

ELSEIF vbrk-fkart = 'ZWCN'.

line10 = 'YOUR ACCOUNT WITH US HAS BEEN CREDITED WITH THE AMOUNT AS MENTIONED BELOW FOR WARRENTY CREDIT NOTE AGAINST,'.

ELSEIF vbrk-fkart = 'G2'.

line10 = 'YOUR ACCOUNT WITH US HAS BEEN CREDITED WITH THE AMOUNT AS MENTIONED BELOW FOR CREDIT MEMO AGAINST,'.

ENDIF.

IF itab-vbeln = vbrp-vbeln.

SELECT SINGLE vkbur FROM vbrp INTO itab-vkbur WHERE vbeln = itab-vbeln AND vbeln IN vbeln AND vkbur IN vkbur.

ELSE.

ENDIF.

***********************

plz. help..

5 REPLIES 5

Former Member
0 Kudos

add condition for VBRK where sales office (VKBUR) as per selection screen

0 Kudos

in which query i add condition...for VBRK or VBRP...

0 Kudos

as VBRK is header you have to add there.. and while selecting data from VBAP which is item details then match VBRK fields including sales office in where condition...

Former Member
0 Kudos

Dear @ABAP@

your problem is solved or not?

Former Member
0 Kudos

You can join tables VBRK and VBRP on the basis ob vbeln and give the sales office in where condition alsong with other required values.

Exapmle

select VBRK vbeln vbrkfkart

VBRP~posnr

into table itab

from VBRK inner join VBRP

on VBRKvbeln = VBRPvbeln

where

VBRK~vbeln in s_vbelb (select options for vbeln) and

VBRP~VKBUR in s_vkbur (select options for sales office).

Now can can loop itab and do further processing

loop at itab.

if itab-fkart = 'RE'.

............

elseif.

..................

endloop.