Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > AFS/DDC/OLE: Function servers

User login

Frontpage Sponsor

Main

Poll
How big is your Baan-DB (just Data AND Indexes)
0 - 200 GB
18%
200 - 500 GB
30%
500 - 800 GB
3%
800 - 1200 GB
6%
1200 - 1500 GB
8%
1500 - 2000 GB
12%
> 2000 GB
23%
Total votes: 66

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 13th March 2015, 14:20
minadursun minadursun is offline
Newbie
 
Join Date: Jul 2014
Posts: 0
minadursun is on a distinguished road
Baan: erpln - DB: oracle - OS: besc
stpapi, inserting lines on tfcmg2500m000 bank transaction session

In Infor ERP-LN 10.4 when I created a patch then bank transaction, I want to import lots of advance payment lines from *.csv file to the Transactions (tfgld1101m000) session.

I started the tfgld1101m000 and added a new batch and new transaction type (bank transaction), then run "Transaction Entry -enter.transactions-" form command. Actually this command is on the menu of the tfgld1101m100 Transaction Types session.

After then Bank Transactions (tfcmg2500m000) session is started via this command. I wanna insert my advance payment lines on this session. On the menu, there is a form command that is Insert -insert.in.details.mode-. Via this command, Bank Transactions session (tfcmg2500m000) is running again with different design -On fp3 from tfgld1101m000, I had got tfcmg2100s000 session screen and that looked like tfcmg2500m000-.

Here is my code below:


Code:
	#pragma used dll ottstpapihand
	#define MAIN.SESSION "tfgld1101m100"
	#define SUB.SESSION "tfcmg2500m000"

function void doit()
{
	boolean tmp.first
	long afs.ret
	
	afs.ret = 0
	error.msg = ""

        stpapi.put.field(MAIN.SESSION, "tfgld101.year", str$(year.f))
	stpapi.put.field(MAIN.SESSION, "tfgld101.btno", str$(btno.f))
	stpapi.put.field(MAIN.SESSION, "tfgld101.ttyp", ttyp.f)
	afs.ret = stpapi.find(MAIN.SESSION,  error.msg)
	if afs.ret <> 1 then
		fp.ret = seq.puts("Error: Could not find the record! ", fp.log)
		stpapi.end.session(MAIN.SESSION, error.msg)
		return
	endif
	afs.ret = stpapi.mark(MAIN.SESSION,  error.msg)
	if afs.ret <> 1 then
		fp.ret = seq.puts("Error: Could not mark the record! ", fp.log)
		stpapi.end.session(MAIN.SESSION, error.msg)
		return
	endif


	stpapi.handle.subproc(MAIN.SESSION, SUB.SESSION, "add", error.msg)

	stpapi.form.command(MAIN.SESSION, 2, "enter.transactions", error.msg)

	stpapi.form.command(SUB.SESSION, 2, "insert.in.details.mode", error.msg) 
	if afs.ret = 0 then
		message(error.msg)
		stpapi.end.session(MAIN.SESSION, error.msg)
		return
	endif

	tmp.first = true
	while seq.gets(buffer, MAX.STR, fp.import) = 0
		if process.records.from.file() = NUMBER.OF.FIELDS then
			create.record(tmp.first)
			tmp.first = false
		else
			fp.ret = seq.puts(buffer & "Data is corrupt " , fp.log)
		endif
	endwhile
	stop.all.processes()
}

function long process.records.from.file() 
{	
	
	fields.scanned = string.scan(buffer, "%s,%s,%s,%f", prm.bpid, prm.bpnm, prm.bpac, prm.amnt)
	return(fields.scanned) 
}


