Automated value generation for key field in db table
Hi All
I have created a table in SE11 and i want to autogenerate a value for the keyfield when the user adds a new record to the table. the keyfield is of type numc. this field represents a document id hence i do not want the user to physically enter in an id. Is it possible to achieve this without any additional coding. I am using a WDA app together with an adobe form to allow user to input data.
Thanks in advance
Regards
Thashin Naicker
There is one more method to do that.
Write a query to fetch all the records from the table into any temporary internal table.
Then, do a looping in that table & increment one temporary variable inside a loop.
after this add first value of your primary field to this temporary variable..
Ex.: To add one more record with an increment to a primary key field is shown below:
DATA: TEMP type I.
TEMP = 1.
SELECT * FROM <TABLENAME> INTO TEMP_TABLE.
ENDSELECT.
LOOP AT TEMP_TABLE.
TEMP = TEMP + 1.
ENDLOOP.
<Tablename>-<fieldname> = TEMP_TABLE-<fieldname> + TEMP.
Note: temp is a temporay variable and temp_table is a temporary table.
Similar Messages
-
Value Help for a field from custom table in BSP
Please let me know, the procedure to create value help for a field from a custom table in BSP using HTMLB.
Thankshi prodigy,
check this code using drop down list.
<b>layout for first page</b>
<htmlb:dropdownListBox id = "ddlist"
table = "<%=t_mara%>"
nameOfKeyColumn = "matnr"
nameOfValueColumn = "matnr"></htmlb:dropdownListBox>
<b>event Oninitialization event of first page</b>
SELECT MATNR UP TO 10 ROWS
INTO TABLE T_MARA
FROM MARA.
<b> event Oninputprocessing event</b>
**Load the manager class
CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
DATA: V_EVENT TYPE REF TO CL_HTMLB_EVENT.
DATA: DATA TYPE REF TO OBJECT.
DATA: V_DATA TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX.
CALL METHOD CL_HTMLB_MANAGER=>GET_EVENT
EXPORTING
REQUEST = RUNTIME->SERVER->REQUEST
RECEIVING
EVENT = V_EVENT
IF V_EVENT->NAME = 'button' AND
V_EVENT->EVENT_TYPE = 'click'.
DATA ?= CL_HTMLB_MANAGER=>GET_DATA( REQUEST =
RUNTIME->SERVER->REQUEST
NAME = 'inputField'
ID = 'matnr'
V_DATA ?= DATA.
IF V_DATA IS NOT INITIAL.
V_MATNR = V_DATA->SELECTION.
ENDIF.
NAVIGATION->SET_PARAMETER( NAME = 'v_matnr' VALUE = V_MATNR ).
NAVIGATION->GOTO_PAGE( 'detail.htm' ).
ENDIF.
<b>in the onInitialization event for detail page</b>SELECT MATNR
ERSDA
ERNAM
LAEDA
AENAM
VPSTA
PSTAT
LVORM
MTART
FROM MARA
INTO TABLE T_MARA
WHERE MATNR = V_MATNR. -
How can we get the value of the key field in a custom data model using governance API?
Dear Team,
How can we get the value of the key field in a custom data model, to be used for manipulation of the change request fields using governance API?
Any kind of help would be sincerely appreciated.
Thanks & Regards,
Tushar.Hi Michael,
Thanks for direction. Let me give more context on this as I'm interested to get more details..One of the issue was to read cross entity field values on UI based on user action and set other entity field behaviour...It is similar to what is being posted here.
For ex: Reading MTART from Basic Data UIBB in MM MDG UI and set the field properties in some other custom entities say ZZETEST. This cannot be done using UI BADI as it only supports single entity at a time and not cross entity. So alternatively we found a solution where we can enhance existing PLMB feederclass cl_mdg_bs_mat_feeder_form by reading the model and the entity as needed as it it proved that it supports cross entity UI field behaviours and so business requirements.
This is a workaround for now.
So the question is How do we achive it using governance API for cross entity field behiaviours.?or what is the right way doing this.
Can we do that using governance API and its' methods?
In the Governance API doc you provided below has referring to below external model as part of gevernance API.
The active or inactive data (before or during the derivation or the check) can be read
with the external data model interface IF_USMD_MODEL_EXT with the method READ_CHAR_VALUE and
the corresponding READ_MODE parameter. To avoid unnecessary flushes (derivations), the NO_FLUSH
parameter should b
e set to ‘X’.
Thanks
Praveen -
How to create value request for screen field text box tt1
How to create value request for screen field text box tt1
i have a text box name tt1,
i want f4 help for that .
remember i am asking for screen i.e done from screen layout not selectio-screen.
Thank you,
Regards,
Jagrut Bharatkumar Shukla,Hi,
Create one Search Help in the SE11 for the particular Field that u want to display. In the Screen(Transaction SE51),For that Text Box in the Attributes,in Dict Tab ->Search Help Field give that Search Help Name.
For Eg,
If u want Purchase Order Numbers in that F4 Help.Create one <b>Search Help</b> by giving Table Name as <b>EKKO</b> & <b>Search Help Parameter</b> as <b>EBELN</b> with Lpos & Rpos as 0 & 1.Save & Activate it.
Give this Search Help Name in Dict Tab ->Search Help Field of that Screen Attributes.
Regards,
Padmam. -
It is possible to assign value range to non key fields in the table?
Hi,
I want to give some range of values to the fields which are non key fields in the table.
is it possible?
can anybody tell me the procedure.
Thanks in Advance,
venkatHI,
It is higjly possible in case of Z-table. but in standard table you can't make any modification.
You assign the value range to the domain of field.
go to SE11 and open the database table.
Select the Data Element of the fieldto which you want assign the range.
Click on its domain .
click on Value Range tab.
Set the range.
Regards,
anirban -
Implications of adding new key fields to existing table
Hi All,
I have searched forum regarding this. But didn't find exact answer.
We are planning to add new key fields to existing Ztable. I want to know the implications of this.
I have checked the where used list of table and found no impact. Only one point is making me to think again and again.
If we add key fields to existing table then we have to adjust the table from SE14 to activate it. But this adjustment doesn't ask for TR.
So if i release my TR, entries in other systems will also be adjusted accordingly??? Business is OK with the new fields values to be blank for existing entries.
Thanks,
Vinod.Yes the data in transported systems will also be adjusted. If this table contains too much data make transport at late hours because it will take long and table can't be used while it's adjusted. In this adjustment process data is copied to a temporary table and moved back to original table using move-corresponding command after key added. There will data loss if you remove a key or key fields field length but in your case it shouldn't be a problem.
Edited by: Gungor Ozcelebi on Jul 2, 2009 9:18 AM -
Key fields in variant tables.
Hi masters,
i would like to know the use of "key field" in variant tables.
according to definition:This indicator shows whether a characteristic is used as a key field for accessing tables. Key fields have the value "X". When the table is accessed, the values assigned to the key fields infer values for the other characteristics.
please give an example of its usage,
thanks regards
RahulHello Rahul,
Please view the following link with the explaination and an example.
http://help.sap.com/saphelp_47x200/helpdata/EN/92/58c5cd417011d189ec0000e81ddfac/frameset.htm
Thanks
Amber -
Key fields and non-key field of condition table
Hello Gurus,
what is key fields and non-key field of condition table?
thanks very much!Key field
Each condition table contains keys that can be used for creating dependent condition records.
for example let take condition type PR00.
PR00 uses access sequence PR02 .
Access sequence PR02 has following tables associated with it namely 304, 305 & 306
When you create a conditon record for PR00 with transaction VK11 or VK31, you have a button 'key combination' which is nothing but fields associated with tables 304, 305 & 306.
In brief, Condition records are always created using specific keys. Condition tables are used to define the structure of the keys of a condition record.
Non key field
For example take condition table 144 - sales deal basic data.
Table 144 is associated with access sequence PBUD.
If you check the fields associated with this table (click technical view button), there are three fields at bottom which do not have 'key' check mark -KDATU, PLTYP, KSTAF
So, when you create a condition record for PBUD, system does not propose these 3 fields in 'key combination' and hence are non key fields.
Please reward points for good answers as this would help increase the total donation that SAP will make to the United Nations World Food Programme. -
HI,
I Created a Z table with a key field of type STRING when I activate the table its showing error that the field of type String not permitted can anybody help whether i should not use string for key field.
thanks in advance,Hi,
Use the data type CHAR for the Key field.
Character string. Fields of type CHAR can have a maximum length of 255 in tables. If you want to use longer character fields in tables, you must choose data type LCHR. There are no restrictions on the length of such fields in structures.
Regards,
Arun -
Updation of Primary Key field in HR Tables (PA2001 and PA2002) - Urgent
Can anyone please tell me how to update a primary key field in HR Tables (PA2001 and PA2002).
I need to update sprps field in both the tables. I used HR_Infotype_Operation function module, but still it is not updating the field.
Pls find the following code snippet for the table PA2001 and let me know if any discrepancies :
TABLES: pa2001.
DATA: it_pa2001 TYPE TABLE OF pa2001,
wa_pa2001 LIKE LINE OF it_pa2001,
DATA: date TYPE d.
date = sy-datum - 100.
SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
WHERE begda BETWEEN date and sy-datum.
WRITE:/.
WRITE:/ 'PA 2001 Records'.
if sy-subrc <> 0.
WRITE:/ 'No Data Exists'.
else.
LOOP AT it_pa2001 INTO wa_pa2001.
WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
ENDLOOP.
endif.
LOOP AT it_pa2001 INTO wa_pa2001.
wa_pa2001-sprps = 'X'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '2001'
number = wa_pa2001-pernr
SUBTYPE =
OBJECTID =
LOCKINDICATOR =
VALIDITYEND =
VALIDITYBEGIN =
RECORDNUMBER =
record = wa_pa2001
operation = 'MOD'
TCLAS = 'A'
DIALOG_MODE = '0'
NOCOMMIT =
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
RETURN =
KEY =
ENDLOOP.
if sy-subrc = 0.
write:/ 'SY-subrc is zero'.
write:/ ' Rows modified = ', sy-dbcnt.
else.
write:/ 'No Record(s) updated'.
endif.
commit work.
WRITE: / 'Updated Records in the Internal Table IT_PA2001'.
SELECT pernr sprps begda endda FROM PA2001 INTO CORRESPONDING FIELDS OF TABLE it_pa2001
WHERE begda BETWEEN date AND sy-datum..
LOOP AT it_pa2001 INTO wa_pa2001.
WRITE:/ wa_pa2001-pernr, wa_pa2001-sprps, wa_pa2001-begda, wa_pa2001-endda.
ENDLOOP.Thanks Kiran.
But I need to change this field as we need to lock the records, as soon as the employee fills his/her time sheets which will be sent for HR Payroll, later on.
When I am updating directly the field the database table PA2001, its not updating but for table PA2002, only few records are being updated.
Is there any other alternative for this problem?
Pls reply.
Thanks,
Harish -
Currency Field as a Key Field in Z Table
I am creating a z table in which i have to make a AMount field as a key field . But it is showing a warning while activating the table stating that "Key field AMTFR has num. type DEC: Buffering not possible, Transport restricted"
How can i clear this warning.
Thanks in advanceIn this design I suggest you add one more field to the table called SLAB Code., which will be the key. You can have it as CHAR data type of whatever length you want.
That way its easy to handle, because tomorrow if the slabs change, you are changing the values of the key fields, this way you can avoid that.
You can probably have composite key of Slab code and validity dates.
Regards,
Ravi
Note - Please mark all the helpful answers -
Drop down for a field in a table
hi friends,
need a help from u, how to maintain the drop down for a field in a table..
advance thanks..Hi,
You can use the function module F4IF_INT_TABLE_VALUE_REQUEST
TABLES: T005T.
DATA: BEGIN OF t_t005 OCCURS 0,
land1 TYPE t005-land1,
END OF t_t005.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(6) v_text FOR FIELD P_LAND1.
PARAMETERS: p_land1 TYPE t005-land1.
SELECTION-SCREEN COMMENT 13(35) v_text1.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
v_text = 'Country'.
v_text1 = ' '.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_land1.
REFRESH: t_t005.
SELECT land1
INTO TABLE t_t005
FROM t005.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = 'T005'
PVALKEY = ' '
retfield = 'LAND1'
dynpprog = sy-repid
DYNPNR = sy-dynnr
dynprofield = 'P_LAND1'
callback_program = sy-repid
value_org = 'S'
TABLES
value_tab = t_t005
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks
Naren -
Drop down in the selection for the field from the table
Hi.
i want to put the drop down for the field from the table fo which i dont know the number of entries for the field zregion1 of the table zbwcntry.
please tell me how to use the function module and what could be the line of codes.
the drop down is for the select option on the slection screen of the classical report.
please help .HI,
Check below code..it may help you.
REPORT Zbunu .
TYPES :BEGIN OF STR ,
MATNR TYPE MATNR ,
END OF STR .
DATA : ITAB TYPE TABLE OF STR WITH HEADER LINE,
VAR TYPE MARA-MATNR .
PARAMETERS : S_MATNR TYPE MATNR ,
P_MATNR TYPE MATNR.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MATNR .
SELECT MATNR FROM MARA INTO
CORRESPONDING FIELDS OF TABLE ITAB UP TO 1000 ROWS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'MATNR'
PVALKEY = ' '
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'S_MATNR'
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = 'X'
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
tables
value_tab = ITAB
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards
Ansumesh -
How To select maximum Value in a specifieid field in internal table.
How To select maximum Value in a specifieid field in internal table?
Step : 1
Sort itab by <Field1> descending.
Just sort the internal table by the field.
STEP: 2
Then read the table at index 1.
Read table itab index 1.
ITAB-FIELD = MAX . " Max field will come in the first row of the internal table.
Regards,
Gurpreet -
"Additional Text" set for messageTextInput fields in Classic Table
i have set "Additional Text" for messageTextInput fields in Classic Table and am expecting that to display when the mouse is hovering on that field. however, that is not happening...
what am i doing wrong ? and what can i do to achieve that (NOTE - i cannot do either short or Long Tip because that looks wierd when data is displayed in a table (multiple rows))
thank you.
UPDATE - could anyone tell me where/when/how does the "Additional Text" data get displayed when the page is rendered ? there is hardly any info on this in the devguide and forum. If "Addtional Text" is not the right way to provide additional information on a field what else can be used (note these fields are in a classic table so i cannot use short/long tip)......
Edited by: user11972136 on Feb 4, 2013 10:33 AMHi,
I tried this case and its working for me.
Could you tell us what version of Jdev and OAF you are using? There might be some issue with that version.
Regards,
Sandeep M.
Maybe you are looking for
-
Quick note to mention that the 'You Tube Living Room' application freezes up my pc... I have to terminate internet explorer. My PC is an XP machine about four years old - I do not have a webcam attached, maybe it was that.... there are not any error
-
How to parse a dynamic xml in java
I have to parse a dynamic xml document : the different TheItemNames and the racine are changing . So , can you help me with a code because to parse a xml document you must presents the racine and TheItemNames
-
I get error -50 every time I try to "share" my video. What can I do?
I have tried sharing my video in different formats, but none work. Also, the error message keeps coming up every 5 minutes,.
-
What is the actual use of T180 table????
Hi Sap Gurus, We hav an requirement that instead of using transaction codes VL01,VL01N,VL02,VL02N,VA01,VA02,, we need to use T180 table. So what is actual use of T180?. Why we use this table? Thanks in advance. Regards.....Kumar
-
I have a second hand iPhone, now since the new update my text tone which is the Tri-Tone seems to glitch and repeat the first part multiple times very quickly and then carry on every time I receive a text. I'm just wondering if there is anyone else h