Create PartPlant records with BPM

Ok I wrote a procedure to do this, and I still get this error. I have no idea what I am missing
** ABL Debug-Alert Stack Trace **
[GetPartPlant bpm/customcode/GetNewPartPlant.p (e:\Epicor905\Server\bpm\customcode\GetNewPartPlant.p) at line 6936
UpdatePost230_A2 bo/Part/Part.p (e:\Epicor905\bpmExec\TrainingBPM\bo\Part\Part.r) at line 10675
Update bo/Part/Part.p (e:\Epicor905\bpmExec\TrainingBPM\bo\Part\Part.r) at line 12675
Update bo/Part/Sink.p (e:\Epicor905\Server\bo\Part\Sink.r) at line 2847
(Procedure: 'GetPartPlant bpm/customcode/GetNewPartPlant.p' Line:6935) MJP30T
** No ttPart record is available. (91) 

 

Most Recent Procedure:

{Bpm/Bpm.i &OBJECT_NAME="Part" &BPM_BO_SOURCE_BO=1 &CUSTCODE=1 &CUR-COMP=""}
{Bpm/MiscCallContext.i}
{core/UserDefinedData.i "new global"}

procedure GetPartPlant:
define input-output parameter dataset for PartDataSet.
define variable ipart as Character.
Define buffer altTTPartPlant for ttPartPlant.
Define buffer altTTPart for ttPart.
{&TRY_PRIVATE}

/*   */
FOR EACH TTPART NO-LOCK.
ipart= TTPART.PartNum.
define variable NewPlant as handle no-undo.
run bo/Part/Part.P Persistent set NewPlant no-error.
if not valid-handle(NewPlant ) or error-status:error then
  do:
  Message "Unable To Create Part Plants".
  return.
end.
DEFINE VARIABLE PLANTEXISTS AS CHARACTER INITIAL ''   NO-UNDO.
DEFINE VARIABLE TEST AS CHARACTER INITIAL ''   NO-UNDO.

 FOR EACH PARTPLANT WHERE PARTPLANT.Company=TTPART.COMPANY AND PARTPLANT.PartNum=TTPART.PartNum NO-LOCK.
  IF AVAILABLE PARTPLANT THEN DO:
   PLANTEXISTS=PLANTEXISTS  + PARTPLANT.Plant + ', '.
  END.
 END.

 FOR EACH PLANT WHERE PLANT.Company=ttpart.company AND  (PLANTEXISTS MATCHES '*' + PLANT.PLANT + '*')=FALSE NO-LOCK.
  IF AVAILABLE PLANT THEN DO:

   FOR EACH UD36 WHERE UD36.COMPANY=PLANT.Company AND UD36.Key1=PLANT.PLANT NO-LOCK.
    IF AVAILABLE UD36 THEN DO:


      run GetNewPartPlant in NewPlant({&input-output_dataset_PartDataSet},input ipart).  
Message Plant.Plant.
   ttPartPlant.Company = TTPART.Company.
    ttPartPlant.PartNum = TTPART.PARTNUM.
    ttPartPlant.Plant = PLANT.Plant.
    ttPartPlant.ReOrderLevel =FALSE.
   TTPARTPLANT.BackFlush=FALSE.
   TTPARTPLANT.CostMethod='A'.
   TTPARTPLANT.TransferLeadTime=3.
   TTPARTPLANT.DaysOfSupply=14.
   TTPARTPLANT.ProcessMRP=TRUE.
   TTPARTPLANT.GenerateSugg=TRUE.
   TTPARTPLANT.BuyToOrder=FALSE.
   TTPARTPLANT.PhantomBOM=FALSE.
   TTPARTPLANT.NonStock=FALSE.
   TTPARTPLANT.QtyBearing=TRUE.
   TTPARTPLANT.KitAllowUpdate=FALSE.
   TTPARTPLANT.KitAllowChangeParms=FALSE.
   TTPARTPLANT.PrimWhse=UD36.SHORTCHAR01.
   TTPARTPLANT.SourceType= IF PLANT.PLANT='MJP02' THEN TTPART.TypeCode ELSE UD36.ShortChar03.
   TTPARTPLANT.TransferPlant=UD36.SHORTCHAR04.
   /*TTPARTPLANT.VendorNumVendorID=''.*/
   /*TTPARTPLANT.PurPoint=''.*/
   /*TTPARTPLANT.BuyerID=''.*/
   /*TTPARTPLANT.PersonID=''.*/
   TTPARTPLANT.LeadTime=0.
   TTPart.Rowmod='U'.
  
             run Update in NewPlant({&input-output_dataset_PartDataset}).
Message "i got here 6".
     end. /*avail ud36*/
    end. /*for ud36*/
      end. /*if avail plant*/
    end. /*each plant*/
end. /*Each ttpart*/
{&CATCH_PRIVATE}
end procedure.



---In vantage@yahoogroups.com, <livingstonmh@...> wrote:

I am trying to create a BPM that will create all of the Partplant records when a new part is entered. I have it pulling some of the defaults I need off of a UD table.

 

I tried using an Updateable BAQ BPM as an example, but I keep getting errors in the server like:

 "createConstants" was not found. (293)

or when I remove that part of the code:

 "ZeroizeBuf" was not found. (293)

and when i removed that i got:

** No ttPart record is available. (91)

 

This is my first venture into creating records with a BPM so I am a bit lost. Follwing is my current code:

def var NEWPLANT as handle no-undo.
def var errorsOccured as logical no-undo.
run bo/Part/Part.p persistent set NEWPLANT.
run createConstants.
do on error undo, leave:
 dataset PartDataSet:empty-dataset().


    create ttPartPlant.
    run ZeroizeBuf(temp-table ttPartPlant:default-buffer-handle).
    ttPartPlant.Company = TTPART.Company.
    ttPartPlant.PartNum = TTPART.PARTNUM.
    ttPartPlant.Plant = PLANT.Plant.
    ttPartPlant.ReOrderLevel =FALSE.
  TTPARTPLANT.BackFlush=FALSE.
  TTPARTPLANT.CostMethod='A'.
  TTPARTPLANT.TransferLeadTime=3.
  TTPARTPLANT.DaysOfSupply=14.
  TTPARTPLANT.ProcessMRP=TRUE.
  TTPARTPLANT.GenerateSugg=TRUE.
  TTPARTPLANT.BuyToOrder=FALSE.
  TTPARTPLANT.PhantomBOM=FALSE.
  TTPARTPLANT.NonStock=FALSE.
  TTPARTPLANT.QtyBearing=TRUE.
  TTPARTPLANT.KitAllowUpdate=FALSE.
  TTPARTPLANT.KitAllowChangeParms=FALSE.
  TTPARTPLANT.PrimWhse=UD36.SHORTCHAR01.
  TTPARTPLANT.SourceType= IF PLANT.PLANT='MJP02' THEN TTPART.TypeCode ELSE UD36.ShortChar03.
  TTPARTPLANT.TransferPlant=UD36.SHORTCHAR04.
  /*TTPARTPLANT.VendorNumVendorID=''.*/
  /*TTPARTPLANT.PurPoint=''.*/
  /*TTPARTPLANT.BuyerID=''.*/
  /*TTPARTPLANT.PersonID=''.*/
  TTPARTPLANT.LeadTime=0.
  
/*
    create ttPart.
    run ZeroizeBuf(temp-table ttPart:default-buffer-handle).
    ttPart.RowIdent = '#' + ttResults.RowIdent.
    ttPart.Company = Constants.CurrentCompany.
    ttPart.PartDescription = ttResults.Part_PartDescription.
    ttPart.PartNum = ttResults.PartPlant_PartNum.
*/
    run GetNewPartPlant in NEWPLANT(input-output dataset PartDataSet, true, true, output dataset BOUpdErrorDataset, output errorsOccured).
    delete object NEWPLANT.
    END.

 

I am trying to create a BPM that will create all of the Partplant records when a new part is entered. I have it pulling some of the defaults I need off of a UD table.

 

I tried using an Updateable BAQ BPM as an example, but I keep getting errors in the server like:

 "createConstants" was not found. (293)

or when I remove that part of the code:

 "ZeroizeBuf" was not found. (293)

and when i removed that i got:

** No ttPart record is available. (91)

 

This is my first venture into creating records with a BPM so I am a bit lost. Follwing is my current code:

def var NEWPLANT as handle no-undo.
def var errorsOccured as logical no-undo.
run bo/Part/Part.p persistent set NEWPLANT.
run createConstants.
do on error undo, leave:
 dataset PartDataSet:empty-dataset().


    create ttPartPlant.
    run ZeroizeBuf(temp-table ttPartPlant:default-buffer-handle).
    ttPartPlant.Company = TTPART.Company.
    ttPartPlant.PartNum = TTPART.PARTNUM.
    ttPartPlant.Plant = PLANT.Plant.
    ttPartPlant.ReOrderLevel =FALSE.
  TTPARTPLANT.BackFlush=FALSE.
  TTPARTPLANT.CostMethod='A'.
  TTPARTPLANT.TransferLeadTime=3.
  TTPARTPLANT.DaysOfSupply=14.
  TTPARTPLANT.ProcessMRP=TRUE.
  TTPARTPLANT.GenerateSugg=TRUE.
  TTPARTPLANT.BuyToOrder=FALSE.
  TTPARTPLANT.PhantomBOM=FALSE.
  TTPARTPLANT.NonStock=FALSE.
  TTPARTPLANT.QtyBearing=TRUE.
  TTPARTPLANT.KitAllowUpdate=FALSE.
  TTPARTPLANT.KitAllowChangeParms=FALSE.
  TTPARTPLANT.PrimWhse=UD36.SHORTCHAR01.
  TTPARTPLANT.SourceType= IF PLANT.PLANT='MJP02' THEN TTPART.TypeCode ELSE UD36.ShortChar03.
  TTPARTPLANT.TransferPlant=UD36.SHORTCHAR04.
  /*TTPARTPLANT.VendorNumVendorID=''.*/
  /*TTPARTPLANT.PurPoint=''.*/
  /*TTPARTPLANT.BuyerID=''.*/
  /*TTPARTPLANT.PersonID=''.*/
  TTPARTPLANT.LeadTime=0.
  
/*
    create ttPart.
    run ZeroizeBuf(temp-table ttPart:default-buffer-handle).
    ttPart.RowIdent = '#' + ttResults.RowIdent.
    ttPart.Company = Constants.CurrentCompany.
    ttPart.PartDescription = ttResults.Part_PartDescription.
    ttPart.PartNum = ttResults.PartPlant_PartNum.
*/
    run GetNewPartPlant in NEWPLANT(input-output dataset PartDataSet, true, true, output dataset BOUpdErrorDataset, output errorsOccured).
    delete object NEWPLANT.
    END.