RavCOder
30th September 2019, 12:56
Hi,
I will explain my problem: I have a table that allows to insert record into from another tables. I created this function to insert my records.

function insert_field_table(){

select tdsls900.* , tdsls400.ofbp, tdsls400.odat, tccom100.nama,
tdsls401.orno, tdsls401.cups, tdsls401.item , tdsls401.qoor
from
tdsls900, tdsls401, tdsls400, tccom100
where tdsls400.ofbp = tdsls401.ofbp
and tdsls400.orno = tdsls900.orno
and tccom100.bpid = tdsls900.bpid

selectdo
tdsls900.bpid = tdsls400.ofbp
tdsls900.nama = tccom100.nama
tdsls900.item = tdsls401.item
tdsls900.cuni = tdsls401.cups
tdsls900.odat = tdsls400.odat
tdsls900.orno = tdsls401.orno
tdsls900.qoor = tdsls401.qoor

db.insert(ttdsls900, db.retry)




rprt_send()
endselect
commit.transaction()

}

However my function doens't work corretcly because don't show nobody records and show me only report's labels.
Regards,
RavCoder

mark_h
30th September 2019, 14:26
Where is your retry point? I would put it in debug mode - and put the commit right after the insert just to make sure it is really inserting any records. In debug mode you can check the selected fields to make sure they have data.

RavCOder
30th September 2019, 15:16
It still doesn't work, I put your suggestions but I do not access the function I wrote, so I don't see if my data is saved or not.


function insert_field_table(){
db.retry.point()
select tdsls900.* , tdsls400.ofbp, tdsls400.odat, tccom100.nama,
tdsls401.orno, tdsls401.cups, tdsls401.item , tdsls401.qoor
from
tdsls900, tdsls401, tdsls400, tccom100
where tdsls400.ofbp = tdsls401.ofbp
and tdsls400.orno = tdsls900.orno
and tccom100.bpid = tdsls900.bpid

selectdo
tdsls900.bpid = tdsls400.ofbp
tdsls900.nama = tccom100.nama
tdsls900.item = tdsls401.item
tdsls900.cuni = tdsls401.cups
tdsls900.odat = tdsls400.odat
tdsls900.orno = tdsls401.orno
tdsls900.qoor = tdsls401.qoor
commit.transaction()
db.insert(ttdsls900, db.retry)




rprt_send()
endselect


}

mark_h
30th September 2019, 15:30
In debug mode as you step thru it you should see this function get called - if not there is another issue. So where are you calling this function from? Post the code so we can see where it gets called from.

And put the commit right after the insert.

RavCOder
30th September 2019, 15:37
here below:



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

choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
if rprt_open() then
read.main.table()

||update_table()
sum_order()
sum_period()
insert_field_table()
rprt_close()
else
choice.again()
endif

mark_h
30th September 2019, 15:58
Not sure what each function does. But you should see it open the report, then call read.main.table() and return from that function. Then call sub_order and return from that function. Same with sum_period() - if it calls each of those and then returns it should call the insert_field_table function. So step thru it in debug mode. If it is not calling that function something is wrong somewhere else.

RavCOder
30th September 2019, 16:21
Hi,
Thanks for your help, unfortunately it doesn't tell me exactly where the problem is and even if it were somewhere else I wouldn't know where it is.
Regards,
RavCoder

mark_h
30th September 2019, 20:36
It has to help - I mean in debug mode you step thru the script and see exactly what happens when. There has to be a reason that code never gets called.

RavCOder
1st October 2019, 10:26
Hi,
unfortunately I debugged my code but didn't jump out.
This is all my code:

****************************** declaration section ***************************
declaration:

table ttdsls400 | Ordini di vendita
table ttdsls401 | Righe ordini di vendita
table ttdsls900 | Nuova tabella che prende i record della tabella tdsls401
table ttccom100
extern domain tcorno orno.f fixed
extern domain tcorno orno.t fixed
extern domain tcyesno txta.txt
extern domain tcyesno txtb.txt
extern string tdsls900.bpid
extern string tdsls900.nama
extern string tdsls900.item
extern string tdsls900.cuni
extern long tdsls900.odat
extern string tdsls900.orno
extern double tdsls900.qoor



extern domain tdsmo somma
extern domain tdqper quantita_periodo



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


|****************************** group section **********************************

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




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

choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
if rprt_open() then
read.main.table()


