Neal Matthews
12th April 2011, 12:41
Hello all,

A few months ago I developed an AFS for Sales Invoices which has now been running live for a few months. Finance have now asked me to look at credit notes coming through the AFS as well.

In theory this should be simple enough just use a Credit Notes Transaction Type in our case SCN. However for some reason the AFS is returning an insert error "Series not defined". The series I am using defintely exists and I have proved this manually through the session. The AFS log also agrees with the variables I am putting into the session so I am at a loss to what is happening. Any ideas greatly appreciated. See below for code and AFS log.

Cheers Neal

tfacr4100m000(34)-RUNNING:
>tfacr4100m000(34) put.field:tfacr400.ttyp SCN
>tfacr4100m000(34) put.field:tfacr400.ninv 4
>tfacr4100m000(34) put.field:tfacr400.cuno B016
>tfacr4100m000(34) put.field:tfacr400.refr 901579
>tfacr4100m000 insert
11dll->serv (add.set+save34)
tfacr4100m000(34)-RUNNING:add.set+save
34serv<-4gl (add.set+save10)
tfacr4100m000(34)-RUNNING:
<tfacr4100m000 Series not defined


if m_credit = 1 then
m_ttyp1 = "SCN"
else
m_ttyp1 = tdsls910.ttyp
endif

message(m_ttyp1)
message(str$(tdsls910.ninv))
message(tdsls945.cuno)
message(str$(tdsls945.orno))

stpapi.put.field( "tfacr4100m000", "tfacr400.ttyp", m_ttyp1 )
stpapi.put.field( "tfacr4100m000", "tfacr400.ninv", str$(tdsls910.ninv))
stpapi.put.field( "tfacr4100m000", "tfacr400.cuno", tdsls945.cuno)
stpapi.put.field( "tfacr4100m000", "tfacr400.refr", str$(tdsls945.orno))

ret=stpapi.insert( "tfacr4100m000", do.update, error ) |INSERT
if error <> "" then
message("insert.err 1 tfacr4100m000 " & error)
put.ptr=seq.puts(str$(tdsls945.orno) & " " & str$(tdsls945.pono) & "INSERT ERROR " & error,open.ptr)
endif

mark_h
12th April 2011, 16:14
Well I went into my system, not a clue on what I was doing and picked order type RD1 (it said credit note type), series defaulted to 28, picked a customer, inserted a record. Dropped your code into my test function server and it worked. Session tfacr4101s000 was started in the background. Now I really don't if I actually tested a credit note - no clue where that series came from. Looked around for it, but did not see anything obvious. Not sure if it was really a valid test - I believe we are on SP28 for 4c4. No clue what I am doing and now I need to go do some cleanup with table maintenance on test system.

Have you tried a get field after the error for the series or ninv field? Make sure the series is still correct. Do you own source code where you could debug what happens in the session.


function creditnote()
{
stpapi.put.field( "tfacr4100m000", "tfacr400.ttyp", "RD1" )
stpapi.put.field( "tfacr4100m000", "tfacr400.ninv", str$(28))
stpapi.put.field( "tfacr4100m000", "tfacr400.cuno", "00500")
stpapi.put.field( "tfacr4100m000", "tfacr400.refr", "Testing")

rc=stpapi.insert( "tfacr4100m000", 1, err ) |INSERT
if err <> "" then
message("insert.err 1 tfacr4100m000 " & err)
stpapi.end.session("tfacr4100m000")
endif
}

Neal Matthews
12th April 2011, 16:35
Hello Mark,

Thanks for the input. This problem is real odd one.

What's the best way of chasing the error I'm afraid my tracing skills aren't that clever these days. I'm guessing that the value of tfacr400.ninv must be incorrect but I can't see how. I've also tried a different credit transaction type but this does the same thing.

Sadly I can't get hold of the source so I'll have to go into debug and have a good look round.

We are only on SP18 for 4c4 so I'm not sure whether that would be an issue. I've checked for later versions of the session but cannot see any.

Cheers Neal

Juergen
12th April 2011, 17:37
Hello Neal,

I think SP18 could not be the problem. I did a quick test with the code posted by Mark on our old and frozen 4c4 (SP15) and it worked.

Which series are defined for the used transaction type in session tfgld0114m000 "Maintain series per transaction type"?

Regards,
Juergen

Neal Matthews
12th April 2011, 17:51
Hello Juergen,

Thanks for the input. The series for the transactions is defined in tfgld0114m000 for the Credit Type transaction SCN. I can also manually create SCN's for series 4 in the session.

Any chance you can try Mark's code with a Sales Credit Note type transaction this may be the issue.

Cheers
Neal

Neal Matthews
12th April 2011, 18:13
Hello guys,

Just found the obvious thing I was missing the test Finance Company (which I'd forgotten about) is where the Sales Credit Notes are being created and guess what this company is missing the series !

Feel pretty stupid now but at least everything now makes sense before I go home to sleep on it.

Thanks for your help.

Cheers Neal:):D

Juergen
12th April 2011, 18:25
Hello Neal,

I can feel with you, but tomorrow the world looks already differently ;)

mark_h
12th April 2011, 21:48
Bet there and done that! :) Glad you found the solution.