‎2009 Jul 23 1:47 PM
Hi all,
My requirment is i am entering the data into screen fields of table control when iam click save button then that data is saving 4 times.
Scenario is based on the field if field = 'y' i need to display the fields of table control in diable mode.i have write the query for this but the i have write append to this this append is reflecting in loop at table control itab.i think for that only i am getting four records in my table control.
when i am deleting also same 4 records are displaying in table control.
With Regards,
saroja.
‎2009 Jul 23 3:20 PM
Dear saroja,
Please,make to some fields as primary key in your z-table.In table control,PAI (update / insert) dont write your code in nested loop,if you have used.
if you are declaring as structure in table control,use chain...field...endchain logic,then move to your z-table.if not,you are using like internal table in table control,just check the values when you are passing to another ITAB.
<<=< Sharing knowledge is a way to innovative >=>>
By,
Yoga
‎2009 Jul 24 3:10 AM
Hi,
saroja ponnam
In ZTABLE atleast you will have one primary KEY.
So only if you have different key, record will saved in Ztable.
If 4 Record is displayed in table control , it will be from Internal Table.
Look at the code where you added a record in IT.
May be the record added 4 times in IT.
Check It and Reply.
‎2009 Jul 24 4:19 AM
Hi Saroja,
<li> try to use the below kind of check before your SELECT statement.
Thanks
Venkat.O*----------------------------------------------------------------------*
* MODULE get_data OUTPUT
*----------------------------------------------------------------------*
MODULE get_data OUTPUT.
IF it_data[] IS INITIAL.
"Write select query here.
"This avoids execution of select query eachtime whenever cursor comes to this place
ENDIF.
ENDMODULE. "get_data OUTPUT
‎2009 Jul 24 7:16 AM
Hi,
Refer:-
it_zekpo is my internal table w/o header line,
wa_zekpo is work area.
Name of input/output fields on screen are:-
wa_zekpo-field1,
wa_zekpo-field2, and so on...
Take a button on the screen with function-code SAVE or in the pf-status take the function code of the standard save button as SAVE.
Use code:-
At screen logic:-
PROCESS BEFORE OUTPUT.
* MODULE status_8003.
LOOP WITH CONTROL po_tab. "po_tab is table control on screen 8003
MODULE read_data.
ENDLOOP.
PROCESS AFTER INPUT.
* MODULE user_command_8003.
LOOP WITH CONTROL po_tab.
MODULE modify_data.
ENDLOOP.
MODULE SAVE_DATA.
In PBO:-
*&---------------------------------------------------------------------*
*& Module READ_DATA OUTPUT
*&---------------------------------------------------------------------*
MODULE read_data OUTPUT.
READ TABLE it_zekpo INTO wa_zekpo INDEX po_tab-current_line. "po_tab is table control name
data : line_count type i.
describe it_zekpo
lines line_count.
po_tab-lines = line_count + 10.
"to increase the number of lines in table control dynamically
ENDMODULE. " READ_DATA OUTPUT
In PAI:-
*&---------------------------------------------------------------------*
*& Module MODIFY_DATA INPUT
*&---------------------------------------------------------------------*
MODULE MODIFY_DATA INPUT.
MODIFY IT_ZEKPO FROM WA_ZEKPO INDEX po_tab-currentline.
"this will modify the contents of existing line
ENDMODULE. " MODIFY_DATA INPUT
*&---------------------------------------------------------------------*
*& Module SAVE_DATA INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE SAVE_DATA INPUT.
DATA : A LIKE SY-DBCNT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'SAVE'. "function code for SAVE button
MODIFY ZEKPO FROM TABLE IT_ZEKPO.
A = SY-DBCNT.
IF SY-SUBRC = 0.
MESSAGE S008 WITH A.
ENDIF.
ENDCASE.
ENDMODULE. " SAVE_DATA INPUT
Hope this helps you.
Regards,
Tarun