2014 Nov 20 6:29 AM
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.
2014 Nov 20 6:36 AM
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
2014 Nov 20 6:50 AM
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.
2014 Nov 20 6:53 AM
i think you are not appending, just add append statement as shown in my code
2014 Nov 20 6:54 AM
2014 Nov 20 6:57 AM
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
2014 Nov 20 7:15 AM
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
2014 Nov 20 7:19 AM
*&---------------------------------------------------------------------*
*& 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
2014 Nov 20 7:23 AM
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