Baanboard.com

Go Back   Baanboard.com > Forum > Baan SIGs > Code & Utilities

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
37%
Installation Wizard into new VRC
39%
Manual into existing VRC
3%
Manual into new VRC
21%
Total votes: 38

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 14th March 2003, 22:20
Francesco's Avatar
Francesco Francesco is offline
Guru
 
Join Date: Aug 2001
Location: Antwerp, BE
Posts: 727
Francesco is on a distinguished road
Baan: 5b - DB: Oracle - OS: Solaris
CODE: Change job parameters automatically

Nothing spectacular, but a handy utility. Please note that this is not generic code. It will have to be modified for every specific situation. It's the idea that matters in this case.

What brought this up was a request to have a job to print a certain report that would always print last month data.

I put this script in a session and attached it to the existing job, so that after job completion, it would autmoatically set the parameters for next month run.

Have fun.

Code:
******************************************************************************
|* cecusadmin001  0  VRC B50o b  uat 
|* Update job parameters
|* This session changes the job parameters of job 'MAPAG' automatically.
|* This script contains hard coded values!!
|* Francesco Frentrop
|* 03-13-03 [10:35]
|******************************************************************************
|* Script Type: 4
|******************************************************************************
                                                                                
|****************************** DECLARATION SECTION ***************************
declaration:
	
	table	tttaad503			| Display Job Input Variables
	
|****************************** FORM	     SECTION ***************************

|****************************** CHOICE      SECTION ***************************
choice.cont.process:
on.choice:
	read.main.table()

|****************************** MAIN TABLE  SECTION ***************************
functions:

function read.main.table()
{
	| The tricky part is that the session variables are stored as a continuous string
	| but in chunks of 200 characters in ttaad503.rcrd.
	| There are multiple records in the table, distinguished by sequence number.
	| Therefore, the first chunk of 200 characters will go in the record with seq. no. 0,
	| the second 200 characters in seq. no. 1, etc.
	| The code below first collects all of the session variables in the string newvalue,
	| and then cuts it up in 200 char chunks. This means that the limit to the total string
	| length is dictated by the maximum string variable size of 1024 bytes.
	| Since it probably won't come down to 24 bytes, I limited it to 1000 characters for
	| added ease and comfort.
	| This assumption is good enough for this particular scenario and helps to keep the code
	| down, but WHEN USING THIS CODE AS A BASIS FOR OTHER (SIMILAR) SCRIPTS, MAKE SURE TO
	| VERIFY THAT THE 1000 CHAR LIMITATION IS NOT EXCEEDED!!
	
	string	newvalue(1000),	currentperiod(2), currentyear(4)
	long yearno, monthno, dayno, hours, mins, secs, refa, x
	
	refa = utc.to.date( utc.num(), yearno, monthno, dayno, hours, mins, secs )
	currentperiod = str$(monthno)
	currentyear = str$(yearno)

	newvalue = ""		| empty newvalue as a precaution. note: "" in string = "
	newvalue = newvalue & "016ncmp.f:=""100"""
	newvalue = newvalue & "016ncmp.t:=""100"""
	newvalue = newvalue & "016ccty.f:=""   """
	newvalue = newvalue & "016ccty.t:=""ZZZ"""
	newvalue = newvalue & "016creg.f:=""   """
	newvalue = newvalue & "016creg.t:=""ZZZ"""
	newvalue = newvalue & "016fisu.f:=""   """
	newvalue = newvalue & "016fisu.t:=""ZZZ"""
	newvalue = newvalue & "022suno.f:=""         """
	newvalue = newvalue & "022suno.t:=""ZZZZZZZZZ"""
	newvalue = newvalue & "029seak.f:=""                """
	newvalue = newvalue & "029seak.t:=""ZZZZZZZZZZZZZZZZ"""
	newvalue = newvalue & "019form.hcur:=""USD"""
	newvalue = newvalue & "024euro.translation:=""0"""
	newvalue = newvalue & "023tfacp004.agan:=""020"""
	newvalue = newvalue & "050tfacp004.desc:=""ACCT AGING WITH OVER 120 DAYS """
	newvalue = newvalue & "016based.on:=""1"""
	newvalue = newvalue & "020selection.on:=""2"""
	newvalue = newvalue & "020print.status:=""1""021print.costinv:=""1"""
	newvalue = newvalue & "019print.fully:=""2"""
	newvalue = newvalue & "025print.anticipated:=""1""014step.f:=""0"""
	newvalue = newvalue & "021last.inv.date:=""0"""
	newvalue = newvalue & "024last.inv.year:=""" & currentyear & """"
	newvalue = newvalue & "021tfgld003.psep:=""/"""
	newvalue = newvalue & "023last.inv.period:=""" & currentperiod & """"
	newvalue = newvalue & "022last.paym.date:=""0"""
	newvalue = newvalue & "025last.paym.year:=""" & currentyear & """"
	newvalue = newvalue & "021tfgld003.psep:=""/"""
	newvalue = newvalue & "024last.paym.period:=""" & currentperiod & """"
	newvalue = newvalue & "023as.on.date:=date()+0018as.on.year:=""0"""
	newvalue = newvalue & "021tfgld003.psep:=""/"""
	newvalue = newvalue & "020as.on.period:=""0"""
	
	| newvalue now contains the string that we have to distribute over the 200 char records
	| in ttaad503.
	
	for x = 0 to (len(newvalue)/200)
		db.retry.point()
		select	ttaad503.rcrd
		from	ttaad503 for update
		where	ttaad503.cjob = " MAPAG"
		and	ttaad503.seri = 1
		and	ttaad503.sequ = :x
		selectdo
			ttaad503.rcrd = newvalue(x * 200 + 1;200) | The x-th chunk of 200
			db.update(tttaad503, db.retry)
			commit.transaction()
		endselect
	endfor
}
__________________
Cheers,

