06-07-2011 5:09 AM
Hi everybody,
My requirement is to update a z-table at runtime according to the data given ata runtime. So the main difficulties for me is that whenever I tried to update the table based on the data given in UI many rows are getting updated as these fields are not unique. So I think if I can get the PRIMARY KEY along with these given fields then I can update only one row at a time.
So Can anyone suggest me how to get PRIMARY KEY of a table based on the data in UI..??
Any suggestions will be appreciated..
Thanks,
Sekhar
06-07-2011 5:42 AM
Hi,
You have to pass the table name to following function module, It provide the key and non key fields of table
* Read table fields
CALL FUNCTION 'CACS_GET_TABLE_FIELDS'
EXPORTING
i_tabname = p_table " Table Name
TABLES
t_keyfield = lt_keyfield " Key Fields
t_nonkeyfield = lt_nonkeyfield. " Non Key Fields
06-07-2011 5:42 AM
Hi,
You have to pass the table name to following function module, It provide the key and non key fields of table
* Read table fields
CALL FUNCTION 'CACS_GET_TABLE_FIELDS'
EXPORTING
i_tabname = p_table " Table Name
TABLES
t_keyfield = lt_keyfield " Key Fields
t_nonkeyfield = lt_nonkeyfield. " Non Key Fields
06-07-2011 6:33 AM
hi,
You can use this FM 'BDL_DDIF_TABL_GET' to get the key field of a particular table.
06-07-2011 6:43 AM
Hi Ravi and Hari,
Thanks for your valuable replies. But I want the Primary Key for those entries which are input through UI. Means the thought process is like I have to search the whole table for the entries made through UI and if fund those entries in a row fetch the primary key..
Kindly direct me a path in this regard.
Thanks,
sekhar
06-07-2011 7:09 AM
U will get primary keys of transparent tables using FM "REUSE_FIELDCALATLOG_MERGE".
pass tyour table name and u will get fieldcatalog filled. In tht their is a field called "KEY" if it has 'X' then tht field is a primary key of transparent tables & if it has "space" then it is not a primary key...
Or else you can try with 'DDIF_TABT_GET'
Or try this code
PARAMETERS: p_table TYPE tabname OBLIGATORY.
DATA: go_strucdescr TYPE REF TO cl_abap_structdescr,
gt_tab_fields TYPE ddfields.
FIELD-SYMBOLS: <gwa_tab_field> TYPE dfies.
TRY .
* Get the details of the DDIC table
go_strucdescr ?= cl_abap_elemdescr=>describe_by_name( p_table ).
CATCH cx_sy_move_cast_error .
MESSAGE 'Error while casting' TYPE 'S'. RETURN.
ENDTRY.
* Check if input is a DDIC table
CHECK go_strucdescr->is_ddic_type( ) = 'X'.
* Get the details of the table fields
gt_tab_fields = go_strucdescr->get_ddic_field_list( ).
* Display the Key fields of the table
LOOP AT gt_tab_fields ASSIGNING <gwa_tab_field> WHERE keyflag = 'X'.
WRITE: / <gwa_tab_field>-fieldname.
ENDLOOP.
06-07-2011 10:35 AM
hello monika,
sorry bymistakely I closed this thread.
In the selection screen what parameter I supposed to give.??
thanks in advance,
Sekhar
06-07-2011 7:22 AM
06-07-2011 10:33 AM
06-22-2011 6:55 AM