musman
21st August 2002, 16:24
Hi

I am trying to update Customer Master Data using API. but for some unknown reason I am not able to update Curreny Code in Maintain Customers session(tccom1101m000).
I have also tried to insert a record using API, but I get an error message 'Currency not found!'

Does anyone know how to solve this problem.

Regards

Muhammad Usman
musman@iffco.com

mark_h
21st August 2002, 16:45
Could you post the code? Someone might notice something wrong. I have, at times, had problems with getting fields to update on a session. Also your profile does not mention what version of Baan so that may be helpful also.

Good Luck!

Mark

musman
21st August 2002, 16:57
I am using Baan IVc4 (SP9) on Sun solaris. The code is as under:

******************************************************************************
|* ustst0830 0 VRC B40O c4 IFFC
|* Update Customers
|* General_User_Unix
|* 2002-08-21
|******************************************************************************
|* Main table tccom010 Customers, Form Type 4
|******************************************************************************

|****************************** declaration section ***************************
declaration:

table ttccom010 | Customers
table ttcmcs019 | Titles
table ttcmcs045 | Areas
table ttcmcs004 | Routes
table ttcmcs031 | Lines of Business
table ttccom001 | Employees
table ttcmcs080 | Forwarding Agents
table ttcmcs013 | Terms of Payment
table ttcmcs011 | Late Payment Surcharges
table ttcmcs041 | Terms of Delivery
table ttcmcs010 | Countries
table ttcmcs046 | Languages
table ttcmcs002 | Currencies
table ttcmcs009 | Credit Insurance Companies
table ttcmcs055 | Invoicing Methods
table ttcmcs034 | Price Lists
table ttfacr311 | Statement of Account Methods
table ttracs100 | Addresses
table ttccom000 | Companies
table ttcmcs042 | Order Types

extern domain tcyesno txta.txt

extern domain tccuno cuno.f fixed
extern domain tccuno cuno.t fixed
extern domain tcyesno txta.txt
extern domain tcnama pcpr.nama
extern domain tcnama pctx.nama
extern domain tcnama pctf.nama
extern domain tcnama ccus.nama
extern domain tcdsca cpls.dsca
extern domain tcdsca pldd.dsca
extern domain tcmcs.str30 error.msg
extern domain tcmcs.str30 msg

#pragma used dll ottstpapihand
****************************** form section **********************************

form.1:
init.form:
get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
read.main.table()


|****************************** field section *********************************

field.cuno.f:
when.field.changes:
cuno.t = cuno.f


|****************************** function section ******************************

|****************************** function section ******************************

functions:

function read.main.table()
{
long count,up.error

db.retry.point()

stpapi.put.field("tccom1101m000","tccom010.cuno","A00006")
count = stpapi.find("tccom1101m000",error.msg)
if count = 1 then
message(" Record Found ")
stpapi.put.field("tccom1101m000","tccom010.nama","Cust Name1")
stpapi.put.field("tccom1101m000","tccom010.ccur","AEs")
up.error = 0
up.error = stpapi.update("tccom1101m000",true,error.msg)
message("%s error.msg ",error.msg)
endif

stpapi.end.session("tccom1101m000")

}

Chandra
21st August 2002, 17:17
Whether the currency you are using for update/ insert of customer master data is present in the currency table. Some times we get this standard error when the currency code being used is not maintained in currency table.

musman
21st August 2002, 17:26
Mr. Chandra

The currency code exists in the Currency Table. Why don't you try to run the same script in a test company?

regards

mark_h
21st August 2002, 18:00
The code looks okay. Can you update that custumer manually with the AEs currency? If you can then it narrows the problem down to the tccom1101m000 session. If that works then try to just update the tccom010.nama for the customer. Make sure that works. It could be that you need a new object for tccom1101m000. I wrote one on this session once, but it only changed the address. We are on 4c3.

Mark

musman
21st August 2002, 18:09
The script updates the customer name where as it does not update the Currency code. I am surprised why it is not doing. The only reason that comes into my mind is that when I try to change the currency code manually in the Maintain Customer session , I get following warning message :

(Message Code: tiitm0101a1: Maintain Customers)

Note: The price lists will not automatically be updated.



Then we have to click on OK button or press enter to continue.. it saves the record. How to tackle this Warning Message in API function. I have also tried to use STPAPI.ENUM.ANSWER function but this also didn't work.

regards

mark_h
21st August 2002, 18:28
That is probably the reason it will not update. I ran into this once - generate manual transfers. In my case it gave warnings and would not do the transfer, but I just reported it as an error to the user. I used stpapi.get.mess.code() to get the message to report to the user. Stpapi.enum.answer will not work because these are not questions, but warnings. In my case I could skip the record and this does not sound feasible in your situation. One work around would be to update all fields via stpapi commands, check for this error, then update all fields except currency via stpapi commands. The update the currency on the table tccom010 itself. The only problem with this is I do not know what else this session may do with the currency.

Sorry, but I do not know how to get around these warning type messages. Anybody else know how to get around them?

Mark

mark_h
21st August 2002, 18:31
I just checked, we had the source. I think what I suggested would work. It looks like you get the message on the when.field.changes of tccom010.ccur. Also if you have the source then you could add a check for api.mode=true to skip the message. Then your function server would work.

Good Luck!

Mark