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: 

Please check user-exit code for any inconsistencies/problems/wrong code

Former Member
0 Kudos
107

Hi,

This will go into USEREXIT_PRICING_PREPARE_TKOMK of MV45AFZZ.

Please check to make sure that this was written correctly and professionally, as well as for performance optimization.

DATA: I_KNVV LIKE KNVV OCCURS 0 WITH HEADER LINE,

I_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.

SELECT * INTO TABLE I_VBAK FROM VBAK.

SELECT * INTO TABLE I_KNVV FROM KNVV

WHERE VKORG = I_VBAK-VKORG AND

VTWEG = I_VBAK-VTWEG.

IF SY-SUBRC = 0.

MOVE KNVV-EIKTO TO TKOMK-ZZEIKTO.

ENDIF.

-


Points will be rewarded.

Thank You,

John

5 REPLIES 5

Former Member
0 Kudos
59

hi John,

U r using select * that can be a performance issue.

<b>

DATA I_EIKTO TYPE KNVV-EIKTO.

DATA: BEGIN OF I_VBAK OCCURS 0,

VKORG LIKE VBAK-VKORG,

VTWEG LIKE VBAK-VTWEG,

END OF I_VBAK.</b>

SELECT VKORG VTWEG INTO TABLE I_VBAK FROM VBAK.

u r moving only 1 field then why u need select * here?

to simplicize...

<b>LOOP AT I_VBAK.

SELECT EIKTO INTO I_EIKTO FROM KNVV

WHERE VKORG = I_VBAK-VKORG AND

VTWEG = I_VBAK-VTWEG.

IF SY-SUBRC = 0.

MOVE I_EIKTO TO TKOMK-ZZEIKTO.

APPEND TKOMK.

ENDIF.</b>

<b>CLEAR I_EIKTO.

ENDLOOP.</b>

Regards

SAB

kostas_tsioubris
Contributor
0 Kudos
59

Hi,

first of all you don't tell us what exactly you want to do, moreover the statement SELECT * INTO TABLE I_VBAK FROM VBAK.

will select everything from vbak into your internal table. you should have a where clause there.

Br

Kostas

Former Member
0 Kudos
59

Hi

DATA: I_KNVV LIKE KNVV OCCURS 0 WITH HEADER LINE,

I_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.

SELECT * INTO TABLE I_VBAK FROM VBAK.

<b>IF sy-subrc = 0 .

sort i_vbak.

SELECT * INTO TABLE I_KNVV FROM KNVV

<b> for all entries in i_vbak</b>WHERE VKORG = I_VBAK-VKORG AND

VTWEG = I_VBAK-VTWEG.

IF SY-SUBRC = 0.

MOVE KNVV-EIKTO TO TKOMK-ZZEIKTO.

ENDIF.

ELSE.

refresh i_vbak.

ENDIF.</b>

Hope this solves your purpose.

Award points if it helps.

-Gaurang

ferry_lianto
Active Contributor
0 Kudos
59

Hi,

Please try this.


SELECT SINGLE EIKTO 
INTO (KNVV-EIKTO)  
FROM KNVV
WHERE KUNNR = VBAK-KUNNR
  AND VKORG = VBAK-VKORG 
  AND VTWEG = VBAK-VTWEG
  AND SPART = VBAK-SPART

IF SY-SUBRC = 0.
  MOVE KNVV-EIKTO TO TKOMK-ZZEIKTO.
ENDIF.

Regards,

Ferry Lianto

Former Member
0 Kudos
59

Hi John,

You are selecting ALL of VBAK and then only selecting the records from KNVV using data that is at the header of of the internal table I_VBAK (where VKORG and VTWEG match).

Were you trying to do something like this?

SELECT SINGLE * FROM knvv WHERE kunnr EQ vbak-kunnr

AND vkorg EQ vbak-vkorg

AND vtweg eq vbak-vtweg

AND spart eq vbak-spart.

if sy-subrc = 0.

move knvv-eikto to tkomk-zzeikto.

endif.