‎2006 Jan 17 9:28 PM
I'm running up against a strange problem. I'm trying to return data from an RFC in a table data structure.
What I'm finding is that no matter how I sort the data in the function module, SAP resorts the data alphanumerically before it leaves the RFC.
Does anyone know how I can get my data to -stay- in the sort order I specified using the SORT command?
‎2006 Jan 18 1:57 PM
There is really no one who knows how function modules sort tables by default?
‎2006 Jan 18 2:00 PM
ColtsFan,
How is the internal table declared?
Signed,
A Steelers Fan...
‎2006 Jan 18 2:04 PM
‎2006 Jan 18 2:04 PM
Hi. It's in the "tables" section of the function module defined LIKE a data dictionary structure with the following fields:
CHAR 4
CHAR 20
CHAR 20
CHAR 20
CHAR 20
CHAR 18
CHAR 20
CHAR 1
INT4 10
CURR 15
CUKY 5
CURR 15
CUKY 5
DEC 5
CHAR 8
CURR 15
CUKY 5
CURR 15
CUKY 5
INT4 10
INT4 10
CHAR 1
CURR 15
CUKY 5
CHAR 30
CHAR 10
When I sort the table in the function module, it looks good! But as soon as the RFC completes the data in the table seems to be re-sorted alphanumberically based on the first CHAR fields in the table.
‎2006 Jan 18 2:10 PM
Please post the entire internal table declaration and the code around your "forced" SORT command.
‎2006 Jan 18 2:13 PM
Hi!
Do you change anything in this table except the order? Because there is a delta managing mechanism to minimize network load during parameter and result passing. In case of internal tables, the RFC server receives the table entries, it creates a local copy of the internal table. Then only delta information is returned to the RFC client. This information is not returned to the RFC client every time a table operation occurs, however; instead, all collected delta information is passed on at once when the function returns to the client.
Maybe sorting is not defined as 'change'.
Rich, did you fill the table inside or outside of the RFC-FM?
Regards,
Christian
‎2006 Jan 18 2:17 PM
‎2006 Jan 18 2:22 PM
Looks like we have tracked down to the source of this riddle. In case of field changes, it's not a problem, otherwise using import / export parameter will be a workaround.
‎2006 Jan 18 2:29 PM
So if I export and then import the table before the function module ends, it will force the new sorting to take effect within the outgoing table?
Let me give that a shot...
‎2006 Jan 18 2:17 PM
Hi,
In Function Module use
Export itab to memory Id 'TEST'.
Import itab from memory Id 'TEST'.
Regards
Amole
‎2006 Jan 18 2:22 PM
Hi Amole,
What will importing and exporting the itab to memory do for me?
‎2006 Jan 18 2:30 PM
Export will write the data to temporary ABAP memory
import will get the data from ABAP memory
itab structure should be same in calling and called program
Regards
Amole
‎2006 Jan 18 2:34 PM
Hi!
I was referring the FM interface definition. Send your table as import parameter (from FM point of view) and give back the result as export parameter - then you trick out the workload optimization of SAP.
You shouldn't need to export into memory / import from memory. This can't work anyway, because you have a <i>remote</i> function call.
Regards,
Christian
‎2006 Jan 18 2:37 PM
Just for reference........but I think Christian is right. Haven't tested it.
report zrich_0003 .
data: itab type table of t001 with header line.
call function 'Z_TEST'.
import itab = itab from memory id 'ZRICHTEST'.
function z_Test.
data: itab type table of t001 with header line.
* Get data and sort it.
export itab = itab to memory id 'ZRICHTEST'.
ENdfunction.
Regards,
Rich Heilman