Application Development 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: 

ABAP CEWB ABAP_IF_CONDITION_MATERIAL_NUMBER 2

marko91
Explorer
0 Kudos

Hello

Im having problems with running the code listed in link

https://answers.sap.com/questions/13028687/abap-cewb-abap-if-condition-material-number.html?childToV...

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.

9 REPLIES 9

Flavio
Active Contributor

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

Flavio
Active Contributor

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

marko91
Explorer
0 Kudos

The code is ok (no error pops up), but nothing happens. Is 'matnr' the number listed in red triangle?

0 Kudos

Yeah. There is a need for prefix. In our case 0000000000000.

For material 51111 you need to write in code 000000000000051111. Thank you.


Flavio
Active Contributor
0 Kudos

Yes, material shall be referenced with its leading zero. You can use the conversion routine for that.

Flavio

marko91
Explorer
0 Kudos

What abaut field component (fieldITM_CLASS_DATA-IDNRK)? Is the code the same?

0 Kudos

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.

Flavio
Active Contributor
0 Kudos

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:

  • the form name has changed, compared to the previous code, as we are now dealing with another field, idnrk (this will however come automatically, from the system)
  • the idnrk code to change has to be passed with leading zero's, as usual

hope this will help clarifying

Flavio

marko91
Explorer
0 Kudos

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).