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

Control break functionality issue in report

manish_malakar0316
Active Participant
0 Likes
4,847

Hi all,

I have an issue in a report which I would like to share with everyone. I am not quite sure why the error is occuring and I cant get the desired output. I have provided the screenshots along with my code so that the issue is clear to all.

I have a custom database table ZWM_IN_OR_RIG as shown.

On passing some parameters and executing, I get the following output:

Now I have sorted the field LOT NUMBER by descending order as per my requirement.

Also the fields ARQTY and DIDQTY must be added based on the indicator field IND. For a new Lot number LOTNO, if IND is "IN" then a summation of ARQTY needs to be done for that lot number. Similarly, if IND is "OUT" then a summation of DIDQTY needs to be done for that lot number.  The difference of the totals of these 2 fields is REMQTY. Repeated lot numbers must be accumulated in one single row. Below is my code and my issues:

              



My issues are:

1) On debugging, I found out that, when 'IND' is OUT, the TOT_DIDQTY isnt getting added   The entire addition part is getting bypassed, i.e. its jumping from line 87 to line 94 !!  But values are getting populated but the addition isnt taking place.




2) After a few records, when IND is 'IN', the collect statement isnt working, whereas its supposed to add the value 100 to the previous value 1000 (as per the output of the database table). The report's incorrect output is below:



So am I using the COLLECT statement incorrectly? Please help.


Regards.


Manish.



1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,818

Create a separate local type with lot number as first field, create a table and work area for that.

Say

Types: begin of ty_new,

         lotno type zlotno,

         whcode type...

         prcode type ...

       ....

        end of ty_new.

data it_new type table of ty_new.

data wa_new type ty_new.

Once you get the data from custom table (After select) , fill the data in this table.

loop at it_zmv_in_or_rig into wa_zmv_in_or_rig.

  move-corresponding wa_zmv_in_or_rig to wa_new.

  apend wa_new to it_new.

  clear : ....

endloop.

Now sort it_new based on lot number.

now.

data lv_qty type zarqty.

loop at it_new into wa_new.

"""move comman of the fields to wa_final.

 

  if wa_new-ind = 'IN'.

     lv_qty = lv_qty + wa_new-arqty.

  elseif wa_new-ind = 'OUT'.

    lv_qty = lv_qty - wa_new-didqty.

endif.

at end of lotno.

   wa_final-remqty = lv_qty.

   clear lv_qty.

   append wa_final to it_final.

   clear : wa_final.

endat.

clear wa_new.

endloop.

endloop.

Try it, it should work.

8 REPLIES 8
Read only

Former Member
0 Likes
4,818

Hi Manish,

Please check documentation of COLLECT for more info,

Collect will add numeric values only when all char fields are same, in this case the indicator as well as date is changing so collect wont add values.

Read only

0 Likes
4,818

Hi,

Ok, I am removing the COLLECT statement. So how do I get my desired output now?

Regards. 

Manish.

Read only

0 Likes
4,818

Use AT NEW or ON CHANGE OF as you are doing now and manually add the variables and append

Read only

Former Member
0 Likes
4,818

Hi Manish,

You used collect inside on change of lotid, Hence whenever change in lot number that time only collect statement will executed( in your example 2 times), that each time indicator seems to be 'IN'.

Remove ONCHANGE of LOTNUMBER, directly Collect to  IT FINAL internal table.

Then loop over IT FINAL  with assigning to field symbol( to calculate difference) , the calculate the difference .

Thanks & Regards,

Arun

Read only

Former Member
0 Likes
4,818

Hi Manish,

I think you have to Use

ON CHANGE OF LOT NO.

instead of ..

ON CHANGE OF WA_ZMW_IN_OR_RIG-LOT NO.

And Ensure that lotno is the first field of your internal table IT_ZMW_IN_OR_RIG.

Regards,

Shashikanth

Read only

0 Likes
4,818

Hi,

When u use only the field while using ON CHANGE OF, there will be an error. The work area has to be mentioned.

Regards.

Manish

Read only

Former Member
0 Likes
4,819

Create a separate local type with lot number as first field, create a table and work area for that.

Say

Types: begin of ty_new,

         lotno type zlotno,

         whcode type...

         prcode type ...

       ....

        end of ty_new.

data it_new type table of ty_new.

data wa_new type ty_new.

Once you get the data from custom table (After select) , fill the data in this table.

loop at it_zmv_in_or_rig into wa_zmv_in_or_rig.

  move-corresponding wa_zmv_in_or_rig to wa_new.

  apend wa_new to it_new.

  clear : ....

endloop.

Now sort it_new based on lot number.

now.

data lv_qty type zarqty.

loop at it_new into wa_new.

"""move comman of the fields to wa_final.

 

  if wa_new-ind = 'IN'.

     lv_qty = lv_qty + wa_new-arqty.

  elseif wa_new-ind = 'OUT'.

    lv_qty = lv_qty - wa_new-didqty.

endif.

at end of lotno.

   wa_final-remqty = lv_qty.

   clear lv_qty.

   append wa_final to it_final.

   clear : wa_final.

endat.

clear wa_new.

endloop.

endloop.

Try it, it should work.

Read only

0 Likes
4,818

Hi,

Perfect solution  . Thanks a lot .  A very simple logic. Wish I thought a little harder!

Regards.

Manish.