Francesco
..............................................................

Admiral Business Solutions | My World | Baan Board | IT Happens!

"If everyone is thinking alike, then somebody isn't thinking" -- George Patton
"It's easy to cry 'bug' when the truth is that you've got a complex system and sometimes it takes a while to get all the components to co-exist peacefully." -- Doug Vargas
Reply With Quote
  #2  
Old 14th March 2003, 23:14
patvdv's Avatar
patvdv patvdv is offline
Board Master
 
Join Date: Aug 2001
Location: Belgium
Posts: 2,167
patvdv is on a distinguished road
Baan: n/a - DB: n/a - OS: AIX, HP-UX, Linux
Looks like a very handy little tool indeed, but is it not easier to use the '+date' notation in the job sessions so that Baan always uses a data relative to the system date?
__________________
Regards,

Patrick Van der Veken - Admin & Founder - (c) 2001-2017 baanboard.com/baanforums.com
Reply With Quote
  #3  
Old 14th March 2003, 23:45
lbencic's Avatar
lbencic lbencic is offline
Guru
 
Join Date: Dec 2001
Location: Lisle, IL, USA
Posts: 1,148
lbencic will become famous soon enough
Baan: 2.2d - LN - DB: most - OS: most
Oo this is so handy, just for the reason you mention. The Baan Job can handle incrementing dates, but I think it has a problem incrementing Periods.

Thanks Francesco :)
Reply With Quote
  #4  
Old 14th March 2003, 23:51
Francesco's Avatar
Francesco Francesco is offline
Guru
 
Join Date: Aug 2001
Location: Antwerp, BE
Posts: 727
Francesco is on a distinguished road
Baan: 5b - DB: Oracle - OS: Solaris
Well, yes, but that would make sense.

Actualy, in this particular case it changes the period, not the date.

Felt very stupid there for a second. ;)
__________________
Cheers,

Francesco
..............................................................

Admiral Business Solutions | My World | Baan Board | IT Happens!

"If everyone is thinking alike, then somebody isn't thinking" -- George Patton
"It's easy to cry 'bug' when the truth is that you've got a complex system and sometimes it takes a while to get all the components to co-exist peacefully." -- Doug Vargas
Reply With Quote
  #5  
Old 14th March 2003, 23:53
patvdv's Avatar
patvdv patvdv is offline
Board Master
 
Join Date: Aug 2001
Location: Belgium
Posts: 2,167
patvdv is on a distinguished road
Baan: n/a - DB: n/a - OS: AIX, HP-UX, Linux
Lisa, thanks for pointing out the mistake to me. Francesco, my fault, accept my humble apologies for questioning the usefulness of your code :)
__________________
Regards,

Patrick Van der Veken - Admin & Founder - (c) 2001-2017 baanboard.com/baanforums.com
Reply With Quote
  #6  
Old 15th March 2003, 00:02
Francesco's Avatar
Francesco Francesco is offline
Guru
 
