Does anyone know if you can do this or has done it?
What do you mean when raised? I’ve written ABL code which brings in part attachments from part entry to the material in job entry automatically when the part is added there. Carrying those through to PO Entry has been on the to do list for some time. Are you just looking to add the part attachment when you add a part to a PO?
-Bobby
Yes, looking to add the part attachment when the part is added to a PO. I would also be interested in the pat attachment relating to material on a job as well.
Here’s my ABL code to create attachments in job entry from part entry for job materials. It works pretty well, only thing is that you have to click refresh to see the attached part. I never really figured that step out. Maybe someone here can provide a small tweak. It should be a pretty similar process going to POEntry.
/* Job Mtl Attachment Update*/
/*BA 9/14/15*/
Define variable JobNum as character no-undo.
Define variable AsmNum as integer no-undo.
Define variable MtlNum as integer no-undo.
Define variable FileName as character no-undo.
Define variable FileDesc as character no-undo.
Define variable DrawingSeq as integer no-undo.
Define variable FileRefNum as integer no-undo.
Define variable AttachNum as integer no-undo.
Define Variable partrefnum as integer no-undo.
Define variable jobmtlfilename as character no-undo.
/* get the job row that has been added or updated*/
For first ttJobMtl where ttjobmtl.RowMod = 'A' or ttjobmtl.RowMod = 'U'.
/* assign key fields to variables*/
Assign JobNum = ttJobMtl.JobNum
AsmNum = ttJobMtl.AssemblySeq
MtlNum = ttJobMtl.MtlSeq.
/* find the last xfileattch record. for this job mtl row. check to see if there is an attachment on the part table */
Find first XfileAttch where XfileAttch.company = cur-comp and XfileAttch.Relatedtofile = "Part" and XfileAttch.Key1 = ttjobmtl.partnum no-lock.
/* if there is an attachment record, then get the file name and description from the xfileref table, assign to variables */
if available xfileattch then do:
Find first XfileRef where XfileRef.company = cur-comp and XfileRef.XFileRefNum = xfileattch.XFileRefNum no-lock.
Assign FileName = XfileRef.XFileName
FileDesc = XfileRef.XFileDesc.
/*this is just to verify that there is a xfileref record, before preceeding */
If available xfileref then do:
/* check to see if there is an attachment for that job row. if there is set the file name for comparision, otherwise set filename to no file */
Find last XfileAttch where XfileAttch.company = cur-comp and XfileAttch.RelatedToFile = "JobMtl" and XfileAttch.Key1 = JobNum and XfileAttch.Key2 = string(AsmNum) and XfileAttch.Key3 = string(MtlNum) no-lock no-error.
if available xfileattch and filename = xfileref.XFileName then
return.
else if available xfileattch and filename <> xfileref.XFileName then
assign attachnum = xfileattch.AttachNum + 1.
else attachnum = 1.
/* get last row of xfileref table, and increment the filerefnum by 1*/
find last xfileref no-lock.
assign filerefnum = xfileref.XFileRefNum + 1.
/* create a row in the xfileattch table */
create xfileattch.
assign xfileattch.Company = cur-comp
xfileattch.Key1 = JobNum
xfileattch.Key2 = string(AsmNum)
xfileattch.Key3 = string(MtlNum)
xfileattch.Key4 = ""
xfileattch.Key5 = ""
xfileattch.RelatedToFile = "JOBMTL":U
xfileattch.Attachnum = attachnum
xfileattch.XFileRefNum = filerefnum.
/*create a row in the xfile ref table */
create xfileref.
assign xfileref.Company = cur-comp
xfileref.XFileRefNum = filerefnum
xfileref.XFileName = FileName
xfileref.XFileDesc = FileDesc.
{lib/PublishInfoMsg.i &InfoMsg = '"Document Attached"'}.
End.
End.
End.
Hope that helps,
Bobby
Normally I notice that a refresh is necessary when you use a post-process directive; it may be that a pre-process directive would alleviate this issue. I’ve never done an attachment before; attachments may be different.
Thanks Bobby finally have been able to get back to this… your code with a bit of tweaking works a treat. I too have the same issue regarding the refresh but minor issue really. I’m using in pre-processing so that made no difference.