Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 1st September 2003, 18:25
learner's Avatar
learner learner is offline
Guru
 
Join Date: Dec 2002
Location: New zealand
Posts: 562
learner is on a distinguished road
Baan: BaaN Vc with sp 28 - DB: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit - OS: HP-UX B.11.31
Question Code for a simple Maintain Session

Hi,

I have used Generate session to generate a simple Maintain session based on my customized table, now what i would like to have is that instead of using Generate session, I would like to write code manually so that i am able to save this in my customized tabel.

So if i have 3 form fields on the form let's say

my.item
item.desc
item.qty


and i also declare these form fields in my program script and attached respective domains to them.

Now the help which i need is that i would like to know what would be the code that will pick up the data entered on the form by the user and when he clicks on SAVE button , it gets saved in the table, and when he click on delete , it is deleted from the customized table.


Regards

Learner
Reply With Quote
  #2  
Old 2nd September 2003, 11:29
Warans Warans is offline
Member
 
Join Date: Dec 2001
Location: Bangalore, India
Posts: 52
Warans is on a distinguished road
Baan: Baan IV c4 - DB: Informix - OS: Unix / Win 2000
Post

Hi,

I did created a session through "Maintain Session" as described by you. I followed these steps:

1. Created a table with 3 fields (Item, Desc, Qty)
2. Inserted a dummy Program Script (no code at all).
3. Inserted a record in Maintain session with Form I type, gave table name as defined in (1) and program script as defined in (2).
4. I created a form with three fields of the main table.

I compiled the script / dumped the form, and executed the session. I could able to insert / delete records in the table.

I guess, as long as the session has the 'defined table' as main table, you can do normal insert/delete/modify options without any code.

Hope this answers your qurey.

Warans
Reply With Quote
  #3  
Old 2nd September 2003, 17:24
learner's Avatar
learner learner is offline
Guru
 
Join Date: Dec 2002
Location: New zealand
Posts: 562
learner is on a distinguished road
Baan: BaaN Vc with sp 28 - DB: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit - OS: HP-UX B.11.31
yaah i agree

Hello,

Yaah i agree , whatever steps u followed i followed the same steps prior to my post on this board, and it worked as expected.

But now my requirement is that i do not want to build a session using GENERATE SESSION, assuming that i have a table with all these 3 fields, I just want to write down the code manually which inserts the record in the table.

How should i go about it.

and also one more thing assuming that there is a form field on the FORM, for which i have declared the program variable in my program script , now i want that this field should be saved in some 2nd table ... how do i do it ?

Regards

Learner
Reply With Quote
  #4  
Old 2nd September 2003, 18:26
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
I think the concept you want to do without is not Generate Session, it's the 4GL Standard Program script. If a session is generated or just inserted, having a Main Table on the session makes it a 4GL session that has all the inserts, reads, saves, and other database actions done by the underlying 'standard program'. This is not code that is visible or modifyable, it happens automatically. It acts against your main table and works in conjunction with the buttons on the form. That's why when you have a basic Maintain/Display session, you don't need any script at all. You are running the base Standard Program against the main table of the session anyway.

So, you want to .. ? Replace that? If you want, you can try removing the main table from the session, and you will have to program it all yourself, but I would not advise this. You would have to use the Form sections to simulate each database action. (Next, Previous, Save, Delete, Update, etc.). Please let us know if that's really what you want to do, but you would be fighting the Baan standard program, and maybe there is another way to do what you want.

A good place to start reading up on all of this the Flow of the Standard Program , and related links.

To update another table, that's not so bad, if there is a solid reference from your session's main table to the related table. You just need to know the sections. When the user chooses 'save', there are several sections executed, including the main.table.io / after.rewrite section. You can use this section to update your related table:

Code:
main.table.io:
after.rewrite:
       select    relatedtable.*
       from      relatedtable for update
       where   relatedtable._index1 = {:maintable.field1, :maintable.field2}
       selectdo
                    relatedtable.fieldx = formfieldx
                    db.update(trelatedtable, db.retry)  
       endselect

