Skip to Content

2 table control in one screen

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Feb 10, 2014 at 02:15 PM

    So what issue you are facing..? what all have you tried..?

    Nabheet

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Feb 10, 2014 at 06: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 11, 2014 at 02: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.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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.

  • Posted on Feb 13, 2014 at 06: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 14, 2014 at 04: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.