05-07-2020 6:28 AM
Hello
Im having problems with running the code listed in link
written by Michael Piesche in transaction CEWB. The request was made by me, thaht code must be run in "cewb/sap item/extras/mass edit/enter formulas/abap editor/" which is listed below.
Michael Piesche is mentioning a option "CEWB with Badis" but this option is not found in CEWB transaction. Is there any other transaction thaht contains "CEWB with Badis" option includet or i have missed mentioned option in CEWB.
05-07-2020 10:19 AM
Hello marko91,
the field 'matnr' is not available in the 'segment' structure, therefore you should get it from, for instance, the MAST table;
here the code I just tried in my sandbox system, which works:
* X is the value you must return
form GET_NEW_ITM_CLASS_DATA_MENGE
using segment structure ITM_CLASS_DATA
changing X.
data l_stlnr type stnum.
select single stlnr into l_stlnr
from mast
where matnr = '000000000004030012'. " replace with your matnr
if segment-stlnr = l_stlnr.
x = 1110. " replace with your quantity
endif.
hope this could help.
Flavio
05-07-2020 12:54 PM
Hi marko91,
the Component (IDNRK) field is available in the 'segment' structure, so the code is sligthly different, no need to fetch data via select, say something like this:
* X is the value you must return
form GET_NEW_ITM_CLASS_DATA_MENGE
using segment structure ITM_CLASS_DATA
changing X.
if segment-idnrk = l_something. " replace with your criterion
x = 84. " replace with your quantity
endif.
endform.
Flavio
05-07-2020 11:48 AM
The code is ok (no error pops up), but nothing happens. Is 'matnr' the number listed in red triangle?
05-07-2020 12:05 PM
Yeah. There is a need for prefix. In our case 0000000000000.
For material 51111 you need to write in code 000000000000051111. Thank you.
05-07-2020 12:56 PM
Yes, material shall be referenced with its leading zero. You can use the conversion routine for that.
Flavio
05-07-2020 12:44 PM
What abaut field component (fieldITM_CLASS_DATA-IDNRK)? Is the code the same?
05-07-2020 7:16 PM
Ok it works, but i need change field ITM_CLASS_DATA-IDNRK in reference of the field 'matnr', like in your first answer. Your code from your first answer doesn't work on field ITM_CLASS_DATA-IDNRK.
05-07-2020 8:49 PM
Hi marko91,
the code for changing the 'idnrk' field is as follows:
* X is the value you must return
form GET_NEW_ITM_CLASS_DATA_IDNRK
using segment structure ITM_CLASS_DATA
changing X.
data l_stlnr type stnum.
select single stlnr into l_stlnr
from mast
where matnr = '000000000000051111'. " here, the matnr to deal with
if segment-stlnr = l_stlnr.
x = '000000000000032123'. " here, the idnrk code to change
endif.
endform.
please note:
hope this will help clarifying
Flavio
05-11-2020 10:48 AM
Ok. But this structure of code doest' work in transaction mm17 when you want to change field MARC-LOSGR (casting lot sitez picture below) in reference of material id (picture below 30771).