Skip to Content
avatar image
Former Member

Data validation in Table maintaince generator

Hi everyone,

I have created a ztable with two fields zparcela,zparcelb and maintained table maintaince generator.i have creted tranaction for sm30.Now i need to validate if the user enters value of zparcela and if zparcelb is empty,error message should be thrown.

I have created events create new entry and written following code

FORM CREATE_NEWENTRY.

IF /SPXTM/TA_PARCEL-ZPARCELB IS INITIAL.

MESSAGE TEXT-T02 TYPE 'E'.

ENDIF.

ENDIF.

ENDFORM.

But i have an issue i not getting the message even the zparcelb is empty.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    May 20, 2011 at 01:48 PM

    Hello,

    Be more specific in your queries if you want better responses! For e.g., you should've provided the TMG event you're using.

    Anyway basck to your qn:

    IF /SPXTM/TA_PARCEL-ZPARCELB IS INITIAL.
    MESSAGE TEXT-T02 TYPE 'E'.
    ENDIF.

    I don't think you can access the table data this way. Depending on the event you're using there are 2 table [TOTAL|http://help.sap.com/saphelp_nw04s/helpdata/en/91/ca9fb9a9d111d1a5690000e82deaaa/content.htm] & [EXTRACT|http://help.sap.com/saphelp_nw04s/helpdata/en/91/ca9f89a9d111d1a5690000e82deaaa/content.htm] which should be used to acess the data.

    Read the online documentation on [TMG events|http://help.sap.com/saphelp_nw04s/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/content.htm] & get back if there are any issues.

    @: Directly changing the TMG screen modules is the last thing you would want to do. If later on someone tries to regenerate the TMG all these changes will be overwritten!

    BR,

    Suhas

    Edited by: Suhas Saha on May 20, 2011 7:19 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 20, 2011 at 01:44 PM

    Hi,

    Please write your code in "Maintainance Screen"... Pls follow the steps:

    1. Go In table maintainance generator of that table,, then at the menu bar => Environment -> Modifications -> Maintain Screens

    2. it popup up a screen with the a screen number. Double click on it. You will be in the flow logic of the screen.

    3. In tha flow logic,, in "PROCESS AFTER INPUT" ,, inside the LOOP statement,, write the code as below:

    chain. 
                  field z_structure-field1.         " It should be the field in concern 
                  module check_field_value.  "  Put the code in this module which you want to check 
            endchain.

    4. Do the same for your second field.

    Regards,

    Lokesh

    Edited by: Lokesh Tarey on May 20, 2011 3:47 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      can any one tell me the excite logic for data validation in table maintaince generator

      FORM abc.

      DATA: F_INDEX LIKE SY-TABIX. "Index to note the lines found

      LOOP AT TOTAL.

      IF <ACTION> = Neuer_eintrag.

      READ TABLE EXTRACT WITH KEY <vim_xtotal_key>.

      IF SY-SUBRC EQ 0.

      F_INDEX = SY-TABIX.

      ELSE.

      CLEAR F_INDX.

      ENDIF.

      (make desired changes to the line TOTAL)

      MODIFY TOTAL.

      CHECK F_INDX GT 0.

      EXTRACT = TOTAL.

      MODIFY EXTRACT INDEX F_INDX.

      ENDIF.

      ENDLOOP.

      SY-SUBRC = 0.

      ENDFORM.

      where to insert my logic.

      Thanku

  • May 20, 2011 at 01:54 PM

    Hi Miriamjs ;

    SAP generate to automatic screens and abap code when maintain screen process.

    You can change screen element properties and change code.

    If your fields be necessary fill (required) you change fields properties for required.

    Best regards.

    Add comment
    10|10000 characters needed characters exceeded

  • May 20, 2011 at 05:50 PM

    Miriam,

    You created the Ztable, right?

    So, for example if your Ztable name is "ZTABLE_PARCEL", just use this name like structure for use any field for your process.

    In your Table Maintenance Generator Go to Environment>Modifications>Events and create a event

    You need create a event:

    05 CREATE_ENTRY1 "Here appeare a icon like EDITOR"

    Doucle click in this icon and insert the next code

    FORM create_entry1.

    CONDENSE ztable_parcel-parcelb.

    IF ztable_parcel-parcelb IS INITIAL.

    MESSAGE 'The field parcelb is empty' TYPE 'E'.

    ENDIF.

    ENDFORM. "create_entry1

    Save and active.

    I hope i can help you.

    Regards,

    Add comment
    10|10000 characters needed characters exceeded

  • May 21, 2011 at 10:20 PM

    Hi,

    I suggest you to read this nice article:

    [Table Maintenance Generator and its Modifications|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/2082425f-416b-2d10-25a3-85b8b6c5302c]

    Jump to section "Events".

    Regards,

    Andrea

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I got my problem solved.

      i have written the below code in chain and chain in screen flowlogic

      MODULE VALIDATE_ZPARCELB INPUT.

      CONDENSE /SPXTM/TA_PARCEL.

      IF /SPXTM/TA_PARCEL-ZPARCELB IS INITIAL.

      Loop at screen.

      IF screen-name = '/SPXTM/TA_PARCEL-ZPARCELB'.

      screen-input = 1.

      modify screen.

      endif.

      endloop.

      MESSAGE E208(00) WITH text-t02.

      ENDIF.

      ENDMODULE. " VALIDATE_ZPARCELB INPUT

      Thanks everyone.