sum_order()
sum_period()
||update_table()
insert_field_table()
rprt_close()
else
choice.again()
endif


|****************************** field section *********************************

field.orno.f:
when.field.changes:
orno.t = orno.f






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

functions:

function read.main.table()
{
select tdsls400.*
from tdsls400
where tdsls400._index1 inrange {:orno.f}
and {:orno.t}


order by tdsls400._index1



selectdo
rprt_send()
endselect
}






function sum_order() {

somma = 0
select tdsls401.ofbp,tdsls401.item
from tdsls401

group by tdsls401.ofbp,tdsls401.item

selectdo
select tdsls401.qoor
from tdsls401
where tdsls401.item = :tdsls401.item
and tdsls401.ofbp = :tdsls401.ofbp

selectdo
somma = somma + tdsls401.qoor


endselect

rprt_send()
endselect




}


function sum_period()
{
quantita_periodo = 0
select tdsls401.ofbp, tdsls401.odat
from tdsls401
group by tdsls401.ofbp, tdsls401.odat
selectdo
select tdsls401.qoor
from tdsls401
where tdsls401.ofbp = :tdsls401.ofbp
and tdsls401.odat = :tdsls401.odat

selectdo
quantita_periodo = quantita_periodo + tdsls401.qoor
endselect
rprt_send()

endselect
}


function insert_field_table(){
db.retry.point()
select tdsls900.* , tdsls400.ofbp, tdsls400.odat, tccom100.nama,
tdsls401.orno, tdsls401.cups, tdsls401.item , tdsls401.qoor
from
tdsls900, tdsls401, tdsls400, tccom100
where tdsls400.ofbp = tdsls401.ofbp
and tdsls400.orno = tdsls900.orno
and tccom100.bpid = tdsls900.bpid

selectdo
tdsls400.ofbp=tdsls900.bpid
tccom100.nama = tdsls900.nama
tdsls401.item = tdsls900.item
tdsls401.cups = tdsls900.cuni
tdsls400.odat = tdsls900.odat
tdsls401.orno = tdsls900.orno
tdsls401.qoor= tdsls900.qoor
db.retry.point()

db.insert(ttdsls900, db.retry)
commit.transaction()



rprt_send()
endselect


}


I hope that someone tell me some suggestion.
If there are parts that are not understood, I will clarify.
Thanks and regards,
RavCoder

bdittmar
1st October 2019, 12:41
Hello,

rprt_sent() is called 4 times in report.open ?
As Mark suggest, trace the variables data in debug mode.

Regards

RavCOder
1st October 2019, 12:56
Hi,

How to track variables in debug mode? I'm a little confused about it
I wrote rprt_sent() because without it don't execute my script.
Regards,
RavCoder

bdittmar
1st October 2019, 13:27
Hello,
here are the debugger commands.

Debugger commands
Debugger commands consist of from one to three words; the words can be separated from each other by one or more spaces. The assignment command is an exception. Here the variable and the value to be assigned are separated by a ':=' sign. Most commands require a line number and/or a source name. If no source name is specified, the default is the current source.

When you start the debugger for an object, the source used by the debugger is first searched for by using the directions in the file fd x.x.<pack.comb.> (where x.x is the bshell version), then it is searched for in the $BSE/tmp directory, and finally in the current directory.

Command Action
b [[source] line_number] Toggle a break point on the current or specified line of the current or specified source. The line is highlighted, when break point is set.

Note that you cannot set break points in included parts in a source. Instead the break point must be set in the included file.

B [source] Display all set break points in the current or specified source.
c [number] Continue (execute the source) up to the next break point. If you specify a number, the debugger skips that number of break points. The executed source lines are not displayed.
CC [number] Same as 'c', except that the executed source lines are displayed.
cc Change the size of the command window. This is valid only when application and debugger are in the same window.
cs Change the size of the source window. This is valid only when the application and debugger are in the same window.
d [source line_number] Delete the break point on the specified line number in the source. If you do not specify a line number, the debugger provides the opportunity to interactively delete any break point in the current source file.
D [source] Delete all set break points in the specified or current source.
delete all Delete all traces and stop instructions.
delete number Delete a specified trace or stop instruction.
ds Delete the source window.
dd Generate a dump of the data dictionary.
<expression> Execute the specified expression.
f [noarg|noname][number] Display stack trace (present nesting of functions), with the arguments of the functions. If you specify a number, only that number of nestings is displayed.

