Passing table record

Kladkul

Member
Good morning,

I am working with a temp-table with which I need to pass each record individually to an outside procedure. Now, I thought about getting the total record count of the table (I was reading the other post asking bout this) and using a DO WHILE but wasn't sure if there was another way?

Edit: I need to be able to pass the entire table to another procedure. Any example code I may reference?
 
Hi...

I think this eg. will help u..


Eg:

DEFINE TEMP-TABLE tt_temp
FIELDS tt_field1 AS CHAR
FIELDS tt_field2 AS CHAR.

CREATE tt_temp.
ASSIGN tt_field1 = "First"
tt_field2 = "sec".

CREATE tt_temp.
ASSIGN tt_field1 = "Third"
tt_field2 = "Four".

FOR EACH tt_temp:
RUN proc1(INPUT tt_field1, INPUT tt_field2).
END.

PROCEDURE proc1:

DEFINE INPUT PARAMETER tt_fir AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER tt_sec AS CHARACTER NO-UNDO.

MESSAGE tt_fir tt_sec
VIEW-AS ALERT-BOX INFO BUTTONS OK.

END PROCEDURE.
 
Yes, but how do I pass the entire table?

I create the table in another program, pass it back to the calling procedure. Then, pass each record of the table into another program.
 
You can pass entire temp-tables to another procedure if the outsite procedure is expecting it. And you can do that using the statement:

Code:
DEFINE TEMP-TABLE exampleTT FIELD testfield AS INTEGER.
 
CREATE exampleTT.
ASSIGN ....
 
 
RUN xxxx(INPUT TABLE exampleTT).
 
 
PROCEDURE xxxx:
/* define the table exacly like the outside table */
DEFINE TEMP-TABLE exampleTT FIELD testfield AS INTEGER.
define input param table for exampleTT .

Hope this could help.
Cheers
 
Does it work the same way for in output param? For instance:

Code:
def input param p-cust        like customer.custnum.
 
run xxxx(input p-cust
            output table p-ttable). 
 
for each p-ttable: 
display f-custnum. 
end.
 
-----------------------------------------------
procedure xxxx: 
def input param p-cust       like customer.custnum.
def output param table for p-ttable. 
def temp-table p-ttable
field f-custnum    like customer.custnum. 
 
create p-ttable. 
assign f-custnum = 9999.
 
/* This is where it gets fuzzy */ 
return temp-table p-ttable.

I know that isn't very accurate, but I believe you'll get an idea of what I'm trying to do.
 
Sure, works that way too. Just make sure the temp-tables definition comes first from the param statement.
There's no need for the return statement either. Since it's an output param, it get filled when you assign something to it.
And I made a mistake, the temp-table cannot by declare inside the procedure, so outside will do.

Your code will look something like this:

Code:
def input param p-cust        like customer.custnum.
[COLOR=red]def temp-table p-ttable[/COLOR]
[COLOR=red]             field f-custnum    like customer.custnum.[/COLOR]  
 
run xxxx(input p-cust
            output table p-ttable). 
 
for each p-ttable: 
display f-custnum. 
end.
 
-----------------------------------------------
procedure xxxx: 
def input param p-cust       like customer.custnum.
 
def output param table for p-ttable. 
 
create p-ttable. 
assign f-custnum = 9999.
 
/* This is where it gets fuzzy */ 
/*return temp-table p-ttable. COMMENTED*/
end procedure.
Cheers.
 
Back
Top