tion1976
7th September 2023, 18:41
I want to open a session from another and to import a variable from the parent session.
Then I want to search for a record in the main table of the called session and if it is not present in the table, to be able to create it by using choice.add.set, or something.
However, the line is not enabled for user input.
What can I do?
Code is below:
choice.add.set:
before.choice:
new.record = true
if not isspace(enno) then
tiitt231.enno = enno
display.all()
endif

OmeLuuk
11th September 2023, 13:22
I want to open a session from another and to import a variable from the parent session.
Then I want to search for a record in the main table of the called session and if it is not present in the table, to be able to create it by using choice.add.set, or something.
However, the line is not enabled for user input.
What can I do?
Code is below:
choice.add.set:
before.choice:
new.record = true
if not isspace(enno) then
tiitt231.enno = enno
display.all()
endif
Something similar to what you intend I have in this piece of code:choice.zoom:
after.choice:
if ( ( not tcibd915.attributes.present(tcibd914.cpln)) or
( not all.tcibd911.in.915(tcibd914.cpln)) ) and
not isspace(g.cpln) then
g.do.update = 1
update.occ() | Trigger 4GL to perform update action.
execute(update.db)
endifThe tcibd915.attributes.present and all.tcibd911.in.915 functions check the completeness of a record in 915 based on the setup, for a selected product line. The update.occ will trigger the 4GL update flag so on update.db it will execute the choice update.db:choice.update.db:
before.choice:
update.occ() | Trigger 4GL to perform update action.
| 4GL sets db.retry.point just after the before.choice
| Prepare updates in the "normal" flow and execute them in the
| after.choice section without extra retry points and commits. Just call
| execute(update.db)
after.choice:
| All additional update actions must be initiated through functions here
if g.do.update = 1 then | make 914 + 915 current
warn.outside.transaction = ""
on.main.table(fill.tcibd914, g.cpln, g.item)
g.do.update = 0
endif
| 4GL will perform the commit transaction after this section.

after.update.db.commit:
| now the STP commit has been done. New transactions must have their own
| db.retry.point() and commit.transaction().
if not isspace(warn.outside.transaction) then
mess("tcgenstring", 1, warn.outside.transaction)
if pos(warn.outside.transaction, "RESTART") <> 0 then
exit("RESTART")
endif
warn.outside.transaction = ""
endif
if (not isspace(g.titl)) and
( all.mandatory.values.filled.915(tcibd914.cpln, tcibd914.item) or
( tcibd914.txtn <> 0 and
not tcibd915.attributes.present(tcibd914.cpln) ) ) then
enable.commands("recreate.texts")
else
disable.commands("recreate.texts")
endif
clean.mess()
Where the fill.tcibd914 function will insert the new records but the errors are cached in the variable warn.outside.transaction which are not shown inside but outside the transaction of 4GL. They may be reason to restart the session instead of just refresh the data.

Maybe that path can help you somewhat further.