avin_ln
14th March 2014, 06:29
Hello Everyone,

I trying to insert project activity in session tppss2100m000. While Inserting a question pop ups everytime. i have handled this question through stpapi.enum.answer. I have the source code of the script so i know the code of the question getting popped up.

I have attached screenshot of the question.

Urgent Help is required.

Thanx

Ankita Patel
14th March 2014, 07:29
Hi,

we can handle questions in AFS using

void stpapi.enum.answer(string session, string question,bset answer)

in your case you said you have already handled it using the above syntax only.
can you please tell what exact error you are getting?

avin_ln
14th March 2014, 08:04
Hi,

Actually its not an error, and i have attached a image of actual message that is popped up.

Thanks

Ankita Patel
14th March 2014, 08:07
can you paste your AFS code?

avin_ln
14th March 2014, 08:22
stpapi.put.field("tppss2100m000", "tppss200.cprj", cprj)
stpapi.put.field("tppss2100m000", "tppss200.cpla", cpla)
ret = stpapi.change.view("tppss2100m000",err)
ret = stpapi.synchronize.dialog("tppss2100m000","add",err)
if ret then
stpapi.put.field("tppss2100m000", "tppss200.cact", cact)
stpapi.put.field("tppss2100m000", "tppss200.desc", desc)
stpapi.put.field("tppss2100m000", "tppss200.seak", seak)
stpapi.put.field("tppss2100m000", "tppss200.cuni", unit)
stpapi.put.field("tppss2100m000", "tppss200.tact", str$(tact))
stpapi.put.field("tppss2100m000", "tppss200.pact", pact)
stpapi.put.field("tppss2100m000", "tppss200.stat", str$(stat))
stpapi.put.field("tppss2100m000", "tppss200.wast", str$(wast))
stpapi.enum.answer("tppss2100m000","tppss20001",tcyesno.no)
ret = stpapi.insert("tppss2100m000",true,err)
if ret then
message("Activity Inserted Successfully")
endif
endif

stpapi.end.session("tppss2100m000")

bhushanchanda
14th March 2014, 09:52
Hi,

The problem in your case is that, you are answering the question when its already popped up. Place it before inserting the activity field.

Here's my working trial.

#pragma used dll ottstpapihand
function main()
{
long ret
string err(50)
stpapi.put.field("tppss2100m000", "tppss200.cprj", "0.90 MM")
stpapi.put.field("tppss2100m000", "tppss200.cpla", "1")
ret = stpapi.change.view("tppss2100m000",err)
ret = stpapi.synchronize.dialog("tppss2100m000","add",err)
if ret then
stpapi.enum.answer("tppss2100m000","tppss20001",tcyesno.no)
stpapi.put.field("tppss2100m000", "tppss200.cact", "3")
stpapi.put.field("tppss2100m000", "tppss200.desc", "testing")
stpapi.put.field("tppss2100m000", "tppss200.seak", "test")
stpapi.put.field("tppss2100m000", "tppss200.tact", "4")
stpapi.put.field("tppss2100m000", "tppss200.pact", "10000001")
stpapi.put.field("tppss2100m000", "tppss200.stat", "1")
stpapi.put.field("tppss2100m000", "tppss200.wast", "1")
ret = stpapi.insert("tppss2100m000",true,err)
if ret then
message("Activity Inserted Successfully")
endif
endif

stpapi.end.session("tppss2100m000")
}

avin_ln
14th March 2014, 10:28
Hello sir,
I have tried your code, But still message is coming.

Regards,
Avin Singhi

bhushanchanda
14th March 2014, 10:31
Hi,

What are you passing for tact,stat & wast? You can try passing the long values like 1,2,3 instead of passing the domain enum code.

Check the example. It works form me. May be you are not passing the correct values.

avin_ln
15th March 2014, 05:31
Hello sir,

I have tried passing long values but still message is coming.

Regards,
Avin Singhi

mark_h
16th March 2014, 03:20
What do you mean the message pops up? When you run afs code it all runs in the background and you should not see any messages. If the actual session or message actually brings it to the foreground then there is something else wrong.

So to me this code looks correct - well except for the synchronize dialog - not sure what it is in the code for, so I took it out.

stpapi.put.field("tppss2100m000", "tppss200.cprj", cprj)
stpapi.put.field("tppss2100m000", "tppss200.cpla", cpla)
ret = stpapi.change.view("tppss2100m000",err)
if ret then
stpapi.put.field("tppss2100m000", "tppss200.cact", cact)
stpapi.put.field("tppss2100m000", "tppss200.desc", desc)
stpapi.put.field("tppss2100m000", "tppss200.seak", seak)
stpapi.put.field("tppss2100m000", "tppss200.cuni", unit)
stpapi.put.field("tppss2100m000", "tppss200.tact", str$(tact))
stpapi.put.field("tppss2100m000", "tppss200.pact", pact)
stpapi.put.field("tppss2100m000", "tppss200.stat", str$(stat))
stpapi.put.field("tppss2100m000", "tppss200.wast", str$(wast))
stpapi.enum.answer("tppss2100m000","tppss20001",tcyesno.no)
ret = stpapi.insert("tppss2100m000",true,err)
if ret then
message("Activity Inserted Successfully")
endif
endif
stpapi.end.session("tppss2100m000")


So the above code should work unless there is a data issue as bhushan stated. My question would be what is in the err code in the stpapi.insert. Right after the stpapi.insert - check err and see what it says.

Now having said all that - there is a remote possibility that answer the question with no will not work. I know in 4c4 one session we created afs code we had to change the default answer for the question. Only then would it work. But first look at the above and see what err is returning.

avin_ln
18th March 2014, 11:43
Activity that i am trying to insert is standard activity(refer table tppdm110). With standard activity only i am getting the message. For default activity my code works perfectly fine

Regards,
Avin Singhi

mark_h
23rd March 2014, 18:51
Once again - what do you mean you are getting the message? What message are you getting and from where in the afs code? You started the thread out asking about a question. The questions answer is set before you do the insert. At the point ret = stpapi.insert("tppss2100m000",true,err) is executed you have the answer set. So what is the value in err?

avin_ln
24th March 2014, 07:59
Message(question) that i am getting is Copy data from Standard Activities?. i have handled this question before stpapi.insert(). whether i click yes or no i am able to insert the data. there is no error in inserting data. problem is created due to this message. If i have 1000 records to insert then this question will come 1000 times

Regards,
Avin Singhi

mark_h
24th March 2014, 14:36
You still have not answered my question - is this actual message box popping up in the middle of the AFS session?

bhushanchanda
24th March 2014, 14:41
Hi,

Yes, you have to answer the question every time you insert a record. Whether its 1000 times or more.

avin_ln
25th March 2014, 07:06
Hi Mark,
Yes actual message box pops up during execution of AFS.

Regards,
Avin Singhi

benito
25th March 2014, 14:26
it should not give you the pop up question if you answered the question at the right time. i am not using this session but would it be possible that this question is generated by the insert command?

mark_h
25th March 2014, 16:27
As Benito mentioned that should not happen. The question should not pop-up in the foreground at all in api mode. I would make sure you had the latest stpapi libraries and version of the session in questions. Best bet is to log a case with infor.

avin_ln
26th March 2014, 06:37
Hi benito,

When i manually try to input the data in the session, this question pop-up when i enter the value in activity field, But in AFS question pop-up when stpapi.insert() is executed. I have handled question for both conditions, but still can't solve this problem.

As Mark suggested logging case with infor would be the best bet.

Thanks Everyone for your help and time
:)

Regards,
Avin Singhi