Skip to Content

ABAP CEWB ABAP_IF_CONDITION_MATERIAL_NUMBER

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.
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Apr 21 at 10:01 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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
  • Posted on Apr 23 at 11:01 AM

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


    untitled-1.jpg (292.6 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 23 at 11:26 AM

    Selection of material is made via filter.


    untitled-2.jpg (267.0 kB)
    Add a comment
    10|10000 characters needed characters exceeded

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

  • Posted on Apr 28 at 06:21 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.