Add row based on previous row in table control?
Dear all,
I have a table control with some rows. Every row contains one button. On button click i want to add another row with dirrerent data. I want to add content based on button text or another columns (ex text views text,) based on this text view, I have to add row. One button can click any no of times. On every click i want to add row, but desired position and content should be based on button click. Any help in doing this??
Cheers,
Venkys.
Refer to these old threads referring this table and button problem.
Adding rows to table
How to create different rows in table or in ALV?
and for the current scenario what you can do is ...
in the eventhandler of the button click .
find out the row number by using the code to read index.
then based upon that add the element in the node at the desired position.
finding the row number
data indx type i.
DATA lo_el TYPE REF TO if_wd_context_element.
lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
indx = lo_el->get_index( ).
and the adding the element at the desired position say n
DATA lo_nd_zdealer TYPE REF TO if_wd_context_node.
lo_nd_zdealer = wd_context->get_child_node( name = 'DEALER' ).
data ls_str type wd_this->element_dealer.
ls_str-id = '00023445'.
ls_str-name = 'sarbjeet'.
ls_str-location = 'hosiarpur'.
ls_str-status = '0001'.
lo_nd_zdealer->bind_structure( new_item = ls_str
set_initial_elements = abap_false
index = n
thanks
sarbjeet singh
Similar Messages
-
Finding all rows based on previous rows column value diffrence
I have an interesting requirement. There is a DATE column and a user in a table and I have to find all rows for all the user for which the previous row and current row has time difference of lets say more than 30 minutes. Rows are already sorted by time.
For example in the following table, we need ID 4 and 6 for user 1.
ID User date
1 1 today 1 hour 0 min 0 s
2 1 today 1 hour 1 min 0 s
3 1 today 1 hour 29 min 0 s
*4 1 today 1 hour 59 min 3 s*
5 1 today 2 hour 10 min 2 s
*6 1 today 2 hour 50 min 7 s*
Edited by: user733179 on Mar 5, 2009 12:00 PMHi,
To get all the users in the result set, outer-join to a table (or subquery, as shown bleow) that has one row per user:
WITH got_dif AS
SELECT id, dt, usr
, (dt - LAG (dt)
OVER ( PARTITION BY usr
ORDER BY dt
) -- difference in days
* 24 * 60 AS minutes_dif
FROM table_x
-- WHERE ... -- if needed
, all_users AS
SELECT DISTINCT usr
FROM table_x
SELECT gd.id, gd.dt, au.usr
, NVL2 ( gd.usr
, 'Okay'
, 'Dif is never > 30'
) AS flag
FROM all_users
LEFT OUTER JOIN got_dif ON gd.usr = au.usr
AND gd.minutes_dif > 30
;Notice that the test for a 30-minute difference is part of the join condition.
You don't need the flag column, and you may not want it.
If you would prefer a separate query of just the users that are not in the original result set, then you can use the original query (modified only slightly) as an EXISTS ior NOT IN sub-query. For example:
SELECT DISTINCT usr
FROM table_x
WHERE usr NOT IN
WITH got_dif AS
SELECT id, dt, usr
, (dt - LAG (dt)
OVER ( PARTITION BY usr
ORDER BY dt
) -- difference in days
* 24 * 60 AS minutes_dif
FROM table_x
-- WHERE ... -- if needed
SELECT usr -- Only 1 column in SELECT clause
FROM got_dif
WHERE minutes_dif > 30
; -
Processing of Rows in the Non-visible area - Table Controls
Hi,
I have a table control. At any given point on the screen the table control displays 17 rows. now there is a functionality thru which the user will be able to paste some values into a particular column of the table control from the clipboard. Then the user will press save to save all the data on the table control into a DB table. the problem is the rows that are not visible on the screen i.e. the rows that has to be seen by scrolling the table control. while looping the table control these rows are not getting looped i.e. the looping ends with first 17 visible rows. how do i make the table control loop at the remaining records also?suppose, your table control name is 'table0'
and you declare it as :
'controls table0 type tableview using screen 100.'
so to process all rows of this table control you should assign for it
'table0-lines = n.'
where n is row count that you know.
then you can use following statement
'LOOP AT <internal table> CURSOR <scroll-var>
[WITH CONTROL <table-control> ]
[FROM <line1> ] [TO <line2> ].
...<actions>...
ENDLOOP.'
result: all n rows will be processed. in your case n is greater than 17. -
Add a new column in Agreement Items table control (ME31K/ME32K/ME33K)
Hi guys,
I have a big issue.
How can I add a new column at Agreement Items table control (ME31K/ME32K/ME33K) level.
Thanks a lot.I think i solved the problem . The single way to to that is to modify the SAP standard Screen.
-
Need to add 2 new columns to the existing table control of C223 transaction
Hi ABAP Gurus,
I have to do a screen enhancement for transaction C223.
Below is the requirement:
need to add 2 new columns to the existing table control of C223 transaction.
there is no customer exits, screen exit or user exit present for this transaction C223, i have found one enhancement spot for this transaction.
i dont have any idea how to do this in standard transaction C223, the table control in C223 saves the data to MKAL table and the table control uses the structure MKAL_EXPAND in the screen program.
i have created an append structure for the 2 fields to the standard table MKAL.
Can anyone please suggest me how this can be done in standard screen C223, will the enhancement spot can be used to do this....
please sugest...
Thanks & RegardsHi Santosh,
Thanks for the reply. I have looked into this Enhancement Spot CPFX_SCREEN_SET , inside this there is only one method INPUT_DISABLED having below parameters
IM_MKAL Importing Type MKAL Production Version
EX_MSGID Exporting Type SY-MSGID Messages, Message
EX_MSGTY Exporting Type SY-MSGTY Messages, Message
EX_MSGNO Exporting Type SY-MSGNO Messages, Message
EX_MSGV1 Exporting Type SY-MSGV1 Messages, Message
EX_MSGV2 Exporting Type SY-MSGV2 Messages, Message
EX_MSGV3 Exporting Type SY-MSGV3 Messages, Message
EX_MSGV4 Exporting Type SY-MSGV4 Messages, Message
EX_INPUT_DISABLE Exporting Type CHAR1 Display Only if X Was Set
the BADI definition present here is a SAP internal so we cant implement the BADI , but we can created a enhancement spot implementation for this. as per my understanding on this the enhancement spot is only for making the table control fields display / change . i dont think this can be used to add two new coloumns to C223 table control.
I am not sure thats why seeking your help/valuable sugestion on this.
Please provide your sugestion on this , so that i can come to conclusion on this issue.
Thanks & Regards
Siddhartha Mishra -
Analytical function need to work based on previous rows result.
My data are sorted based on sartdatetime column.but i need the sum(value) based on below condition.
Condition :
i need to check with current row with previous rows
if they are same then i need to sum the value with previous row.
else i need to start the summation.
My data like below:
Rownum Code Sartdatetime Value
1 4619 12/9/2012 11:00 219
2 5344 12/9/2012 14:39 27
3 4619 12/9/2012 15:11 20
4 4619 12/9/2012 19:33 14
5 4619 12/9/2012 20:53 16
6 6851 12/9/2012 21:21 1
7 4619 12/9/2012 21:22 35
8 5623 12/10/2012 1:59 4
9 5623 12/10/2012 2:03 3
10 5623 12/10/2012 2:06 5
11 4619 12/10/2012 2:17 1
12 5623 12/10/2012 2:18 5
13 5623 12/10/2012 2:25 2
14 5623 12/10/2012 2:27 2
15 4619 12/10/2012 2:29 30
Eg:
Take the first row. For that no previous rows. So we directly added the value like below.
Rownum Code Sartdatetime Value sum(val)
1 4619 12/9/2012 11:00 219 219
take the seconds row, we can check the code value (5344)with first row value (4619). the values are different . So our summation like.
2 5344 12/9/2012 14:39 27 27
for third row , we can check the code value (4619)with second row value (5344). the values are different . So our summation like.
3 4619 12/9/2012 15:11 20 20
for fourth row we can check the code value (4619)with second row value (4619). the values are same. So our summation like.
4 4619 12/9/2012 19:33 14 34 - The sum of previous row result.
5 th row also same value so
5 4619 12/9/2012 20:53 16 50T he sum of previous row result.
then the same value come again in 7 th row so here we need to start the summation like below.
7 4619 12/9/2012 21:22 35 35.
i want the result like below.
Rownum Code Sartdate time Value Expected result
1 4619 12/9/2012 11:00 219 219
2 5344 12/9/2012 14:39 27 27
3 4619 12/9/2012 15:11 20 20
4 4619 12/9/2012 19:33 14 34
5 4619 12/9/2012 20:53 16 50
6 6851 12/9/2012 21:21 1 1
7 4619 12/9/2012 21:22 35 35
8 5623 12/10/2012 1:59 4 4
9 5623 12/10/2012 2:03 3 7
10 5623 12/10/2012 2:06 5 12
11 4619 12/10/2012 2:17 1 1
12 5623 12/10/2012 2:18 5 5
13 5623 12/10/2012 2:25 2 7
14 5623 12/10/2012 2:27 2 9
15 4619 12/10/2012 2:29 30 30
Please helpHi,
Welcome to the forum!
Here's one way to do what you want:
WITH got_grp_id AS
SELECT code, starttime, value
, ROW_NUMBER () OVER ( ORDER BY starttime ) AS r_num
, ROW_NUMBER () OVER ( ORDER BY starttime )
- ROW_NUMBER () OVER ( PARTITION BY code
ORDER BY starttime
) AS grp_id
FROM table_x
SELECT r_num
, code
, starttime
, value
, SUM (value) OVER ( PARTITION BY code, grp_id
ORDER BY starttime
) AS sum_value
FROM got_grp_id
ORDER BY starttime
;For an explanation of the Fixed Difference technique, see {message:id=9953384} and/or {message:id=9957164}
Whenever you have a problem, please post CREATE TABLE and INSERT statements for your same data. For example:
CREATE TABLE table_x
( code NUMBER (4)
, starttime DATE UNIQUE
, value NUMBER
INSERT INTO table_x (code, starttime, value)
VALUES (4619, TO_DATE ( '12/9/2012 11:00', 'MM/DD/YYYY HH24:MI'),
219);
INSERT INTO table_x (code, starttime, value)
VALUES (5344, TO_DATE ( '12/9/2012 14:39', 'MM/DD/YYYY HH24:MI'),
27);
INSERT INTO table_x (code, starttime, value)
VALUES (4619, TO_DATE ( '12/9/2012 15:11', 'MM/DD/YYYY HH24:MI'),
20);
INSERT INTO table_x (code, starttime, value)
VALUES (4619, TO_DATE ( '12/9/2012 19:33', 'MM/DD/YYYY HH24:MI'),
14);
INSERT INTO table_x (code, starttime, value)
VALUES (4619, TO_DATE ( '12/9/2012 20:53', 'MM/DD/YYYY HH24:MI'),
16);
INSERT INTO table_x (code, starttime, value)
VALUES (6851, TO_DATE ( '12/9/2012 21:21', 'MM/DD/YYYY HH24:MI'),
1);
INSERT INTO table_x (code, starttime, value)
VALUES (4619, TO_DATE ( '12/9/2012 21:22', 'MM/DD/YYYY HH24:MI'),
35);
INSERT INTO table_x (code, starttime, value)
VALUES (5623, TO_DATE ( '12/10/2012 1:59', 'MM/DD/YYYY HH24:MI'),
4);
INSERT INTO table_x (code, starttime, value)
VALUES (5623, TO_DATE ('12/10/2012 2:03' , 'MM/DD/YYYY HH24:MI' ),
3);
INSERT INTO table_x (code, starttime, value)
VALUES (5623, TO_DATE ( '12/10/2012 2:06', 'MM/DD/YYYY HH24:MI'),
5);
INSERT INTO table_x (code, starttime, value)
VALUES (4619, TO_DATE ( '12/10/2012 2:17', 'MM/DD/YYYY HH24:MI'),
1);
INSERT INTO table_x (code, starttime, value)
VALUES (5623, TO_DATE ( '12/10/2012 2:18', 'MM/DD/YYYY HH24:MI'),
5);
INSERT INTO table_x (code, starttime, value)
VALUES (5623, TO_DATE ( '12/10/2012 2:25', 'MM/DD/YYYY HH24:MI'),
2);
INSERT INTO table_x (code, starttime, value)
VALUES (5623, TO_DATE ('12/10/2012 2:27' , 'MM/DD/YYYY HH24:MI' ),
2);
INSERT INTO table_x (code, starttime, value)
VALUES (4619, TO_DATE ( '12/10/2012 2:29', 'MM/DD/YYYY HH24:MI'),
30);
COMMIT; See the forum FAQ {message:id=9360002}
Output:
R_NUM CODE STARTTIME VALUE SUM_VALUE
1 4619 12/9/2012 11:00 219 219
2 5344 12/9/2012 14:39 27 27
3 4619 12/9/2012 15:11 20 20
4 4619 12/9/2012 19:33 14 34
5 4619 12/9/2012 20:53 16 50
6 6851 12/9/2012 21:21 1 1
7 4619 12/9/2012 21:22 35 35
8 5623 12/10/2012 01:59 4 4
9 5623 12/10/2012 02:03 3 7
10 5623 12/10/2012 02:06 5 12
11 4619 12/10/2012 02:17 1 1
12 5623 12/10/2012 02:18 5 5
13 5623 12/10/2012 02:25 2 7
14 5623 12/10/2012 02:27 2 9
15 4619 12/10/2012 02:29 30 30Edited by: Frank Kulash on Dec 24, 2012 6:44 AM
Added sample data. -
Editing one row at a time in a table control
Good day all
I need your urgent assistance with the problem below:
At first time load, the table control needs to allow input on the first line only, validation will then be done through clicking a “check” button. After the check has been done, table control needs to open up the second row for input and grey out the first one. This sequence needs to follow every time a check has been performed.
After the check has been done, table control needs to show the previously entered data on the first line but grey it out, and open up only the second row for input.
The table control has been created using a wizard with an internal table and I am working on dialog/screen programming. The table control has been created as an output control but it needs to perform as both and output and input control.
I have made changes to the “MODULE tc_create_ph2_get_lines OUTPUT.” Which is created by the wizard as follows:
The module is in the PBO Section.
IF it_tab is initial. "it_tab being the internal table that stores the data from the table control
DESCRIBE TABLE it_tab LINES lv_num.
LOOP AT SCREEN.
IF tc_create_ph2-current_line <> 1.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
tc_create_ph2-current_line = lv_num + 1.
LOOP AT SCREEN.
IF tc_create_ph2-current_line <> lv_num + 1 .
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
Your assistance will be highly appreciated.Hi Dineo,
This module would make all line non editable except the last line, which will be open for input.
LOOP AT IT_ST INTO WA_ST WITH CONTROL MATERIAL CURSOR
MATERIAL-CURRENT_LINE.
module mod_screen.
ENDLOOP.
module MOD_SCREEN output.
data : tc_lines type n.
describe table it_st LINES tc_lines.
* loop at screen.
if material-current_line le tc_lines.
loop at screen.
screen-input = 0.
modify screen.
endloop.
endif.
endmodule.
When checking and saving data, after saving data delete all lines of tc internal table except the last added row, if you want only the last record to appear in the table. -
Adding a Multiple Rows Without Clearing Previous Row Details
Dear All,
I want to Add multiple rows at the same time in a matrix at the same time .My problem here is When i add the New rows to the matrix already added data need to remail in the matrix , I cant put Matrix.Clear or Datasource.clear.
When i add multiple rows previous row details is duplicated to next rows how to avoid thus
MohamedHi,
try this,
If (pVal.ItemUID = "BTNUID") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then
Dim fr As SAPbouiCOM.Form
Dim sel As Integer
Dim oMatrix1 As SAPbouiCOM.Matrix
fr = SBO_Application.Forms.Item(FormUID)
oMatrix1 = fr.Items.Item("mtx_136").Specific
fr.DataSources.DBDataSources.Item(2).Clear()
sel = oMatrix1.GetNextSelectedRow
oMatrix1.AddRow(1, sel)
End If
"mtx_136" is your matrix ID
and "BTNUID" is your button ID -
How to make Single row of an entire collumn of table control- Changeable
Hi ,
In Module Pool , in table control , I've all the rows in a specific column as "read only". However, with a specific "if statement" I want one row of that column as editable.
For example ,
if itab-name1 = 'PRITHVI'.
Make that row, editable.
Keep the rest of the column unaffected.
I used the following code in my program in PBO:
module STATUS_0005 output.
Loop AT SCREEN .
if screen-name = '%#AUTOTEXT009'
AND I_MARKLIST-STUDENT_NAME1 = 'SUNIL SHARMA'.
SCREEN-INPUT = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
endmodule.
I've tried this, but in vain .. ! Please give me suitable solutions ASAP.Hi,
try like this..
in the PBO of screen flow logic..
loop at I_MARKLIST with control tc.
MODULE CHANGE.
endloop.
IN THAT CHANGE MODULE WRITE...
IF I_MARKLIST-STUDENT_NAME1 = 'SUNIL SHARMA'.
LOOP AT SCREEN.
IF SCREEN-NAME = '%#AUTOTEXT009'.
SCREEN-INPUT = 1.
ELSE.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
SCREE-INPUT = 0.
MODIFY SCREEN.
ENDLOOP.
ENDIF. -
The first row should be editable in a table control
Hi Everyone,
I have a requirement for a screen, where we have a table control and we allow only a column to be in editable mode.
Now we dont require the entire coulmn to be on editable or input mode, we require only the first entry(latest entry) to be in ediatble mode. Rest should be in display mode.
Can we accomplish this.
Regards,
RajHi,
try this way..
PROCESS BEFORE OUTPUT.
* Module screen GUI-Screen&Status and Screen Logic
MODULE status_1020.
* Table control for OUTPUT
LOOP AT t_zcxref_classes INTO wa_zcxref_classes
WITH CONTROL tc_batch .
MODULE charac_classname_out.
ENDLOOP.
MODULE charac_classname_out OUTPUT.
* Table control reading values from input screen & displaying on screen
READ TABLE t_zcxref_classes INTO wa_zcxref_classes
INDEX tc_batch-current_line.
* Logic for screen Display when Required Flag = 'D'
IF tc_batch-current_line = 1.
LOOP AT SCREEN.
IF screen-name = 'WA_ZCXREF_CLASSES-ATWRT'. "Pass the field name in the table control to make disply
screen-input = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
ENDMODULE. " CHARAC_CLASSNAME_OUT OUTPUT
Prabhuda -
Add Custom field to standard screen with table control
Hello,
I need to add two custom fields to a standard screen in CAT2 transaction(not using any screen exit).I will be given SSCR key.The standard screen (screen no. 2100) only has a table control.
How can I add the custom field such that it appears as a field on the screen when CAT2 transaction is opened.
Do i need to write any code?
I'm new to ABAP so could you please give a detailed explanation.
Also, do i need to change the 'fixed columns' field in the table control?
Regards,
Monica.hi,
1) find the screen
2) add new fields to the screen
3) program PBO and PAI
regards,
Wojciech -
Add columns with custom fields in the table control of MIGO
Hi,
I have to add custom fields in the table control view of item in the MIGO. I have added the fields in the GOITEM structure and i am able to display it in the item details tab. I want the same fields to be visible as columns in the table control view of the items.
I found that TV_GOITEM is the control in SAPLMIGO program referring to the table control of items but it is referring only to the standard fields available in Screen 200.
Please let me know if there is any screen exit or option to add the custom fields in the control TV_GOITEM.
Thanks.Hi,
Thanks for your reply. I have added the custom fields in the item detail. But the customer wants the custom fields in the table view also.
Is there any screen exit available to modify the table control of MIGO?
Thanks. -
Is it possible to add icons to a field in the table control ?
Dear Gurus,
Greetings..............
Is it possible to add icons to the line item of a field in the table control ?
Thanks in advance
Raj KumarHI
YES IT IS POSSIBLE.
DO THE FOLLOWING
1.DECLARE INCLUDE <ICON>.
2.IN YOUR INTERNAL TABLE DECLARE FIELD ICON
icon(4) TYPE c,
3. POPULATE YOUR INTERNAL TABLE WITH APPROPRIATE ICONS BY SELECTING FROM INCLUDE SPECIFIED ABOVE.
EG:
wa2-icon = '@5C@'.
4.PASS IT TO FIELDCAT
wa_fieldcat-fieldname = 'ICON'.
wa_fieldcat-icon = 'X'. " Displayed as Icon
wa_fieldcat-tabname = ' '.
wa_fieldcat-seltext = 'Status'.
wa_fieldcat-coltext = text-001.
APPEND wa_fieldcat TO it_fieldcat. -
Add fields to CAT2 data entry area table control
Hi All,
I have a requirement where in I need to add a column after every day ( Moday , Tuesday.. ) in CAT2 to enable the user to enter short text description for the time entry accountabiity. For this I will have to add 7 additional columns to the table control of the data entry area one beside each day. The description entered by the user should be updated in the database.
I am thinking of using screen exit CATS0012. But not very sure how to go about it.
Pls help.
Thanks in Advance.
Regards,
JoshiThanks Ankush. I am going for the CATS0005 option. I have created a customer project TSHEET within an existing PS package on the system. The system prompted me to obtain a transport number which I guess will attach the new project to the package in future.
Could you advise further on how to do this in practise? My instructions say 'on the initial project administration screen select the Enhancement components field and choose Change. In fact there appear to be 2 options - either Components or Enhancements assignement. If I choose Enhancements assignment I am prompted to enter the name of an exit. I entered CATS0005 as I have to bring this into the customer project somehow. Within package MY_CATS_INTERFACE appeared however CATS0005 was not recognised within this package. Likewise CI_CATSDB was not recognised.
Any advise useful
Thanks
Rachel -
Count MySQL rows based off Value in Dynamic Table
Greetings all. I have 2 MySQL tables; 1 that contains the names of my classes.(Class A, Class, B, etc.) and 1 table that contains the names of students in each Class (for example Class A: John Doe; Class A: Susie Smith.; Class B: Jane Doe). In the 2nd table the Class name is in its own column and the student's name is in a 2nd column.
I currently have a dynamic repeating table that lists the names of all of the classes from the 1st table. What I'm trying to do is add a second column to this repeating dynamic table that lists the number of students in each class. For example; Row 1 of the dynamic table would say "Class A | 5; Class B | 3; Class C | 7, etc.). The dynamic table works perfectly to list the class names. For the life of me I can't figure out how to perform a count for each class to insert in the repeating table. I will be adding more Classes which as why I'm trying to set up the counting query dynamically. So far I have only been able to figure out how to count the total rows in the 2nd table, or count the rows with a specified class name. Any advice or guidance on how to count the number of rows in the 2nd MySQL table based off the class name in the repeating table is much appreciated. Thank you for any and all help. Have a great day.Select count(*), Class from MyTable
Group by Class
Time to learn about SQL:
http://www.w3schools.com/sql/sql_intro.asp
Maybe you are looking for
-
Uploaded custom, theme not showing in repository
I have copied a existed theme_4 from images/themes/theme_4 to them_200. when i am trying to export the same from repository, that is not showing in the list.. I have followed the below steps to create new custom theme 1) in images/themes/theme_4 copi
-
Disk needs to be repaired - which disc to use SL/Tiger?
I've just done a verify disk, and it needs repairing. It then asks you start up your computer with another disc - such as Mac Installation Disc - and then use Disk Utility to repair disk. What I'm not sure about is, do I use the disc for Snow Leopar
-
How does LR use Daylight/Tungsten settings in a camera profile?
Didn't see this in the very excellent DNG profile faq. If I make a profile that has different settings for daylight and tungsten, how exactly does LR decide when to use each? For instance, I would imagine that if I choose the Tungsten preset for WB,
-
Perfect Hardware for Gaming?
hi guys, i'm wanting to buy a new MacPro... to use for day-trading, but also for serious gaming (PC games via BootCamp). Although I'm willing to spend whatever money it takes on hardware to get the best possible gaming experience, I don't want to was
-
TS4118 Can I retrieve to do list from old calendar after upgrading to mountain lion?
Can I retrieve "to do list" from old calendar after upgrading to mountain lion?