2009 Jul 09 11:07 AM
Hello everyone,
Requirement says for a particular field in a table, default values should appear when new entries tab is clicked.
This has been achieved by adding a module under PBO of the function group of the table maintainance generator.
__________________________________________________________
IF FUNCTION = 'SAVE' or FUNCTION = 'NEWL' .
ztest_term-plant = 'MX01'.
ENDIF.
__________________________________________________________
So this code works when new entries button or SAVE button is clicked.
The issue is there is a date field in this table.If the format of the date is wrong it throws a system error as we know.
So when the system error araises it gives a pop-up asking us whether we want to cancel or not.
When 'YES' in the pop-up is choosen, the default entries disappear which should not happen.
Even when an error pops up the default values should remain as it is.
Can anyone suggest how this issue can be solved.
Regards,
Chandra.
Hello everyone,
Requirement says for a particular field in a table, default values should appear when new entries tab is clicked.
This has been achieved by adding a module under PBO of the function group of the table maintainance generator.
__________________________________________________________
IF FUNCTION = 'SAVE' or FUNCTION = 'NEWL' .
ztest_term-plant = 'MX01'.
ENDIF.
__________________________________________________________
So this code works when new entries button or SAVE button is clicked.
The issue is there is a date field in this table.If the format of the date is wrong it throws a system error as we know.
So when the system error araises it gives a pop-up asking us whether we want to cancel or not.
When 'YES' in the pop-up is choosen, the default entries disappear which should not happen.
Even when an error pops up the default values should remain as it is.
Can anyone suggest how this issue can be solved.
Regards,
Chandra.
2009 Jul 09 12:09 PM
hi,
why dont you use exception in that case.
try to catch that error exception yourself and just display a custom message....
hope this will surely help you!!!
Thanks & Regards,
Punit Raval.
2009 Jul 09 12:30 PM
Hello Punit,
Thanks for your reply.
But i couldnt get what your trying to say.
Can you please explain it more clearly.
Regards,
Chandu
2009 Jul 09 12:48 PM
hi,
see when the save button gets clicked a pai module will get triggered ... now the problem arises when the date format is not proper and so it throws an system exception... so what i mean to say is that you enclose that pai module in try and catch block and try to get the name of the exception which is being thrown and then catch that exception and write your handler statement
in the catch block...... means you are going to process the exception now....
also according to your problem ... what you do is just display simple warning message on the screen like the date format is not correct..
also check out how to catch the runtime exception for reference :
http://help.sap.com/saphelp_nw70/helpdata/en/cf/f2bbce142c11d3b93a0000e8353423/content.htm
hope this will surely help you!!!!
thanks & regards,
punit raval.
2009 Jul 09 4:32 PM
Hi ,
Insetad of writing in PBO.. once you try writing all these default values and date in events of table maintainance geneator.
In Table maintainance generator, follow the below path,
Environment -- Modification --- events..
there create an event for 01 Before saving the data in the database and 05 Creating a new entry .
Give some form names against the event and create it and save in an include..
Now write code by writing the form as shown below:
The below thing is for code 01 i.e. Before saving the data in the database
----
***INCLUDE LYMTID_E136_MATPRF01 .
----
FORM ztest.
DATA : BEGIN OF ls_access.
INCLUDE STRUCTURE Ztable. " Table name.
DATA : indicator TYPE c,
END OF ls_access.
LOOP AT total INTO ls_access.
CASE ls_access-indicator.
WHEN 'N'. "" this ehile creating new entries
CREATED BY
ls_access-modified_by = sy-uname. " passing user name value into one of the fields of the table
CREATED DATE
ls_access-modify_date = sy-datum.
MODIFY total FROM ls_access.
WHEN 'U'. "Update " this is when updating an existing entry
CHANGED BY
ls_access-modified_by = sy-uname.
CHANGED DATE
ls_access-modify_date = sy-datum.
MODIFY total FROM ls_access.
ENDCASE.
ENDLOOP.
ENDFORM.
In above code TOTAL is global variable and it contains all teh newly enetered and existing entries.So you can directly hard code your values inrequired fields.
and of 05 i..e Creating a new entry .
To display some error messages like :
If some field is initial , then throw error. wrie code in 05 event
Hope this helps.
Thnaks ,
Srilakshmi
2009 Jul 13 5:12 AM
Hello,
I have already tried with events and it didn't work. So had to go for coding in PBO.
And moreover the issue is that whenever there is some error while maitaining values in table, after clicking on yes in the pop-up the values in the current record get refreshed. But the requirement says one value should remain by default even after error pops up.
Regards,
Chandra
2009 Jul 10 5:49 AM
Hi,
Please check the events associated with this table.. And check how they are handling the pop-up.. Maybe they are clearing all the fields one you click on OK.. Check this and do the necessary changes..
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |