✏️ Explanatory Question

RMAs are showing open when they are invoiced

👁 26 Views
📘 Detailed Answer
🟢 Easy
26
Total Views
1
Related Qs
0%
Progress
💡

Answer with Explanation

🧾 Problem Summary:

You have RMA (Return Merchandise Authorization) records where:

  • The RMA header is showing “Open”,
  • But the RMA line is already “Invoiced.”

Also:

  • These RMAs have "hidden" lines or leftover reservations in the background.

This script forcibly cleans up RMA lines stuck in “Awaiting” status by resetting ExpectedRetQty. Once all lines are updated, the header status recalculates and reflects “Closed” correctly, resolving visual mismatches and potential backend issues (inventory, reports, etc.).


internal final class Ansari_RMAsareShowingOpen
{
    /// <summary>
    /// Class entry point. The system will call this method when a designated menu 
    /// is selected or when execution starts and this class is set as the startup class.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        SalesLine salesLine;
        container con  = [
            'SO0012841648', 'SO0012966020', 'SO0013818463', 'SO0013952092', 'SO0014033246',
            'SO0014200608', 'SO0014311955', 'SO0014319700', 'SO0014461221', 'SO0014734463',
            'SO0014782335', 'SO0014784571', 'SO0015082115', 'SO0015146940', 'SO0015166170',
            'SO0015431448', 'SO0015600158', 'SO0015682662', 'SO0015944752'];
 
        for(int i = 1; i <= conLen(con); i++)
        {
            while select forupdate salesLine
            where salesLine.SalesId ==  conPeek(con, i)
                && salesLine.ReturnStatus == ReturnStatusLine::Awaiting
                && salesLine.ExpectedRetQty == 1.0
            {
                if(salesLine.RecId)
                {
                    ttsbegin;
                    salesLine.ExpectedRetQty = -1;
                    salesLine.update();
                    ttscommit;
                }
            }
 
    
        }
    }

}