02-10-2014 1:31 PM
Hi all,
I have req. where i have 2 table control in 1 screen. and i need to transfer data from one table control to another table control. when we click on pushbutton. i need to transfer slected data from frst table control to another table control where line is selected.
can you plz help in this..
Thanks
02-10-2014 2:15 PM
So what issue you are facing..? what all have you tried..?
Nabheet
02-11-2014 10:04 AM
Hi Nabheet,
I have got data in first Table control. Lets say 10 records...Now i select 4th record in first table control and at the same time i selected 7th row in 2nd table control.. My req is to get 4th record in 7th row position in 2nd table control.when i press the pushbutton
i tried to write the same in PAI..but when i press the pushbutton ...it is not working as it is not holding the selected record.
TYPES : BEGIN OF TYTAB1 ,
CH1 TYPE C ,
CARRID TYPE SFLIGHT-CARRID ,
CONNID TYPE SFLIGHT-CONNID ,
FLDATE TYPE SFLIGHT-FLDATE ,
PRICE TYPE SFLIGHT-PRICE ,
END OF TYTAB1.
TYPES : BEGIN OF TYTAB2 ,
CH2 TYPE C ,
CARRID TYPE SPFLI-CARRID ,
CONNID TYPE SPFLI-CONNID ,
CITYFROM TYPE SPFLI-CITYFROM ,
CITYTO TYPE SPFLI-CITYTO ,
END OF TYTAB2 .
DATA : ITAB1 TYPE STANDARD TABLE OF TYTAB1.
DATA : ITAB2 TYPE STANDARD TABLE OF TYTAB2.
DATA : WATAB1 TYPE TYTAB1.
DATA : WATAB2 TYPE TYTAB2.
DATA : OKCODE TYPE SY-UCOMM .
CONTROLS : TB1 TYPE TABLEVIEW USING SCREEN 9000.
CONTROLS : TB2 TYPE TABLEVIEW USING SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
SELECT CARRID CONNID FLDATE PRICE FROM SFLIGHT INTO CORRESPONDING FIELDS OF TABLE ITAB1 UP TO 30 ROWS.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
CASE OKCODE.
WHEN 'LEFT'.
data : l_index type sy-index.
data : l2_index type sy-index.
clear watab1.
loop at itab1 into watab1 where ch1 = 'X'.
modify itab1 from watab1 index sy-tabix transporting ch1.
read table itab2 into watab2 with key ch2 = 'X'.
clear l_index.
l_index = sy-tabix.
check sy-subrc eq 0.
watab2-ch2 = space.
modify itab2 from watab2 index l_index.
endloop.
Thanks
02-10-2014 6:27 PM
Hi,
I didnt got the last line. When you click push button you want to transfer data from one table control to another table control.
You mean to say what all data is there in 1st table control should transfer to second one?
Am I right?
BR
Sumeet
02-11-2014 2:44 AM
What's the difficulty you are facing?
It's nothing but transfer from first table control's internal table data to second table control's internal table in your PUSH button PAI business logic.
02-11-2014 10:05 AM
I have got data in first Table control. Lets say 10 records...Now i select 4th record in first table control and at the same time i selected 7th row in 2nd table control.. My req is to get 4th record in 7th row position in 2nd table control.when i press the pushbutton
i tried to write the same in PAI..but when i press the pushbutton ...it is not working as it is not holding the selected record.
TYPES : BEGIN OF TYTAB1 ,
CH1 TYPE C ,
CARRID TYPE SFLIGHT-CARRID ,
CONNID TYPE SFLIGHT-CONNID ,
FLDATE TYPE SFLIGHT-FLDATE ,
PRICE TYPE SFLIGHT-PRICE ,
END OF TYTAB1.
TYPES : BEGIN OF TYTAB2 ,
CH2 TYPE C ,
CARRID TYPE SPFLI-CARRID ,
CONNID TYPE SPFLI-CONNID ,
CITYFROM TYPE SPFLI-CITYFROM ,
CITYTO TYPE SPFLI-CITYTO ,
END OF TYTAB2 .
DATA : ITAB1 TYPE STANDARD TABLE OF TYTAB1.
DATA : ITAB2 TYPE STANDARD TABLE OF TYTAB2.
DATA : WATAB1 TYPE TYTAB1.
DATA : WATAB2 TYPE TYTAB2.
DATA : OKCODE TYPE SY-UCOMM .
CONTROLS : TB1 TYPE TABLEVIEW USING SCREEN 9000.
CONTROLS : TB2 TYPE TABLEVIEW USING SCREEN 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
SELECT CARRID CONNID FLDATE PRICE FROM SFLIGHT INTO CORRESPONDINGFIELDS OF TABLE ITAB1 UP TO 30 ROWS.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
CASE OKCODE.
WHEN 'LEFT'.
data : l_index type sy-index.
data : l2_index type sy-index.
clear watab1.
loop at itab1 into watab1 where ch1 = 'X'.
modify itab1 from watab1 index sy-tabix transporting ch1.
read table itab2 into watab2 with key ch2 = 'X'.
clear l_index.
l_index = sy-tabix.
check sy-subrc eq 0.
watab2-ch2 = space.
modify itab2 from watab2 index l_index.
endloop.
Thanks
02-11-2014 11:12 AM
DATA: tmp_index TYPE sy-tabix.
loop at itab1 where ch1 = 'X'.
CLEAR: tmp_index.
read table itab2 with key ch2 = 'X'.
if sy-subrc = 0.
tmp_index = sy-tabix. "Index of the second table control selected record
CLEAR: itab2.
itab2-carrid = itab1-carrid.
itab2-connid = itab1-connid.
INSERT itab2 INDEX tmp_index.
endif.
endloop.
02-11-2014 12:17 PM
Hi Nabheet i tried your code. its not working as i the selected values is not 'X'. hence not going inside the loop.
02-11-2014 12:17 PM
Hi prabhu i tried your code. its not working as i the selected values is not 'X'. hence not going inside the loop.
02-11-2014 12:24 PM
Have you assigned the selection line CH1 and CH2 during table control creation?
02-11-2014 5:16 PM
yes ofcorse...i have assingned ch1 for tbcontrol1 and ch2 for table contrl2.
can you give a small example ...
02-12-2014 2:43 AM
If you had assigned, then automatically on selection, the value would become 'X' in PAI.
Example for?
02-12-2014 9:49 AM
TYPES : BEGIN OF STR ,
ch1 TYPE c ,
CARRID TYPE SFLIGHT-CARRID ,
CONNID TYPE SFLIGHT-CONNID ,
FLDATE TYPE SFLIGHT-FLDATE ,
PRICE TYPE SFLIGHT-PRICE ,
END OF STR.
TYPES : BEGIN OF STR1 ,
ch2 TYPE c ,
CARRID TYPE SPFLI-CARRID ,
CONNID TYPE SPFLI-CONNID ,
COUNTRYFR TYPE SPFLI-COUNTRYFR ,
COUNTRYTO TYPE SPFLI-COUNTRYTO ,
CITYFROM TYPE SPFLI-CITYFROM ,
CITYTO TYPE SPFLI-CITYTO ,
END OF STR1 .
ch1 and ch2 i have assigned in screen element. at the below...when designing table control tb1 and tb2.
i need a small example to display values from 1 table control to another based on our selection..
Thanks
02-12-2014 10:10 AM
The code which I had presented above should work.
Have you tested that code in PAI of that push button?
Can you paste the screen shot of your screen?
Sometimes problems arise because of layout of two table controls in one screen.
02-13-2014 8:38 AM
Hi Arun,
In screen element, table control1, w/sel cloumn i have given wa_str-ch1....to slect particular row. similarly for 2nd table control i have given wa_str1-ch2.
this ch1 and ch2 i have declared in types dec. for both sflight and spfli structures.
02-13-2014 8:48 AM
HI arun,
I tried the same code which you have given in debug mode...the issue is it is not selecting the particular row and hence not going inside the loop statement.
lets say a small example...
types: begin of ty1,
matnr type mara-matnr,
ernam type mara-ernam,
ch1,
end of ty1.
types: begin od ty2,
matnr type mara-matnr,
ernam type mara-ernam,
end of ty2.
it1 type table of ty1 it2 type table ty2. wa1 type ty1 wa2 type ty2. PROCESS BEFORE OUTPUT. MODULE STATUS_9000. loop at it1 into wa1 WITH CONTROL tb1 . endloop. loop at it2 into wa2 WITH CONTROL tb2 . endloop. * PROCESS AFTER INPUT. loop at it1. endloop. loop at it2. ENDLOOP. MODULE USER_COMMAND_9000. DATA: tmp_index TYPE sy-tabix. loop at it1 into wa1 where ch1 = 'X'. CLEAR: tmp_index. read table it2 into wa2 with key ch2 = 'X'. if sy-subrc = 0. tmp_index = sy-tabix. "Index of the second table control selected record CLEAR: wa2. wa2-matnr = wa1-matnr. wa2-ernam = wa1-ernam. * INSERT INTO INDEX tmp_index. endif. endloop. in the screen element i have given w/sel column as wa1-ch1 for tb1.....and wa2-ch2 as tb2.
02-13-2014 9:48 AM
Ok. You have mapped work area into table control.
Try with this code:
DATA: tmp_index TYPE sy-tabix.
loop at itab1 into watab1 where ch1 = 'X'.
CLEAR: tmp_index.
read table itab2 into watab2 with key ch2 = 'X'.
if sy-subrc = 0.
tmp_index = sy-tabix. "Index of the second table control selected record
CLEAR: itab2.
watab2-carrid = watab1-carrid.
watab2-connid = watab1-connid.
INSERT watab2 into itab2 INDEX tmp_index.
endif.
endloop.
02-14-2014 3:56 AM
Hi Arun, I tried your above code.. But when i put debugger on loop statement //and execute the report...it is bypassing the code because it is not holding the X(selected values). i have 2 questions. ch1 ..i have declared in types structure along with other fields...and when i created the table control..i have put CH1 as a field also. and in screen attributes at bottom i have given..w/sel column as wa-ch1. is this fine? Thanks
02-14-2014 4:09 AM
While creating table control, during line selectability you have to assign ch1 for first table control and ch2 for second table control.
02-14-2014 4:32 AM
Yes i did the same..i have assign for both the table controls... is it possible if you can give sample code like 2 table control with 2-2 same fields.. and carrid and connid and transfer the values from 1 Tb1 to another 2 TB2. it would be great help as i dont understand why is it not working? Thanks
02-14-2014 4:50 AM
Can you paste the full screen shot of your screen FLOW LOGIC?
You have to ensure screen flow logic is in the following order.
PROCESS BEFORE OUTPUT.
First table control codes
Second table control codes
MODULE STATUS_SCREEN.
PROCESS AFTER INPUT.
First table control codes
Second table control codes
MODULE USER_COMMAND_SCREEN
If not, arrange it in the above order.
02-13-2014 6:19 AM
Write it in the PAI at the click of your pushbutton.
FORM transfer_data .
DATA: lt_index_rows1 TYPE lvc_t_row,
lt_index_rows2 TYPE lvc_t_row,
ls_index_rows LIKE LINE OF lt_index_rows1,
ls_sflight LIKE LINE OF gt_sflight_1,
ls_sflight1 LIKE LINE OF gt_sflight_1,
ls_sflight_temp LIKE LINE OF gt_sflight_1,
lv_lines1 TYPE i,
lv_lines2 TYPE i,
lv_flag1 TYPE i,
lv_flag2 TYPE i.
CALL METHOD gr_grid1->get_selected_rows
IMPORTING
et_index_rows = lt_index_rows1.
CALL METHOD gr_grid2->get_selected_rows
IMPORTING
et_index_rows = lt_index_rows2.
DESCRIBE TABLE lt_index_rows1 LINES lv_lines1.
IF sy-subrc <> 0.
MESSAGE 'Select a row from the first table' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
IF lv_lines1 <> 1.
MESSAGE 'Select only one row' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
DESCRIBE TABLE lt_index_rows2 LINES lv_lines2.
IF sy-subrc <> 0.
MESSAGE 'Select a row from the second table' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
IF lv_lines2 <> 1.
MESSAGE 'Select only one row' TYPE 'S' DISPLAY LIKE 'E'.
ELSE.
CLEAR ls_index_rows.
READ TABLE lt_index_rows1 INTO ls_index_rows INDEX 1.
IF sy-subrc = 0.
READ TABLE gt_sflight_1 INTO ls_sflight INDEX ls_index_rows-index.
IF sy-subrc = 0.
CLEAR ls_index_rows.
READ TABLE lt_index_rows2 INTO ls_index_rows INDEX 1.
IF sy-subrc = 0.
READ TABLE gt_sflight_2 INTO ls_sflight1 INDEX ls_index_rows-index.
IF sy-subrc = 0.
CLEAR ls_sflight_temp.
MOVE ls_sflight1 TO ls_sflight_temp.
CLEAR ls_sflight1.
MOVE ls_sflight TO ls_sflight1.
CLEAR ls_sflight.
MOVE ls_sflight_temp TO ls_sflight.
CLEAR ls_sflight_temp.
LOOP AT gt_sflight_2 INTO ls_sflight_temp.
IF ls_sflight_temp = ls_sflight1.
lv_flag2 = 1.
* MESSAGE 'Data Already Exists' TYPE 'E' DISPLAY LIKE 'E'.
* LEAVE TO SCREEN 0.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
LOOP AT gt_sflight_1 INTO ls_sflight_temp.
IF ls_sflight_temp = ls_sflight.
* MESSAGE 'Data Already Exists' TYPE 'E' DISPLAY LIKE 'E'.
* LEAVE TO SCREEN 0.
lv_flag1 = 1.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
IF lv_flag1 = 1 AND lv_flag2 = 1.
MESSAGE 'In both table data already exists.' TYPE 'S' DISPLAY LIKE 'E'.
ELSEIF lv_flag2 = 1.
MESSAGE 'Table 2 has already that data' TYPE 'S' DISPLAY LIKE 'E'.
CLEAR ls_index_rows.
READ TABLE lt_index_rows1 INTO ls_index_rows INDEX 1.
DELETE gt_sflight_1 INDEX ls_index_rows-index.
INSERT ls_sflight INTO gt_sflight_1 INDEX ls_index_rows-index.
* APPEND ls_sflight TO gt_sflight_1.
ELSEIF lv_flag1 = 1.
MESSAGE 'Table 1 has already that data' TYPE 'S' DISPLAY LIKE 'E'.
CLEAR ls_index_rows.
READ TABLE lt_index_rows2 INTO ls_index_rows INDEX 1.
DELETE gt_sflight_2 INDEX ls_index_rows-index.
INSERT ls_sflight1 INTO gt_sflight_2 INDEX ls_index_rows-index.
* APPEND ls_sflight1 TO gt_sflight_2.
ENDIF.
CALL METHOD gr_grid1->refresh_table_display.
CALL METHOD gr_grid2->refresh_table_display.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CALL METHOD gr_grid1->refresh_table_display.
CALL METHOD gr_grid2->refresh_table_display.
I did it a little bit fast. Improve it where necessary.
Regards
Dhananjay
02-14-2014 4:58 AM
Hi
You can just transfer the contents by looping the internal table that you assign for your table control to the work area of the other table control and appending it. You have to write the code in PAI.
Warm Regards
Suneesh