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

Coding Error

Former Member
0 Likes
460

Dear All,

Will you please let me know what's wrong in the following code?

form zf_caluc .

CASE sy-ucomm.

WHEN 'CALUC'.

loop at gt_alv into gs_alv.

gv_calc = gs_alv-bdmng - gs_alv-enmng.

if gv_calc > 300.

exit.

elseif gv_calc < 300.

gs_alv-labst = gv_calc.

endif.

append gs_alv to gt_alv.

modify gt_alv from gs_alv .

endloop.

when 'back'.

LEAVE PROGRAM.

ENDCASE.

Thanks in Advance,

Ranjan

endform. " zf_caluc

Title was edited by:

Alvaro Tejada Galindo

1 ACCEPTED SOLUTION
Read only

former_member189629
Active Contributor
0 Likes
425

form zf_caluc .

CASE sy-ucomm.

WHEN 'CALUC'.

loop at gt_alv into gs_alv.

gv_calc = gs_alv-bdmng - gs_alv-enmng.

if gv_calc > 300.

exit.

elseif gv_calc < 300.

gs_alv-labst = gv_calc.

endif.

<b>append gs_alv to gt_alv.

modify gt_alv from gs_alv .</b> * Either do an APPEND or MODIFY. Y Both?

endloop.

when 'back'.

LEAVE PROGRAM.

ENDCASE.

3 REPLIES 3
Read only

former_member189629
Active Contributor
0 Likes
426

form zf_caluc .

CASE sy-ucomm.

WHEN 'CALUC'.

loop at gt_alv into gs_alv.

gv_calc = gs_alv-bdmng - gs_alv-enmng.

if gv_calc > 300.

exit.

elseif gv_calc < 300.

gs_alv-labst = gv_calc.

endif.

<b>append gs_alv to gt_alv.

modify gt_alv from gs_alv .</b> * Either do an APPEND or MODIFY. Y Both?

endloop.

when 'back'.

LEAVE PROGRAM.

ENDCASE.

Read only

Former Member
0 Likes
425

At first look....This is wrong...


append gs_alv to gt_alv.
modify gt_alv from gs_alv .

If you are appending gs_alv to gt_alv...Why are you modifiying gt_alv from gs_alv???

Anyway...What's the error your getting???

Greetings,

Blag.

Read only

Clemenss
Active Contributor
0 Likes
425

Hi KCR,

if you APPEND to a table you are LOOPing AT, this will loop forever. The EXIT condition gv_calc > 300 may be never fulfilled because it is no defined that gs_alv-bdmng - gs_alv-enmng will ever be more than 300.

Honestly: Nothing is wrong with the code. It's just a bit useless.

Regards,

Clemens