noarg only the names of functions are displayed

noname arguments are displayed but not their names

fdebug Show the open tables on the command window.
Fdebug Print the open tables to the spooler.
g [source] line_number Continue program execution at the specified line number (goto).
help (or ?) Start the Help Viewer for debugger options.
l Display the full list of program variables.
L Display the list of program variables that have a value, and display their current values. To stop displaying the contents of an array, enter 'n' at the question 'More ?'.
lp Print the output of the 'l' command.
Lp Print the output of the 'L' command.
mem Generate a dump including information about the memory allocated.
p Go to the source line currently being processed (this is useful after the view or seek command). The line is indicated by a greater than (>) sign before the line number.
q Exit the debugger (quit).
return Continue execution until the end of the current function.
s [number] Execute the program step by step, the specified number of instructions at a time (default is 1). During execution, the intermediate source lines are not displayed.
S [number] Similar to 's', except that a function call is executed as a single statement.
slow [number] Reduce the rate of running source code. The maximum number is 100; the minimum (and default) number is 0.
split number Split the command and source window. The specified number is the last line of the command window. This is often used after resizing the Debugger window.
status [trace|stop|number] Display traced variables and/or stop instructions. If you specify a number, only that traced variable or stop instruction is displayed.
stop if <expression> Stop execution when expression is True.
stop in <function> Stop execution when function is entered.
sym Generate a dump of the symbol table.
trap off Disables ‘trap on’. This command is available only when the bshell was started with the -dbgcpu flag.
trap on The debugger stops after execution of every function call. This command is available only when the bshell was started with the -dbgcpu flag.
swin off There is a separate window for stack, array and long string in debugger. The appearence of this second window can be switched off with "swin off".
swin on There is a separate window for stack, array and long string in debugger. The appearence of this second window can be switched on with "swin on".
t variable Trace the specified variable during program execution. The execution of the program stops every time the value of the variable is changed. You cannot trace array variables or common variables.
T variable [value] Same as 't', except that program execution is not stopped when the variable changes. If you specify a value, execution stops when the variable gets that value.
u [variable] Stop tracing the specified variable. If no variable is specified, you can stop tracing each variable interactively.
U Stop tracing all variables currently being traced.
v [source] line_number Display a specified source line in the source window (view). If line_number is greater than the total number of lines, the last line is displayed.
v {+-} number Shift the display to the source line that is number lines before or after the current source line.
/pattern Seek a matching text pattern in the current source and display that line.
[function.]variable [/option] Display the value of a specified variable. If you specify a function, the value of the local variable of that function is displayed. Otherwise, the value of the variable of the current function or the global variable is displayed. If a variable has no value (empty string or zero number), the value is not displayed.

/ option can have the following values:

/ Use to display the value of a variable that has the same name as a Debugger command. For example, ‘b/’ displays the value of variable b.
/d Print the flags of the variable and the dimension for arrays.
/D Display the number of bytes allocated in a long or double variable. Display the number of bytes for one element in a string array.
/g For a string containing the compact string representation of a UUID, display the standard string representation of the UUID. See UUID overview.
The following options are useful for record buffers and binary data. They display the value of a string variable with its full declared length, regardless of NUL characters.
/x NUL characters are displayed as ‘^@’.
/X Characters with values 0 to 31 are displayed as ‘\x<value in hex>’.
/b All characters are displayed as ‘ \x<value in hex>’.
/l Interpret field as UTC field and print in local time and prints current time zone.
/u Interpret field as UTC field and print in utc time.


variable := value Assign a value to a variable. The value can be:

a string constant or expression

a numeric constant or expression

a variable name

vi Activate the vi editor for the current source at the current source line. Changing the source has no influence on the source displayed by the debugger in the source window.
width value Change the width of command and source window. You can specify any value in the range 80 to 132.
<Ctrl>D/<Ctrl>U Page down or up in source.
<Esc> Toggle between normal and history mode.
<Arrow up>/ <Arrow down> In history mode, these display previously executed commands on the command line. In normal mode, these move the cursor through the source.


Regards

RavCOder
1st October 2019, 13:47
Thanks for sending me the debug commands but keep showing me the record data on my report.

mark_h
1st October 2019, 14:52
Maybe this will help you understand report. So first comment out these three lines: sum_order()
sum_period()
insert_field_table()
That leaves only the read main table.