function create.record(boolean first.i)
{
	long afs.ret
	string tmp.str(MAX.STR) mb
	
	stpapi.put.field(SUB.SESSION, "tfcmg204.year", str$(year.f))
	stpapi.put.field(SUB.SESSION, "tfcmg204.btno", str$(btno.f))
	stpapi.put.field(SUB.SESSION, "tfcmg204.ttyp", str$(ttyp.f))
	stpapi.put.field(SUB.SESSION, "tfcmg204.docd", str$(docd.f))
	stpapi.put.field(SUB.SESSION, "tfcmg204.docn", str$(seri.f))
	stpapi.put.field(SUB.SESSION, "tfcmg204.lino", "1")
	stpapi.put.field(SUB.SESSION, "tfcmg204.tran", str$(tfcmg.tran.advance.paym))
	stpapi.put.field(SUB.SESSION, "tfcmg204.bpid", prm.bpid)
	stpapi.put.field(SUB.SESSION, "tfcmg204.ccur", ccur.f)
	stpapi.put.field(SUB.SESSION, "tfcmg204.amnt", str$(prm.amnt))
	prm.bpnm = referance.f & " " & prm.bpnm
	stpapi.put.field(SUB.SESSION, "tfcmg204.refr", prm.bpnm)
	afs.ret = stpapi.insert(SUB.SESSION, true, error.msg)
	if afs.ret = 0 then
		tmp.str = "Error: "  & buffer & " Message: " & mb.cast.to.str$(error.msg)
		fp.ret = seq.puts(tmp.str, fp.log)
		afs.ret = stpapi.recover(SUB.SESSION, error.msg)
	endif

}

function generate.tmp.file.names()
{
	long r_number
	
	r_number = random()
	
	remote.file.name = getenv$("BSE") & "/tmp/import_items_uploaded_" & str$(r_number) & ".txt"
	log.file.name = getenv$("BSE") & "/tmp/import_items_log_" & str$(r_number) & ".txt"
}

function stop.all.processes()
{
	stpapi.end.session(SUB.SESSION, error.msg)
	stpapi.end.session(MAIN.SESSION, error.msg)
}
My *.csv file format is below:

123456,Mark Smith,666666,128.6
654321,Alice Silver,5555555,32.51


First column is Business Partner ID,
Second column is BP name,
Third one is bank account
Fourth one is amount.

My problem is that,
On fp3 my main session was tfgld1101m000 and this program was working very vell. I change it with tfgld1101m100 on 10.4. It works but one line is added, next one is not.
For example if I have 10 lines, the program added only 5 lines and these are 1., 3., 5., 7., 9. ones.

I could not understand why. Please share your experience and thoughts with me.

Thanks in advance.

Mina
Reply With Quote
  #2  
Old 15th March 2015, 21:28
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,371
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Hi,

First thing to check will be the data. Check if you are manually able to insert the records.

If the data is OK, you can try using suspend() function after your insert (or after one of the form commands which is taking more time to execute). Something like suspend(500) will be fine.

May be the first record is taking time to save as with 10.4 the number of DAL hooks and dependencies have increased.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
Sponsored Links
  #3  
Old 14th May 2019, 05:05
sghatge's Avatar
sghatge sghatge is offline
Junior Member
 
Join Date: Apr 2006
Location: Pune
Posts: 29
sghatge is on a distinguished road
Baan: LN 6.1 FP2 - DB: TBASE - OS: SOLARIS 2.5
Document Series not set as per set in AFS LN 10.4

I have also some AFS issue for session tfcmg2500m000. when I set the series "1905" for field tfcmg204.docn but system is taking first or last series internally in LN 10.4 version.

Anybody can know this issue then please correct me.

SG
__________________
Regards,

ShashiG
Reply With Quote
  #4  
Old 14th May 2019, 13:55
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,250
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Post your code maybe someone will see something. Do you own source where you could debug what tfcmg2500m000 is doing?
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #5  
Old 14th May 2019, 16:22
sghatge's Avatar
sghatge sghatge is offline
Junior Member
 
Join Date: Apr 2006
Location: Pune
Posts: 29
sghatge is on a distinguished road
Baan: LN 6.1 FP2 - DB: TBASE - OS: SOLARIS 2.5
Find the code

