-   AFS/DDC/OLE: Function servers (
-   -   Copy (option dupl.occur) with AFS ?? (

Guillaume.G 13th January 2003 14:59

Copy (option dupl.occur) with AFS ??

I want to simulate the dupl.occur action with the AFS.
But after several try, it's not work !!!!!

In my case i want to copy à record of tipcs2121m000

So what is the solution to user dupl.occur with AFS ???

Thank you for your help


mark_h 13th January 2003 16:56

Not sure it is possible.
I think this is one of the features that is not possible using AFS. Like in this post what I recommend trying is to do a find of the record you want to copy, then put the new key fields(or item), then try a insert. This may work. If you do try it I would be interested in knowing if it did work.

Good Luck!


Guillaume.G 13th January 2003 17:16

Dupl.occur is possible but ....
Hi mark_h,

I try your solution, but it's not work
because the field of the screen is not in the API field buffer so the fields are empty (==> Error message )
Your idea is correct if you make a stpapi.get.field for all field of all form of the session
and for the copy you make a put field of all field (with modify value) and finish with an insert.
But the very big problem is the code of the choice.dupl.occur of the session is NOT executed !!!!

So i find an another solution which it's possible only if you have the program script std. and with stpapi.application.option.

the solution is :
you create a user.9 option in the std script (tipcs2121)
if api.mode then

And in the specific program
stpapi.application.option(ARTPCS, 1, 9, error)
if error <> "" then
retsave =,error)
if retsave = 0 then
message.erreur = "Pb sauvegarde Article :"
& strip$(error)
retour = 7

Best Regard


lbencic 13th January 2003 17:25

Guillaume -
Good Idea :)
Also, you can add a section like that to the standard code without modifying the source code at all using the wrapper tools out there - QKEY, RMCgen and the freeware version on these boards: 'rush'.

Good thinking outside of the box - so much of the AFS programming needs that.

mark_h 13th January 2003 18:05

Excellent Solution
Great solution Guillaume.G and thanks to Lisa for pointing out how the extended source solutions could work with this. I have to keep this in mind . :)


goooch 21st January 2005 09:36

And what about stpapi.application.option( "...", 1, -32 (or any form option relative to user.0), error ) ?
(looks like it works, tdsls4102s000 raises copy session tdsls4201s000, for example, but I did not play with it enough time, sorry)

mark_h 21st January 2005 14:49

Interesting concept. The instructions mention executing only user.0 thru user.9. I just tested stpapi.application.option("tibom8411m000",1,-25,msg) to see if it would print a report(of course the print option was set on this session) - it did work.

If you did use it just be prepared that this functionality might not work or exist in the future. Of course it is not like future releases will never break API function server. I have not seen any new documentation on API commands, so good find Goooch. Others may want to test this and report back.


mefreakboy 13th June 2006 22:00

If anybody is interested, I have tried the above suggestion and it does work for copying records. I am using a "template" supplier to copy to a new temporary supplier that is being handled by file transfers, replacing only the supplier code and name fields. Here's a sampling of the code for B4c4:

if tccomf2101m000.find() <> 1 then
|error - can't find supplier template
stpapi.application.option( "tccom2101m000", 1, -32, err.mess)

Thanks to all those who hinted at a solution here. There are way too many fields in the supplier table to make this a palatable experience.


baangeek77 11th June 2007 15:36

i realize this is a year old (almost exactly a year old i just noticed :)) but this is exactly what i was looking for , thx so much mefreakboy! just curious, where can I find a list of codes to use for stapi.application.option. in other words how do you know -42 is for copy and -25 is for print? if any one knows i'd appreciate it. Thx!


mark_h 12th June 2007 14:30

You get the numbers from the maintain form, then standard options. This gives you a list with the number associated with that option.

garias 11th March 2017 16:34

Any option for Infor LN
Since stpapi.application.option does not work for Infor LN
which option we could use to enable the dupl.occur command in a session called by AFS



All times are GMT +2. The time now is 02:30.

©2001-2017 - -