timb25
24th July 2013, 21:48
What is the best way to accomplish this seemingly simple customization?
First referring to: LN6.1 FP5
-----------------------------------------------------
Starting with AR open entries session - tfacr2520m000
When I highlight a record, I want to click Specific and select a custom session. (I've already added my custom session to the form command)

When this custom session opens, I want to display the document number, etc. (PK) and allow the user to insert 1 record of more information about this AR record, but in a different table.

The PK in the tfacr200 table is: ttyp, ninv, line, tdoc, docn, lino
The PK in the custom table tfacr930 is the same: ttyp, ninv, line, tdoc, docn, lino
There are 3 additional fields in the tfacr930 table for entry.

I'm going insane trying to get this to work. This should be simple in nature, but nothing seems to be working as expected.

Thanks for any help!

-Tim

mark_h
24th July 2013, 23:33
Well sorry I can't help, but maybe this helps someone else help you. What exact problems or errors are you encountering? As much detail as possible to help an LN person to make a recommendation. Again sorry I can't help, but maybe one day in the future I will get to work on LN.

timb25
24th July 2013, 23:52
Please see the word attachment of the screen progression that I want to accomplish.

Also here is my code. This is on the called custom session.


zoom.from.all:
on.entry:
import.tfacr200.fields()


functions:

function import.tfacr200.fields()
{
import("tfacr200.ttyp", tfacr930.ttyp)
import("tfacr200.ninv", tfacr930.ninv)
import("tfacr200.line", tfacr930.line)
import("tfacr200.tdoc", tfacr930.tdoc)
import("tfacr200.docn", tfacr930.docn)
import("tfacr200.lino", tfacr930.lino)
}

mark_h
25th July 2013, 02:16
On 4c4 I have never had that work. I usually import to the same field name. Then assign the field to the new table field. So I would basically import tfacr200 into tfacr200, then set tfacr930 = tfacr200. I can't remember why but back in the early 2000's I had issues with a called session knowing about a table record in the parent session. From that point forward I did not try it. I also usually use zoom type fields on export from one session and for import. Then set the table field. Another for example I usually say like zoom.item = tiitm001.item, export zoom.item, import zoom.item, tablexx.item = zoom.item. I know there are better ways, but it works for me.

OOPS only referring to import/export. I can't answer the LN questions you had. Sorry about that.

bhushanchanda
25th July 2013, 04:54
Ok,

I will take this one. Have done this many times.

First add the customized session to the form commands of the main session. Do copy the session to current VRC. Now, in the form command, the "command availability" field should be - "One Record Selected".

What I always do is, declare the variables having domains similar to the imported variables and now do this:-

before.program:

import("prog.name$",calling.session)

if calling.session = "tfacr2520m000" then
import("tfacr200.ttyp",ttyp)
import("tfacr200.ninv",ninv)
...
...
endif



field.tfacr930.ttyp:

before.display: | you can use before.field too

tfacr930.ttyp = ttyp

field.tfacr930.ninv:

before.display:

tfacr930.ninv = ninv

........... | Do this for all the form fields

Thats it.

Also, make the imported fields as display fields else the user will play with them ;)

bhushanchanda
25th July 2013, 10:46
Also,

Add this for the additional fields:-

field.tfacr930.text:

before.display:

select tfacr930.*
from tfacr930
where tfacr930._index1 = {:ttyp,:ninv,:line,:tdoc,:docn,:lino}
selectdo
endselect

This will display the values for the other non imported fields if any information is already inserted in the table.

timb25
25th July 2013, 18:31
Thanks for the replies Mark and Bhushan!!

Bhushan - that worked awesomely! (for the most part)

I made all the changes. Now when I 'zoom' to that session from the tfacr2520 session the first time, I can add the record. Added text into that text box. Save and exit. Go back into that record to see the data but the text in the text box would not appear.

SO... I changed the session to use the text manager thinking that might make a difference.

