02-03-2021 12:11 PM
Hello gurus,
Need your help with the logic. i need to delete the line item which has the similar batch originating from similar or different sales order. i need to add up their quantity and just show them once accumulated. Stuck in this logic in the adobe form output. Any help would be more than appreciated.
Regards,
Hamza
02-03-2021 4:06 PM
Hey,
if you check out the code below (which is a simplified version of what you posted), you'll quickly see it is rather meaningless:
IF ls_data-matnr EQ ls_data-matnr.
..
ENDIF
Why? Simply because you are comparing the variables with itself (it is like writing "IF a = a."). So first thing you would have to do is have the different line items in different structures (if you're sticking with this approach).
Or, forget about this approach and go for a statement like LOOP AT .. GROUP BY. If you group by the batch (and related fields) then all that rests to do is calculate the total quantity.
02-03-2021 12:40 PM
i'm trying to write this code in the loop but it's not exactly doing what i want. Also, i need some clarity on how to delete/hide the row with the similar material and batch no.
if ls_data-matnr eq ls_data-matnr and ls_data-charg eq ls_data-charg.
ls_data-fkimg = ls_data-fkimg + ls_data-fkimg.
endif.
02-03-2021 4:06 PM
Hey,
if you check out the code below (which is a simplified version of what you posted), you'll quickly see it is rather meaningless:
IF ls_data-matnr EQ ls_data-matnr.
..
ENDIF
Why? Simply because you are comparing the variables with itself (it is like writing "IF a = a."). So first thing you would have to do is have the different line items in different structures (if you're sticking with this approach).
Or, forget about this approach and go for a statement like LOOP AT .. GROUP BY. If you group by the batch (and related fields) then all that rests to do is calculate the total quantity.
02-03-2021 4:10 PM
patrick.vannierop what about deleting the line item with the same batch?
02-03-2021 4:13 PM
also can u please suggest how should i use LOOP AT .. GROUP BY in my current scenario?
02-03-2021 8:00 PM
Something like this?
LOOP AT [table_line_items] INTO grp
GROUP BY ( key1 = grp-matnr key2 = grp-charg ).
*... prepare "grouped" item ...*
LOOP AT GROUP grp INTO member.
*... add member-fkimg to ...*
ENDLOOP.
*... add "grouped" item to [table_grouped_items] ...*
ENDLOOP.
*... replace contents of [table_line_items] with contents of [table_grouped_items]
To explain my pseudo-code, you need to define by what fields you want to group of course, the MATNR & CHARG are just an example.
Per group grp of (line items) you then:
Once all the items/groups have been dealt with, replace the content of your line items table with the contents of the table containing the grouped items.
02-09-2021 7:01 AM