Please find code below for version LN10.4. you can use variables as you wish for testing purpose. Actual issue is for set document number field i.docn at the time of inserting record. it is not set as is set "1905". I am using transaction type "B21" and month wise series "yymm". there are so may series we have maintained in the series table. for e.g first series is "1305" and last default series is "9999". I am trying to using series "1905" but in AFS it is always taking "9999". if I am blocking "9999" then it is taking first series "1305" but not taking I defined "1905". all other fields are set ok.
Code:
	domain 	tfgld.btno 	m.btno
	bref.f = "S-" & logname$ & "-" & str$(tfvir316.bpid)
	message("Generating Batch for date " & sprintf$("%D(%02d/%02m/%4Y)", m.dt))
 	|create batch (tfgld1101m000) ================================
	stpapi.put.field("tfgld1101m000", "tfgld100.tedt", str$(m.dt))
	stpapi.put.field("tfgld1101m000", "tfgld100.bref", bref.f)
	result = stpapi.insert("tfgld1101m000", true, err.mess)
	if result <> 0 and isspace(err.mess) then
		stpapi.get.field("tfgld1101m000", "tfgld100.year", m.val)
		f.year = lval(m.val)
		stpapi.get.field("tfgld1101m000", "tfgld100.btno", m.val)
		m.btno = lval(m.val)
		
		stpapi.put.field("tfgld1101m100", "tfgld101.year", str$(f.year))
		stpapi.put.field("tfgld1101m100", "tfgld101.btno", str$(m.btno))
		result = stpapi.change.view("tfgld1101m100", err.mess)
		stpapi.put.field("tfgld1101m100", "tfgld101.ttyp",tfvir316.otyp)
		result = stpapi.insert("tfgld1101m100", true, err.mess)		
		if result = 0 then
			b.exit = 1
			while true
				stpapi.get.mess.code("tfgld1101m000", err.mess)
				if isspace(err.mess) then
					break
				endif
				logline("Create Batch Message : " & err.mess)
			endwhile
		endif
		if b.exit = 1 then
			stpapi.end.session("tfgld1101m000")
			GOTO GOTERR
		endif
		|stpapi.get.field( "tfgld1101m000", "tfgld101.btno", m.val)
		logline("Created Batch No : " & str$(m.btno))

	
		stpapi.put.field( "tfgld1101m100", "tfgld101.year", str$(f.year))
		stpapi.put.field( "tfgld1101m100", "tfgld101.btno", str$(m.btno))
		stpapi.put.field( "tfgld1101m100", "tfgld101.ttyp", tfvir316.otyp)
		result = stpapi.find("tfgld1101m100", err.mess)
		result = stpapi.mark("tfgld1101m100", err.mess)
		stpapi.handle.subproc( "tfgld1101m100", "tfcmg2500m000", "add" )
		stpapi.form.command( "tfgld1101m100", 5, "enter.transactions", err.mess )

		domain	tcamnt		m.cram, m.rmam, m.oram
		domain	tcorno		m.sono
		m.lino = 1
		
		if m.lino = 1 then
			stpapi.put.field( "tfcmg2500m000", "tfcmg204.docn", str$(i.docn))   
		endif

		|stpapi.put.field( "tfcmg2500m000", "tfcmg204.lino", str$(m.lino) )
		utc.to.local(tfvir316.dodt, mD1, mD2)  
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.docd", str$(mD1) )
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.ccur", p.ccur )
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.rate", str$(p.curt) )
		m.tran = ltoe(6)
		if p.ninv <> 0 then
			m.tran = ltoe(1)
		endif
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.tran", str$(m.tran) )
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.bpid", p.bpid )
		if p.ninv <> 0 then
			stpapi.put.field( "tfcmg2500m000", "tfcmg204.tinv", p.ttyp )
			stpapi.put.field( "tfcmg2500m000", "tfcmg204.ninv", str$(p.ninv) )
		endif
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.amnt", str$(p.amnt) )
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.refr", p.refr)
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.vatc", "IND" )
		stpapi.put.field( "tfcmg2500m000", "tfcmg204.cvat", "NOTAX")
		result = stpapi.insert("tfcmg2500m000", true, err.mess)
		suspend(500)
		result = stpapi.save("tfcmg2500m000", err.mess)
		if result = 0 then
			b.exit = 1
			while true
				stpapi.get.mess.code("tfcmg2500m000", err.mess)
				if isspace(err.mess) then
					break
				endif
				logline("Create Document Message : " & err.mess)
			endwhile
		else
			stpapi.get.field( "tfcmg2500m000", "tfcmg204.ttyp", o.ityp )
			stpapi.get.field( "tfcmg2500m000", "tfcmg204.docn", m.val )
			o.idoc = val(m.val)
			stpapi.get.field( "tfcmg2500m000", "tfcmg204.lino", m.val )
			o.ilin = val(m.val)
			logline("Created Document No : " & o.ityp & " / " & str$(o.idoc) & " / " & str$(o.ilin))
		
		stpapi.end.session("tfcmg2500m000")
		stpapi.end.session("tfgld1101m100")
		stpapi.end.session("tfgld1101m000")
