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

problem with select.....endselect

Former Member
0 Likes
1,111

Hi All,

When i'm trying to create new condition records in txn :

VK11

, 'm facing a problem in the subroutine vtweg_pruefen of the include program MV13AF0V which is included in the main pgm SAPMV13A .
The problem is that, even though i've only 1 record in the dbtable

TVKOV

for the combination vp_vkorg and vp_vtweg, the select statement is fetching 2 values. Is this a problem with buffering?

FORM vtweg_pruefen USING vp_vkorg vp_vtweg vp_error.

DATA: vtwku_tmp LIKE tvkov-vtwku.

  • Satz bereits gelesen

IF tvkov-vkorg <> vp_vkorg OR

tvkov-vtwko <> vp_vtweg.

  • Prüftabelle lesen

SELECT * FROM tvkov WHERE vkorg = vp_vkorg

AND vtwko = vp_vtweg.

  • Die erste Kundensparte setzen

IF vtwku_tmp IS INITIAL.

vtwku_tmp = tvkov-vtwku.

ENDIF.

  • Nicht eindeutig ?

IF vtwku_tmp NE tvkov-vtwku.

CLEAR tvkov-vtwku.

IF NOT call_modus IS INITIAL AND

NOT maapv-vtweg IS INITIAL.

tvkov-vtwku = maapv-vtweg.

ENDIF.

EXIT.

ENDIF.

ENDSELECT.

  • Workarea initial stzen

IF sy-subrc <> 0 AND NOT vp_error IS INITIAL.

CLEAR tvkov.

  • Anlegen von Kondition in dieser Verkaufsorganisation nicht erlaubt

MESSAGE e076 WITH vp_vtweg vp_vkorg.

ENDIF.

ENDIF.

ENDFORM.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,037

true with your table values it will surely give the duplicates as

SELECT * FROM tvkov WHERE vkorg = vp_vkorg

AND vtwko = vp_vtweg.

vtwko is being checked for the distribtion channel and not vtweg. Can the vtwko that is the reference values be changes or not.

9 REPLIES 9
Read only

Former Member
0 Likes
1,037

Hi, just check if the other record is having a deletion flag set in.

Krishna

Read only

Former Member
0 Likes
1,037

try using select single......

or else

use where deletion flag eq space in ur select statement....

Read only

0 Likes
1,037

Hi Krishna/Ramesh,

There is no deletion flag in the table. I am wondering as how I can change a standard program.

Read only

Former Member
0 Likes
1,037

are you sure its looping through the 2nd time to get the values. i tried to debug and it gets only one value. There is no deletion flag as the table data is populated from the functional setting. Could you be more specific if its only during creation that you get 2 values or is it the same while changing and display.

Read only

0 Likes
1,037

MANDT VKORG VTWEG VTWKO VTWAU VTWKU VLGFI VLTYP VLKEB

100 0001 01 01 01

100 0001 03 01 03

Hi Kshamatha,

Make sure ur entries in the table <u>TVKOV</u> are same as above, i.e., the values in the field VTWKU must be different for the same sales organization only then u can replicate my problem. I didn't check during change but i'm facing the problem during creation(VK11). U can maintain the entries in the table with the txn <b>VOR1</b>

Read only

0 Likes
1,037

1st Rcrd: 100(MANDT ) 0001(VKORG) 01(VTWEG) 01(VTWKO) 01(VTWKU )

2nd Rcrd: 100(MANDT ) 0001(VKORG) 01(VTWEG) 01(VTWKO) 03( VTWKU)

Read only

Former Member
0 Likes
1,037

Ratan,

I feel you have got it wrong ..table TVKOV cannot store 2 enteries for the same sales org and distibution channel as the particular fields are the primary key for the table.

It seems that you have missed something in debugging !!

Regards

Anurag

Read only

0 Likes
1,037

Hi Anurag,

Yes, it can't 've 2 values, but it is fetching the second record in the table with the same value of vkorg. One more interesting point that i've observed is

1. When i've placed a break-point at the SELECT statement, the control doesn't stop at the break-point for the second time.(which makes sense as there is only 1 record)

2. but when I've created a watch point with the condition

tvkov-vtwtu NE value fetched during first pass in the select....endselect statement, the control stops at the SELECT statement, by then the value of the field tvkov-vtwtu is already changed.

Read only

Former Member
0 Likes
1,038

true with your table values it will surely give the duplicates as

SELECT * FROM tvkov WHERE vkorg = vp_vkorg

AND vtwko = vp_vtweg.

vtwko is being checked for the distribtion channel and not vtweg. Can the vtwko that is the reference values be changes or not.