Now when i go into the session to see a previously entered record, it says record already exists after clicking the text button.

I'm not sure the best way to handle this text field because it could get lengthy. (meaning should i use the text manager)

bhushanchanda
25th July 2013, 18:50
Hi Timb,

What does the button text do? Does it have any script attached? Also, have you added the select loop in the field section for the two fields i.e. catagory code and action code?

Like:-

field.field_name:

before.display:

select tfacr930.*
from tfacr930
where tfacr930._index1 = {:ttyp,:ninv,:line,:tdoc,:docn,:lino}
selectdo
endselect

Because, I guess the fields stored are not getting retrieved.

timb25
25th July 2013, 22:55
Bhushan.. Ok I removed the text manager button and went back to the original text form field. I have the select code under each of the other non imported fields. Here is the code:


before.program:
import.tfacr200.fields()

field.tfacr930.ttyp:
before.display:
tfacr930.ttyp = x.ttyp

field.tfacr930.ninv:
before.display:
tfacr930.ninv = x.ninv

field.tfacr930.line:
before.display:
tfacr930.line = x.line

field.tfacr930.tdoc:
before.display:
tfacr930.tdoc = x.tdoc

field.tfacr930.docn:
before.display:
tfacr930.docn = x.docn

field.tfacr930.lino:
before.display:
tfacr930.lino = x.lino

field.tfacr930.catn:
before.display:
select tfacr930.catn
from tfacr930
where tfacr930._index1 = {:x.ttyp, :x.ninv, :x.line, :x.tdoc, :x.docn, :x.lino}
selectdo
endselect

field.tfacr930.actn:
before.display:
select tfacr930.actn
from tfacr930
where tfacr930._index1 = {:x.ttyp, :x.ninv, :x.line, :x.tdoc, :x.docn, :x.lino}
selectdo
endselect

field.tfacr930.text:
before.display:
select tttxt010.text
from tfacr930, tttxt010
where tfacr930._index1 = {:x.ttyp, :x.ninv, :x.line, :x.tdoc, :x.docn, :x.lino}
and tfacr930.text = tttxt010.ctxt
selectdo
endselect


functions:

function import.tfacr200.fields()
{
import("prog.name$",calling.session)

if calling.session = "tfacr2520m000" then
import("tfacr200.ttyp", x.ttyp)
import("tfacr200.ninv", x.ninv)
import("tfacr200.line", x.line)
import("tfacr200.tdoc", x.tdoc)
import("tfacr200.docn", x.docn)
import("tfacr200.lino", x.lino)
endif
}


Thanks,
-Tim

bhushanchanda
26th July 2013, 09:10
Hi Timb,

I have not played with the text fields on form. I will get back to you if found any solution.

bhushanchanda
26th July 2013, 10:30
Ok,

Here's what you need to do:-

Declare these variables:-

string bbuf(80,40)
string btext(500)
long b1
string text1(240)

And include this library:-

#include<bic_text>

field.tfacr943.text:

before.display:

btext = ""
text1 = ""
for b1 = 1 to
text.to.buf("tfacr943.text", "2", 5, bbuf)
btext = strip$(btext)&" "&strip$(bbuf(1,b1))
endfor
text1 = btext

text.buf.to.field("tfacr943.text", text1)

timb25
26th July 2013, 18:38
Bhushan,
That text piece has worked perfectly! Thank you!

Still trying to figure out why i cannot modify a record that has already been inserted in the custom table.

bhushanchanda
26th July 2013, 20:02
Hi Timb,

Congrats for that. Now, for the next thing, i.e. to modify the text, just add this:-

choice.add.set:

after.choice:

select tfacr943.*
from tfacr943 for update
where tfacr943._index1 = {:ttyp,:ninv,:line,:tdoc,:docn,:lino}
selectdo
db.delete(ttfacr943,db.retry,elocked)
commit.transaction()
endselect

And there you go! :)