Join Date: Aug 2001
Location: Antwerp, BE
Posts: 727
Francesco is on a distinguished road
Baan: 5b - DB: Oracle - OS: Solaris
No problem, Pat

And Lisa, glad you find it useful.
__________________
Cheers,

Francesco
..............................................................

Admiral Business Solutions | My World | Baan Board | IT Happens!

"If everyone is thinking alike, then somebody isn't thinking" -- George Patton
"It's easy to cry 'bug' when the truth is that you've got a complex system and sometimes it takes a while to get all the components to co-exist peacefully." -- Doug Vargas
Reply With Quote
  #7  
Old 16th December 2003, 02:01
Francesco's Avatar
Francesco Francesco is offline
Guru
 
Join Date: Aug 2001
Location: Antwerp, BE
Posts: 727
Francesco is on a distinguished road
Baan: 5b - DB: Oracle - OS: Solaris
Bug alert

This just in.

Somebody pointed out to me that the session as listed above was now causing data corruption.

It caused me some headaches, but I finally figured out what the issue is. The first three numbers that lead the fieldnames (like 016ncmp.f) indicate the length of the stringpart to follow.

Consequently, when we went from September to October, the changed datestring became one character longer (9 -> 10) and the leading "checksum" should have been updated accordingly.

I will post an updated version this week, unless somebody beats me to it. Just thought I'd let y'awl know.
__________________
Cheers,

Francesco
..............................................................

Admiral Business Solutions | My World | Baan Board | IT Happens!

"If everyone is thinking alike, then somebody isn't thinking" -- George Patton
"It's easy to cry 'bug' when the truth is that you've got a complex system and sometimes it takes a while to get all the components to co-exist peacefully." -- Doug Vargas
Reply With Quote
  #8  
Old 16th December 2003, 17:52
Francesco's Avatar
Francesco Francesco is offline
Guru
 
Join Date: Aug 2001
Location: Antwerp, BE
Posts: 727
Francesco is on a distinguished road
Baan: 5b - DB: Oracle - OS: Solaris
Bug Fix

Well, I won't get any style-points on this one, but it does the trick.

Code:
|*	Rev.No. 5  ceB50obuat  26 Nov 03 rmcmilli
|* This is to revert back to the original code set.[revision number = 5]
|*	Rev.No. 6  ceB50obuat  26 Nov 03 rmcmilli
|* |
|*	Rev.No. 7  ceB50obuat  15 Dec 03 ffrentro
|* Changed job parameter for testing purposes
|*	Rev.No. 8  ceB50obuat  15 Dec 03 ffrentro
|* Changed job parameters for testing
|*	Rev.No. 9  ceB50obuat  15 Dec 03 ffrentro
|* Parameter change for testing
|*	Rev.No. 10  ceB50obuat  15 Dec 03 ffrentro
|* Replaced spaces with 0 in 029seak.f
|******************************************************************************
|* cecusadmin001  0  VRC B50o b  uat 
|* Update job parameters
|* This session changes the job parameters of job 'MAPAG' automatically.
|* This script contains hard coded values!!
|* ffrentro
|* 03-13-03 [10:35]
|******************************************************************************
|* Script Type: 123
|******************************************************************************
                                                                                
|****************************** DECLARATION SECTION ***************************
declaration:
#ident "@(#)cecusadmin001  ceB50obuat  uscobrmfa-ug-36  Rev.No. 11  15 Dec 03  ffrentro"
	
	table	tttaad503			| Display Job Input Variables
	
	
	
|****************************** FORM	     SECTION ***************************

|****************************** CHOICE      SECTION ***************************
choice.cont.process:
on.choice:
|	execute(print.data)
|	
|choice.print.data:
|on.choice:
	read.main.table()

|****************************** MAIN TABLE  SECTION ***************************
functions:

