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: 

Can we validate fields in SM30?

Former Member
0 Kudos

Hello,

Can we do field validations using SM30?

If yes then please suggest....How can I do that..Plz explain me with an example...

ANy suggestions would be appreciated...

Regards,

Kittu

1 ACCEPTED SOLUTION

prasanth_kasturi
Active Contributor
0 Kudos

hi,

you can do validations

make use of events in the TMG

create subroutienes and write the code there

the below link gives steps to create events

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20im...

example

if matnr is initial.

message 'ENTER A VALUE' type 'E'.

endif.

regards

prasanth

9 REPLIES 9

prasanth_kasturi
Active Contributor
0 Kudos

hi,

you can do validations

make use of events in the TMG

create subroutienes and write the code there

the below link gives steps to create events

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20im...

example

if matnr is initial.

message 'ENTER A VALUE' type 'E'.

endif.

regards

prasanth

Former Member
0 Kudos

Hi,

sm30 is used to view the ' Call Up View Maintenance

Use one ofthe following concepts (Priority wise)

1. check Table.

2. Search Help .

3. Set the values in the attribute to some constant values.

when you go into the Events There is a Informatio ICON(ctrlshiftf1).this will take you to the SAP Documentatio and there you can see the Additional Events and the replaceme events.the one i was refering to is in Additional Events Cod 01-before saving.Following Code is For 01

FORM abc.

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

LOOP AT TOTAL.

IF <ACTION> = desired constant.

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.

here <Action>

GELOESCHT : flagged for deletion

NEUER_EINTRAG : New entry

AENDERN : changed entry

UPDATE_GELOESCHT : entry first changed and then flagged fo deletion

NEUER_GELOESCHT : entry first newly created, not yet saved, an then flagged for deletion

ORIGINAL : the same as the database status

so like above u can do validation.

thanks

abdul

Former Member
0 Kudos

Hello prasanth kasturi, shaik abdul

As mentioned in the link....

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20im...

I had cretaed a Z table and in step 3 --> I had clicked on Events --> After that NEW Entries

Here in this screen : I had selected 05 - Creating a NEw Entry.

After that when I click on Editor, it is not responding. If it allows me to write the source code then I will be done with the validations PLz Help.

ANy suggestions will be appreciated...

Regards,

Kittu

0 Kudos

Hi Kittu

After you select 05 and enter your routiene name

press enter

then in the editor tab a symbole like doc appears

double click on it

then in the include write the code

hope i am clear

reward if helpful

prasanth

Former Member
0 Kudos

Hi,

You can as well validate the fields in SM30. For that u need to code in the Function group created for that Z table.

If u have maintained the Table maintenance generator, u would have created the Function Group.

Goto SE80 and give the Function group created for that table in change mode. In that goto Screens.

In the screens, in PAI, please follow the code given below

+process after input.

module detail_exit_command at exit-command.

module detail_set_pfstatus.

chain.

field zxxx-zvkorg module keycombine.

module set_update_flag on chain-request.

endchain.

chain.

field zxxx-zvkorg .

module detail_pai.

endchain.+

Add the MODULE after the field for which u need to add the logic for validation (given in Bold above). and put the logic u want in the module as given below.

+module keycombine input.

data: begin of t_key occurs 0,

vkorg type tvko-vkorg,

bukrs type t001-bukrs,

end of t_key.

select single vkorg bukrs from tvko

into gt_key where

vkorg = zxxx-zvkorg and

bukrs = zxxx-zbukrs.

if sy-subrc ne 0.

message 'Company code and Sales org combination does not exist'

type 'E'.

endif.

endmodule. " KEYCOMBINE INPUT+

Please reward if useful.

Regards,

Asif Ali Khan

Former Member
0 Kudos

Hello Prasanth kasturi, Shaik abdul,

Thank you for your response!

I apprecaite it!

Regards,

Kittu

Edited by: Kittu on Jun 11, 2008 2:21 PM

Former Member
0 Kudos

hi,

go to SE80

then open the FG inside which u have created the table maintenance for the table for which u want to put the condition

now to go the view on the left handside down corner i.e. Object Name

u can ur FG name drill down and then click on then screens

then u can see the table maintenance screen number click on that

on the right hand side u will see the code.....

Under PROCESS AFTER INPUT.

u will see bunch f code inside

LOOP AT EXTRACT.

CHAIN.

FIELD ZARK_ALV_TEST-EMPLOYEE .

FIELD ZARK_ALV_TEST-LOCATION .

perform F_validate.

FIELD ZARK_ALV_TEST-QUOTA .

FIELD ZARK_ALV_TEST-GRADE .

ENDCHAIN.

ENDLOOP.

say in my case i need to validate LOCATION field

so i write a perform and declare that in any include in my FG

and code will be as follows :

if ZARK_ALV_TEST-EMPLOYEE = ' '.

if ZARK_ALV_TEST-LOCATION = ' '.

message E000(38) with " Enployee is null so loaction cant be null. plz enter value i location." .

endif.

endif.

Former Member
0 Kudos

hi....

The code for your table maintainenece can be viewed through the function group you give while generating table maintainennece.

Go to se80,gie the name of the function group and then make changes in the code for your validation or else you can create a new screen an code for that screen by creating a new table control for your exixting table.

Then write the logic for validatiing.

Former Member
0 Kudos

Hello Guys,

Thank you for your response and for your great help!

Points are rewarded.

My issue is fixed!

Have a great evening!

Regards,

Kittu