Increment Number field when duplicate Key2 in UD

FYI, this didn't work.

I've tried this on a data directive and it didn't work either.  

The data is being populated by Service Connect workflow I wrote so maybe I'll try to do that incrementing in the workflow, but that's a whole other issue.

Hello, 


I'm trying to emulate the activity of creating line numbers in my UD table.  


Essentially, if a UD01 record is entered and the Key2 field is not a duplicate of an existing UD01 record, I want the Number05 field to be 1.  if a UD01 record is entered and the Key2 field is a duplicate of an existing UD01 record, I want the Number05 field to increment by 1.  


So far, I have a single pre-processing directive with no condition that runs this code:


FIND LAST ud01 where ud01.company=ttud01.company and ud01.key2=ttud01.key2 no-lock no-error.


IF NOT AVAILABLE ud01 then do:

Assign ttud01.number05 = 1.

Next.


IF Available ud01 then do:

assign ttud01.number05 = ud01.number05 + 1.

end.


end.

 


The code validates but the effect does not occur.  I think I'm having an issue with the error.  Should I split the code and create 2 BPMs that independently test for each scenario?  Is pre-processing even the correct action?  Should this be a data directive?  Am I way off in how I'm approaching this?


Thanks for any help in advance.

Wouldn't it be:

assign ttud01.number05 = TTud01.number05 + 1.


Steven G.



On Thursday, December 10, 2015 9:47 AM, "jockthemotie@... [vantage]" <vantage@yahoogroups.com> wrote:


 
<div id="ygrps-yiv-628080638yiv5740925386ygrp-text">
  
  
  <div></div><div><span>Hello,&nbsp;</span></div><div><span><br clear="none"></span></div><div><span>I&#39;m trying to emulate the activity of creating line numbers in my UD table. &nbsp;</span></div><div><span><br clear="none"></span></div><div><span>Essentially, if a UD01 record is entered and the Key2 field is not a duplicate of an existing UD01 record, I want the Number05 field to be 1. &nbsp;</span><span style="word-spacing:normal;">if a UD01 record is entered and the Key2 field <i>is</i> a duplicate of an existing UD01 record, I want the Number05 field to increment by 1. &nbsp;</span></div><div><span style="word-spacing:normal;"><br clear="none"></span></div><div><span style="word-spacing:normal;">So far, I have a single pre-processing directive with no condition that runs this code:</span></div><div><span style="word-spacing:normal;"><br clear="none"></span></div><div>FIND LAST ud01 where ud01.company=ttud01.company and ud01.key2=ttud01.key2 no-lock no-error.</div><div><br clear="none"></div><div>IF NOT AVAILABLE ud01 then do:</div><div>Assign ttud01.number05 = 1.</div><div>Next.</div><div><br clear="none"></div><div>IF Available ud01 then do:</div><div>assign ttud01.number05 = ud01.number05 + 1.</div><div>end.</div><div><br clear="none"></div><div><span></span></div><div>end.</div><div><span>&nbsp;</span></div><div><span><br clear="none"></span></div><div><span>The code validates but the effect does not occur. &nbsp;I think I&#39;m having an issue with the error. &nbsp;Should I split the code and create 2 BPMs that independently test for each scenario? &nbsp;Is pre-processing even the correct action? &nbsp;Should this be a data directive? &nbsp;Am I way off in how I&#39;m approaching this?</span></div><div><span><br clear="none"></span></div><div><span>Thanks for any help in advance.</span></div>

