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: 

Validations for Dynamic Internal table.?

Former Member
0 Kudos
125

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
74

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

5 REPLIES 5

ThomasZloch
Active Contributor
0 Kudos
74

Sounds like a time bomb to me...what if your users decide to "test" your tool with tables like USR02 or BSEG?

Thomas

0 Kudos
74

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.

0 Kudos
74

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

Former Member
0 Kudos
75

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

Former Member
0 Kudos
74

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