‎2007 May 16 2:43 PM
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
‎2007 May 16 2:46 PM
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
‎2007 May 16 2:49 PM
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
‎2007 May 16 2:51 PM
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
‎2007 May 16 2:54 PM
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
‎2007 May 16 2:55 PM
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.