06-16-2015 12:24 PM
Hi all,
I have to pass data from lt_data (which is TYPE REF TO DATA) to hashed table lha_table.
and this hashed table data is used further in passing to standard method (parameter is of type HASHED TABLE).
pls guide me how can i do this. Thanks.
Regards,
Venkat
06-16-2015 7:05 PM
Hi,
it is easy,
you can assign your data ( type ref to data ) to hashed table,
and then pass your hased table to method with parameter hashed table
try this code to understand, hopfully will help you.
REPORT ztest200.
DATA: lr_data TYPE REF TO data,
lt_tab TYPE HASHED TABLE OF mara
WITH UNIQUE KEY matnr.
FIELD-SYMBOLS <lt_data> TYPE HASHED TABLE.
START-OF-SELECTION.
ASSIGN lt_tab TO <lt_data>.
CREATE DATA lr_data LIKE <lt_data>.
ASSIGN lr_data->* TO <lt_data>.
SELECT * FROM mara INTO TABLE <lt_data> UP TO 10 ROWS.
zibo_cl_test=>pass_hash_table( it_data = <lt_data> ).
BREAK-POINT.
D
d
If you want to pass the LR_DATA ( type ref to data) to hash table, I don't think that you can, because they have difference data type , so you have to pass the ref to dynamic table
assign ref to <lt_data>.. as I have written in Code
look to this syntax error while i was trying to pass ref_data to hash table through method.
f
Regards
Ibraihm
06-17-2015 6:54 AM
Hi,
Thanks for ur detail reply.
why do you declare lt_tab with hashed table of mara with unique key matnr.
because hashed table in my method parameter it's generic. means it's like below.
it_data type hashed table
Regards,
Venkat
06-17-2015 8:06 AM
Hi,
it just an example to fill the ITAB, so if you need it as generic
you can use this
FIELD-SYMBOLS <lt_data> TYPE HASHED TABLE.
in method also I have defined as generic.
see the method,
I have only passed the data to the method ( hashed table generic)
06-17-2015 9:10 AM
Hi,
my code is as below.
Data: lt_data type ref to data.
field-symbols: <it_hash_data> type hashed table.
after calling some standard method i will get data into lt_data. (i don't know unique in this)
then this data lt_data i have to pass to method parameter (let say it_hash_data which is of type hashed table).
step1:
step2: create data lt_data like <it_hash_data>.
step3 : assign lt_data->* to <it_hash_data>.
step1 is not clear for me. can you please guide. thanks.
Regards,
Venkat
06-17-2015 10:53 AM
Hi,
yes are right, you dont know about which unique key,
so you have to the following steps,
so
1. Data: lt_data type ref to data.
field-symbols: <it_hash_data> type hashed table.
so. hier you call standard method and you will get lt_data (ref to data ) goooood.
now lt_data ( has entries and you want to pass to method type hashed table)
ASSIGN lt_data->* TO <it_hash_data>.
call you method
pass_hash_table( it_data = <it_hash_data> ).
and it works ,
I have tried it out, and if you need the code I can send you.
Regards
Ibrahim,