BPM to write UD fields from QuoteDtl to OrderDtl (During PasteIn

Update - I got it working!

SalesOrder.Update
pre-processing

condition: there is at least one added row in the ttOrderDtl table

4GL code:
Find first ttorderdtl where ttorderdtl.rowmod="A" or ttorderdtl.rowmod="U" no-lock no-error. 
If available ttorderdtl then do:
If ttOrderdtl.quoteNum <> 0 then Do:
find first quotedtl where ttOrderdtl.Company = quotedtl.Company and  ttOrderdtl.quoteNum = quotedtl.quoteNum  and ttOrderdtl.quoteline = quotedtl.quoteline  no-lock.
If available quotedtl then do:
if not error-status:error  then do:
ttOrderDtl.Number02 = QuoteDtl.Number02.
end.
end.  
end.
end.

Hi,

We are currently on Vantage 8.03.  I am trying to write a bpm to copy fields from QuoteDtl to OrderDtl when paste-inserting lines into a sales order.


Can anyone help me with this non-working bpm 4GL code?


My bpm for SalesOrder.GetNewOrderDtl.  It doesn't work:

For each ttOrderDtl:

    Find first QuoteDtl no-lock where QuoteDtl.Company = cur-comp and QuoteDtl.QuoteNum = ttOrderDtl.QuoteNum and QuoteDtl.QuoteLine = ttOrderDtl.QuoteLine no-error.

    If available QuoteDtl then do:

        ttOrderDtl.Character01 = QuoteDtl.Character01.

        Find first OrderDtl no-lock where RowID(OrderDtl) = to-RowID (ttOrderDtl.RowIdent) no-error.

        If available OrderDtl then do:

            run lib\updateTableBuffer.p (input buffer OrderDtl:handle, input "Character01", input QuoteDtl.Character01).

        end.

    end.

end.





My bpm for Quote.CreateOrder.  It works perfectly:
for each ttquotedtl:
find first orderdtl no-lock where OrderDtl.Company = CUR-COMP and OrderDtl.OrderNum = OrderNum and OrderDtl.QuoteNum = ttQuoteDtl.QuoteNum and OrderDtl.QuoteLine = ttQuoteDtl.QuoteLine no-error.
if available OrderDtl then do:
run lib\updateTableBuffer.p (input buffer OrderDtl:handle, input "Character01", input ttQuoteDtl.Character01).
end.
end.


Dan,

Can you give us the error code you're getting. I can parse through your ABL better if I know what the error and code are.
 
Thanks,
Jonathan Lang
I.T Manager
Database Engineer



On Thursday, February 11, 2016 8:16 PM, "daniel.nickoley@... [vantage]" <vantage@yahoogroups.com> wrote:


 
<div id="ygrps-yiv-658037136yiv0682188917ygrp-text">
  
  
  <div></div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">Hi,<br clear="none"><br clear="none">We are currently on Vantage 8.03. &nbsp;I am trying to write a bpm to copy fields from QuoteDtl to OrderDtl when paste-inserting lines into a sales order.</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;"><br clear="none"></div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">Can anyone help me with this non-working bpm 4GL code?</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;"><br clear="none"></div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;"><span style="text-decoration:underline;"><strong>My bpm for SalesOrder.GetNewOrderDtl. &nbsp;It doesn&#39;t work:</strong></span></div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">For each ttOrderDtl:</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp;&nbsp;&nbsp;&nbsp;Find first QuoteDtl no-lock where QuoteDtl.Company = cur-comp and QuoteDtl.QuoteNum = ttOrderDtl.QuoteNum and QuoteDtl.QuoteLine = ttOrderDtl.QuoteLine no-error.</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp;&nbsp;&nbsp;&nbsp;If available QuoteDtl then do:</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp; &nbsp; &nbsp; &nbsp; ttOrderDtl.Character01 = QuoteDtl.Character01.</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp; &nbsp; &nbsp; &nbsp; Find first OrderDtl no-lock where RowID(OrderDtl) = to-RowID (ttOrderDtl.RowIdent) no-error.</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If available OrderDtl then do:</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run lib&#92;updateTableBuffer.p (input buffer OrderDtl:handle, input &quot;Character01&quot;, input QuoteDtl.Character01).</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end.</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">&nbsp;&nbsp;&nbsp;&nbsp;end.</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;">end.</div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;"><br clear="none"></div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;"><span style="text-decoration:underline;"><strong><br clear="none"></strong></span></div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;"><br clear="none"></div><div><span></span></div><div style="margin-top:0px;margin-bottom:0px;font-family:Arial;"><br clear="none"><span style="text-decoration:underline;"><strong>My bpm for Quote.CreateOrder. &nbsp;It works perfectly:</strong></span><br clear="none">for each ttquotedtl:<br clear="none"><span class="ygrps-yiv-658037136yiv0682188917Apple-tab-span" style="white-space:pre;">	</span>find first orderdtl no-lock where OrderDtl.Company = CUR-COMP and OrderDtl.OrderNum = OrderNum and OrderDtl.QuoteNum = ttQuoteDtl.QuoteNum and OrderDtl.QuoteLine = ttQuoteDtl.QuoteLine no-error.<br clear="none"><span class="ygrps-yiv-658037136yiv0682188917Apple-tab-span" style="white-space:pre;">	</span>if available OrderDtl then do:<br clear="none"><span class="ygrps-yiv-658037136yiv0682188917Apple-tab-span" style="white-space:pre;">	</span>run lib&#92;updateTableBuffer.p (input buffer OrderDtl:handle,&nbsp;input &quot;Character01&quot;,&nbsp;input ttQuoteDtl.Character01).<br clear="none"><span class="ygrps-yiv-658037136yiv0682188917Apple-tab-span" style="white-space:pre;">	</span>end.<br clear="none">end.</div><div><span><br clear="none" class="ygrps-yiv-658037136yiv0682188917yui-cursor"></span></div>

</div>
 


<div style="color:#fff;height:0;"></div></div>
#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917 -- #ygrps-yiv-658037136yiv0682188917ygrp-mkp { border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mkp hr {
border:1px solid #d8d8d8;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mkp #ygrps-yiv-658037136yiv0682188917hd {
color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mkp #ygrps-yiv-658037136yiv0682188917ads {
margin-bottom:10px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mkp .ygrps-yiv-658037136yiv0682188917ad {
padding:0 0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mkp .ygrps-yiv-658037136yiv0682188917ad p {
margin:0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mkp .ygrps-yiv-658037136yiv0682188917ad a {
color:#0000ff;text-decoration:none;}
#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-sponsor #ygrps-yiv-658037136yiv0682188917ygrp-lc {
font-family:Arial;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-sponsor #ygrps-yiv-658037136yiv0682188917ygrp-lc #ygrps-yiv-658037136yiv0682188917hd {
margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-sponsor #ygrps-yiv-658037136yiv0682188917ygrp-lc .ygrps-yiv-658037136yiv0682188917ad {
margin-bottom:10px;padding:0 0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917actions {
font-family:Verdana;font-size:11px;padding:10px 0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917activity {
background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917activity span {
font-weight:700;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917activity span:first-child {
text-transform:uppercase;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917activity span a {
color:#5085b6;text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917activity span span {
color:#ff7900;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917activity span .ygrps-yiv-658037136yiv0682188917underline {
text-decoration:underline;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917attach {
clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917attach div a {
text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917attach img {
border:none;padding-right:5px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917attach label {
display:block;margin-bottom:5px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917attach label a {
text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 blockquote {
margin:0 0 0 4px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917bold {
font-family:Arial;font-size:13px;font-weight:700;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917bold a {
text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 dd.ygrps-yiv-658037136yiv0682188917last p a {
font-family:Verdana;font-weight:700;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 dd.ygrps-yiv-658037136yiv0682188917last p span {
margin-right:10px;font-family:Verdana;font-weight:700;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 dd.ygrps-yiv-658037136yiv0682188917last p span.ygrps-yiv-658037136yiv0682188917yshortcuts {
margin-right:0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917attach-table div div a {
text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917attach-table {
width:400px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917file-title a, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917file-title a:active, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917file-title a:hover, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917file-title a:visited {
text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917photo-title a, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917photo-title a:active, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917photo-title a:hover, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div.ygrps-yiv-658037136yiv0682188917photo-title a:visited {
text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 div#ygrps-yiv-658037136yiv0682188917ygrp-mlmsg #ygrps-yiv-658037136yiv0682188917ygrp-msg p a span.ygrps-yiv-658037136yiv0682188917yshortcuts {
font-family:Verdana;font-size:10px;font-weight:normal;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917green {
color:#628c2a;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917MsoNormal {
margin:0 0 0 0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 o {
font-size:0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917photos div {
float:left;width:72px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917photos div div {
border:1px solid #666666;height:62px;overflow:hidden;width:62px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917photos div label {
color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917reco-category {
font-size:77%;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917reco-desc {
font-size:77%;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 .ygrps-yiv-658037136yiv0682188917replbq {
margin:4px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-actbar div a:first-child {
margin-right:2px;padding-right:5px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mlmsg {
font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mlmsg table {
font-size:inherit;font:100%;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mlmsg select, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 input, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 textarea {
font:99% Arial, Helvetica, clean, sans-serif;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mlmsg pre, #ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 code {
font:115% monospace;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mlmsg * {
line-height:1.22em;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-mlmsg #ygrps-yiv-658037136yiv0682188917logo {
padding-bottom:10px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-msg p a {
font-family:Verdana;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-msg p#ygrps-yiv-658037136yiv0682188917attach-count span {
color:#1E66AE;font-weight:700;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-reco #ygrps-yiv-658037136yiv0682188917reco-head {
color:#ff7900;font-weight:700;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-reco {
margin-bottom:20px;padding:0px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-sponsor #ygrps-yiv-658037136yiv0682188917ov li a {
font-size:130%;text-decoration:none;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-sponsor #ygrps-yiv-658037136yiv0682188917ov li {
font-size:77%;list-style-type:square;padding:6px 0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-sponsor #ygrps-yiv-658037136yiv0682188917ov ul {
margin:0;padding:0 0 0 8px;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-text {
font-family:Georgia;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-text p {
margin:0 0 1em 0;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-text tt {
font-size:120%;}

#ygrps-yiv-658037136 #ygrps-yiv-658037136yiv0682188917 #ygrps-yiv-658037136yiv0682188917ygrp-vital ul li:last-child {
border-right:none !important;}
#ygrps-yiv-658037136



Hi Jonathan,

Actually, there is no error message.

However, I have inserted some debugging code to pop up message boxes when that part of the code is triggered.

Message 1 pops up fine. But message 2 and message 3 do not pop up.

This tells me that my For Each, Find codes are flawed somehow.
First Query: Can't find the relevant QuoteDtl
2nd Query: Can't find the relevant OrderDtl (or just not prompted, as the first query failed, and the 2nd query is nested).

My bpm for SalesOrder.GetNewOrderDtl.  It doesn't work:

Define Variable debugMessage2 as Character.
Define Variable debugMessage3 as Character.

Assign debugMessage1 = "1 BPM started".
{lib/PublishInfoMsg.i &InfoMsg = debugMessage1 &InfoSeverity = {&MESSAGE_INFO}}

For each ttOrderDtl:
    Find first QuoteDtl no-lock where QuoteDtl.Company = cur-comp and QuoteDtl.QuoteNum = ttOrderDtl.QuoteNum and QuoteDtl.QuoteLine = ttOrderDtl.QuoteLine no-error.
    If available QuoteDtl then do:

                                         /* Pop up box if this part of the code is working */
Assign debugMessage2 = "2 BPM found available OrderDtl".
{lib/PublishInfoMsg.i &InfoMsg = debugMessage3 &InfoSeverity = {&MESSAGE_INFO}}

        ttOrderDtl.Character01 = QuoteDtl.Character01.
        Find first OrderDtl no-lock where RowID(OrderDtl) = to-RowID (ttOrderDtl.RowIdent) no-error.
        If available OrderDtl then do:

                 /* Pop up box if this part of the code is working */
Assign debugMessage3 = "3 BPM found available QuoteDtl".
{lib/PublishInfoMsg.i &InfoMsg = debugMessage2 &InfoSeverity = {&MESSAGE_INFO}}

            run lib\updateTableBuffer.p (input buffer OrderDtl:handle, input "Character01", input QuoteDtl.Character01).
        end.
    end.
end.