‎2012 Sep 28 9:30 AM
Hi Experts,
Can we create variable fields in database table(SE11) , that is name of the field is not fixed. We need to select the name of field from drop down or F4 then enter the correspond value for that field.
For example. : From dropdown we need to select emp name or emp number as the field name . If we select EMP NAME as field name then we can able to enter some employee name as field value..
Pls tell me how to do this.
Thanks ,
Ram
‎2012 Sep 30 12:08 AM
Hi Ramu,
not sure, if I really understood what you like to do.
My interpretation: you want a screen with a drop down box. If you select 'Number' from the drop down, you can enter an employee number. If you select 'Name' you can enter a name.
If that interpretation is right: I do not see that this has to do anything with how you create the database table. I rather think it has to do with the UI -> you could create a drop down box with fixed values. Then create 2 input fields, one for number, one for name. Depending on the value of the drop down box, you show one of the 2 input fields and hide the other.
Best regards
Thorsten
‎2012 Oct 04 3:23 PM
Ramu,
Your question seems to be confusing. You want the variable field names to be able to create the table on runtime or the table with actual fields (like number, name, date of birth, address fields etc) are already present and you need to populate the values.
What I feel is the second case where the filed names are actually defined in table, but you want the variable values to be entered on the fields based on the drop down values of field names. In such case, you first need to take the field names from DD03L table where you will give your table name and extract the field names. This is then passed into the dropdown list. Generate the corresponding entry/input field with length as the selected length. Using Field symbols, populate the field values for that field and respective key. This will help you in generating the record for the given key fields of that table. You need to develop the logic for inserting/appending the records.
If you want the first thing to happen, like dynamic table, then I will suggest you to create the internal table and then export the same to DATABASE indx(??) eg. Saving and reading table & records will have statement
EXPORT itab to DATABASE indx(index1) ID 'TABLE' from wa. ---> Saving
IMPORT itab1 to itab2 from DATABASE indx(index1) ID 'TABLE' ---> Reading.
The data will be stored in the INDX table from where you can retreive the data. Please check SAP Documentation for playing around with DATABASE indx table.
Regards,
Hardik Mehta
‎2012 Oct 15 10:18 AM
Hi,
The field name is entered in the selection screen, and inappropriate to that field value F4 help values will be displayed.By menas of dynamic select query, this criteria is possible.
There is no need of variable name in table.
Example:
Declare gt_mara internal table with all possible variable fields.
* Internal table and Workarea Declaration
DATA:lt_field_list TYPE STANDARD TABLE OF ty_field_list,
l_wa_fieldlist TYPE ty_field_list.
parameter:p_fname type char20,
p_fval type char100.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fval.
l_wa_fieldlist-field = p_fname.
APPEND l_wa_fieldlist TO lt_field_list.
CLEAR l_wa_fieldlist.
select (lt_field_list)
FROM mara
INTO TABLE gt_mara.
lc_fname = p_fname.
*Function module for F4
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = lc_fname
dynpnr = sy-dynnr
value_org = 'S'
TABLES
value_tab = gt_mara
return_tab = lt_return.
Hope this helps your query
Regards,
Ramya