‎2008 Jun 21 6:59 AM
hi experts,
I want to put check on quantity field of goods movement screen of co11n transaction if material exists.
I am using the fiedexit & below code to read values & put check.
DATA: i_dynfields TYPE TABLE OF dynpread WITH HEADER LINE,
num TYPE i,
v_erfmg TYPE mb_erfmg.
DO 11 TIMES.
num = sy-index.
i_dynfields-fieldname = 'MATNR'.
i_dynfields-stepl = num.
APPEND i_dynfields.
i_dynfields-fieldname = 'ERFMG'.
i_dynfields-stepl = num.
APPEND i_dynfields.
ENDDO.
ENDIF.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = 'SAPLCOWB'
dynumb = '0500'
translate_to_upper = 'X'
REQUEST = ' '
PERFORM_CONVERSION_EXITS = ' '
PERFORM_INPUT_CONVERSION = ' '
DETERMINE_LOOP_INDEX = ' '
TABLES
dynpfields = i_dynfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT i_dynfields.
IF i_dynfields-fieldname = 'MATNR'.
IF i_dynfields-fieldvalue IS NOT INITIAL.
READ TABLE i_dynfields WITH KEY fieldname = 'ERFMG'
stepl = num.
IF sy-subrc EQ 0.
IF i_dynfields-fieldvalue = 0 OR
i_dynfields-fieldvalue = space.
MESSAGE e004(zmsg2) WITH 'Quantity cannot be zero or empty'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFUNCTION.
but this is not executing the error message.
pls tell me where it is wrong.
‎2008 Jun 21 11:50 AM
hi all,
now it is triggering error message. but now the problem is it is displaying message even when the quantity is ne 0.
I think there need to do some conversion from char to packed.
because if i give IF i_dynfields-fieldvalue = 0, in the below code, it is giving the error message for all values of fieldvalue.
LOOP AT i_dynfields WHERE fieldname EQ 'COWB_COMP-MATNR'.
IF i_dynfields-fieldvalue IS NOT INITIAL.
READ TABLE i_dynfields WITH KEY fieldname = 'COWB_COMP-ERFMG'
stepl = i_dynfields-stepl.
IF i_dynfields-fieldvalue = 0. "OR
MESSAGE e004(zmsg2) WITH 'Quantity cannot be zero or empty'.
ENDIF.
ENDIF.
ENDLOOP.
Any suggestions?
‎2008 Jun 21 12:19 PM
Hi ,
As per ur code given as below:
LOOP AT i_dynfields WHERE fieldname EQ 'COWB_COMP-MATNR'.
IF i_dynfields-fieldvalue IS NOT INITIAL.
READ TABLE i_dynfields WITH KEY fieldname = 'COWB_COMP-ERFMG'
stepl = i_dynfields-stepl.
IF i_dynfields-fieldvalue = 0. "OR
MESSAGE e004(zmsg2) WITH 'Quantity cannot be zero or empty'.
ENDIF.
ENDIF.
ENDLOOP.
If u want to display the message when fieldvalue = 0, then i think u should check ur statement after the loop.
The statements which i have highlighted in bold is contradicting to each other.
Similary the fieldnames in loop statement and in read are different.
In ur code the loop will repeat for fieldnames only = ''COWB_COMP-MATN' and not ''COWB_COMP-ERFMG''.
Reward if helpful ***
Regards,
Ruby.