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: 

Check Table validation General code needed

former_member194669
Active Contributor
0 Kudos

Hi,

I have a requirement to update 2 custom tables. Each table have more 230 field each.

and have 90 check tables assigned to the fields.

I need a common code to validate before updating into this table,

i need to validate the fields against the check tables assigned to that field.

I know i how to validate field with each check table.

But i need a common function module. class or some code that i can use commonly passing field value, check table and i need return value

Anybody having code please paste it here.

Your help appreciated.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Happy to see that you ask questions too.. i had an impression that you only solve them

Why dont you create a subroutine in you program?

FORM f_validate USING field TYPE c

value TYPE any

tabname TYPE c

CHANGING return TYPE c.

FIELD-SYMBOLS : w_field TYPE any.

SELECT SINGLE ( field )

FROM ( tabname )

INTO w_field

WHERE ( field ) EQ value.

If sy-subrc NE 0.

retrurn = 'X'.

ENDIF.

ENDFORM.

Thanks and Best Regards,

Vikas Bittera.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Happy to see that you ask questions too.. i had an impression that you only solve them

Why dont you create a subroutine in you program?

FORM f_validate USING field TYPE c

value TYPE any

tabname TYPE c

CHANGING return TYPE c.

FIELD-SYMBOLS : w_field TYPE any.

SELECT SINGLE ( field )

FROM ( tabname )

INTO w_field

WHERE ( field ) EQ value.

If sy-subrc NE 0.

retrurn = 'X'.

ENDIF.

ENDFORM.

Thanks and Best Regards,

Vikas Bittera.

0 Kudos

Vikas,

Thanks for your reply. My brain not upto the mark due to long hours working

Your reply will solve my issue.

Points awarded

Former Member
0 Kudos

I have verified AT SE37 and Found many ( Search term would be CHECKTABL*

Check the below FM :

CALL FUNCTION 'CHECKTABLE_GET'

EXPORTING

VALUECHECKFIELDNAME = SPACE

VALUECHECKTABLE = SPACE

VALUECHECKVALUE = SPACE

VALUEFIELDNAME = FIELD_DFIES-FIELDNAME

VALUELANGUAGE = SY-LANGU

VALUETABNAME = FIELD_DFIES-TABNAME

MAXENTRIES = MAXENTRIES

SHOW_LIST = SPACE

IMPORTING

RETCODE = RC

TABLES

DYNPSELECT = DYNPSELECT

VALUES = VALUES

VALUESSTRUCTURE = VALUESSTRUCTURE

EXCEPTIONS

OTHERS = 1.

Look at report RDD00DOC.

Otherwise create one perform routine ,pass the table and fields dynamically'

Thanks

Seshu

uwe_schieferstein
Active Contributor
0 Kudos

Hello a®s

The code samples already given solve the problem to verify the existence of single values in check tables. However, this may not be sufficient.

Assuming that one ore more foreign-key relations in your custom tables have more than one foreign-key fields then this logic is insufficient.

The classical example is table SFLIGHT. Look at the foreign-key relation for field CONNID:

SPFLI	MANDT	SFLIGHT	MANDT
SPFLI	CARRID	SFLIGHT	CARRID
SPFLI	CONNID	SFLIGHT	CONNID

While field MANDT can be neglected you may find a foreign-key value for CARRID in table S_CARR and the corresponding value for CONNID in SPFLI but not the combination of both in table SFLIGHT.

Thus, for any foreign-key relation having multiple check-table fields you have to use a more elaborate logic.

Regards

Uwe