Application Development 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: 

Data validation in Table maintaince generator

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

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

11 REPLIES 11

Former Member
0 Kudos

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

0 Kudos

Best not to put the logic in the screen. If the screen is changed, the logic will be lost.

Rob

0 Kudos

Hi Rob,

I have try this way

FORM CREATE_NEWENTRY.

DATA : BEGIN OF WA.

INCLUDE STRUCTURE /SPXTM/TA_PARCEL.

DATA : END OF WA.

IF WA-ZPARCELB IS INITIAL.

MESSAGE TEXT-T02 TYPE 'E'.

ENDIF.

ENDFORM.

But when i enter value in 1st field and press ENTER.i'm getting No vendor specified.

my message please maintain original serialnumber is not displaying even second field is empty.

0 Kudos

See the response from Suhas Saha.

Rob

0 Kudos

HI,

I tried this way

FORM CREATE_NEWENTRY.

DATA : BEGIN OF WA.

INCLUDE STRUCTURE /SPXTM/TA_PARCEL.

DATA : END OF WA.

IF WA-ZPARCELB IS INITIAL.

MESSAGE TEXT-T02 TYPE 'E'.

ENDIF.

ENDFORM.

But not working still.

0 Kudos

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

SuhaSaha
Advisor
Advisor
0 Kudos

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

former_member212713
Contributor
0 Kudos

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.

former_member235395
Contributor
0 Kudos

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,

andrea_olivieri
Contributor
0 Kudos

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

0 Kudos

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.