2011 Jul 13 2:43 PM
Hi,
I have created ONE program for all custom table maintenence.
ie. One program will be used with selection screen as Table name,
what ever custom table the user gives, he will be able to create,
modity, delete entries from it. I used the concept of dynamic internal
tables.
I am struct on the part of VALIDATIONS for the fields, like date, time, etc fields
i am not able to achieve validations. After INSERTing entries in table, it
is throwing error that Format of date/time is invalid, and it inserts blank
value in that field. Instead i should restrict before Inserting the record
in table. How to do validations for dynamic internal tables?
Any help wil be higly valued.!
Code snippet:
WHEN 'SAVE'.
* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_tabnam
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF NOT grid1 IS INITIAL .
CALL METHOD grid1->check_changed_data .
ENDIF .
SORT i_mod BY row.
DELETE ADJACENT DUPLICATES FROM i_mod COMPARING row.
lh_norec = LINES( i_mod ).
lh_total = lh_norec.
SHIFT lh_total LEFT DELETING LEADING space.
* Z Table Update
IF i_mod[] IS NOT INITIAL.
LOOP AT i_mod INTO lwa_mod.
READ TABLE <i_itab> INTO <wa_tab> INDEX lwa_mod-row.
IF sy-subrc = 0 .
IF lh_flag NE 'X'.
MODIFY (p_tabnam) FROM <wa_tab>.
ELSE.
INSERT (p_tabnam) FROM <wa_tab>.
IF sy-subrc NE 0.
MESSAGE e067(56).
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
CONCATENATE lh_total ' ' text-s01 INTO lh_succ SEPARATED BY space.
MESSAGE i000(00) WITH lh_succ.
ELSE.
MESSAGE i000(00) WITH text-s02.
ENDIF.
* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_tabnam.
CLEAR : i_mod[],
lh_flag.
Thanks,
Padma
2011 Jul 13 3:35 PM
Hi,
How about looping through entries of DD03l for the input table name and then validate all the fields of the table which have abap type(field INTTYPE) as 'D' or 'T' after user input. Just a thought !!!.
Regards,
Pawan
2011 Jul 13 2:50 PM
Sounds like a time bomb to me...what if your users decide to "test" your tool with tables like USR02 or BSEG?
Thomas
2011 Jul 14 6:44 AM
Good Doubt !
We are restricting the user to maintain only Z or Y Tables.
Thats why i have mentioned in my question as program to maintain custom tables.
Any input on my query will be welcomed.
Thanks.
2011 Jul 14 10:47 AM
Now I see it, that's quite a relief
Sorry, can't help with the actual problem at this point, I'm sure others will.
Thomas
2011 Jul 13 3:35 PM
Hi,
How about looping through entries of DD03l for the input table name and then validate all the fields of the table which have abap type(field INTTYPE) as 'D' or 'T' after user input. Just a thought !!!.
Regards,
Pawan
2011 Jul 13 4:03 PM
Hi,
I suggest you to check the date and time values. I had problems similar to yours and I had to format the date and time before saving or modifying anything in the database. Compare the database values and the internal table values, and modify them.
Betty