2006 Sep 04 11:00 AM
Hello!
I have a very annoying problem with this user-exit MV45AFZZ...
It is annoying, because it is working in the 99% of the cases and in 1% it is not working.
When I'm testing my code it is always working fine. In 99% of the cases it is working fine. But there are several documents when the code is not running. In these cases ppl who are working with the module are calling me, I'm testing it in the same system with the same values and the document is perfect for me.
It seems like some kind of database locking problem, but I don't know how to solve this bug.
The problem is within the code-part between the
>>> NyT and
<<< NyT lines
The problem occurs, when VBAK-AUART <> 'BV'.
The code:
FORM USEREXIT_MOVE_FIELD_TO_VBAP.
*{ INSERT MEDK900234 1
*RH
tables: zvonz, "table 4 route - plant association
vbep,
zmaxacs,
zmaxany,
usr05,
konv.
DATA: T_KONV LIKE KONV occurs 0.
DATA: WVBAK LIKE VBAK .
data: begin of wvbap occurs 0,
VBELN like vbap-VBELN,
POSNR like vbap-posnr,
MATNR like vbap-matnr,
matkl like vbap-matkl,
end of wvbap.
****eddigiek melyik héten
data: begin of wvbep occurs 0,
VBELN like vbap-VBELN,
POSNR like vbap-posnr,
MATNR like vbap-matnr,
edatu like vbep-edatu,
whet like scal-week,
matkl like vbap-matkl,
vrkme like vbep-vrkme,
bmeng like vbep-bmeng,
end of wvbep.
data: begin of wvbepsum occurs 0,
MATNR like vbap-matnr,
matkl like vbap-matkl,
whet like scal-week, "200512
vrkme like vbep-vrkme,
bmeng like vbep-bmeng,
end of wvbepsum.
******aminek vizsgáljuk
data: begin of wvbepapa occurs 0,
VBELN like vbap-VBELN,
POSNR like vbap-posnr,
edatu like vbep-edatu,
whet like scal-week,
MATNR like vbap-matnr,
matkl like vbap-matkl,
vrkme like vbep-vrkme,
bmeng like vbep-bmeng,
end of wvbepapa.
data: begin of wvbepasum occurs 0,
MATNR like vbap-matnr,
matkl like vbap-matkl,
whet like scal-week,
bmeng like vbep-bmeng,
vrkme like vbep-vrkme,
end of wvbepasum.
data: whet like scal-week,
wdb like vbep-bmeng.
If SVBAP-TABIX = 0. "létrehozás
clear wvbak.
if not vbak-vgbel is initial.
SELECT SINGLE * FROM VBAK
INTO WVBAK
WHERE VBELN = vbak-vgbel.
if Wvbak-VBTYP = 'G'. "szerz.
if not vbap-posnr is initial and "000001
vbap-vgbel is initial.
vbap-vgbel = vbak-vgbel.
endif.
endif. "g
endif. "not vbak-vgbel is initial
>>> NyT 2006.07.25 - Kiszállítási hely és Kiszállító gyár
meghatározás áthelyezése a bizonylat mentéséhez tartozó exitből ide
IF vbak-auart = 'BV'. "azonnali kiszállítás
SELECT SINGLE * FROM usr05
WHERE bname = sy-uname AND
parid = 'WRK'.
IF sy-subrc = 0.
vbap-werks = usr05-parva.
vbap-vstel = usr05-parva.
ENDIF.
ELSE. "nem azonnali kiszállítás
SELECT SINGLE * FROM zvonz
WHERE route = vbap-route AND
spart = vbap-spart.
IF sy-subrc <> 0. "Ha SPART nincs töltve
SELECT SINGLE * FROM zvonz
WHERE route = vbap-route.
ENDIF.
IF sy-subrc = 0.
vbap-werks = zvonz-werks.
vbap-vstel = zvonz-vstel.
ENDIF.
ENDIF. "auart
<<< NyT 2006.07.25
ENDIF. "létrehozás
ENDFORM.
2006 Sep 04 11:54 AM
Hi,
Try to use XVBAP instead of VBAP struture. At run time,
XVBAP will have the current item values and VBAP gets filled from XVBAP only.
Solved the problem?
Regards
2006 Sep 04 11:54 AM
Hi,
Try to use XVBAP instead of VBAP struture. At run time,
XVBAP will have the current item values and VBAP gets filled from XVBAP only.
Solved the problem?
Regards
2022 Jan 28 8:15 AM
Hello, I had to change region of Shipt To Party from ADRC in MV45AFZZ when sales order gets saved.
I tried it with changing xvbadr but i did not work.
The solution which worked for me is with function modules around ADDR_UPDATE if address exists on database and ADDR_MAINTAIN_COMPLETE if only address handle exits but not on databse. I added the form in MV45AFZZ USER_SAVE_DOCUMENT_PREPARE:
*&---------------------------------------------------------------------*
*& Form UPDATE_WE_ADDRESS_REGION
*&---------------------------------------------------------------------*
* Update Region of WE
*----------------------------------------------------------------------*
FORM update_we_address_region USING p_region.
FIELD-SYMBOLS: <fs_badr> LIKE xvbadr,
<fs_vbpa> LIKE xvbpa.
DATA: ls_addr1_sel TYPE ADDR1_SEL,
ls_addr1_value TYPE ADDR1_VAL,
ls_addr1_data TYPE ADDR1_DATA,
lt_return TYPE TABLE OF ADDR_ERROR,
lv_return_code TYPE AD_RETCODE,
lv_address_handle TYPE AD_HANDLE.
LOOP AT xvbpa[] ASSIGNING <fs_vbpa> WHERE parvw = 'WE'.
READ TABLE xvbadr[] ASSIGNING <fs_badr> WITH KEY adrnr = <fs_vbpa>-adrnr.
IF sy-subrc eq 0.
<fs_badr>-regio = p_region.
clear: ls_addr1_sel, ls_addr1_value, ls_addr1_data, lv_return_code.
ls_addr1_sel-addrnumber = <fs_badr>-adrnr.
call function 'ADDR_GET'
exporting
address_selection = ls_addr1_sel
importing
address_value = ls_addr1_value
exceptions
parameter_error = 1
address_not_exist = 2
version_not_exist = 3
internal_error = 4
others = 5.
" case if address exists on database already
IF sy-subrc EQ 0.
MOVE-CORRESPONDING ls_addr1_value TO ls_addr1_data.
ls_addr1_data-region = p_region.
REFRESH lt_return.
CALL FUNCTION 'ADDR_UPDATE'
EXPORTING
address_data = ls_addr1_data
address_number = ls_addr1_value-addrnumber
nation = ls_addr1_value-nation
check_empty_address = ' '
check_address = ' '
IMPORTING
returncode = lv_return_code
TABLES
error_table = lt_return
EXCEPTIONS
address_not_exist = 1
parameter_error = 2
version_not_exist = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc EQ 0 AND lv_return_code NE 'E'.
CALL FUNCTION 'ADDR_MEMORY_SAVE'
EXCEPTIONS
address_number_missing = 1
person_number_missing = 2
internal_error = 3
database_error = 4
reference_missing = 5
OTHERS = 6.
IF sy-subrc EQ 0.
CALL FUNCTION 'ADDR_MEMORY_CLEAR'
EXCEPTIONS
unsaved_data_exist = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
ELSE.
" case if address handle exists but not on database
lv_address_handle = <fs_badr>-adrnr.
DATA: lt_addr_complete TYPE SZADR_ADDR1_COMPLETE.
CALL FUNCTION 'ADDR_GET_COMPLETE'
EXPORTING
ADDRHANDLE = lv_address_handle
IMPORTING
ADDR1_COMPLETE = lt_addr_complete
EXCEPTIONS
PARAMETER_ERROR = 1
ADDRESS_NOT_EXIST = 2
INTERNAL_ERROR = 3
WRONG_ACCESS_TO_ARCHIVE = 4
ADDRESS_BLOCKED = 5
OTHERS = 6.
IF sy-subrc EQ 0.
READ TABLE lt_addr_complete-addr1_tab INDEX 1 ASSIGNING FIELD-SYMBOL(<fs_complete_addr>).
IF sy-subrc EQ 0.
<fs_complete_addr>-data-region = p_region.
REFRESH lt_return.
DATA: lv_update_kz TYPE AD_UPDFLAG.
lv_update_kz = 'U'.
CALL FUNCTION 'ADDR_MAINTAIN_COMPLETE'
EXPORTING
updateflag = lv_update_kz
addr1_complete = lt_addr_complete
address_group = 'SD01'
CONSIDER_CONSNUMBER_FOR_INSERT = 'X'
IV_TIME_DEPENDENT_COMM_DATA = 'X'
IMPORTING
RETURNCODE = lv_return_code
TABLES
ERROR_TABLE = lt_return
EXCEPTIONS
PARAMETER_ERROR = 1
ADDRESS_NOT_EXIST = 2
HANDLE_EXIST = 3
INTERNAL_ERROR = 4
ADDRESS_BLOCKED = 5
OTHERS = 6.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
2022 Jan 28 8:25 AM
Hi raphael.sommer
you have to create your own question on this forum
2022 Jan 28 8:29 AM
ok, but this should be the solution regarding this question, I have searched and tried a lot of things, and this worked
2022 Jan 28 8:42 AM