Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

TABLE CONTROL VALUES UPDATE

0 Likes
4,564

Hi All. I am working on table control. I am using LOOP WITH CONTROL .  MODULE ENDLOOP. within this i am providing data to be output to the table control. Successful till here. Data gets populated in table control. Now, when the user provides a new entry in the table control, the new value disappears. In PAI, i am not getting the value that the user inserted. suppose the table control has 15 records and the user tries to create new entry on 16th record, then the record doesn't gets updated, even in pai i am not able to get the value of the newly added record. I am not using table control with wizard. But i have defined everything as it should. Can any one help me on this. I want the user shall be able to add new record to the end of the table control, and update it. please provide answers in context with loop with control and not step loop. Thanks in advance.

8 REPLIES 8
Read only

Former Member
0 Likes
2,738

Hi

ypu need to write module in LOOP ENDLOOP under PAI

PAI

LOOP at ITAB

     module modify_itab.

ENDLOOP.

_______________________________________________

module MODIFY_ITAB input.

   MODIFY ITAB INDEX TC-CURRENT_LINE.

     IF sy-subrc <> 0.

        append itab.

     ENDIF.

endmodule.


regards

laxman

Read only

0 Likes
2,738

this is exactly what i am trying to do. In pai if i change any existing record, its coming to the pai, and then i am updating the internal table in pbo, so the changed value gets updated. But when i try to insert new record ... please read the post again..

How can i insert a new record to the last line of the table control ?

Thanks Your attempt appreciated.

Read only

0 Likes
2,738

i think you are not appending, just add append statement as shown in my code

Read only

former_member202818
Active Contributor
0 Likes
2,738

Hi,

The new record has to be updated in internal table of table control.. so that you have to have a new module inside loop at PAI.

MODIFY itab FROM wa INDEX tbc-current_line. "Modify existing records

IF sy-subrc <> 0.       

APPEND wa TO itab.              "Append new record

ENDIF.

For More...

Regards

Sreekanth

Read only

Former Member
0 Likes
2,738

HI,

check this code.

data : t_lines type i.

Descrbe it_tab lines t_lines.  "this is before inserting new record.

if t-current_line > t_lines.

append the record.

else.

modify it index t-current_line.

endif.

Message was edited by: Vijay Vikram

Read only

0 Likes
2,738

this is my code :

REPORT ZTEST_ALV_REPORT2.

TABLES MARA.

CONTROLS V_TABSTRIP TYPE TABSTRIP.

DATA : v_matnr TYPE mara-matnr,

        it_mara TYPE TABLE OF mara,

        wa_mara TYPE mara ,

        ok_code TYPE sy-ucomm,

        v_sel   TYPE c,

        v_lines TYPE i.

CONTROLS v_control TYPE TABLEVIEW USING SCREEN '9000'.

DATA : wa_cols TYPE SCXTAB_COLUMN,

        IT_COLS TYPE TABLE OF SCXTAB_COLUMN .

SELECT-OPTIONS : so_matnr FOR v_matnr.

*DATA wa_mara TYPE mara.

START-OF-SELECTION.

SELECT * FROM mara into TABLE it_mara

          UP TO 500 ROWS WHERE

                         matnr in so_matnr.

IF IT_MARA IS NOT INITIAL .

   DESCRIBE TABLE IT_MARA LINES V_LINES.

ENDIF.

   call SCREEN 9000 .

*&---------------------------------------------------------------------*

*&      Module  STATUS_9000  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE status_9000 OUTPUT.

*  SET PF-STATUS 'xxxxxxxx'.

*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_9000  OUTPUT

*&---------------------------------------------------------------------*

*&      Module  FILL_TABLE_CONTROL  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE fill_table_control OUTPUT.

LOOP AT SCREEN.

     IF screen-name = 'MARA-MATNR'.

         screen-input = 1 .

         screen-color = 5 .

     MODIFY SCREEN.

     ENDIF.

ENDLOOP.

      V_CONTROL-LINES = V_LINES.

      V_CONTROL-V_GRID = 1 .

      APPEND WA_COLS TO IT_COLS.

   READ TABLE IT_MARA INTO

              MARA INDEX V_CONTROL-CURRENT_LINE.

   wa_mara = mara.

ENDMODULE.                 " FILL_TABLE_CONTROL  OUTPUT

*&---------------------------------------------------------------------*

*&      Module  READ_TABLE_CONTROL  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE read_table_control INPUT.

*  IF wa_mara NE mara.

     v_LINES = v_control-lines + 1.

     MODIFY IT_MARA FROM

            MARA INDEX v_lines.

*  ENDIF.

ENDMODULE.                 " READ_TABLE_CONTROL  INPUT



Read only

0 Likes
2,738

*&---------------------------------------------------------------------*

*&      Module  READ_TABLE_CONTROL  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE read_table_control INPUT.

*  IF wa_mara NE mara.

     v_LINES = v_control-lines + 1.

     MODIFY IT_MARA FROM

            MARA INDEX v_lines.

         

          IF sy-subrc <> 0.      

               APPEND wa_mara TO it_mara.             "Append new record

            ENDIF.


*  ENDIF.

ENDMODULE.                 " READ_TABLE_CONTROL  INPUT



change like this

Read only

Former Member
0 Likes
2,738


try this


MODULE read_table_control INPUT.

*  IF wa_mara NE mara.

     if v_LINES  > v_control-lines + 1.

append it_mara from mara.

else.

     MODIFY IT_MARA FROM

            MARA INDEX v_lines.

*  ENDIF.

ENDMODULE.                 " READ_TABLE_CONTROL  INPUT