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

marko91
Explorer
0 Kudos

Hello

My name is Marko and i have a problem with IF function in transaction cewb/sap_item/items overview/mass change. I want to create a IF statement in ABAP editor when certan material is listed the field Quantity (ITM_CLASS_DATA-MENGE) changes.

Materail 11111



* X is the value you must return
form GET_NEW_ITM_CLASS_DATA_MENGE
using segment structure ITM_CLASS_DATA
changing X.

IF MBM_CLASS_VIEW-MATNR ='11111'.  
   write '2222'.  
ELSE.  
   write ''.
  
ENDIF.
9 REPLIES 9

michael_piesche
Active Contributor
0 Kudos

You dont give any detailed information about your problem, but looking at your coding, I have to assume, that your problem is based on missing leading zeros for your material number.

  • The MATNR datatype is either 18 or 40 characters, depending on your system and the activation status for 40 character material codes (ECC or S/4HANA).
  • And the Material Codes can be numeric or alphanumeric.
    If they are alphanumeric, no leading zeros are used for internal representation
  • If they are numeric, based on standard customizing and standard functionality, the system handles these internally (runtime/database) with leading zeros, especially to realize numeric sorting, whereas externally (GUI), the leading zeros are omitted
    e.g.: '11111' is the external representation of '000000000000011111' internally with 18 character MATNR and '0000000000000000000000000000000000011111' internally with 40 character MATNR.
  • Therefore, I strongly assume, that MBM_CLASS_VIEW-MATNR holds the value of an internal MATNR with leading zeros, which will not work with comparing it to a value that does not have leading zeros.
  • Normally, the switch from external representation in GUI to internal representation in runtime processing is done automatically, based on the underlying DDIC.
  • However, in some cases, as in yours, it is neccessary to switch between internal/external representation also in the runtime processing.
    In order to switch between these two, you should use the Conversion Exit defined by the underlying DDIC domain for MATNR:
    - FM CONVERSION_EXIT_MATN1_INPUT is used to switch from external to interal
    - FM CONVERSION_EXIT_MATN1_OUTPUT is used to switch from internal to external

See the following coding to fix your 'problem'.

DATA matnr TYPE matnr. " is either 18 or 40 characters, depending on your system and activation status (ECC or S/4HANA)
matnrchk = '11111'.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
     EXPORTING
          INPUT  = matnrchk
     IMPORTING
          OUTPUT = matnrchk
     EXCEPTIONS
          OTHERS = 1.
IF sy-subrc <> 0.
  " handle exception
ENDIF.

IF MBM_CLASS_VIEW-MATNR = matnrchk.
   WRITE '2222'.  
ELSE.  
   WRITE ''.
ENDIF.

(If this is not your problem at all, please be more specific, give screenshots, syntax/runtime errors, observed vs. expected behaviour, ...)

0 Kudos

Hello i updated my answer. Please recheck the topic.

0 Kudos

Hello receck topic. I updated my answer.

0 Kudos

Hello

I updated my answer, plase check.

0 Kudos

Marko Skvarča, so what have you found out after changing the coding to fill the MATNR with leading zeros?

>> Thank you for appropriate answer but i will need so more explanation. I copy your code to sap/cewb/sap item/extras/mass edit/enter formulas/abap editor/ and change the number id and the resolt of if statment.

Is your IF statement now executed? If so, I assume you have encountered the next problem, which is that you dont know 'where to write' the new value?

If you want someone to be notified, you have to either comment their question, or mention them directly in your post, like this Marko Skvarča.

If your problem has been solved by now, please follow up on your open question.

  • mark an answer as accepted if it helped you solve your problem
  • or post an answer of yourself and accept it if you found another useful solution yourself
  • or redirect your question to another question that is related and was useful to solve your problem
  • in the end, close your question

marko91
Explorer
0 Kudos

I want a code to create an if statement if MBM_CLASS_VIEW-MATNR = 50080 write 84 in field ITM_CLASS_DATA-MENGE.

marko91
Explorer
0 Kudos

Selection of material is made via filter.

If you know where to place the coding, my initial answer will work. I assume you dont know where to place your coding? In that case, your question shouldnt be about an arbitrary IF-statement, it should be about how to manipulate CEWB with Badis, Enhancements Spots, User Exits or Modifications.

marko91
Explorer
0 Kudos

Thank you for appropriate answer but i will need so more explanation. I copy your code to sap/cewb/sap item/extras/mass edit/enter formulas/abap editor/ and change the number id and the resolt of if statment.