kathuria
5th May 2005, 10:22
Hi,
I am tring to insert record in form type 3. At the time of stpapi.change.view("",) it returning value 2 rather than 1. I am also attaching code. Pls. do needful.
Regards
Sanjay Kathuria
dayn = sprintf$("%u010",tipol003.sdat)
timn = sprintf$("%U002",tipol003.sdat)
timn.new = timn(1;2) & timn(4;2)
stpapi.put.field("bptmm1120m000","bptmm120.emno"," ")
stpapi.put.field("bptmm1120m000","bptmm120.year",str$(tipol003.year))
stpapi.put.field("bptmm1120m000","bptmm120.peri",str$(tipol003.peri))
ret = stpapi.change.view("bptmm1120m000", w.err.msg)
|if ret > 0 then
|ret = stpapi.synchronize.dialog("tisfc0130m000", "add", w.err.msg)
stpapi.put.field("bptmm1120m000","bptmm120.orno",str$(tipol003.pdno))
stpapi.put.field("bptmm1120m000","bptmm120.opno",str$(tipol003.opno))
stpapi.put.field("bptmm1120m000","bptmm120.tano",str$(tipol003.tano))
stpapi.put.field("bptmm1120m000","bptmm120.cwoc",str$(tipol003.cwoc))
stpapi.put.field("bptmm1120m000","bptmm120.mcno",str$(tipol003.mcno))
stpapi.put.field("bptmm1120m000","bptmm120.wtsc",str$(tipol003.wtsc))
if strip$(shiftl$(dayn)) = "Monday" then
stpapi.put.field("bptmm1120m000","start.day",str$(etol(tcdynm.monday)))
endif
if strip$(shiftl$(dayn)) = "Tuesday" then
stpapi.put.field("bptmm1120m000","start.day",str$(etol(tcdynm.tuesday)))
endif
if strip$(shiftl$(dayn)) = "Wednesday" then
stpapi.put.field("bptmm1120m000","start.day",str$(etol(tcdynm.wednesday)))
endif
if strip$(shiftl$(dayn)) = "Thursday" then
stpapi.put.field("bptmm1120m000","start.day",str$(etol(tcdynm.thursday)))
endif
if strip$(shiftl$(dayn)) = "Friday" then
stpapi.put.field("bptmm1120m000","start.day",str$(etol(tcdynm.friday)))
endif
if strip$(shiftl$(dayn)) = "Saturday" then
stpapi.put.field("bptmm1120m000","start.day",str$(etol(tcdynm.saturday)))
endif
if strip$(shiftl$(dayn)) = "Sunday" then
stpapi.put.field("bptmm1120m000","start.day",str$(etol(tcdynm.sunday)))
endif
stpapi.put.field("bptmm1120m000","start.time",timn.new)
stpapi.enum.answer("bptmm1120m000","bptmms0001", tcyesno.yes)
stpapi.put.field("bptmm1120m000","bptmm120.cuni","hrs")
stpapi.put.field("bptmm1120m000","bptmm120.hrma",str$(tipol003.mchr))
stpapi.insert("bptmm1120m000",true,w.err.msg)
if isspace(w.err.msg) then
stpapi.end.session("bptmm1120m000")
endif
|endif
mark_h
5th May 2005, 14:27
My first thought was - Is the emno field actually blank or is it 0? That maybe why it is returning another view.
kathuria
5th May 2005, 14:52
Hi,
How i can ensure you. It's latest patch and session.We are using SSA ERP LN 6.1.
Regards
Sanjay
mark_h
5th May 2005, 16:00
What about the emno field question?
My signature contains the "mantra" phrase, only as a reminder to all posters. Using these AFS function servers differs from place to place.
lbencic
5th May 2005, 16:28
Hi - I have not played yet with AFS on LN, but the find it notoriously messed up. It's not the AFS's fault, it the way Baan finds records, sometimes when you type in the key in the find, it goes to the next record and you have to scroll around. This is probably because in some cases the full key is not actually on the form...
If a find is returning a 2 for you all the time (it's much better than a 0, you are probably close), check your key field values on the form (do a get.field for each key field), and compare it with the record you are trying to find. Sometimes it has the correct entry and did not return a 1. Sometimes it has the correct view (Employee) and not the correct line. In that case you can issue a stpapi.browse.set until you find your record on the lines.
kathuria
6th May 2005, 10:16
Hi,
Can i set order of form. After that return value of stpapi.change.view() should be one.
Sanjay
kathuria
6th May 2005, 12:34
Hi,
If manual entering value in view fields menas group fields not in set fields and save-exit from session after than AFS is working fine . If i am on any other record in that case it's able to insert records. any one can tell me to set up group fields.It's urgent. :mad:
Regards
sanjay
lbencic
6th May 2005, 16:46
Not quite following all of that. The change.view command is supposted to set the view fields, I have not played with it in a while, but, when you issue the change view, even if it returns 2, did you query the emno field (stpapi.get.field for emno after change view). What value does emno show then?
kathuria
9th May 2005, 12:34
Hi,
I am describing three case.
Case -1
If i am using stpapi.change.view() after put value in key fields. It's not able to insert record in required period.
e.g. if current running period is 2005/11 but i want to insert record in period 2005/1. It will not insert record in period 2005/1 but it will insert same record in period 2005/11 after not given any error message in stpapi.insert() function.
Case -2:
If i am using function stpapi.change.view() rather than stpapi.change.key(). Int this case it's inserting record in first view.
Case -3:
If i am assigning value in key fields manually and save + exit from session for same key. In this AFS insert record properly.
I am not able to corelate all these cases. If any one aware about that. Please help us. It's urgent.
Regards
Sanjay
lvdvelde
12th July 2005, 23:01
Hey Sanjay,
I think the mistake you made is a classical one.
Because the view you are trying to find is not found, the records are inserted (added) to the wrong view (the one that was found). Alle you have to do is set the key fields again, because stpapi.change.view may have returned '2' (another key found). If the returnvalue was '1' , the view was found. So you have to check this.
This will it look like:
stpapi.put.field("bptmm1120m000","bptmm120.emno"," ")
stpapi.put.field("bptmm1120m000","bptmm120.year",str$(tipol003.year))
stpapi.put.field("bptmm1120m000","bptmm120.peri",str$(tipol003.peri))
ret = stpapi.change.view("bptmm1120m000", w.err.msg)
if ret = 2 then | another key found, so set key fields again (RTFM!)
stpapi.put.field("bptmm1120m000","bptmm120.emno"," ")
stpapi.put.field("bptmm1120m000","bptmm120.year",str$(tipol003.year))
stpapi.put.field("bptmm1120m000","bptmm120.peri",str$(tipol003.peri))
endif
stpapi.put.field("bptmm1120m000","bptmm120.orno",str$(tipol003.pdno))
stpapi.put.field("bptmm1120m000","bptmm120.opno",str$(tipol003.opno))
stpapi.put.field("bptmm1120m000","bptmm120.tano",str$(tipol003.tano))
stpapi.put.field("bptmm1120m000","bptmm120.cwoc",str$(tipol003.cwoc))
stpapi.put.field("bptmm1120m000","bptmm120.mcno",str$(tipol003.mcno))
stpapi.put.field("bptmm1120m000","bptmm120.wtsc",str$(tipol003.wtsc))
I agree with Mark - are you trying to insert " " for bptmm120.emno?
Lex
Evert-Jan Bosch
27th January 2006, 12:33
You' d better use dal 2 scripting as is mentioned in:
http://www.baanboard.com/baanboard/showthread.php?p=93290#poststop
Table bptmm120 is converted to dal 2!
Holger R
27th January 2006, 13:51
[QUOTE
Can i set order of form. After that return value of stpapi.change.view() should be one.
You can change the order of the session by using the command "stpapi.sort.by(session, ordernumber, errormsg)"
Holger
henkvdh
12th April 2007, 10:22
in session bptmm1120m000 it is programmed in such a way that the period that you book hours is always the current period or the previous period.
Depending on the parameter by user in bpmdm0102m000.
No matter what you fill in in the view, this parameter is ruling!
Just a question of bad programming.
kanikahada
25th January 2013, 13:22
i am trying to insert lot in type 3 form, i am getting return value as 1 in change.view , but still it is at 1st record only, why can it be so?
Holger R
25th January 2013, 13:53
i am trying to insert lot in type 3 form, i am getting return value as 1 in change.view , but still it is at 1st record only, why can it be so?
Are you sure, you are using the right index for your change.view?
Look at the session, which index is used and don't fill the whole index. At least, 1 field must be empty
henkvdh
26th January 2013, 14:46
The view command is only setting the view, still need to do the find command after this, for finding the right record within the view.
kanikahada
28th January 2013, 05:06
ya index is correct and 1 field is kept empty
kanikahada
28th January 2013, 11:37
Did that,still the data gets inserted in 1st data group instead of the required one,here is the code-
stpapi.put.field("whltc1100m000","whltc100.item.sgement.1","")
stpapi.put.field("whltc1100m000","whltc100.item.sgement.2",item)
ret = stpapi.change.view("whltc1100m000",msg)
ret = stpapi.find("whltc1100m000",error)
if ret = 1 then
ret1 = stpapi.synchronize.dialog("whltc1100m000","add",error.msg)
stpapi.put.field("whltc1100m000","whltc100.item.sgement.1","")
stpapi.put.field("whltc1100m000","whltc100.item.sgement.2",item)
stpapi.put.field("whltc1100m000","whltc100.clot",str$(set.lot))
stpapi.put.field("whltc1100m000","whltc100.olot","1")
stpapi.put.field("whltc1100m000","whltc100.bfbp",str$(supp))
ret2 = stpapi.insert("whltc1100m000",true,error.msg)
if ret2 <> 1 then
ret =stpapi.recover("whltc1100m000",error)
stpapi.end.session("whltc1100m000")
|return(false)
endif
else
ret = stpapi.change.view("whltc1100m000",msg)
stpapi.put.field("whltc1100m000","whltc100.item.sgement.1","")
stpapi.put.field("whltc1100m000","whltc100.item.sgement.2",item)
stpapi.put.field("whltc1100m000","whltc100.clot",str$(set.lot))
stpapi.put.field("whltc1100m000","whltc100.olot","1")
stpapi.put.field("whltc1100m000","whltc100.bfbp",str$(supp))
ret2 = stpapi.insert("whltc1100m000",true,error.msg)
if ret2 <> 1 then
ret = stpapi.recover("whltc1100m000",error)
stpapi.end.session("whltc1100m000")
|return(false)
endif
endif
it goes in if part and adds the data in 1st data group,the return values are always 1
mark_h
28th January 2013, 16:01
Try removing the first change.view. Looking at this thread (http://www.baanboard.com/baanboard/showthread.php?t=54140&highlight=whltc1100m000) the very first part of the code only does a find. Since I do not know LN when you say very first data group what do you mean? It almost sounds like you need something other than just the item to find the right data group as you call it.
kanikahada
29th January 2013, 05:16
by very first data group i just meant that the first record of type 3 form, let me check in the thread you have given
kanikahada
29th January 2013, 05:27
by the thread, it seems afs didnt work and it ended up in use of DAL,also after removing 1st change.view it still inserts data in first item.
kanikahada
29th January 2013, 06:02
yesss....it is done succesfully using DAL ,it could not be done anyhow by using afs....thnks
kanika
mark_h
29th January 2013, 15:37
Glad you got it working with DAL. I believe for LN they always recommending using the DAL functionality first. I am still confused on the find part - because if you do a find on an item then I expect it to find the first record. On a type 3 multi-occurence plus view form I expect to put all the view fields to find the correct record - thats what confuses me. I will stick to the simple 4c4 coding - LN is confusing enough. :)
henkvdh
30th January 2013, 10:04
There where more problems before with inserting a new record in an empty view.
cherokee
18th December 2013, 15:47
Just to add a bit to this one.
I had the several problems inserting in type 3 session; sometimes the record was inserted on a diffrent data group(year,week, supplier) or returning error messges related to the data validation (ie. invalid date for period specfied).
I realized that if there was at least one record in the session with same data group for the year and period only, every thing was going fine but, for the very first time when there was no data group before, was not able to insert on a new group.
I only declared the table(tpppc232) of the session I am calling on my FS script and everything went fine!
Hope this could help someone.