How to find out the primary key column of a database table?
Hi
Given the following scenario :
Given an inputfield, the user can enter a table name. The code behind will base on the table name given and extract out the fieldname of the primary key and concatenate the two field to become a unique string.
Eg. Order ID and Product ID make out a primary key.
How do i achieve that? Any code sample?
Regards,
Rayden
Check the below code :
REPORT zTest no standard page heading.
data : i_DD03P like DD03P occurs 0 with header line.
data v_table like DCOBJDEF-NAME.
parameters : p_table like dd02l-tabname.
start-of-selection.
v_table = p_table.
CALL FUNCTION 'BDL_DDIF_TABL_GET'
EXPORTING
NAME = v_table
STATE = 'A'
LANGU = 'E'
IMPORTING
GOTSTATE =
DD02V_WA =
DD09L_WA =
TABLES
DD03P_TAB = i_DD03P
DD05M_TAB =
DD08V_TAB =
DD12V_TAB =
DD17V_TAB =
EXCEPTIONS
ILLEGAL_INPUT = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at i_DD03P.
if i_dd03p-KEYFLAG = 'X'.
write:/ 'Key fields', i_dd03p-FIELDNAME.
endif.
endloop.
Thanks
Seshu
Similar Messages
-
How to find out the primary key of oracle apps tables
Hii,,
My Question is How to find the primary key in the apps table...Is there any Query or other way to find out???
for eg.
I want to find out the primary key of the AP_INVOICES_ALL table...just tell me how can i get the primary key of this table.
I am currently using toad for the query..
Please guide me...you can define the primary key when you create table
or add the primary key after the table creation by 'ALTER TABLE ... ADD constraint pk_nme primary key (col1, col2)';
you could use below sql to check the detail of primary key:
1) check out the table definition directly:
select dbms_metadata.get_ddl('TABLE','EMP') FROM DUAL;
2) check out the columns of primary key:
select * from user_constraints where constraint_type='P' AND table_NAME='EMP';
select * from user_cons_columns where CONSTRAINT_NAME='PK_EMP';And BTW, it is madam, not sir. :)
Edited by: PhoenixBai on Dec 17, 2010 1:07 PM -
How to find out the primary and failover DNS name
Hi;
This sounds very stupid, but could some one please tell me how to find out the name/dns name of the primary and failover server without using the CDS console.
any help is appreciatedIs this what you want?
$ /usr/lib/ldap/ldap_cachemgr -g
cachemgr configuration:
server debug level 0
server log file "/var/ldap/cachemgr.log"
number of calls to ldapcachemgr 12729
cachemgr cache data statistics:
Configuration refresh information:
Previous refresh time: 2005/08/07 23:54:59
Next refresh time: 2005/08/08 00:55:00
Server information:
Previous refresh time: 2005/08/14 15:15:00
Next refresh time: 2005/08/15 03:15:00
server: ldap1.example.com, status: UP
server: ldap2.example.com, status: UP
server: ldap3.example.com, status: UP
Cache data information:
Maximum cache entries: 256
Number of cache entries: 0
Gary -
How to find out the tablename and column name
Hi,
I have inserted a value (say 'I am here') in a table. but i don't know which is getting inserted this value.
Now i want to know which table and colums has this value (I am here). How to find out as without knowing the table name.
Is there any option to get the tablename and colum??.
Please help me.
thanks.Does nobody document their code anymore?
See my response Re: How to find out a tablename for one possible solution.
HTH
John -
Knowing the primary key columns of the given table
Hi,
How can I get the primary key columns of the given table?
Regards,
Sachin R.K.You can find the constraint_name from all_constraints/user_constraints for constraint_type = 'P' (which is the primary key constraint).
And then see which columns are in for the constriant_name
in all_cons_columns/user_cons_columns view.
Below is the example
select acc.column_name from
all_cons_columns acc, all_constraints ac
where acc.constraint_name = ac.constraint_name
and acc.table_name = 'DEPT' AND acc.owner = 'SCOTT'
and ac.constraint_type = 'P'
Hope this helps
Srinivasa Medam -
How do find out the number of rows
how to find out the number of rows of as all tables in a schema with one sql statement
Hi,
What u can try doing is...
declare
numrows number;
begin
for i in (select tname from tab)
loop
execute immideate 'select count(1) into numrows from ' | | i.tname ;
dbms_output.put_line(numrows);
end loop;
end;
Hope this helps. This works only in 8i. So if u need to do the same in 8.0 u have to use dbms_sql pkg.
The logic is same but the way u open ands execute the code is a bit diff.
Best Of Luck.
Regards,
Ganesh R -
How to find out the selected column in Table Control
Hi all,
How to find out the selected column in Table Control?
Thanks & Regards,
YJRHi,
Let your table control name in Screen painter be TC1.
READ TABLE TC1-COLS INTO WA_COLS (some wok area)
WITH KEY SELECTED = 'X'.
IF SY-SUBRC = 0.
CLEAR: W_DUMMY, W_COL_NAME.
SPLIT WA_COLS-SCREEN-NAME AT '-' INTO W_DUMMY
W_COL_NAME.
endif.
W_COL_NAME gives you the column name.
Hope it helps.
cheers
sharmistha -
How to find out the rows inserted between a time period.
Hi,
Please help me to solve this.
Table - emp.
Colmns - empno(Primary Key),ename, mgr
How to find out the rows inserted between a time period.
For eg:- Between 02-Oct-2006 1 PM and 03-Oct-2006 2 PM.
regards,
Mathew.Hi,
Maybe work:
For each row, ORA_ROWSCN returns the conservative upper bound system change number (SCN) of the most recent change to the row. This pseudocolumn is useful for determining approximately when a row was last updated. It is not absolutely precise, because Oracle tracks SCNs by transaction committed for the block in which the row resides
e.g.:
SGMS@ORACLE10> create table test(cod number);
Table created.
SGMS@ORACLE10> insert into test values (1);
1 row created.
SGMS@ORACLE10> insert into test values (2);
1 row created.
SGMS@ORACLE10> commit;
Commit complete.
SGMS@ORACLE10> insert into test values (3);
1 row created.
SGMS@ORACLE10> commit;
Commit complete.
SGMS@ORACLE10> select SCN_TO_TIMESTAMP(ora_rowscn),ora_rowscn,cod from test;
SCN_TO_TIMESTAMP(ORA_ROWSCN) ORA_ROWSCN COD
06/11/06 08:56:56,000000000 727707205 1
06/11/06 08:56:56,000000000 727707205 2
06/11/06 08:57:05,000000000 727707210 3Cheers -
How to find out the Transactions used per month & the USER who used that
Hi,
1)How to find out the Transactions used per month & the USER who used that?
2)and can i get the above same for minimum 20 month?
System : SAP- Enterprise Core Component.You can use my program...
*& Report Z_ABAP_TCODE_MONITOR
*****& Program Type : Report *
*****& Title : Z_ABAP_TCODE_MONITOR *
*****& Transaction code : ZTCODE_USAGE *
*****& Developer name : Shailendra Kolakaluri *
*****& Deveopment start date : 26 th Dec 2011 *
*****& Development Package : ZDEV *
*****& Transport No : DEVK906086 *
*****& Program Description : This program is to display
*List all tcodes executed during previous day.
*& Show the number of users executing tcodes
*& Modification history
REPORT Z_ABAP_TCODE_MONITOR.
*& List all tcodes executed during previous day.
*& Show the number of users executing tcodes
TYPE-POOLS : slis.
DATA: ind TYPE i,
fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
layout TYPE slis_layout_alv,
variant TYPE disvariant,
events TYPE slis_t_event WITH HEADER LINE,
heading TYPE slis_t_listheader WITH HEADER LINE.
*REPORT z_report_usage.
TYPES: BEGIN OF zusertcode,
date TYPE swncdatum,
user TYPE swncuname,
mandt TYPE swncmandt,
tcode TYPE swnctcode,
report TYPE swncreportname,
count TYPE swncshcnt,
END OF zusertcode.
*data : date type n.
DATA: t_usertcode TYPE swnc_t_aggusertcode,
wa_usertcode TYPE swncaggusertcode,
wa TYPE zusertcode,
t_ut TYPE STANDARD TABLE OF zusertcode,
wa_result TYPE zusertcode,
t_result TYPE STANDARD TABLE OF zusertcode.
PARAMETER: month TYPE dats DEFAULT sy-datum.
*PARAMETER: date TYPE dats.
*select-options : username for wa_usertcode-account.
START-OF-SELECTION.
PERFORM get_data.
PERFORM get_fieldcatalog.
PERFORM set_layout.
PERFORM get_event.
PERFORM get_comment.
PERFORM display_data.
FORM get_data .
*date = sy-datum - 2 .
After start-of-selection add this line (parameter Month required 01 as day).
concatenate month+0(6) '01' into month.
CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
EXPORTING
component = 'TOTAL'
ASSIGNDSYS = 'DEV'
periodtype = 'M'
periodstrt = month
TABLES
usertcode = t_usertcode
EXCEPTIONS
no_data_found = 1
OTHERS = 2.
wa-date = month.
*wa-date = date.
wa-mandt = sy-mandt.
wa_usertcode-account = username.
LOOP AT t_usertcode INTO wa_usertcode.
wa-user = wa_usertcode-account.
IF wa_usertcode-entry_id+72 = 'T'.
wa-tcode = wa_usertcode-entry_id.
wa-report = space.
ELSE.
wa-tcode = space.
wa-report = wa_usertcode-entry_id.
ENDIF.
COLLECT wa INTO t_ut.
ENDLOOP.
SORT t_ut BY report ASCENDING.
CLEAR: wa, wa_result.
endform.
FORM get_fieldcatalog .
fcat-tabname = 't_ut'.
fcat-fieldname = 'DATE'.
fcat-seltext_l = 'Date'.
fcat-key = 'X'.
APPEND fcat.
CLEAR fcat.
fcat-tabname = 't_ut'.
fcat-fieldname = 'MANDT'.
fcat-seltext_l = 'Client'.
fcat-key = 'X'.
APPEND fcat.
CLEAR fcat.
fcat-tabname = 't_ut'.
fcat-fieldname = 'USER'.
fcat-seltext_l = 'User Name'.
fcat-key = 'X'.
APPEND fcat.
CLEAR fcat.
fcat-tabname = 't_ut'.
fcat-fieldname = 'TCODE'.
fcat-seltext_l = 'Transaction Code'.
fcat-key = 'X'.
APPEND fcat.
ENDFORM.
*& Form SET_LAYOUT
text
--> p1 text
<-- p2 text
FORM set_layout .
layout-colwidth_optimize = 'X'.
ENDFORM. " SET_LAYOUT
*& Form GET_EVENT
text
--> p1 text
<-- p2 text
*FORM get_event .
events-name = slis_ev_top_of_page.
events-form = 'TOP_OF_PAGE'.
APPEND events.
*ENDFORM. " GET_EVENT
**& Form GET_COMMENT
text
--> p1 text
<-- p2 text
*FORM get_comment .
DATA: text(30).
text = 'Billing Report'.
heading-typ = 'H'.
heading-info = text.
APPEND heading.
*ENDFORM. " GET_COMMENT
**& Form top_of_page
text
--> p1 text
<-- p2 text
*FORM top_of_page .
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = heading[]
I_LOGO =
I_END_OF_LIST_GRID =
*ENDFORM. " top_of_page
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
FORM display_data .
sort t_ut[].
DELETE ADJACENT DUPLICATES FROM t_ut[] COMPARING ALL FIELDS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
is_layout = layout
it_fieldcat = fcat[]
i_save = 'A'
is_variant = variant
it_events = events[]
TABLES
t_outtab = t_ut
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " DISPLAY_DATA -
How to find out the users currently logged into ODI
Hi all,
How to find out the users currently logged into ODI Work Repository?
Thanks.Hi,
It stores all the final queries in work rep table i.e "SNP_SESS_TXT_LOG" and the column is "TXT".
Here u can find all the ODI bkp process queries.Pls specify the SESS_NO for purtivular task u want to check which u can get this in ODI operator.
I dont think so that it will keep the substituted value(because its implicit and temporary process) but it will keep all the default values in the table SNP_VAR_SESS and the column is "DEF_V".
Thanks,
katukota -
How to find out the table name
hi,
how to find out the table name in which the data from a particular structure in a particular screen is saved,
please tell me the procedure to find out the table name for saving the structure data that is inputted at runtime.
Thanks,
chinnuHi Chinnu,
Below are the tables that are referred to find out the table names
DD02L Table contains the SAP Tables.
DD02T Table contains the SAP Table Texts.
DD01L Table contains the Domains
DD01T Table contains the Domain Texts.
DD03L Table contains the Table Fields.
DD03T Table contains the Table Field Texts. (Language Dependent)
DD04L Table contains the Data Elements.
DD04T Table contains the Data Element Texts.
DD05s Table contains the Foreign Key Fields
last words with L and T only. L->Database Fetch T-> Text
And the procedure to retrive the table name is as follows
1. Go to se11
2. Enter table name DD03T and execute
3. In the next screen you can find Tables, fields, test etc. there you can enter the field name in the fields
and execute.
4. you can get all tables which contains the field.
I hope this will solve your problem
Regards,
Chandru -
How to find out the common things between two rpds?
How to find out the common things between two rpds? And place the common things in a common RPD.
I thought of one solution.
Original RPD = A
Modified RPD = B
XML Patch created for A-B = X
Now open the XML Patch in IE or Mozilla and delete the columns/tables/variable/etc,. from the Original RPD A.
But its a cumbersome process, if the XML file is of very less size its Ok. If its 10-20 MB then going line by line and deleting the change is not the process to be followed.
I have to check whether its just the delete or modify or drop.
Let me know your thoughts. -
HOW to find out the tablespace space utilized by a patch after applying the
someone has already applied the patch in test env before recording the tablespace size , so I cannot find out the figure in test env.
So is there any general practice or general guidelines on it?
hOW to find out the tablespace space utilized by a patch after applying the patch?
Thanks & Regards,
Sree.
Edited by: 846579 on Mar 22, 2011 10:50 PMI think there is no direct way to determine what tablespace is utilized by a patch from the README file. You could check the content of the patch file and see what modules are affected (assuming there are changes and the database level), then query DBA_USERS (DEFAULT_TABLESPACE column) for those schemas which are updated by a patch. Or, you could check the size of the tablespaces before and after applying the patch and you will determine what tablespaces have been utilized (provided that the application services are down, and none of the application users is connected to the application).
Thanks,
Hussein -
Hi ,
How to find out the latest Record in per_all_people_f and per_all_assignments_f
Requirement : Need to find out the latest record in per_all_people_f and per_all_assignments_f to update the attribute column with pre defined value . Its not possible to track only with person_id / assignment_id and effective end date
SELECT pp_id
FROM (SELECT app.person_id pp_id,
asf.*
FROM apps.per_all_people_f app,
apps.per_all_assignments_f asf
WHERE --app.person_id=123568 and
asf.person_id = app.person_id AND
app.effective_end_date = to_date('31-dec-4712') AND
asf.effective_end_date = to_date('31-dec-4712')
GROUP BY app.person_id)
HAVING COUNT(pp_id) > 1
GROUP BY pp_id
This query also returns more than 1 value for person_id .
It would be great if you put comment on this .. Thanks in advance ,
AryaI am getting more records with asf.primary_flag='Y' . If you give ur mail id , i will send the sample data
ASSIGNMENT_ID EFFECTIVE_START_DATE EFFECTIVE_END_DATE BUSINESS_GROUP_ID RECRUITER_ID GRADE_ID POSITION_ID JOB_ID ASSIGNMENT_STATUS_TYPE_ID PAYROLL_ID LOCATION_ID PERSON_REFERRED_BY_ID SUPERVISOR_ID SPECIAL_CEILING_STEP_ID PERSON_ID RECRUITMENT_ACTIVITY_ID SOURCE_ORGANIZATION_ID ORGANIZATION_ID PEOPLE_GROUP_ID SOFT_CODING_KEYFLEX_ID VACANCY_ID PAY_BASIS_ID ASSIGNMENT_SEQUENCE ASSIGNMENT_TYPE PRIMARY_FLAG APPLICATION_ID ASSIGNMENT_NUMBER CHANGE_REASON COMMENT_ID DATE_PROBATION_END DEFAULT_CODE_COMB_ID EMPLOYMENT_CATEGORY FREQUENCY INTERNAL_ADDRESS_LINE MANAGER_FLAG NORMAL_HOURS PERF_REVIEW_PERIOD PERF_REVIEW_PERIOD_FREQUENCY PERIOD_OF_SERVICE_ID PROBATION_PERIOD PROBATION_UNIT SAL_REVIEW_PERIOD SAL_REVIEW_PERIOD_FREQUENCY SET_OF_BOOKS_ID SOURCE_TYPE TIME_NORMAL_FINISH TIME_NORMAL_START BARGAINING_UNIT_CODE LABOUR_UNION_MEMBER_FLAG HOURLY_SALARIED_CODE REQUEST_ID PROGRAM_APPLICATION_ID PROGRAM_ID PROGRAM_UPDATE_DATE ASS_ATTRIBUTE_CATEGORY ASS_ATTRIBUTE1 ASS_ATTRIBUTE2 ASS_ATTRIBUTE3 ASS_ATTRIBUTE4 ASS_ATTRIBUTE5 ASS_ATTRIBUTE6 ASS_ATTRIBUTE7 ASS_ATTRIBUTE8 ASS_ATTRIBUTE9 ASS_ATTRIBUTE10 ASS_ATTRIBUTE11 ASS_ATTRIBUTE12 ASS_ATTRIBUTE13 ASS_ATTRIBUTE14 ASS_ATTRIBUTE15 ASS_ATTRIBUTE16 ASS_ATTRIBUTE17 ASS_ATTRIBUTE18 ASS_ATTRIBUTE19 ASS_ATTRIBUTE20 ASS_ATTRIBUTE21 ASS_ATTRIBUTE22 ASS_ATTRIBUTE23 ASS_ATTRIBUTE24 ASS_ATTRIBUTE25 ASS_ATTRIBUTE26 ASS_ATTRIBUTE27 ASS_ATTRIBUTE28 ASS_ATTRIBUTE29 ASS_ATTRIBUTE30 LAST_UPDATE_DATE LAST_UPDATED_BY LAST_UPDATE_LOGIN CREATED_BY CREATION_DATE TITLE OBJECT_VERSION_NUMBER
931510 7-Nov-08 31-Dec-12 122 (null) (null) (null) 3978 1 (null) 14402 (null) 220150 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 2 E Y (null) 100035417-2 (null) (null) (null) 45948739 (null) (null) (null) (null) (null) (null) (null) 868007 (null) (null) (null) (null) 449 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 26-Aug-08 26-Aug-08 122 (null) (null) (null) 3980 3 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
916076 26-Aug-08 31-Dec-12 122 (null) (null) (null) 3980 1 4 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 B Y (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 25-Feb-08 25-Aug-08 122 (null) (null) (null) 3980 1 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) -
How to find out the standard info stucture for a customized IS in LIS
Hi All
I have to run the statistical set up for the customized info structure S763 for the application plant maintenance in LIS. But i dont know whether it was copied from a standard SAP info structure or it was enhanced from a standard info structure.
I have even checked out all the standard IS for plant maintenance but it is not matching. The closest match is S063 but a few characteristics and a key figure is missing.
Could anybody guide me how to find out the standard info structure?
Any help would be of great help.
Regards
SaddyHi Ganesh
No..it didnt solve my problem. MC23 only displays the info structures. I have a customized info structure S763 which was created long time back. Im not sure whether it was copied from a standard info structure or enhanced from a standard info structure.
I have to give the source info structure name to run statistical set up. The closest one which matches with the S763 is S063 but it is missing few characteristics and key figure.
does it means that the IS S063 was enhanced?? Am i right?? If it was enhanced how will i run the statistical setup for the same...
I hope i have explained clearly.
Do provide ur valuable input.
Regards
Saddy
Maybe you are looking for
-
My iphone is no longer working I have black screen with a picture of the itunes logo and a USB cable. When I try to connect my iphone to itunes the device is not detected, can anyone help me? I desperatley need my phone back
-
How the heck do I automatically organize my files?
I know it worked before. Like everytime I would add a new song into my library, I know iTunes would automatically make files all nice and stuff. But since the new stupid upgrade (when iTunes changed it's interface) it won't do it anymore! I went to m
-
Wiki Permissions issue.
I have one user who it seems has a problem with Wiki permissions. They are in the Group for the wiki but they cannot access it. I have tried various things even some command line stuff but the user stubbornly will not get added- Very odd, has anyone
-
Two-way or only one-way syncing between G4 and mobile??
I have a Sony Ericcsson k750i mobile. When I first got it, I went through my Address Book (on my powerbook) and sorted it all out and synced with the phone (so all the numbers in the Address Book transfered to the phone). No problem. But now, if I sy
-
I have a report that previously used to include a "group tree". Later versions of the report the group tree is gone and the group tree button has been disabled. I've checked "report options" and "options" to make sure the the the "group tree" optio