Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

loop at with where statement why not possible

Former Member
0 Likes
841

Hello Experts,

This is part of the code for the BADI.

When I use the below code I get the error "in Loop..Where the line type should be statically defined"

Error Code:

method IF_EX_OPENHUB_TRANSFORM~TRANSFORM.

data: l_s_data_in type /BIC/CYZTRX.

data: l_s_data_out type /BIC/CZZTRX.

clear e_t_data_out.

loop at i_t_data_in into l_s_data_in

where /BIC/ZI_MARKET EQ SPACE

and SOURSYSTEM EQ DO

and /BIC/ZGN_SLDTO NE SPACE.

move-corresponding l_s_data_in to l_s_data_out.

insert l_s_data_out into table e_t_data_out.

endloop.

endmethod.

Code with no Check error:

method IF_EX_OPENHUB_TRANSFORM~TRANSFORM.

data: l_s_data_in type /BIC/CYZTRX.

data: l_s_data_out type /BIC/CZZTRX.

clear e_t_data_out.

loop at i_t_data_in into l_s_data_in.

if l_s_data_in-/BIC/ZI_MARKET EQ SPACE

and l_s_data_in-SOURSYSTEM EQ 'DO'

and l_s_data_in-/BIC/ZGN_SLDTO NE SPACE.

move-corresponding l_s_data_in to l_s_data_out.

insert l_s_data_out into table e_t_data_out.

else.

continue.

endif.

endloop.

endmethod.

I would like to use the logic in the Where statment instead of writing it as a seperate IF statement. Wondering if there is any error in the first code. Is there any other method of acheving this. Please suggest.

Many thx in adv.

Sandhya

5 REPLIES 5
Read only

Former Member
0 Likes
753

The reason is that the structure of the internal table I_T_DATA_IN is not known to the BADI, but once transported to the work area I_S_DATA_IN which has a defined structure that the BADI can recognize, the individual structure level checks are possible.

Rishi

Read only

Former Member
0 Likes
753

Sandhya,

I think the rule is; during comparision the field on the left of the '=' should belong to the table(internal). Looking at your code, it doesn't belong to the table.

Kshitij

Read only

Former Member
0 Likes
753

I would modify your code as follows.


method IF_EX_OPENHUB_TRANSFORM~TRANSFORM.
  data: l_s_data_in type /BIC/CYZTRX.
  data: l_s_data_out type /BIC/CZZTRX.
  data: l_it_data type /BIC/CYZTRX occurs 0.

  l_it_data[] = i_t_data_in[].
  clear e_t_data_out.
  loop at l_it_data into l_s_data_in
                   where /BIC/ZI_MARKET EQ SPACE
                     and SOURSYSTEM     EQ DO
                     and /BIC/ZGN_SLDTO NE SPACE.
    move-corresponding l_s_data_in to l_s_data_out.
    insert l_s_data_out into table e_t_data_out.
  endloop.
endmethod.

Hope this helps.

Srinivas

Read only

Former Member
0 Likes
753

Hi Sandhya,

You have not closed your . I hope that issue is not succesfully resolved. Can you please mark that thread as answered?

Coming to your current problem, in the first case, you seem to have forgotten to put the quotes around DO. Remember, 'DO' is a literal where as DO will be a variable. If this is not the cause for the error, please get back...

Regards,

Anand Mandalika.

Read only

0 Likes
753

Nice catch!