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

My loop statement with a where condition does not work.

aris_hidalgo
Contributor
0 Likes
297

Hello experts,

I was wondering why does my loop statement with a where clause does not get any records.

I am sure there is an existing record in my itab since I checked it. Anyway, below is my

code guys.

LOOP AT it_finaltab ASSIGNING <fs_finaltab>.

IF <fs_finaltab>-asset_dum IS INITIAL AND

<fs_finaltab>-parent IS INITIAL.

CLEAR wa_output.

MOVE-CORRESPONDING <fs_finaltab> TO wa_output.

APPEND wa_output TO it_output.

ELSEIF NOT <fs_finaltab>-asset_dum IS INITIAL

AND <fs_finaltab>-parent IS INITIAL.

READ TABLE it_output2 WITH KEY funcloc = <fs_finaltab>-funcloc

asset_dum = <fs_finaltab>-asset_dum

asset = <fs_finaltab>-asset

parent = <fs_finaltab>-parent

INTO wa_output2.

IF sy-subrc <> 0.

CLEAR wa_output2.

MOVE-CORRESPONDING <fs_finaltab> TO wa_output2.

APPEND wa_output2 TO it_output2.

LOOP AT it_finaltab ASSIGNING <wa_finaltab> -


> does not get any records

WHERE parent = <fs_finaltab>-asset.

IF sy-subrc = 0.

MOVE-CORRESPONDING <wa_finaltab> TO wa_output2.

APPEND wa_output2 TO it_output2.

ENDIF.

ENDLOOP.

CLEAR wa_output2.

ELSE.

CONTINUE.

ENDIF.

ELSEIF NOT <fs_finaltab>-asset_dum IS INITIAL

AND NOT <fs_finaltab>-parent IS INITIAL.

READ TABLE it_finaltab WITH KEY asset = <fs_finaltab>-parent

ASSIGNING <wa_finaltab>.

IF sy-subrc = 0.

READ TABLE it_output2 WITH KEY funcloc = <fs_finaltab>-funcloc

asset_dum = <fs_finaltab>-asset_dum

asset = <fs_finaltab>-asset

parent = <fs_finaltab>-parent

INTO wa_output2.

IF sy-subrc <> 0.

MOVE-CORRESPONDING <wa_finaltab> TO wa_output2.

APPEND wa_output2 TO it_output2.

LOOP AT it_finaltab ASSIGNING <wa_finaltab> -


> does not get any records

WHERE parent = wa_output2-asset.

IF sy-subrc = 0.

MOVE-CORRESPONDING <wa_finaltab> TO wa_output3.

APPEND wa_output3 TO it_output2.

ENDIF.

ENDLOOP.

ENDIF.

ELSE.

CONTINUE.

ENDIF.

ENDIF.

ENDLOOP.

I checked my itab during debugging and I am sure there is a record where its parent field has the same value as

of the <fs_finaltab>-asset and wa_output2-asset. Help would be greatly appreciated. Thanks a lot guys and take care!

1 ACCEPTED SOLUTION
Read only

sergey_korolev
Active Contributor
0 Likes
259

As far as I remember asset number has ALPHA conversion exit, that is internally it is stored with leading zeroes. Check if both fields <b>asset</b> and <b>parent</b> has the same internal represenatation.

Also statement

IF sy-subrc = 0.

inside your second LOOP WHERE is absolutely redundant.

1 REPLY 1
Read only

sergey_korolev
Active Contributor
0 Likes
260

As far as I remember asset number has ALPHA conversion exit, that is internally it is stored with leading zeroes. Check if both fields <b>asset</b> and <b>parent</b> has the same internal represenatation.

Also statement

IF sy-subrc = 0.

inside your second LOOP WHERE is absolutely redundant.