Skip to Content
0
Feb 04, 2012 at 07:08 AM

Read a structure with out specifying its field/component names-Dynamically?

44 Views

Hello

My requirements:

I need to write a module pool prog., which updates a Z_material_master_data_table, which tables has 150 fields (i knew its odd having 150 fields in a master table).

On the module pool prog. i need to place the fileds in 2 columns, say left column(for current data) with 150 fields and right column(user input data for updating the Z_material_master_data_table) with 150 fields

When user opens the prog., user will be presented with a initial screen, where in user enters the material number (for which user want a updation ) then, the user will redirected to 2nd screen where in my prog. will default/prepopulate the left side fields with the current(old) data. Now user has to input his/her data (new) for updating any field of the z_master_data_table.

And after finishing the user clicks a push button with title of 'UPDATE'

Now, my prog. has update the entry in the z_material_master_data_table. The 2nd screen looks like below,

 

_Currnet data_ -------------------------------------- _New data_

Current Material description ---------------------- New Material description
The field will placed here  ------------------------ The field will placed here to 
for showing the current data                              inputting the new data by user

As there are 150 fields, i would not like to write validation (cross checking whether user entered the data on each field) on every field of 150 in number.

The 2nd reason, they want the prog. a kind of dynamic in nature, like going further, if the business want to add a new field, say 151_field to the the table, they dont want to change the prog. (just keeping the 151_field should enough) to address this newely added field.

By thinking field symbols approach, i created 2 structures for old data and another for new data. These structurer are replicas of z_material_master_data_table, but 2nd (new) structure field names posses a an extra 4 chararctes like '_UPD', say for example, ZZMAKTX will be the fileld name in structure_1 (old) and its name will be ZZMAKTX_UPD in 2nd structure(new)

Pls. give me some code snippet for (my above requiremnet) reading a structure DYNAMICALLY with out specifying/mentioning the field names for each and every field or give me any better idea to meet my requirement

Thank you