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: 

Validating the fields of two internal tables(not records)

0 Kudos

Hi ABAPer,

I am new to ABAP technology.

Requirement :

There is one excel sheet file and i am transporting into internal table(ts_ipfile). There is another table (Mapping table - suppose ztxxttmrul). I have to validate the excel sheet file data with the mapping table. there are 23 fields in the ts_ipfile. i have done the max part. i have to validate one of the field from the excel sheet with standard sap table tmc1t8 and in one of the fields (GSTRU) of table tmc1t containing the table name. I have to extract the table name from the field and their components. I have done that. i have insert it into internal table say suppose(ts_fieldlist).

Next is i have to compare the fields name present in the ts_fieldlist with the internal table's field names(ts_ipfile) containing excel sheet records. If it matches then i have to check the value under that field name and proceed with that.

could you please look into this as I am solving since 2 days  but i am unable to do that.

6 REPLIES 6

Former Member
0 Kudos

How is your internal table ts_fieldlist being maitained, i.e does each field name is one row in the table?

If that is the case then you can

Read ts_ts_fieldlist with the key ts_ipfile-fld_name (whatever that name is).. When this has happened I am not sure from where you are getting field name but I guess that should be easy..

Hope this helps.

Former Member
0 Kudos

Hi Shashikant,

I guess you have to  give some more detail:

- what is the content of Excel file?

- what is the layout of your Excel? the 23 fields are in one row only, or one field per row?

- what do you need to validate? each one of this 23 fields or the entire row?

- what is the following action after validation? Or do you only need true/false validation?

Regards,

Tabrez

0 Kudos

I am sending you the excel sheet file. These records present in the excel fiIe is going to insert in mapping tabe. And i have to validate field SOKC (SO key combination) against the table TMC1T(standard SAP).

Fields present in TMC1T( Mandt, GSTRU, GSTXT).

If GSTXT(SOKEY excel file) is matched then I have to extract table name present in field GSTRU. Then extract field names of that corresponding table.

Next is to compare those field names with the field name present in the excel sheet file Iike

KSCHLVKORGVTWEGSPARTKUNNR

Note : 4th row of the exceI sheet is not included in the internal table.

IF fieId names is matched then I have to check the data against that fieId Iike it is intiaI or not.

PIease heIp me on this.

0 Kudos

Hi Shashikant,

I hope you have the logic for the first part where you move the excel sheet into internal table and validate the SOKEY from excel sheet against the table TMC1T. once you get the table name in TMC1T you the below snipet..


data: begin of lt_dd03l occurs 0,
  tabname like dd03l-tabname,
  fieldname like dd03l-fieldname,
end of lt_dd03l.


select tabname fieldname from dd03l into table lt_dd03l where tabname = tmc1t-gstru.
if sy-subrc = 0.
endif.

This will give you the list of fields in the table identified in TMC1T-GSTRU. Let us know where you are struggling so that we can provided you specific help.


regards


0 Kudos
Hi Shashikant,
  • What do you mean by

IF fieId names is matched then I have to check the data against that fieId Iike it is intiaI or not.

Will you query the table returned by TMC1T to get the content of those fields? You will need a key to query the table but I assume that you do have it in the Excel file.
The steps involved in this should be something like this
  1. Import excel file and store its contents in internal table
  2. Store Excel fields in internal table, lets call it lt_excel_fields.
  3. Store SO KEY Combination into a variable
  4. Get table name from TMC1T and store it into a variable, lets call it lv_tablename
  5. Create table to store fields, you can use the suggested by Abhijit

               data: begin of lt_dd03l occurs 0,

                        tabname like dd03l-tabname,

                        fieldname like dd03l-fieldname,

               end of lt_dd03l.

   6. Get field names from table returned by the previous query. You have already the solution to this given by Abhijit

               select tabname fieldname from dd03l into table lt_dd03l where tabname = lv_tablename.

   7. Check if Excel fields are present on lt_dd03l and subsequent processing

     loop at lt_excel_fields into lw_excel_fields.

          loop at lt_dd03l into lw_dd03l where fieldname = lw_excel_fields-fieldname.

              << your logic here. Perhaps something like this:                   

                    select (lw_excel-fieldname) from (lv_tablename) into .

          endloop.

     endloop.

Regards,

Tabrez

0 Kudos

Thanks for your heIp