2009 Nov 02 6:05 PM
Hi,
I have a FM with a changing parameter of type TABLE,
I want to use loop at on this table with WHERE Clause
FUNCTION Z_DATA_RECCOUNT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" CHANGING
*" REFERENCE(T_SOURCE_PACKAGE) TYPE TABLE
FIELD-SYMBOLS: <l_s_source_package> type ANY,
<temp_buffer> type any.
LOOP AT t_source_package ASSIGNING <temp_buffer>
WHERE /bic/tr = '2' AND
/bic/res = '3'.
But the system is saying that:
Error:
"In "LOOP ... WHERE ..." the row type of the table must be statically defined statically defined"
Please advice
Hello,
You can do this because READ TABLE supports dynamic tokens
But then you will read only 1 line of the table which contradicts the usage of LOOP ... WHERE
BR,
Suhas
2009 Nov 02 6:09 PM
2009 Nov 02 6:11 PM
Nopes, not working:
It is saying:
The field "T_SOURCE_PACKAGE" specified under LIKE has no type.
2009 Nov 02 6:11 PM
Hello Merc,
This is because the Field Symbol <temp_buffer> is generic & its type is not determined till runtime.
So when you are trying to use LOOP ... WHERE & giving the fieldnames
WHERE /bic/tr = '2' AND /bic/res = '3'.the compiler cannot determine that these fields are available in <temp_buffer>.
Hence you are getting this error.
I have a question, if you know the tables fields then why have you decalred the TABLES param as generic ?
BR,
Suhas
PS: LOOP ... WHERE does not support dynamic tokens. So you have to think of some workaround for this
2009 Nov 02 6:19 PM
Ok, But if I do:
FUNCTION Z_DATA_RECCOUNT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" CHANGING
*" REFERENCE(T_SOURCE_PACKAGE) TYPE TABLE
DATA: temp_buffer LIKE SORTED TABLE OF l_s_source_package
WITH UNIQUE KEY /BIC/SETRADAT
/BIC/SERESNAM.
"There are 2000 records in t_source_package table.
READ TABLE t_source_package into temp_buffer
WITH TABLE KEY /BIC/SETRADAT = '2'
/BIC/SERESNAM = '3'.
Error:
The specified type has no structure and therefore no component called "/BIC/SETRADAT". component called "/BIC/SETRADAT".
Thats cuz t_source_package is of type table, how shall I get the type of it and assign to it it ?
2009 Nov 02 6:25 PM
I think i resolved it like this
READ TABLE t_source_package into temp_buffer
WITH TABLE KEY ('/BIC/SETRADAT') = <TRADE_DATE>
('/BIC/SERESNAM') = <RESOURCE_NAME>.
2009 Nov 02 6:30 PM
Hello,
You can do this because READ TABLE supports dynamic tokens
But then you will read only 1 line of the table which contradicts the usage of LOOP ... WHERE
BR,
Suhas
2009 Nov 02 6:32 PM
2009 Nov 02 6:45 PM
2009 Nov 02 6:46 PM
Saha,
What shall I do then, I need more records not just one, Please help !
2009 Dec 16 9:07 AM
Hi Merc
Try the following non performant workaround:
LOOP AT t_source_package ASSIGNING <temp_buffer>.
IF <temp_buffer>-/bic/tr = '2' AND <temp_buffer>-/bic/res = '3'.
" Do your coding
ENDIF.
ENDLOOP.
Best regards
Markus
Edited by: Markus Hofmann on Dec 16, 2009 10:08 AM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |