Application Development 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: 

Control statements in loop s with where cond

Former Member
0 Kudos
98

Hi All,

I am using control statements in the loop which as where condition , The program works fine but , there is warning message , Is it appropriate to still use .

Thanks in advance

Vinay

12 REPLIES 12

former_member181995
Active Contributor
0 Kudos
71

What warning message?

But you can ignore the warning message np.

0 Kudos
71

Hi Amit ,

Thanks For ur reply , Its just a warning but i am worried about the consistency , It worked fine for all my test scenerios , But still wanted know if its appropriate .

Thanks

vinay

0 Kudos
71

below is the code .

LOOP AT gt_data_table INTO gs_data_table WHERE cust IN s_cust

AND site IN s_plant

AND acc_grp = gv_acc_grp

AND commodity IN s_commd

AND season IN s_season.

lv_partial_stk = lv_partial_stk + gs_data_table-available_stk.

lv_over_stk = lv_over_stk + gs_data_table-available_stk.

IF NOT gs_data_table-available_stk IS INITIAL.

APPEND gs_data_table TO gt_data_table1.

ENDIF.

lv_cust = gs_data_table-cust.

lv_commodity = gs_data_table-commodity.

lv_season = gs_data_table-season.

AT END OF lv_str1 .

IF gs_data_table-site_typ = 'COUNTRY'.

gs_cust_cntry_stk-cust = gs_data_table-cust .

gs_cust_cntry_stk-commodity = gs_data_table-commodity.

gs_cust_cntry_stk-season = gs_data_table-season.

gs_cust_cntry_stk-cntry_stk = lv_partial_stk.

APPEND gs_cust_cntry_stk TO gt_cust_cntry_stk.

ENDIF.

IF gs_data_table-site_typ = 'PORT'.

gs_cust_port_stk-cust = gs_data_table-cust .

gs_cust_port_stk-commodity = gs_data_table-commodity.

gs_cust_port_stk-season = gs_data_table-season.

gs_cust_port_stk-port_stk = lv_partial_stk.

APPEND gs_cust_port_stk TO gt_cust_port_stk.

ENDIF.

CLEAR lv_partial_stk.

ENDAT.

AT END OF lv_str.

gs_cust_overall_stk-cust = lv_cust.

gs_cust_overall_stk-commodity = lv_commodity.

gs_cust_overall_stk-season = lv_season.

gs_cust_overall_stk-overall_stk = lv_over_stk .

CLEAR lv_over_stk.

APPEND gs_cust_overall_stk TO gt_cust_overall_stk.

ENDAT.

ENDLOOP.

Thanks Guys

vinay

0 Kudos
71

Yup,it would't affect your program results at all,but it always better to remove them as much as possible.

what message you are getting?

0 Kudos
71

Hi Vinay,

You code looks ok to me.. I dont think your program would have any problem in future...

Thanks,

Chidanand

Former Member
0 Kudos
71

Hi Vinay ..

Paste the code ... for better answers.

Regards,

Sg

Former Member
0 Kudos
71

Hi,

Can you put the code here to make it more clear?

Thanks and Regards,

Chris Gu

Former Member
0 Kudos
71

Hi

currently your code is looking ok and it should work fine.

But concistency of result would depend upon your data coz it not recommended to use the control statement within a loop when you are using where condition.

You should not use control level statements in loops where the line selection is

restricted by WHERE or FROM and TO. Neither should the table be modified

during the loop.

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb381a358411d1829f0000e829fbfe/content.htm

Regards

Neha

0 Kudos
71

Thanks All for your replies ,

Here the message amit ,

Program: ZSTR_STORAGE_FEE_CALCULATION Row: 127 [Prio 3]

The LOOP statement processing will be limited

(FROM, TO and WHERE additions in LOOP)

Interaction with group change processing (AT NEW, ...) is undefined

(The message can be hidden with "#EC *)

Regards

Vinay kolla

0 Kudos
71

Since you are using Where condition with Loop,it means some entries may miss at "At end" due to Where check with loop.So its just warning message for letting you about loop proccesing with AT END but as you are getting desired results so you may ignore this.

0 Kudos
71

Thanks Amit

Regards

vinay

0 Kudos
71

Hi Vinay

You are getting this warning coz SAP itselt suggest not use control break within a loop otherwise you might get undesired results but if you are sure in your case you are gettign the right results then you can ignore the warning and move ahead.

Regards

Neha