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

Changing message type

Former Member
0 Likes
1,822

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,659

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

16 REPLIES 16
Read only

Former Member
0 Likes
1,659

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

Read only

0 Likes
1,659

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

Read only

Former Member
0 Likes
1,659

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

Read only

Former Member
0 Likes
1,659

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

Read only

Former Member
0 Likes
1,660

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

Read only

0 Likes
1,659

Dear Mr. Vinod,

Where should I include this function

-Chinna

Read only

0 Likes
1,659

Add the code in user exit "MV45AFZZ" - "USEREXIT_SAVE_DOCUMENT_PREPARE".

Regards

Vinod

Read only

0 Likes
1,659

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

Read only

0 Likes
1,659

Dear Vinod,

<removed by moderator>

-Chinna

Edited by: Thomas Zloch on May 20, 2010 3:50 PM

Read only

0 Likes
1,659

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

Read only

0 Likes
1,659

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

Read only

0 Likes
1,659

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

Read only

0 Likes
1,659

Dear Mr. Vinod,

so just trying to control returns.

-Chinna

Edited by: Chinna on May 20, 2010 1:39 PM

Read only

0 Likes
1,659

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

Read only

0 Likes
1,659

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

Read only

ThomasZloch
Active Contributor
0 Likes
1,659

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