Application Development and Automation 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:Ā 
Read only

Table entry validation:event 01

jaheer_hussain
Active Contributor
0 Likes
3,862


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.

8 REPLIES 8
Read only

Former Member
0 Likes
2,220

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

Read only

jaheer_hussain
Active Contributor
0 Likes
2,220

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.

Read only

former_member196651
Contributor
0 Likes
2,220

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

Read only

0 Likes
2,220

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.

Read only

0 Likes
2,220

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

Read only

0 Likes
2,220

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

Read only

jaheer_hussain
Active Contributor
0 Likes
2,220

Hi,

This is the way I have created subroutine.Can somebody tell me what is the problem?

Read only

0 Likes
2,220

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