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 maintenace generator validation

Former Member
0 Likes
1,233

Hi Friends,

I have to do validation in Table maintenacne generator but i am not getting the value in the fields that are used in validation,I am not getting the value into the fields which i gave as input through SM30.

I have attached the coding below.I am not geeting the values which were indicated in BOLD.

SELECT SINGLE MATNR

WERKS

LVORM

FROM MARC

INTO E_MARC

WHERE MATNR = ZCXXPT0529CTRL-MATNR

AND WERKS = ZCXXPT0529CTRL-WERKS.

IF SY-SUBRC EQ 0

AND E_MARC-MATNR IS NOT INITIAL

AND E_MARC-WERKS IS NOT INITIAL.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,200

Hi Sumodh,

I have declared the code in the events part of Table maintence generator.

Please find the code as given below.

FORM BEFORE_SAVE.

TABLES: MARC.

TYPES: BEGIN OF Y_STRUCT_MARC,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

LVORM TYPE LVOWK,

END OF Y_STRUCT_MARC.

DATA: E_MARC TYPE Y_STRUCT_MARC.

CONSTANTS:C_X(1) TYPE C VALUE 'X'.

SELECT SINGLE MATNR

WERKS

LVORM

FROM MARC

INTO E_MARC

WHERE MATNR = ZCXXPT0529CTRL-MATNR

AND WERKS = ZCXXPT0529CTRL-WERKS.

IF SY-SUBRC EQ 0

AND E_MARC-MATNR IS NOT INITIAL

AND E_MARC-WERKS IS NOT INITIAL.

IF E_MARC-LVORM EQ C_X.

MESSAGE E999(ZC) WITH 'Inserted material-plant combination is marked for deletion'.

  • SET SCREEN 0001.

  • EXIT.

*

ENDIF.

ELSE.

MESSAGE E999(ZC) WITH 'Inserted material-plant combination deos not exists'.

  • SET SCREEN 0001.

  • EXIT.

ENDIF.

ENDFORM. "before_save

13 REPLIES 13
Read only

Former Member
0 Likes
1,200

why dont you just have MARC declared as checktable for your field? no reason to validate manually yourself then.

Read only

Former Member
0 Likes
1,200

Hello,

This thing u needs to be done in the Events of the table mantaince generator. There are many events avilable for doing the various purpose.

In se11 goto Utilities - table maintenance generator and in that environment and events.

inside that enter the form name and create a include in the fgr and create the form in that include.

By this way u can do the validation and at the same time u will get the values too.

With Regards,

Sumodh.P

Read only

Former Member
0 Likes
1,201

Hi Sumodh,

I have declared the code in the events part of Table maintence generator.

Please find the code as given below.

FORM BEFORE_SAVE.

TABLES: MARC.

TYPES: BEGIN OF Y_STRUCT_MARC,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

LVORM TYPE LVOWK,

END OF Y_STRUCT_MARC.

DATA: E_MARC TYPE Y_STRUCT_MARC.

CONSTANTS:C_X(1) TYPE C VALUE 'X'.

SELECT SINGLE MATNR

WERKS

LVORM

FROM MARC

INTO E_MARC

WHERE MATNR = ZCXXPT0529CTRL-MATNR

AND WERKS = ZCXXPT0529CTRL-WERKS.

IF SY-SUBRC EQ 0

AND E_MARC-MATNR IS NOT INITIAL

AND E_MARC-WERKS IS NOT INITIAL.

IF E_MARC-LVORM EQ C_X.

MESSAGE E999(ZC) WITH 'Inserted material-plant combination is marked for deletion'.

  • SET SCREEN 0001.

  • EXIT.

*

ENDIF.

ELSE.

MESSAGE E999(ZC) WITH 'Inserted material-plant combination deos not exists'.

  • SET SCREEN 0001.

  • EXIT.

ENDIF.

ENDFORM. "before_save

Read only

0 Likes
1,200

Hi,

Here in the select query u r not able to get the value?

With Regards,

Sumodh.P

Read only

0 Likes
1,200

And still this is a simple MARC existence check, thats exactly what you would gain when using a check table.

Read only

0 Likes
1,200

Hi Sumodh,

Yes in the select query the value that i gave in Table maintenace using SM30 does not eixsts.

ZCXXPT0529CTRL-MATNR is blank.

ZCXXPT0529CTRL-WERKS is blank.

can you help me on it.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,200

Which event are you using for this validation?

I think you have to use the TOTAL and / or EXTRACT internal tables to make the selection from MARA.

Please refer to this online documentation for details: [http://help.sap.com/saphelp_NW70EHP1core/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/content.htm]

@Florian:

And still this is a simple MARC existence check, thats exactly what you would gain when using a check table

The OP needs to validate the deletion-indicator is checked for the material-plant combo as well. A check table wouldn't check this, right ?

Edited by: Suhas Saha on May 4, 2010 3:26 PM

Read only

0 Likes
1,200

Hi,

Just use the event 5 for this. I think at that time ur purpose will be done.

With Regards,

Sumodh.P

Read only

0 Likes
1,200

Hello,

You must be doing your validation in PAI of the table maintainance screen. Before your subroutine, in between LOOP and ENDLOOP, add the field statment for the field you are using in select query.

Thanks,

Tanweer

Edited by: Tanweer Zaki on May 4, 2010 3:31 PM

Read only

0 Likes
1,200

Hello,

You must be doing your validation in PAI of the table maintainance screen. Before your subroutine, in between LOOP and ENDLOOP, add the field statment for the field you are using in select query.

Thanks,

Tanweer

Read only

0 Likes
1,200

Hi Sumodh,

Thanks problem is solved.

Regards

RAM

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,200

So i understand you are validating for new entries creation only. What about the entry being changed, in that case your validation will not trigger.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,200

If its only to check the existence of material with plant , then the best solution is already given by Florian

Also mark the check box foreign key check in screen attributes of the field