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

divide...

Former Member
0 Likes
983

hi,

how to divide fields vbrp-netwr and vbrp-fkimg?

i used this>

REPORT ZDIVIDE.

tables: vbrp.

data : pcena type vbrp,

cena type vbrp-netwr,

kolicina type vbrp-fkimg,

ls_vb type vbrp,

lt_vb type table of vbrp.

select-options: P_cena for vbrp-netwr.

select-options: P_kolic for vbrp-fkimg.

start-of-selection.

break-point.

select * from vbrp appending table lt_vb where netwr in p_cena and fkimg in p_kolic.

move-corresponding ls_vb to pcena.

COMPUTE CENA = CENA / kolicina.

write :cena.

result O.

5 REPLIES 5
Read only

Former Member
0 Likes
843

Do this way ..


loop at ls_vb.

ls_vb-CENA = ( ls_vb-CENA ) / ( ls_vb-kolicina ).
modify ls_vb index sy-tabix transporting CENA.
endloop.

Regards,

Santosh

Read only

Former Member
0 Likes
843

Is it becasue there is no data in ls_vb .

Do you need to do a

read table lt_vb into ls_vb index 1

Maybe....

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
843

????

First get the valid record from VBRP, you would probably be selecting using VBELN and POSNR in your WHERE clause.

data: xvbrp type vbrp.
data: result type p decimals 2.

parameters: p_vbeln type vbrp-vbeln,
            p_posnr type vbrp-posnr.

select Single * into xvbrp from vbrp
            where vbeln = p_vbeln
              and posnr = p_posnr.
if sy-subrc =  0
   and xvbrp-fkimg <> 0.
result = xvbrp-netwr / xvbrp-fkimg.
endif.

Regards,

Rich Heilman

Read only

anversha_s
Active Contributor
0 Likes
843

hi

try this.

loop at <b>lt_vb into ls_vb</b>.

ls_vb-CENA = ( ls_vb-CENA ) / ( ls_vb-kolicina ).

modify lt_vb from ls_vb transporting CENA.

clear ls_vb.

endloop.

rgds

anver

if hlped pls mark points

Read only

Former Member
0 Likes
843

In the given code you are to initialising the values for Cena and kolicina. Hence the result is zero.

Try the below

<b>cena = pcena-cena/pcena-kolicina.</b>