function read.main.table()
{
	| The tricky part is that the session variables are stored as a continuous string
	| but in chunks of 200 characters in ttaad503.rcrd.
	| There are multiple records in the table, distinguished by sequence number.
	| Therefore, the first chunk of 200 characters will go in the record with seq. no. 0,
	| the second 200 characters in seq. no. 1, etc.
	| The code below first collects all of the session variables in the string newvalue,
	| and then cuts it up in 200 char chunks. This means that the limit to the total string
	| length is dictated by the maximum string variable size of 1024 bytes.
	| Since it probably won't come down to 24 bytes, I limited it to 1000 characters for
	| added ease and comfort.
	| This assumption is good enough for this particular scenario and helps to keep the code
	| down, but WHEN USING THIS CODE AS A BASIS FOR OTHER (SIMILAR) SCRIPTS, MAKE SURE TO
	| VERIFY THAT THE 1000 CHAR LIMITATION IS NOT EXCEEDED!!
	
	string	newvalue(1000),	currentperiod(2), currentyear(4), tempstring(200)
	long yearno, monthno, dayno, hours, mins, secs, refa, x
	
	refa = utc.to.date( utc.num(), yearno, monthno, dayno, hours, mins, secs )
	currentperiod = str$(monthno)
	currentyear = str$(yearno)

	newvalue = ""		| empty newvalue as a precaution. note: "" in string = "
	newvalue = newvalue & "016ncmp.f:=""100"""
	newvalue = newvalue & "016ncmp.t:=""100"""
	newvalue = newvalue & "016ccty.f:=""   """
	newvalue = newvalue & "016ccty.t:=""ZZZ"""
	newvalue = newvalue & "016creg.f:=""   """
	newvalue = newvalue & "016creg.t:=""ZZZ"""
	newvalue = newvalue & "016fisu.f:=""   """
	newvalue = newvalue & "016fisu.t:=""ZZZ"""
	newvalue = newvalue & "022suno.f:=""         """
	newvalue = newvalue & "022suno.t:=""ZZZZZZZZZ"""
	newvalue = newvalue & "029seak.f:=""               0"""
	newvalue = newvalue & "029seak.t:=""ZZZZZZZZZZZZZZZZ"""
	newvalue = newvalue & "019form.hcur:=""USD"""
	newvalue = newvalue & "024euro.translation:=""0"""
	newvalue = newvalue & "023tfacp004.agan:=""020"""
	newvalue = newvalue & "050tfacp004.desc:=""ACCT AGING WITH OVER 120 DAYS """
	newvalue = newvalue & "016based.on:=""1"""
	newvalue = newvalue & "020selection.on:=""2"""
	newvalue = newvalue & "020print.status:=""1""021print.costinv:=""1"""
	newvalue = newvalue & "019print.fully:=""2"""
	newvalue = newvalue & "025print.anticipated:=""1""014step.f:=""0"""
	newvalue = newvalue & "021last.inv.date:=""0"""
	| This is where it gets double tricky. We are changing values and therefore, we will also have
	| to change the leading three-digit number that indicates the total length of the relevant
	| string part. To do so, the string value is stored in a temporary string without the leading
	| number and is then dressed up using the dress.up function that adds the 3-digit lead.
	tempstring = "last.inv.year:=""" & currentyear & """"
	dress.up(tempstring)
	newvalue = newvalue & tempstring
	
	newvalue = newvalue & "021tfgld003.psep:=""/"""
	
	tempstring = "last.inv.period:=""" & currentperiod & """"
	dress.up(tempstring)
	newvalue = newvalue & tempstring
	
	newvalue = newvalue & "022last.paym.date:=""0"""
	
	tempstring = "last.paym.year:=""" & currentyear & """"
	dress.up(tempstring)
	newvalue = newvalue & tempstring
	
	newvalue = newvalue & "021tfgld003.psep:=""/"""
	
	tempstring = "last.paym.period:=""" & currentperiod & """"
	dress.up(tempstring)
	newvalue = newvalue & tempstring
	
	newvalue = newvalue & "023as.on.date:=date()+0018as.on.year:=""0"""
	newvalue = newvalue & "021tfgld003.psep:=""/"""
	newvalue = newvalue & "020as.on.period:=""0"""
	
	| newvalue now contains the string that we have to distribute over the 200 char records
	| in ttaad503.
	
	for x = 0 to (len(newvalue)/200)
		db.retry.point()
		select	ttaad503.rcrd
		from	ttaad503 for update
		where	ttaad503.cjob = "MAPAG2"
		and	ttaad503.seri = 1
		and	ttaad503.sequ = :x
		selectdo
			ttaad503.rcrd = newvalue(x * 200 + 1;200) | The x-th chunk of 200
			db.update(tttaad503, db.retry)
			commit.transaction()
		endselect
	endfor
}

function void dress.up(ref string base.string())
{
	string string.length(3)
	
	string.length = str$(len(base.string) + 3)
	while len(string.length) < 3
		string.length = "0" & string.length
	endwhile
	
	base.string = string.length & base.string
	
}
__________________
Cheers,

