Application Development and Automation 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: 
Read only

How do I validate against a Data Element within ABAP?

Former Member
0 Likes
2,417

I'm working on an ABAP that will upload a CSV file into SAP and create Activity Group Authorisations based on the contents of the CSV. One of the requirements is that the CSV is validated before processing.

How can I validate a value against a Data Element specification?

For info, I'm trying to validate Activity Group Org Level values. For example, is the value read from the CSV a valid BUKRS value? I need to confirm to the user that all the data is good the actual creating of the auth's starts.

Thanks,

Malc

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,251

Thanks for the answers but they don't quite answer my question. My CSV input file will have something like this:

Company Code, BUKRS, 800

Business Area, GSBER, 400

Account Type, KOART, 5

For BUKRS and GSBER I now see that I can check the Data Elements "Value table" and validate against it but some of my fields don't have a value table, eg KOART.

When I read the CSV I need to check that "5" is a valid value for KOART. For example, if the CSV contained:

Account Type, KOART, wumpus

I need to detect that "wumpus" is not a valid value for KOART. Is there a SAP function I can call to check if a value is a valid value for any given Data Element?

Thanks,

Malc

5 REPLIES 5
Read only

Vinod_Chandran
Active Contributor
0 Likes
1,251

Hi Malc,

You need to find out the corresponding database table and validate against that. One way to find out the table is to go to the domain and look for the value table.

Thanks

Vinod

Read only

0 Likes
1,251

You will need to validate against table T001 for BUKRS.

Select Single * from t001w
           where bukrs = itab-bukrs.
If sy-subrc <> 0.
Messsage E001(00) with 'Company Code not found'.
Endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,252

Thanks for the answers but they don't quite answer my question. My CSV input file will have something like this:

Company Code, BUKRS, 800

Business Area, GSBER, 400

Account Type, KOART, 5

For BUKRS and GSBER I now see that I can check the Data Elements "Value table" and validate against it but some of my fields don't have a value table, eg KOART.

When I read the CSV I need to check that "5" is a valid value for KOART. For example, if the CSV contained:

Account Type, KOART, wumpus

I need to detect that "wumpus" is not a valid value for KOART. Is there a SAP function I can call to check if a value is a valid value for any given Data Element?

Thanks,

Malc

Read only

0 Likes
1,251

Try the function module DDIF_FIELDINFO_GET which will return the possible values of a field. Then you can check the value from the file.

Read only

0 Likes
1,251

Here is a sample.....



data: dbdiff_values type ddfixvalues, "Festwerttexte zu dbdiffkind
      dbdiff_val    type ddfixvalue.

parameters: p_koart type koart.

at selection-screen.

  call function 'DDIF_FIELDINFO_GET'
       exporting
            tabname      = 'BSEG'
            fieldname    = 'KOART'
            lfieldname   = 'KOART'
       tables
            fixed_values = dbdiff_values.

  read table dbdiff_values into   dbdiff_val
                   with key low = p_koart.

  if sy-subrc <> 0.
    message e001(00) with 'Entry not found'.

  endif.

Regards,

Rich Heilman