endif
__________________
Regards,

ShashiG

Last edited by mark_h : 14th May 2019 at 19:20. Reason: Add code tags
Reply With Quote
  #6  
Old 14th May 2019, 20:03
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,250
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Assuming you are only trying 1 transaction you can always try this:

Code:
		result = stpapi.insert("tfcmg2500m000", false, err.mess)
		suspend(500)
		result = stpapi.save("tfcmg2500m000", err.mess)

What I would do to start with is right before the insert - do a get field on tfcmg204.docn to see what is in it. Do the insert with false, do a get field on tfcmg204.docn and see what is in it. Then do the save and again get the tfcmg204.docn to see what is in it. Everything I see looks okay from just glancing at it. We are on 4c4 and do not have this session.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #7  
Old 15th May 2019, 06:57
sghatge's Avatar
sghatge sghatge is offline
Junior Member
 
Join Date: Apr 2006
Location: Pune
Posts: 29
sghatge is on a distinguished road
Baan: LN 6.1 FP2 - DB: TBASE - OS: SOLARIS 2.5
Hi Mark,
I have tried as you suggested but same thing happening. Still document generating with 9999 series as "9999xxxx".
Is there any other way?
__________________
Regards,

ShashiG
Reply With Quote
  #8  
Old 15th May 2019, 13:48
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,250
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Did you check the variable before the insert and after the insert to see exactly when it changed from what you input? My suspicion is you put all the fields, but since you are running in API mode it does not hit all the normal events like it normally would. Then you do an insert and one of those events is changing the series on you. Again just a suspicion - without source code no way I know of to see exactly what is happening.

I know what I would do - but can speak for you. With LN you try DAL2 functionality to try to do something thing. I can't speak to that since we are on 4c4. What I would do on my 4c4 system (we do not own source code) I would make the session a qkey (source extender) type session. I would then add all the events into it and put it in debug mode. While I can't see actual code I could step thru it seeing exactly what event or actions might be occurring to change the series. So for example if I saw when I hit the insert command it hit the after.input of tfcmg204.docn and it changed it then, I could always work around that event with qkey. I could say if not api.mode then run normally otherwise skip this event.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Question mr_suleyman Tools Development 37 11th November 2016 08:14
Paramter receipt schedule is activate, so cannot start the session mostrightfuture Finance, Invoicing and Integration 0 23rd January 2006 10:10
Wrong standard cost used in Integration Transaction Lines handyb Finance, Invoicing and Integration 3 25th October 2005 04:38
Problem with inserting several SLS lines lakoon AFS/DDC/OLE: Function servers 4 20th August 2004 16:36
problem in inserting multiple lines in table joshua Tools Development 1 27th November 2003 14:17


All times are GMT +2. The time now is 00:50.


©2001-2018 - Baanboard.com - Baanforums.com