Note, there are plenty of ways to do this. A lot depends on how you are storing it on the form, etc. This example assumes you can fill formfieldx with the value you want, you may need to use arrays, etc, if you are using a multi-occurance form. You will also need an after.write and after.delete section. In this example, you don't use commits or set the retry point, because the standard program will do that for this section.
Reply With Quote
Sponsored Links
  #5  
Old 2nd September 2003, 18:38
learner's Avatar
learner learner is offline
Guru
 
Join Date: Dec 2002
Location: New zealand
Posts: 562
learner is on a distinguished road
Baan: BaaN Vc with sp 28 - DB: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit - OS: HP-UX B.11.31
Well thanks that's what i have been looking for. So your sugesstion is that in case of MAINTAIN SESSION ( Type 1) i should not write my own code since that would lead to more coding.........

but the code which u wrote for update, is that for UPDATING a record in the 2nd table or is it INSERTING a new record in 2nd Table ???

sorry i don't have the baan access right away at this moment otherwise i would have tested the same myself.

Regards

Learner
Reply With Quote
  #6  
Old 2nd September 2003, 18:42
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
That code is for the update. As mentioned, you will probably also need.

Code:
main.table.io:
after.write:
     relatedtable.field1 = xxx
     relatedtable.field2 = yyy
     db.insert(trelatedtable, db.retry)

after.delete:
     select   relatedtable.*
     from     relatedtable for update
     where  relatedtable._index1 = {:maintable.field1, :maintable.field2}
     selectdo
                 db.delete(trelatedtable, db.retry)
     endselect

That will cover the inserts and deletes if you want them. Probably want better error checking and messaging, etc.
Reply With Quote
  #7  
Old 2nd September 2003, 18:49
learner's Avatar
learner learner is offline
Guru
 
Join Date: Dec 2002
Location: New zealand
Posts: 562
learner is on a distinguished road
Baan: BaaN Vc with sp 28 - DB: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit - OS: HP-UX B.11.31
Thanks !!

Hello,

Thanks for this timely help, i will check it and in case of any doubt will revert back.

One more thing i would like to ask u is that since u said in case of multi-occurance form i will have to take arrays , but how will the input row on the form will get created ???

i mean how dynamically with the click of insert button i would be able to create a Multi ocurrance row on the form ?? Is it very tough to create this ?

Regards

Learner
Reply With Quote
  #8  
Old 2nd September 2003, 19:00
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
I guess I'm referring to a form that is already multi-occurance for the main table, not that you can easily put up a multi - occurance section for a field on a form that is base single occurance.

If you want multi-occurance on the main table, go back to the Generate Session step and choose multi-occurance, and the standard program will take care of the inserts/rows for you.
Reply With Quote
  #9  
Old 3rd September 2003, 17:47
learner's Avatar
learner learner is offline
Guru
 
Join Date: Dec 2002
Location: New zealand
Posts: 562
learner is on a distinguished road
Baan: BaaN Vc with sp 28 - DB: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit - OS: HP-UX B.11.31
1 more basic doubt

Hello,

Thanks all the tips u gave worked.

I have 1 more basic doubt assuming that I have a customized table in which 30 fields , and i have 5 index on this table.

Now my first index contains 7 fields, now if i generate a MAINTAIN SESSION , i took form type as 3 i.e. Multioccurance + view + Main.

Now when the session gets generated , it places field at header level and rest of the fields at row Level or detail level.

Now my doubt is how or on what basis does BaaN decides that these r fields of the Index that should be placed as header and the other fields should be placed as detail.

Please note that i have created MAINTAIN SESSION which is of FORM TYPE 3

Regards

Learner
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
Maintain Generic Units ttaad1106m000 mark_h Tools Development 2 5th March 2004 14:43
Payment of blocked supplier pmahto Finance, Invoicing and Integration 1 11th September 2003 20:36
Problem when invoking a session from another manusatsangi Tools Development 9 18th August 2003 13:40
Session Type - Maintain learner Tools Development 3 27th May 2003 18:10
parent session code (without parent source) mbdagla Tools Development 2 11th October 2002 09:25


All times are GMT +2. The time now is 05:02.


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