<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="https://www.schweda.net/style_feed.css" ?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:atom="http://www.w3.org/2005/Atom"	
	xmlns:dc="http://purl.org/dc/elements/1.1/" > 
<channel>
    <title>schweda.net - Blog</title>
    <link>https://www.schweda.net/</link>
    <description>schweda.net - Blog - Blog-Beitraege</description>
    <language>de-at</language>
    <copyright>Copyright 2006-2026</copyright>
    <generator>schweda.net</generator>
    <managingEditor>heinz.schweda@schweda.net (Heinz Schweda)</managingEditor>
    <webMaster>heinz.schweda@schweda.net (Heinz Schweda)</webMaster>
    <category>Blog</category>
	<atom:link href="https://www.schweda.net/blog_rss.php?bid=518" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[Reservieren/Unreservieren einer Auftragsposition]]></title>
<description><![CDATA[
<p>Beispiele wie man eine Auftragsposition reserviert oder unreserviert findet man im Internet des &Ouml;fteren. Allerdings habe ich kein Beispiel&nbsp;gefunden, wo anschlie&szlig;end gepr&uuml;ft wurde ob diese Reservierung auch gut gegangen ist.
</p>


<p>Deshalb habe ich mir ein solches St&uuml;ck Code selbst erarbeiten d&uuml;rfen. Dabei vergleiche ich ganz einfach den vorher reservierten Wert mit dem danach reservierten Wert. Ist dieser ident, gehe ich davon aus, da&szlig; die Reservierung nicht gut gegangen ist.
</p>


<pre class="pre_blog_axcode">
static void reserveSalesLine(Args _args)
{
    InventTransIdSumSingleStatus inventTransIdSumSingleStatus;
    SalesLine salesLine;
    InventMovement inventMovement;
    InventDim inventDim;
    InventDimParm inventDimParmCriteria;
    InventQtyReservPhysical oldReservedQty;
    InventQtyReservPhysical newReservedQty;
    InventUpd_Reservation inventUpd_Reservation;
    InventQty reserveQty;

    // Inline method to get current reserved quantity for specific inventDim
    InventQtyReservPhysical getReservedQty()
    {
        inventDimParmCriteria.initFromInventDim(inventDim);        

        inventTransIdSumSingleStatus = InventTransIdSumSingleStatus::newTransOriginIdStatus(InventTransOriginSalesLine::findInventTransOriginId(salesLine.DataAreaId, salesLine.InventTransId),
                                                                                            StatusReceipt::None,
                                                                                            StatusIssue::ReservPhysical);
        inventTransIdSumSingleStatus.parmInventDimCriteria(inventDim);
        inventTransIdSumSingleStatus.parmInventDimParmCriteria(inventDimParmCriteria);

        return inventTransIdSumSingleStatus.reservPhysical();
    }

    // Sales order line
    salesLine = SalesLine::findInventTransId(&#39;012431&#39;);
    inventMovement = InventTrans::findTransId(salesLine.InventTransId).inventMovement(true);

    // Build inventDim-Record, where the quantity should be reserved
    inventDim.clear();
    inventDim.InventSiteId      = &quot;1&quot;;
    inventDim.InventLocationId  = &quot;12&quot;;
    inventDim.wmsLocationId     = &quot;12&quot;;
    inventDim = InventDim::findOrCreate(inventDim);

    // Get current physical reserved Quantity
    oldReservedQty = getReservedQty();

    // Set quanity which should be reserved (negative values to reserve, postive value to unreserve)
    reserveQty = -2;

    inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventMovement,
                                                                inventDim,
                                                                reserveQty,
                                                                true);
    inventUpd_Reservation.updateNow();

    // Get new reserved quantity
    newReservedQty = getReservedQty();

    // Compare old and new reserved quantity to identify if reservation failed
    if(oldReservedQty == newReservedQty)
    {
        error(&quot;Reservation failed.&quot;);
    }
}
</pre>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Sat, 03 Jan 2015 19:50:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=518</link>
<comments>https://www.schweda.net/blog_ax.php?bid=518</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=518</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=518</wfw:commentRss>
</item>
<item>
<title>Kommentar von Lewis Batcher</title>
<description><![CDATA[Thank you. I was able to get unreserved and then reserve working.]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Thu, 10 Nov 2016 00:31:00 +0100</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=518</link>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=518</guid>
<author>Lewis Batcher</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=518</wfw:commentRss>
</item>
<item>
<title>Kommentar von Guest</title>
<description><![CDATA[Very helpful piece of code, thank you.]]></description>
<category></category>
<pubDate>Thu, 01 Dec 2016 23:02:00 +0100</pubDate>
<link>https://www.schweda.net/blog.php?bid=518</link>
<guid isPermaLink="true">https://www.schweda.net/blog.php?bid=518</guid>
<author>Guest</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog.php?bid=518</wfw:commentRss>
</item>
<item>
<title>Kommentar von Francisco</title>
<description><![CDATA[Muchas gracias, resolviste mi problema]]></description>
<category></category>
<pubDate>Fri, 19 Mar 2021 04:10:00 +0100</pubDate>
<link>https://www.schweda.net/blog.php?bid=518</link>
<guid isPermaLink="true">https://www.schweda.net/blog.php?bid=518</guid>
<author>Francisco</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog.php?bid=518</wfw:commentRss>
</item>
<item>
<title>Kommentar von Peter</title>
<description><![CDATA[Thanks for your code]]></description>
<category></category>
<pubDate>Mon, 18 Oct 2021 10:59:00 +0200</pubDate>
<link>https://www.schweda.net/blog.php?bid=518</link>
<guid isPermaLink="true">https://www.schweda.net/blog.php?bid=518</guid>
<author>Peter</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog.php?bid=518</wfw:commentRss>
</item>
<item>
<title>Kommentar von Piyush</title>
<description><![CDATA[How can i use it in Custom service integration in D365 FO]]></description>
<category></category>
<pubDate>Thu, 18 May 2023 08:03:00 +0200</pubDate>
<link>https://www.schweda.net/blog.php?bid=518</link>
<guid isPermaLink="true">https://www.schweda.net/blog.php?bid=518</guid>
<author>Piyush</author>
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Heinz Schweda</dc:creator>
<wfw:commentRss>https://www.schweda.net/blog.php?bid=518</wfw:commentRss>
</item>
</channel>
</rss>	
