‎2010 May 04 10:38 AM
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.
‎2010 May 04 10:47 AM
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
‎2010 May 04 10:43 AM
why dont you just have MARC declared as checktable for your field? no reason to validate manually yourself then.
‎2010 May 04 10:43 AM
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
‎2010 May 04 10:47 AM
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
‎2010 May 04 10:50 AM
Hi,
Here in the select query u r not able to get the value?
With Regards,
Sumodh.P
‎2010 May 04 10:51 AM
And still this is a simple MARC existence check, thats exactly what you would gain when using a check table.
‎2010 May 04 10:54 AM
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.
‎2010 May 04 10:55 AM
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
‎2010 May 04 10:58 AM
Hi,
Just use the event 5 for this. I think at that time ur purpose will be done.
With Regards,
Sumodh.P
‎2010 May 04 11:01 AM
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
‎2010 May 04 11:01 AM
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
‎2010 May 04 11:28 AM
‎2010 May 04 11:35 AM
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.
‎2010 May 04 10:59 AM
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