function read.main.table()
{
select tdsls400.*
from tdsls400
where tdsls400._index1 inrange {:orno.f} and {:orno.t}
order by tdsls400._index1
selectdo
rprt_send()
endselect
}


The above is going to take an input range of orders, find every tdsls400 record in the range and send all of the fields to the report. So now you get a report on tdsls400.

RavCOder
1st October 2019, 15:18
Thanks this I got it into my head, but my problem as I have already said in other threads was that from this main table and from other tables (tdsls400 and tccom100) I have to display certain fields in a new table that I already created (tdsls900 ). I had created a function to do that takes the tables and inserts them into the external variables I created.
This one:

function insert_field_table(){
db.retry.point()
select tdsls900.* , tdsls400.ofbp, tdsls400.odat, tccom100.nama,
tdsls401.orno, tdsls401.cups, tdsls401.item , tdsls401.qoor
from
tdsls900, tdsls401, tdsls400, tccom100
where tdsls400.ofbp = tdsls401.ofbp
and tdsls400.orno = :tdsls900.orno
and tccom100.bpid = :tdsls900.bpid

selectdo
tdsls900.bpid = tdsls400.ofbp
tdsls900.nama = tccom100.nama
tdsls900.item = tdsls401.item
tdsls900.cuni = tdsls401.cups
tdsls900.odat = tdsls400.odat
tdsls900.orno = tdsls401.orno
tdsls900.qoor = tdsls401.qoor


db.insert(ttdsls900, db.retry)
commit.transaction()



rprt_send()
endselect



then the other two were other functions that I needed to make simple sums and those in my report can be seen if I put in after reading the main table.
I tried to do as you said but I still don't see the values, I also checked if I had input fields and they are in my report.
Now it displays the report but without displaying the values ​​of the records.

I'm in a blind alley for now and I can't do anything else, maybe I'm missing certain logics.
Regards,
RavCoder

mark_h
1st October 2019, 15:29
My interpretation of what I read and the report. Just my swag of getting a report. Understand the report first before you try to write records. I do not guarantee it will work we do not have or use any of these tables.

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

table ttdsls400 | Ordini di vendita
table ttdsls401 | Righe ordini di vendita
table ttdsls900 | Nuova tabella che prende i record della tabella tdsls401
table ttccom100
extern domain tcorno orno.f fixed
extern domain tcorno orno.t fixed
extern domain tcyesno txta.txt
extern domain tcyesno txtb.txt


extern domain tdsmo somma
extern domain tdqper quantita_periodo



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


|****************************** group section **********************************

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


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

choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
if rprt_open() then
read.main.table()
rprt_close()
else
choice.again()
endif


|****************************** field section *********************************

field.orno.f:
when.field.changes:
orno.t = orno.f

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

functions:

function read.main.table()
{
| This would get you orno, item, ofbp, odat
select tdsls400.orno, tdsls401.item, tdlsls401.ofbp, tdsls401.odat
from tdsls400
where tdsls400._index1 inrange {:orno.f} and {:orno.t}
and tdsls401.orno = tdsls400.orno
group by tdsls400.orno, tdsls401.item, tdlsls401.ofbp,tdsls401.odat
selectdo
| This gets somma or the sum of all orders for that item and ofbp
sum_order()
| This gets quantita_periodo or the sum of all orders for that ofbp and that odat
sum_period()
| So now when you do the report send you have 1 set of records:
| tdsls400.orno, tdsls401.item, tdlsls401.ofbp, tdsls401.odat, somma (total order for that item and ofbp)
| , quantita_periodo total orders for ofbp and oday
rprt_send()
endselect
}

| Sum current tdsls400.orno
function sum_order()
{
somma = 0
select sum(a.qoor):somma
from tdsls401 a
where a.item = :tdsls401.item
and a.ofbp = :tdsls401.ofbp
selectdo
endselect
}
function sum_period()
{
quantita_periodo = 0
select sum(b.qoor):quantita_periodo
from tdsls401 b
where b.ofbp = :tdsls401.ofbp
and b.odat = :tdsls401.odat
selectdo
endselect
}

RavCOder
1st October 2019, 17:29
Hi,
Thank you again for your support, but I'm trying to debug my code and I noticed that it doesn't really fit into the function.
Regards,
RavCoder