Skip to Content
author's profile photo Former Member
Former Member

logic- for required format output

Hi,

I have a situation where material number has multiple entries(rows).

I required to show only single row output some of the respective material number quantity fields needs to be ADDED and some of the quantity should be same as a single row field value.

example :

following below code gives us output

<b>'Material' 'Quant1' 'Quant2'</b>

1000-A 10 999

1000-A 20 999

1000-B 10 700

1000-B 20 700

1000-B 30 700

but i need output in 2 lines only.

<b>'Material' 'Quant1' 'Quant2'</b>

1000-A 30 999

1000-B 60 700

i.e Quant1 values should be added and Quant2 values should remain same.

report x.

data: begin of itab occurs 0,

matnr(10) type c,

quant1(4) type c,

qunat2(4) type c,

end of itab.

itab-matnr = '1000-A'.

itab-quant1 = '10'.

itab-quant2 = '999'.

APPEND itab.

itab-matnr = '1000-A'.

itab-quant1 = '20'.

itab-quant2 = '999'.

APPEND itab.

itab-matnr = '1000-B'.

itab-quant1 = '10'.

itab-quant2 = '700'.

APPEND itab.

itab-matnr = '1000-B'.

itab-quant1 = '20'.

itab-quant2 = '700'.

APPEND itab.

itab-matnr = '1000-B'.

itab-quant1 = '30'.

itab-quant2 = '700'.

APPEND itab.

write : /10 'Material' , 30 'Quant1' , 45 'Quant2' .

loop at itab.

write : /10 itab-matnr , 30 itab-quant1 , 45 itab-quant2 .

endloop.

Any ideas?

Regards

Praveen

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Mar 03, 2007 at 03:13 PM

    Hi,

    Please try this.

    ...
    data: wa_itab like itab.
    
    sort itab by matnr.
    
    loop at itab.
      move itab to wa_itab.
    
      at end of matnr.
        sum.
        write : /10 wa_itab-matnr , 30 itab-quant1 , 45 itab-quant2 .
      endat.
    endloop.
    
    ...
    

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 03, 2007 at 02:33 PM

    When you are doing loop-Endloop use AT NEW and SUM for Quant1 field,

    And display there only.

    Regards,

    Amit

    Reward all helpful replies.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.