‎2010 May 18 9:43 AM
Dear Experts,
Pesently when I copy Billing/Invoice reference into Return order, if the Item & qauntity is already returned sitll system is allowing to return it again with V1449 Message"There are already returns for item 000010" which is a information and which cannot be changed as Error by using OVAH. So please help me to change this following assosicated program for making the message as an ERROR.
IF vbak-vbtyp CN vbtyp_lp.
IF vbap-kzfme IS INITIAL.
da_mengev = xvbapf-hmenge * quan_1 * us_umvkn / us_umvkz.
ELSE.
da_mengev = xvbapf-hmengev * quan_1.
ENDIF.
IF vbak-vbtyp = charh.
da_mengev = da_mengev - us_kwmeng.
ENDIF.
IF da_mengev > 0.
WRITE da_mengev TO da_mengec UNIT vbap-vrkme.
SET CURSOR FIELD us_feldname LINE sy-stepl.
MESSAGE ID 'V1' TYPE da_dia NUMBER 499
WITH vbap-posnr da_mengec us_vrkme.
ENDIF.
ENDIF.
-Chinna
‎2010 May 18 12:16 PM
Hi,
You have to extract the Details of return order quanties created using the reference invoice number from the DB table VBFA.
Below code may help you
call function 'SD_VBFA_READ_WITH_VBELV'
exporting
i_vbelv = <ref_doc>
i_bypassing_buffer = l_x
i_refresh_buffer = l_x
tables
et_vbfa = et_vbfa
exceptions
record_not_found = 1
others = 2.
if sy-subrc eq 0.
loop at xvbap.
read table et_data into wa_data with key posnr = xvbap-posnr.
move 0 to l_rfmng.
loop at et_vbfa assigning <ls_vbfa> where posnv = xvbap-itm_number
and vbtyp_n = 'H'.
add <ls_vbfa>-rfmng to l_rfmng.
endloop.
compute l_rfmng = wa_data-fkimg - l_rfmng.
if xvbap-kwmeng gt l_rfmng .
raise message
endif.
endloop.
endif.
Regards
Vinod
‎2010 May 18 10:11 AM
Dear Chinna,
not sure if I understood your requirement correctly, but if you only want to change the message to an "error" message you need to set the variable "da_dia = "E" in your coding extract.
IF vbak-vbtyp CN vbtyp_lp.
IF vbap-kzfme IS INITIAL.
da_mengev = xvbapf-hmenge * quan_1 * us_umvkn / us_umvkz.
ELSE.
da_mengev = xvbapf-hmengev * quan_1.
ENDIF.
IF vbak-vbtyp = charh.
da_mengev = da_mengev - us_kwmeng.
ENDIF.
IF da_mengev > 0.
WRITE da_mengev TO da_mengec UNIT vbap-vrkme.
SET CURSOR FIELD us_feldname LINE sy-stepl.
" set to error
da_dia = 'E'.
MESSAGE ID 'V1' TYPE da_dia NUMBER 499
WITH vbap-posnr da_mengec us_vrkme.
ENDIF.
ENDIF.
Best regards
Arno
‎2010 May 18 11:56 AM
Dear Arno,
It is now showing as error.
But the problem is, if I have 10Q in invoice, if I return once 5Q, then later if I am returning other 5.. for that also it is showing error, which is not correct.
It has to show error only once all 10Q of Invoice is returned and if I try to return the 11th item from same invoice.
I feel it is checking only at item level please help me how can I make it check even at Quantity level.
-Chinna
‎2010 May 18 10:12 AM
Hi,
This message cannot be changed to error message. You have to write custom code & error message in userexit 'MV45AFZZ' form routine : USEREXIT_SAVE_DOCUMENT_PREPARE.
Regards
Vinod
‎2010 May 18 10:32 AM
Hi Chinna,
execute SPRO
SAP Customizing Implementation Guide->Financial Accounting->Accounts Receivable and Accounts Payable->Business Transactions->Down Payment Made->Down Payments/Down Payment Requests->Change Message Control
Give your application area nad there you can maintain the message type as error.
May be this will help.
Else try searching for message control in IMG (spro).
You will get list changing message type in various area.
there you can look out for your desired area.
Regards,
Kamini
‎2010 May 18 12:16 PM
Hi,
You have to extract the Details of return order quanties created using the reference invoice number from the DB table VBFA.
Below code may help you
call function 'SD_VBFA_READ_WITH_VBELV'
exporting
i_vbelv = <ref_doc>
i_bypassing_buffer = l_x
i_refresh_buffer = l_x
tables
et_vbfa = et_vbfa
exceptions
record_not_found = 1
others = 2.
if sy-subrc eq 0.
loop at xvbap.
read table et_data into wa_data with key posnr = xvbap-posnr.
move 0 to l_rfmng.
loop at et_vbfa assigning <ls_vbfa> where posnv = xvbap-itm_number
and vbtyp_n = 'H'.
add <ls_vbfa>-rfmng to l_rfmng.
endloop.
compute l_rfmng = wa_data-fkimg - l_rfmng.
if xvbap-kwmeng gt l_rfmng .
raise message
endif.
endloop.
endif.
Regards
Vinod
‎2010 May 18 12:31 PM
‎2010 May 18 12:32 PM
Add the code in user exit "MV45AFZZ" - "USEREXIT_SAVE_DOCUMENT_PREPARE".
Regards
Vinod
‎2010 May 20 7:20 AM
Dear Vinod,
I have made few changes when I was getting errors, but still I m facing errors...
DATA: et_vbfa TYPE VA_VBFAVB_T.
call function 'SD_VBFA_READ_WITH_VBELV'
exporting
i_vbelv = '<ref_doc>'
i_bypassing_buffer = 'l_x'
i_refresh_buffer = 'l_x'
tables
et_abfa = et_vbfa
exceptions
record_not_found = 1
others = 2.
if sy-subrc eq 0.
loop at xvbap.
read table lt_data into wa_data with key posnr = xvbap-posnr.
move 0 to l_rfmng.
loop at et_vbfa assigning <ls_vbfa> where posnv = xvbap-itm_number
and vbtyp_n = 'H'.
add <ls_vbfa>-rfmng to l_rfmng.
endloop.
compute l_rfmng = wa_data-fkimg - l_rfmng.
if xvbap-kwmeng gt l_rfmng .
raise message
endif.
endloop.
endif.
but I m getting following error..
Field "LT_DATA" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . . . . . .
where should I declare lt_data, please help
-Chinna
‎2010 May 20 9:15 AM
Dear Vinod,
<removed by moderator>
-Chinna
Edited by: Thomas Zloch on May 20, 2010 3:50 PM
‎2010 May 20 9:25 AM
Hi,
You have to add below code above the currently written code
data : it_key type wb2_sales_key_stab,
wa_key type wb2_sales_key,
lt_data type wb2_vbrp_stab,
wa_data type wb2_vbrp.
move <ref_doc> to wa_key-vbeln. "<ref doc> is reference billing doc
append wa_key to it_key.
call function 'WB2_VBRP_ARRAY_READ'
exporting
it_key = it_key
i_refresh = ' '
i_refresh_all = ' '
importing
et_data = lt_data.Regards
Vinod
‎2010 May 20 9:39 AM
Dear Vinod,
Thanks for you immediate help,
but now I am getting following error..
Field "L_RFMNG" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . . . . . .
-Chinna
‎2010 May 20 10:36 AM
Hi,
Check whether all variables are defined.. I have written only the abstract code. The variable mentioned in your
error is to be defined as
data : l_rfmng type rfmng,
l_x type char01 value 'X'.
field-symbols : <ls_vbfa> type vbfa.Regards
Vinod
Edited by: Vinod Kumar on May 20, 2010 3:08 PM
‎2010 May 20 11:05 AM
Dear Mr. Vinod,
so just trying to control returns.
-Chinna
Edited by: Chinna on May 20, 2010 1:39 PM
‎2010 May 20 11:22 AM
Dear Mr. Vinod,
I am again getting the following error.
The line type of the table "ET_VBFA" is not compatible with field
symbol type "<LS_VBFA>".It will be really great help if you can exactly give the code for caling this Function.
-Chinna
‎2010 May 20 11:31 AM
Chinna,
Have an ABAPER implement the solution given by Vinod. If you still have functional issues (not syntax issues) then get back on this post.
Che Eky
‎2010 May 20 2:55 PM
Indeed, please consult a local ABAP developer, everybody was very patient, giving helpful information, but now it is time to stop the step-by-step ABAP course. This is not the place to explain that a variable has to be declared before it can be used in the code.
Thread locked.
Thomas