Francesco
14th January 2003, 00:18
I was recently asked to give somebody of our EDI group access to the exchange module, so that she could perform imports as required.

Since I am reluctant to give anybody access to exchange for obvious reasons, I decided to write a session that would limit exchange capabilities to a single (predefined) script and grant access to this session instead.

Below is the code that I used in the script for this session. The form really only requires a start button, but you can make that as fancy as you wish.


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

declaration:
| Includes
#include "ituxch0224"
#include <bic_tt>

| Variables normally found on form, all made extern
extern domain tuxch.cxch cxch.f fixed | Exchange scheme (mandatory)
extern domain tuxch.cxch cxch.t fixed |
extern domain tuxch.cbat cbat.f fixed | Batch
extern domain tuxch.cbat cbat.t fixed |
extern domain tuxch.pint seqn.f | Sequence Number
extern domain tuxch.pint seqn.t |
extern domain tuxch.yesno comp.yn | Change Company Number
extern domain tuxch.comp scr.comp | Company No.
extern domain tuxch.redo redo.type | Type of redo xch scheme
extern domain tuxch.yesno error.rej.yn | Include error rejected recs in redo
extern domain tuxch.yesno cond.rej.yn | Include conditional rejects in redo

| Program variables
string SCHEME(8) | Exchange Scheme to be run
string BATCH(8) | Batch to be run
| long SEQN | Sequence Number to be run

|****************************** program section *******************************

before.program:
SCHEME = "ODYEDIBP" | Exchange scheme to be activated by session
BATCH = "10"
| SEQN = 10

| Set exchange type to non-regular
xch.type = nre.import
| Set key value
ukey = generate.unique.key()

| Set form variables
cxch.f = SCHEME
cxch.t = SCHEME
cbat.f = BATCH
cbat.t = BATCH
seqn.f = 0
seqn.t = 9999
scr.comp = get.compnr()
redo.type = tuxch.redo.new

skip.yn = no

suppress.yn = no
error.rej.yn = no
cond.rej.yn = no
uncompress.yn = no

|****************************** form section **********************************

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

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

choice.cont.process:
before.choice:
check.all.input()
on.choice:
status.off()
process.range.of.xch.schemes()
status.on()
after.choice:
handle.run.num(true)

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

functions:

function extern display.log.table()
{
table ttuxch009 | Log table (Batch Lines)

tuxch009.cxch = cxch.f
tuxch009.txch = xch.type
if redo.type = new.run then
tuxch009.runn = run.num - 1
else
tuxch009.runn = run.num
endif
tuxch009.tryn = get.next.try.num(tuxch009.cxch, xch.type,
tuxch009.runn) - 1
if xch.type = nre.import then
tuxch009.cbat = cbat.f
else
tuxch009.cbat = ""
endif
start.session(MODELESS, "tuxch0509m000", "tuxch0224m000", "")
}