</div>
 


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

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mkp hr {
border:1px solid #d8d8d8;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mkp #ygrps-yiv-628080638yiv5740925386hd {
color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mkp #ygrps-yiv-628080638yiv5740925386ads {
margin-bottom:10px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mkp .ygrps-yiv-628080638yiv5740925386ad {
padding:0 0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mkp .ygrps-yiv-628080638yiv5740925386ad p {
margin:0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mkp .ygrps-yiv-628080638yiv5740925386ad a {
color:#0000ff;text-decoration:none;}
#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-sponsor #ygrps-yiv-628080638yiv5740925386ygrp-lc {
font-family:Arial;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-sponsor #ygrps-yiv-628080638yiv5740925386ygrp-lc #ygrps-yiv-628080638yiv5740925386hd {
margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-sponsor #ygrps-yiv-628080638yiv5740925386ygrp-lc .ygrps-yiv-628080638yiv5740925386ad {
margin-bottom:10px;padding:0 0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386actions {
font-family:Verdana;font-size:11px;padding:10px 0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386activity {
background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386activity span {
font-weight:700;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386activity span:first-child {
text-transform:uppercase;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386activity span a {
color:#5085b6;text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386activity span span {
color:#ff7900;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386activity span .ygrps-yiv-628080638yiv5740925386underline {
text-decoration:underline;}

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

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386attach div a {
text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386attach img {
border:none;padding-right:5px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386attach label {
display:block;margin-bottom:5px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386attach label a {
text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 blockquote {
margin:0 0 0 4px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386bold {
font-family:Arial;font-size:13px;font-weight:700;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386bold a {
text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 dd.ygrps-yiv-628080638yiv5740925386last p a {
font-family:Verdana;font-weight:700;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 dd.ygrps-yiv-628080638yiv5740925386last p span {
margin-right:10px;font-family:Verdana;font-weight:700;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 dd.ygrps-yiv-628080638yiv5740925386last p span.ygrps-yiv-628080638yiv5740925386yshortcuts {
margin-right:0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386attach-table div div a {
text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386attach-table {
width:400px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386file-title a, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386file-title a:active, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386file-title a:hover, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386file-title a:visited {
text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386photo-title a, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386photo-title a:active, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386photo-title a:hover, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div.ygrps-yiv-628080638yiv5740925386photo-title a:visited {
text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 div#ygrps-yiv-628080638yiv5740925386ygrp-mlmsg #ygrps-yiv-628080638yiv5740925386ygrp-msg p a span.ygrps-yiv-628080638yiv5740925386yshortcuts {
font-family:Verdana;font-size:10px;font-weight:normal;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386green {
color:#628c2a;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386MsoNormal {
margin:0 0 0 0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 o {
font-size:0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386photos div {
float:left;width:72px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386photos div div {
border:1px solid #666666;height:62px;overflow:hidden;width:62px;}

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

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386reco-category {
font-size:77%;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386reco-desc {
font-size:77%;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 .ygrps-yiv-628080638yiv5740925386replbq {
margin:4px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-actbar div a:first-child {
margin-right:2px;padding-right:5px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mlmsg {
font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mlmsg table {
font-size:inherit;font:100%;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mlmsg select, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 input, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 textarea {
font:99% Arial, Helvetica, clean, sans-serif;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mlmsg pre, #ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 code {
font:115% monospace;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mlmsg * {
line-height:1.22em;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-mlmsg #ygrps-yiv-628080638yiv5740925386logo {
padding-bottom:10px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-msg p a {
font-family:Verdana;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-msg p#ygrps-yiv-628080638yiv5740925386attach-count span {
color:#1E66AE;font-weight:700;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-reco #ygrps-yiv-628080638yiv5740925386reco-head {
color:#ff7900;font-weight:700;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-reco {
margin-bottom:20px;padding:0px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-sponsor #ygrps-yiv-628080638yiv5740925386ov li a {
font-size:130%;text-decoration:none;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-sponsor #ygrps-yiv-628080638yiv5740925386ov li {
font-size:77%;list-style-type:square;padding:6px 0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-sponsor #ygrps-yiv-628080638yiv5740925386ov ul {
margin:0;padding:0 0 0 8px;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-text {
font-family:Georgia;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-text p {
margin:0 0 1em 0;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-text tt {
font-size:120%;}

#ygrps-yiv-628080638 #ygrps-yiv-628080638yiv5740925386 #ygrps-yiv-628080638yiv5740925386ygrp-vital ul li:last-child {
border-right:none !important;}
#ygrps-yiv-628080638



Thanks Steve, 

I figured if I'm incrementing, I need to be incrementing on the LAST UD01 record that that the FIND brings up, which is why I had it as ud01.number05 + 1. 

But I'll switch it up and see what happens.