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

abap code

Former Member
0 Likes
546

i have a table in alv with info that i wont to display .the table do some calcultion and i wont that when one field (row)is empty put in 0 (zero). i write code lie this but it dont work any suggestion.

this is the code :

ORM utilization .

LOOP AT itab INTO wa_itab.

IF wa_itab-util IS INITIAL.

wa_itab-util = '0'.

ELSEIF wa_itab-reg > 0.

wa_itab-util = wa_itab-yyquota - wa_itab-reg.

MODIFY itab FROM wa_itab TRANSPORTING util.

CLEAR wa_itab.

ENDIF.

ENDLOOP.

ENDFORM. " utilization

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
526

Hi,

Instead it would be fine if you define field itab-util as

NUMC instead if char and keep data size same as it is for char. Hence it shall take by default 0 value instead of blank.

This will solve your query.

*REWARD if so

4 REPLIES 4
Read only

Former Member
0 Likes
527

Hi,

Instead it would be fine if you define field itab-util as

NUMC instead if char and keep data size same as it is for char. Hence it shall take by default 0 value instead of blank.

This will solve your query.

*REWARD if so

Read only

0 Likes
526

try..

LOOP AT itab INTO wa_itab.
IF wa_itab-util = ''.
wa_itab-util = '0'.
MODIFY itab FROM wa_itab TRANSPORTING util.
ELSEIF wa_itab-reg > 0.
wa_itab-util = wa_itab-yyquota - wa_itab-reg.
MODIFY itab FROM wa_itab TRANSPORTING util.
CLEAR wa_itab.
ENDIF.
ENDLOOP.

Read only

0 Likes
526

Hi,

You are modifying the internal table only in else statement. use that modify statement after if. It may work.

Try this

LOOP AT itab INTO wa_itab.

IF wa_itab-util = ''.

wa_itab-util = '0'.

MODIFY itab FROM wa_itab TRANSPORTING util.

CLEAR wa_itab.

ELSEIF wa_itab-reg > 0.

wa_itab-util = wa_itab-yyquota - wa_itab-reg.

MODIFY itab FROM wa_itab TRANSPORTING util.

CLEAR wa_itab.

ENDIF.

ENDLOOP.

If it helps you kindly reward the points.

Regards,

Kiran i

Read only

anversha_s
Active Contributor
0 Likes
526

hi,

its ALV,

so i think u can do this in field catlog itself.

check this options in the field catlog.

lzero(1) type c, " leading zero

no_zero(1) type c, " write no-zero

rgds

anver

<i>pls makr points if hlped</i>