Francesco
..............................................................

Admiral Business Solutions | My World | Baan Board | IT Happens!

"If everyone is thinking alike, then somebody isn't thinking" -- George Patton
"It's easy to cry 'bug' when the truth is that you've got a complex system and sometimes it takes a while to get all the components to co-exist peacefully." -- Doug Vargas

Last edited by gfasbender : 26th October 2004 at 19:42.
Reply With Quote
  #9  
Old 26th October 2004, 17:07
ltannous's Avatar
ltannous ltannous is offline
Senior Member
 
Join Date: Sep 2002
Location: Canada
Posts: 280
ltannous is on a distinguished road
Baan: 4c4 - DB: Oracle - OS: UNIX
Compilation Errors

I am getting compilation errors for the \ expressions.
Error( 49):Error: '\" not exptected. It repeats this up to line 81
Reply With Quote
  #10  
Old 26th October 2004, 17:31
lbencic's Avatar
lbencic lbencic is offline
Guru
 
Join Date: Dec 2001
Location: Lisle, IL, USA
Posts: 1,148
lbencic will become famous soon enough
Baan: 2.2d - LN - DB: most - OS: most
There's just a little typo on the ident - remove the '\' from the ident line.
Reply With Quote
  #11  
Old 26th October 2004, 19:21
~Vamsi's Avatar
~Vamsi ~Vamsi is offline
Guru
 
Join Date: Aug 2001
Location: San Diego CA, USA
Posts: 590
~Vamsi will become famous soon enough
Baan: ~*~ - DB: ~*~ - OS: ~*~
It is my fault. The code styling I wrote seems to fail on this forum. Patrick, could you please remove the "HTML allowed" on this forum. We may have to redo some of the postings though.
__________________
~Vamsi
Vamsi Potluru
Baan XL Yet another tool to format Baan output in Excel from Baan Board
This one just happens to be free :)

Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #12  
Old 26th October 2004, 19:52
gfasbender gfasbender is offline
Senior Member
 
Join Date: Aug 2001
Location: Seattle, WA USA
Posts: 172
gfasbender is on a distinguished road
Baan: Baan IV, Baan5, A&D extension - DB: Oracle, MSSQL, Informix - OS: Unix, NT
I don't think it's the HTML setting in this forum. I think it's the "[code=baan]" interpreter. Pat, has something with this changed recently?
__________________
Gordon Fasbender
GW Consulting
Reply With Quote
Sponsored Links
  #13  
Old 26th October 2004, 20:55
patvdv's Avatar
patvdv patvdv is offline
Board Master
 
Join Date: Aug 2001
Location: Belgium
Posts: 2,167
patvdv is on a distinguished road
Baan: n/a - DB: n/a - OS: AIX, HP-UX, Linux
It is indeed a conflict between HTML parsind and the enscript code styling. I have switched HTML off as we don't really need it anyway and it is safer as well. Any volunteers to redo and update the code Index thread in the Wiki?
__________________
Regards,

Patrick Van der Veken - Admin & Founder - (c) 2001-2017 baanboard.com/baanforums.com
Reply With Quote
  #14  
Old 27th October 2004, 02:30
~Vamsi's Avatar
~Vamsi ~Vamsi is offline
Guru
 
Join Date: Aug 2001
Location: San Diego CA, USA
Posts: 590
~Vamsi will become famous soon enough
Baan: ~*~ - DB: ~*~ - OS: ~*~
Gordon,

The syntax highlighting is done using enscript. When we migrated from version 2 to version 3 of the vBulletin software I ported the integration. What I did miss was support for HTML based forums.

When I saw the problem reported, we had two options.
- Go fix the enscript integration
- Reevaluate our need for HTML

Again I apologize for not having done a better job at coding the integration and testing it.

As for maintaining the index on Wiki - count me out :).
__________________
~Vamsi
Vamsi Potluru
Baan XL Yet another tool to format Baan output in Excel from Baan Board
This one just happens to be free :)

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 Off
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change session settings in job NPRao Tools Administration & Installation 4 12th May 2003 20:44
Job History log file changed after TIMEZONE change. ericthomas Operating Systems & Databases 1 14th April 2003 17:48
CODE: Modify Job Parameters mark_h Code & Utilities 0 13th September 2002 19:33
How I can change syntax code message ? MauroME Tools Administration & Installation 5 9th March 2002 21:26


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


©2001-2017 - Baanboard.com - Baanforums.com