sgoupil
8th February 2008, 20:17
I'm trying to do this session through function server. When we go (manually) in this session on form 2 (Database User Data), we insert a new record, put the Database User (new database user in my case), wich starts sub session ttdba0201s000 Enter Password on form 2 New Password, put the 2 fields available New Password and Re-enter new password and click OK, goes back to the main session with an encrypted password, then we continue the process.

I do the same steps in my code, but when I do a stpapi.update on the subsession ttdba0201s000, I get the following error "Input cancelled on field pass.wd.old" which is not on the form. Anybody can help? Here is my code.

stpapi.put.field("ttdba0115m000", "ttdba015.db.user", target.user)
stpapi.handle.subproc("ttdba0115m000", "ttdba0201s000", "add")
stpapi.put.field("ttdba0201s000", "pass.wd.1", h.passwd1)
stpapi.put.field("ttdba0201s000", "pass.wd.2", h.passwd2)
stpapi.update("ttdba0201s000", 1, gapi.error.code ) ||||||||| Here is when I get the error message!!!!!
stpapi.save("ttdba0201s000", gapi.error.code)
if not isspace(gapi.error.code) then
message("Could not save password " & gapi.error.code)
endif
stpapi.end.session("ttdba0201s000")

stpapi.put.field("ttdba0115m000", "ttdba015.db.group", h.dbgroup)
stpapi.put.field("ttdba0115m000", "ttdba015.cubb", str$(h.cubb))
stpapi.put.field("ttdba0115m000", "ttdba015.dba", str$(h.dba))
stpapi.update("ttdba0115m000", 1, gapi.error.code )
stpapi.save("ttdba0115m000", gapi.error.code)
if not isspace(gapi.error.code) then
message("Could not save dba password " & gapi.error.code)
endif
stpapi.put.field("ttdba0115m000", "ttdba015.dbse", h.dbse)
stpapi.put.field("ttdba0115m000", "ttdba015.db.user", target.user)
ret = stpapi.find("ttdba0115m000")
if ret = 1 then
ret = stpapi.mark("ttdba0115m000")
stpapi.handle.subproc("ttdba0115m000", "ttdba0200s000", "add")
stpapi.application.option("ttdba0115m000", 1, 1, gapi.error.code)
if not isspace(gapi.error.code) then
message("Could not open session Enter DBA password")
message("The error is: " & gapi.error.code)
else
put.mesg.on.form("Enter DBA Passord", 1)
stpapi.put.field("ttdba0200s000", "dba.name", h.dbaname)
stpapi.put.field("ttdba0200s000", "pass.wd", h.passwd)
stpapi.save("ttdba0200s000", gapi.error.code)
if not isspace(gapi.error.code) then
message("Could not save dba password " & gapi.error.code)
endif
stpapi.end.session("ttdba0200s000")
endif
record.count = record.count + 1
show.bar()
else
message("User " & target.user & " not found for dba conversion")
endif
stpapi.end.session("ttdba0115m000")

mark_h
8th February 2008, 20:22
Are you sure you need an update or a save? Will a continue work? We do not use those session, but it seems to me one that I saw that asked for a old and new password needed to have okay clicked - in this case a continue would have worked.

sgoupil
8th February 2008, 20:33
There is an OK button. But when you run a ttstpcreatdll for that session, there is no stpapi.continue.process option, only an update and a save, that's why I thought the update option would replicate the OK button

mark_h
8th February 2008, 20:38
ttstpcreatdll does not always create everything I think it should. Try continue and see if it solves your problem. No promises it will work, but I have seen that issue before with ttstpcreatdll. I only use that to get a feel for what is available for a session - the I use the stpapi commands like you did.

sgoupil
8th February 2008, 20:43
I tried with the stpapi.continue.process, and I got the same error....

mark_h
9th February 2008, 04:08
I just noticed something that is not correct:

stpapi.put.field("ttdba0115m000", "ttdba015.db.user", target.user)
stpapi.handle.subproc("ttdba0115m000", "ttdba0201s000", "add")
stpapi.put.field("ttdba0201s000", "pass.wd.1", h.passwd1)

When you put the first field on ttdba0115m000 it activates that session. I would expect your code to look like this:

stpapi.put.field("ttdba0115m000", "ttdba015.db.user", target.user)
stpapi.put.field("ttdba0115m000", "ttdba015.db.group", h.dbgroup)
stpapi.put.field("ttdba0115m000", "ttdba015.cubb", str$(h.cubb))
stpapi.put.field("ttdba0115m000", "ttdba015.dba", str$(h.dba))
stpapi.handle.subproc("ttdba0115m000", "ttdba0201s000", "add")
stpapi.update("ttdba0115m000", 1, gapi.error.code ) |Maybe insert
stpapi.save("ttdba0115m000", gapi.error.code) | may just need update
stpapi.put.field("ttdba0201s000", "pass.wd.1", h.passwd1)
stpapi.put.field("ttdba0201s000", "pass.wd.2", h.passwd2)
stpapi.update("ttdba0201s000", 1, gapi.error.code )
stpapi.save("ttdba0201s000", gapi.error.code)
if not isspace(gapi.error.code) then
message("Could not save password " & gapi.error.code)
endif
stpapi.end.session("ttdba0201s000")

Typically to activate a subsession you have to perform an action(insert,update,save, continue, change view) on the main session. Just putting a field on the main session will not activate the subsession. With your code you activate one main session, then activate a subsession which is not controlled by the main session. That pass.wd.old might be something that needs to be passed or populated from the main session, so you need the main session to control the subsession. Not that the update and save you have could be 1 of maybe 3 or 4 possibilities - one a straight update, two a straight insert, three a change.view or 4 a combination of one or two like you have. Sometimes you just have to play with a session to see what command will work.

You should be able to see this by watching the parent and process id's in the option dialog window - doing a ps while in debug mode. An example would be like the following (not sure about the 1):

pid parent pid process
xx 1 <your program>
yy xx ttdba0115m000
zz yy ttdba0201s000

I bet in your case you saw

pid parent pid process
xx 1 <your program>
yy xx ttdba0115m000
zz xx ttdba0201s000

Well I hope I explained this and again no promises it will work on your system. I am going by all the other sessions I have automated.