cancel
Showing results for 
Search instead for 
Did you mean: 

AR Credit Memo: Override default amount of AR Invoice

rajesh_khater
Active Participant
0 Kudos

Hi,

In the AR Credit Memo transaction, when we click on Copy From and choose AR Invoice, I want to automatically bring the Open Amount of the Invoice into the AR Credit Memo Total (LC) field. By default, the system brings the full amount of the AR Invoice. I want to override this behaviour.

How can I do this? Can I get the code sample please.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rajesh,

As far as I seen the behavior, I am afraid that it is not possible to override the behavior.

Because the value in the Total Field depends on the data at the row levels.

I had tried the same once on the older version and somehow managed to get it, but what SAP did that it automatically did some calculations and put the value in Discount Field automatically which I never assigned.

So I don't think that it is possible.

Still wait for the expert suggestion.

Hope t helps.

Thanks & Regards

Ankit Chauhan

rajesh_khater
Active Participant
0 Kudos

You are right Ankit that the value in the Total field depends on the data at the row levels.

Example, if AR Invoice has 5 rows, then all 5 rows are copied to AR Credit Memo with the original amounts, and since there is no row level "open amount" at all (in the sense whether the amount is received or not, as the incoming payment is against whole invoice, not row level), so it does not make sense also to override this behaviour.

So my revised requirement is like this:

I will have a UDF at AR Credit Memo header level: Purpose, which can have 2 values.

1. Goods / Service Return

- In this case, let the default behaviour remain.

2. Discount / Write Off

- In this case, I do not want to show the Draw Document Wizard, and I want to change the AR Credit Memo document to Service Type, and have a single row in the AR Credit Memo, with a predefined ledger called "Discount" or "Write Offs" and set the Total amount equal to the Open Amount of the AR Invoice.

I hope this may be possible with SDK?

So if I trap the Choose button in List of AR Invoices window, how can I stop the Draw Document Wizard screen, and how can I convert the AR Credit memo to Service Type and fill the grid?

Or even if the Draw Document wizard is shown, and it fills the data, I want to refill the AR Credit Memo grid to have only a single row with a single GL and the open amount of AR Invoice.

rajesh_khater
Active Participant
0 Kudos

I tried this in the ItemEvent:

if (formType == 10012)        //List of AR Invoices in AR Credit Memo->Copy From

{

    if (pVal.ItemUID.Equals("1")    //Add / Update Button
          && pVal.Before_Action == true)

    {

    BubbleEvent = false;
   

SBO_Application.StatusBar.SetText("Choose Event Fired", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);

SAPbouiCOM.Form activeForm = null;
activeForm = SBO_Application.Forms.ActiveForm;

activeForm.Close();

    }

}

Because I set BubbleEvent to false, the Draw Document Wizard is not coming and due to activeForm.Close() the List of AR Invoices window is getting closed.

How do I read the current selected AR Invoice before closing the window, and how do I fill the AR Credit Memo grid?

Thanks.

rajesh_khater
Active Participant
0 Kudos

I got up to this far. I am able to read the currently selected AR Invoice in the List of AR Invoices, stop the Draw Document Wizard, clear the grid in AR Credit Memo, and change the AR Credit Memo to Service Type.

While trying to set value for GL Code and Total fields in the matrix, I am getting error: Addon failed with exception.

if (formType == 10012)  //List of AR Invoices in AR Credit Memo->Copy From

{

    if (pVal.ItemUID.Equals("1")   //Choose Button
     && pVal.Before_Action == true

    {

BubbleEvent = false;
SBO_Application.StatusBar.SetText("Choose Event Fired", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);

SAPbouiCOM.Form activeForm = null;

activeForm = SBO_Application.Forms.ActiveForm;

SAPbouiCOM.Matrix oMatrix1;
oMatrix1 = (SAPbouiCOM.Matrix)activeForm.Items.Item("7").Specific;
int row = oMatrix1.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_SelectionOrder);

SBO_Application.StatusBar.SetText("Selected Row: " + row.ToString(), SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);

string docNumStr = ((SAPbouiCOM.EditText)oMatrix1.Columns.Item("DocNum").Cells.Item(row).Specific).Value;
int docNum = int.Parse(docNumStr);

SBO_Application.StatusBar.SetText("Selected Row: " + row.ToString() + ", DocNum: " + docNumStr, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);

activeForm.Close();

activeForm = SBO_Application.Forms.ActiveForm;

SAPbouiCOM.Matrix oMatrix2;

//Matrix for Item Type document
oMatrix2 = (SAPbouiCOM.Matrix)activeForm.Items.Item("38").Specific;

oMatrix2.Clear();

//Matrix for Service Type document
oMatrix2 = (SAPbouiCOM.Matrix)activeForm.Items.Item("39").Specific;

oMatrix2.Clear();

SAPbobsCOM.Documents oDocuments;oDocuments = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
oDocuments.GetByKey(docNum);

SBO_Application.StatusBar.SetText("DocNum: " + docNumStr + ", Posting Date: " + oDocuments.TaxDate.ToString("dd-MMM-yyyy"), SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);

//Change document type to Service
SAPbouiCOM.ComboBox oCombo1;
oCombo1 = (SAPbouiCOM.ComboBox)activeForm.Items.Item("3").Specific;

oCombo1.Select("Service", SAPbouiCOM.BoSearchKey.psk_ByDescription);

//((SAPbouiCOM.EditText)oMatrix2.Columns.Item("2").Cells.Item(1).Specific).String = "635030";

//This gives error "Addon failed with exception"
((SAPbouiCOM.EditText)oMatrix2.Columns.Item("12").Cells.Item(1).Specific).String = "1000.00";

    }

}