BurghMan
22nd October 2004, 22:46
I am making my first attempt at AFS. I am attempting to automate the print order documents session (tisfc0408m000). The reason for this is that our company started printing all documents duplex to save money. When printing a range of production orders and when the route sheet is an odd number of pages, the start a new route sheet prints on the back of the paper. They want all new route sheets to start on a new sheet of paper.

I thought with AFS I could print each document individually to solve this problem.

I am posting my code. I copied the original forms to my session and added afs. to all form fields. I am getting a “No data within selection” message.

Also, I have AFS logging turned on, but I am not sure what to look for. I can post the afs log if that would help.

Thanks in advance,

|********************************************************
declaration:
#pragma used dll ottstpapihand
|*********************************************************
choice.cont.process:
on.choice:
execute(print.data)
choice.print.data:
on.choice:
if rprt_open() then
read.main.table()
rprt_close()
else
choice.again()
endif
functions:
|******************************************************
function read.main.table()
{
afs.pdno = afs.pdno.f
while afs.pdno <= afs.pdno.t
afs.tisfc0408m000()
afs.pdno = afs.pdno + 1
endwhile
}
|*********************************************************
function afs.tisfc0408m000()
{
|*********************************************************

cprj.f = afs.cprj.f | ( I added afs. to all the fields on my form
cprj.t = afs.cprj.t
pdno.f = afs.pdno.f
pdno.t = afs.pdno.t
opno.f = afs.opno.f
opno.t = afs.opno.t
prdt.t = afs.prdt.t

|********************************************************
stpapi.enum.answer("tisfc0408m000", "order.sorted", tisfc.osrt.order)
stpapi.put.field("tisfc0408m000","cprj.f", afs.cprj.f)
stpapi.put.field("tisfc0408m000","cprj.t", afs.cprj.t)
stpapi.put.field("tisfc0408m000","pdno.f", str$(afs.pdno.f))
stpapi.put.field("tisfc0408m000","pdno.t", str$(afs.pdno.t))
stpapi.put.field("tisfc0408m000","opno.f", str$(afs.opno.f))
stpapi.put.field("tisfc0408m000","opno.t", str$(afs.opno.t))
stpapi.put.field("tisfc0408m000","prdt.t", str$(afs.prdt.t))
stpapi.enum.answer("tisfc0408m000", "document.sorted", tisfc.dsrt.doc.by.order)
stpapi.enum.answer("tisfc0408m000", "print.org", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "print.dupl", tcyesno.yes)
stpapi.enum.answer("tisfc0408m000", "print.modi", tcyesno.yes)
stpapi.enum.answer("tisfc0408m000", "covn.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "roul.b", tcyesno.yes)
stpapi.enum.answer("tisfc0408m000", "oprn.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "matl.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "matn.b", tcyesno.no)
stppapi.enum.answer("tisfc0408m000", "subn.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "chel.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "sawl.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "collect.sawl", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "cutl.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "collect.cutl", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "recn.b", tcyesno.no)
stpapi.enum.answer("tisfc0408m000", "insn.b", tcyesno.no)
|*********************************************************
error.msg.1 = ("Error Setting Report")
error.msg.2 = ("Error Printing Report")
**********************************************************

stpapi.set.report("tisfc0408m000", "rtisfc040802001","ASCII",error.msg.1)
stpapi.print.report("tisfc0408m000", error.msg.2)
stpapi.end.session("tisfc0408m000")

|*********************************************************

}

mark_h
23rd October 2004, 17:31
A quick search turned up this thread (http://www.baanboard.com/baanboard/showthread.php?t=16088) . Check out his code and some of the comments. I think the first thing you need to do is use str$ on the enumerated fields. You may have to play with which report to set. Not sure about this, but I just did outbound advice and in order to get the shortage listing I actually have to set the report to the advice report. Just something to think about, but first check the other post.

Mark

BurghMan
26th October 2004, 16:42
mark_h,

I tried setting using the str$ on all ennumerated fields and I have the report set to the route sheet in this statement.
stpapi.set.report("tisfc0408m000", "rtisfc040802001","ASCII",error.msg.1)
Is that what you mean?

The thread also mentioned setting the report group to 14. I tried that and setting the report group to 2 (reportgrp = 2) since there is no report group 14 attached to print order documents that I can see.

I am still getting the " No Data within selection error"

Is there any documentation that you know of on the afs log?

Thanks in advance, BurghMan

Paul P
27th October 2004, 05:50
Dear BurghMan,

Simply use stpapi.put.field() for all those fields you use in the codes since they are screen fields to be filled up. Please use stpapi.enum.answer() only to answer pop-up questions that normally appear if you execute the session manually.

Rgds,
Paul

mark_h
27th October 2004, 16:04
Paul is correct - I just noticed all of your stpapi.enums. Here is what worked for me to get only the routing list.


string msg(100)
domain tcdate today
today = date.num()
stpapi.put.field("tisfc0408m000", "order.sorted", str$(tisfc.osrt.order))
stpapi.put.field("tisfc0408m000","ccot.f", " ")
stpapi.put.field("tisfc0408m000","ccot.t", "ZZZ")
stpapi.put.field("tisfc0408m000","cprj.f", "")
stpapi.put.field("tisfc0408m000","cprj.t", "ZZZZZZ")
stpapi.put.field("tisfc0408m000","pdno.f", "323419")
stpapi.put.field("tisfc0408m000","pdno.t", "323419")
stpapi.put.field("tisfc0408m000","opno.f", "")
stpapi.put.field("tisfc0408m000","opno.t", "999")
stpapi.put.field("tisfc0408m000","prdt.t", str$(today+1000))
stpapi.put.field("tisfc0408m000", "document.sorted", str$(tisfc.dsrt.doc.by.order))
stpapi.put.field("tisfc0408m000", "print.org", str$(tcyesno.yes))
stpapi.put.field("tisfc0408m000", "print.dupl", str$(tcyesno.yes))
stpapi.put.field("tisfc0408m000", "print.modi", str$(tcyesno.yes))
stpapi.put.field("tisfc0408m000", "covn.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "roul.b", str$(tcyesno.yes))
stpapi.put.field("tisfc0408m000", "oprn.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "matl.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "matn.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "subn.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "chel.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "sawl.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "collect.sawl", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "cutl.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "collect.cutl", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "recn.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "insn.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "pcdl.b", str$(tcyesno.no))
stpapi.put.field("tisfc0408m000", "print.config", str$(tcyesno.no))
stpapi.set.report("tisfc0408m000", "rtisfc040801000","D66",msg)
stpapi.continue.process("tisfc0408m000", msg)
stpapi.end.session("tisfc0408m000")


Please note that I am on 4c4 A&D 1. So I might have some fields on my form that you do not have.

Mark

BurghMan
29th October 2004, 22:07
You and Paul are both correct. It is working great, thanks so much for your help!!