ā2014 Apr 01 2:52 PM
Hi,
I have created a z* table with key fields Material and plant.I want to validate material and plant while entering data in the table.I am doing validation with table MARC.I am using event 01.
but while executing(creating records),what ever I am entering data for material an plant are not passing in the following code.
SELECT SINGLE * FROM MARC WHERE MATNR EQ ZMMYF-MATNR AND WERKS EQ ZMMYF-ZPLANT.
Can some body throw light on this issue,please?
TABLES:MARC.
* INCLUDE LZMMYFD... " Local class definition
INCLUDE LSVIMDAT . "general data decl.
INCLUDE LZMMYFT00 . "view rel. data dcl.
form BEF_SAVE.
SELECT SINGLE * FROM MARC WHERE MATNR EQ ZMMYF-MATNR AND WERKS EQ ZMMYF-ZPLANT.
IF SY-SUBRC <> 0.
* MESSAGE 'PLEASE CHECK YOUR INPUT' I TYPE.
MESSAGE 'please check your input' TYPE 'I'.
ENDIF.
ENDFORM.
ā2014 Apr 01 3:37 PM
Jaheer,
Can you confirm the below:
1. Is your table name ZMMYF?
2. the sub routine name that you mentioned in the event BEF_SAVE?
3. How are you creating entries? Thru SM30 or thru SE11 or thru any program?
If you creating the entries thru program using insert or modify, the event will not get called. But if are creating the entries thru SE11 or SM30 your event should get called.
Let us know.
thanks,
Vikram.M
ā2014 Apr 02 10:10 AM
Hi,
I have put code like this,but I am getting error saying that 'Total' is Unknown.Can some body throw light on this issue,please?
1.ZMMYF is my table
2.I am creating entry thru sm30.
FUNCTION-POOL ZMMYF MESSAGE-ID SV.
TABLES:MARC.
* INCLUDE LZMMYFD... " Local class definition
INCLUDE LSVIMDAT . "general data decl.
INCLUDE LZMMYFT00 . "view rel. data dcl.
form BEF_SAVE.
DATA: BEGIN OF WA_TOTAL.
INCLUDE STRUCTURE ZMMYF.
INCLUDE STRUCTURE VIMTBFLAGS.
DATA: END OF wa_total.
LOOP AT TOTAL INTO WA_TOTAL.
ć
ć
SELECT SINGLE * FROM MARC WHERE MATNR EQ WA_TOTAL+3(18) AND WA_WERKS EQ TOTAL+21(4).
IF SY-SUBRC <> 0.
MESSAGE 'please check your input' TYPE 'I'.
ENDIF.
ENDLOOP.
ENDFORM.
ā2014 Apr 02 10:33 AM
Hi Jaheer,
When u are checking for error using 01 event, then it need to be done in a special way. Consider the following example :
LOOP AT total.
CASE <action>.
WHEN neuer_eintrag. "New entry
READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc = 0.
ZMMYF = extract.
SELECT SINGLE * FROM MARC WHERE MATNR EQ ZMMYF-MATNR AND
WERKS EQ ZMMYF-ZPLANT.
IF sy-subrc <> 0.
MESSAGE 'Error' TYPE 'S' DISPLAY LIKE 'E'.
vim_abort_saving = 'X'.
EXIT.
ENDIF.
ENDIF.
ENDCASE.
ENDLOOP.
Please try this and revert.
Thanks & Regards,
Abijith
ā2014 Apr 02 10:52 AM
Hi,
Thank you.
I have put your code in the in my form of include LZMMYFTOP.Is it correct?
Still I am getting the same error saying TOTAL is unknown.
ā2014 Apr 02 11:17 AM
Jaheer what i feel the way you have created your subroutine or you are activating it is incorrect. You subroutine is contained in an include and just check it is being included in program after total/extract declaration include only
Nabheet
ā2014 Apr 02 11:20 AM
Hi Jaheer,
Place the code in the form routine that you had created for 01 event. Then activate the form routine. Similerly activate the entire function module that you had created for the TMG.
Thanks & Regards,
Abijith
ā2014 Apr 02 11:58 AM
Hi,
This is the way I have created subroutine.Can somebody tell me what is the problem?
ā2014 Apr 02 12:05 PM
Hi Jaheer,
Please always create a new include for each of your event in TMG. In the above case, please select the first option provided by SAP by default.
Do one thing here? Please delete the TMG created and all the includes. Then create a new one and add new includes for each of your events.
Thanks & REagrds,
Abijith