cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP routine for calculating QTY

Former Member
0 Kudos

I have to introduce and calculate the qty value

The data looks like in the ODS layer

Document Order Item Contract Material

185000480 0100 001 ZL0001

185000480 0200 001 ZL0002

185000480 0200 002 ZL0002

185000480 0300 001 ZL0003

185000480 0300 002 ZL0003

185000480 0300 003 ZL0003

185000480 0300 006 ZL0003

185000480 0300 008 ZL0003

Infocube level QTY needs to be calculated based on material and line item per document like below,

Document Order Item Contract Material qty

185000480 0100 001 ZL0001 1

185000480 0200 001 ZL0002 1

185000480 0200 002 ZL0002

185000480 0300 001 ZL0003 1

185000480 0300 002 ZL0003

185000480 0300 003 ZL0003

185000480 0300 006 ZL0003

185000480 0300 008 ZL0003

I have write the ABAP code

data: zqty type i.

if comm_structure-document <> 0 and

comm_sturcutre-item <> 0 and

comm_sturcuture-material <> ' '

zqty = zqty +1

endif.

result = zqty.

ZQTY is not populating properly.

Advance Thanks for your help to correct this issue.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try this logic it should work

data: zqty type i.

zqty = comm_strucutre-qty

if comm_structure-document <> 0 and

comm_sturcutre-item <> 0 and

comm_sturcuture-material <> ' '

<b>comm_structure-qty<>0</b>

zqty = zqty +qty

endif.

( In this case it vl check if qty is not equal to zero then only qty will be added.)

result = zqty.