2018 Jun 19 1:34 PM
Hi Friends,
I came across the "for" statement, upon checking our system version shows we're using 740 sp-level 0017.
i_test = value #( for wa_bukrs in i_bukrs( wa_bukrs-bukrs ) ).
*Error the syntax for a method specification is "objref->method or...
*if i try the other form...
data(i_test2) = value ty_bukrs( for wa_bukrs in i_bukrs( wa_bukrs-bukrs ) ).
*Error No component exists with the name "FOR". "FOR".
I know its basic, but i've tried several ways and different forums, these all point to same syntax which doesn't work at all.. any inputs will be appreciated.
Thank you.
2018 Jun 20 9:25 AM
DATA flights type table of sflight.
DATA carrids type table of sflight-carrid.
carrids = value #( for <flight> in flights ( <flight>-carrid ) ). " space before parenthesis
Beware the spaces in ABAP, they are very important ! (space before parenthesis)
Hi Friends,
I came across the "for" statement, upon checking our system version shows we're using 740 sp-level 0017.
i_test = value #( for wa_bukrs in i_bukrs( wa_bukrs-bukrs ) ).
*Error the syntax for a method specification is "objref->method or...
*if i try the other form...
data(i_test2) = value ty_bukrs( for wa_bukrs in i_bukrs( wa_bukrs-bukrs ) ).
*Error No component exists with the name "FOR". "FOR".
I know its basic, but i've tried several ways and different forums, these all point to same syntax which doesn't work at all.. any inputs will be appreciated.
Thank you.
2018 Jun 19 3:01 PM
2018 Jun 20 4:13 AM
Thanks Horst, is it possible to have the syntax checked and recommend possible solution? I can't make it work. thanks.
2018 Jun 20 6:22 AM
Aren't you able to compare it yourself with the syntax and the examples from the documentation?
You have to specify an internal table behind IN. But you use the syntax for a function call.
2018 Jun 20 6:39 AM
Looks like an importing parameter rather than a function call.
2018 Jun 20 6:46 AM
Yeah, the name, but the parentheses behind i_bukrs are the syntax for a function(al method) call and that's also what the syntax check complains. It doesn't care for names. And i_ could also mean itab, who knows.
2018 Jun 20 7:03 AM
I didn't look to closely, but thought perhaps it's an attempt at some kind of Value expression!
2018 Jun 20 1:03 PM
i_ is an internal table in the OP's standards. How I hate typing prefixes!
2018 Jun 20 8:14 AM
Hi jeff.
I guest what you want to do is fetch company code from i_burks to i_test.
if so, i think FOR GROUPS could be used:
i_test = VALUE #( FOR GROUPS burks OF <fs_burks> IN i_burks GROUP BY <fs_burks>-burks WITHOUT MEMBERS ( burks ) ).
2018 Jun 21 5:43 AM
2018 Jun 20 9:25 AM
DATA flights type table of sflight.
DATA carrids type table of sflight-carrid.
carrids = value #( for <flight> in flights ( <flight>-carrid ) ). " space before parenthesis
Beware the spaces in ABAP, they are very important ! (space before parenthesis)
2018 Jun 20 11:25 AM
Thanks All, I removed the space before the parenthesis however, I still get an error:
TYPES: BEGIN OF ty_bukrs,
bukrs TYPE bukrs,
butxt TYPE butxt,
ort01 TYPE ort01,
land1 TYPE land1,
waers TYPE waers,
spras TYPE spras,
ktopl TYPE ktopl.
TYPES: END OF ty_bukrs.
data(i_test2) = value ty_bukrs( for wa_bukrs in i_bukrs ( wa_bukrs-bukrs ) ).
"Error no component exists with the name "FOR"."FOR".
any ideas? thank you.
2018 Jun 20 1:10 PM
2018 Jun 20 1:12 PM
Maybe this will make it clear:
TYPES: BEGIN OF ty_bukrs,
bukrs TYPE bukrs,
butxt TYPE butxt,
ort01 TYPE ort01,
land1 TYPE land1,
waers TYPE waers,
spras TYPE spras,
ktopl TYPE ktopl.
TYPES: END OF ty_bukrs.
DATA i_bukrs TYPE STANDARD TABLE OF ty_bukrs.
TYPES ty_company_codes TYPE STANDARD TABLE OF bukrs WITH DEFAULT KEY.
DATA(i_test2) = VALUE ty_company_codes( FOR wa_bukrs IN i_bukrs ( wa_bukrs-bukrs ) ).
Your FOR expression was not returning data of type ty_bukrs.
2018 Jun 20 1:33 PM
Thanks Matthew, working now. but can you also make the code below work (please include declarations similar to your previous answer). having trouble using "#" in this example:
i_test = value #( for wa_bukrs in i_bukrs ( wa_bukrs-bukrs ) ).
Thanks!
2018 Jun 21 7:41 AM
2018 Jun 21 10:58 AM
2019 Jun 11 2:23 PM
Hello Jeff,
I am getting the same error No component exists with name "FOR" . "FOR"
Could you please let me know how did you solve your issue.
Thanks in advance.
Best Regards,
Kavya
2019 Jun 27 9:30 PM
Hi Kavya, Please see answer of Sandra Rossi. Normally space issue. thanks.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |