‎2009 Feb 28 6:50 AM
Hi Guru's,
I have a table control and the its ready for input.
When I enter the data and press enter the data is being updated in the ztable.
But my requierment is the data should be updated only on pressing the save button and the data should be visible in the table control even after pressing the enter key.
Please suggest the logic.
regards,
W. Archana
‎2009 Mar 02 3:38 AM
Hi
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 solves your problem.
Thanks & Regards,
Tarun Gambhir
‎2009 Mar 01 10:28 AM
Block Enter by using:
Check SY-UCOMM NE ' '.
MODULE user_command_0100 INPUT.
CHECK SY-UCOMM NE ' ' .
CASE sy-ucomm.
WHEN 'SAVE'.
Modify <>.
ENDCASE.
ENDMODULE.
Hope this resolves your issue.
Regards,
Gurpreet
‎2009 Mar 02 5:57 AM
Hi Guru's ,
I tried with the logic but didn't work pleas esuggest....got stuck just because of it..
Regards,
W. Archana
‎2009 Mar 02 6:07 AM
Hi,
Try with the above logic provided with me...
It will definitely work.
Take the function code for the for the standard save button in pf-status as SAVE.
Regards,
Tarun
‎2009 Mar 02 6:23 AM
Hi.
I'hv done the same but... my ztable is been updated with entries on pressing the standard save button....but my problem is when I press the enter key the table control fields become blank...
how to over come this issue......
I hope I'm clear what the problem is ?
Regards,
W. Archana
‎2009 Mar 02 6:28 AM
Hi,
When you give some data in the table control and hit ENTER key, PAI is executed:-
*&---------------------------------------------------------------------*
*& 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
So this module will be executed, as it contains no use of sy-ucomm. Automatically this code will be executed and the line of table control will be appended to the internal table inside the loop with table control.
Make sure that you dont use the sy-ucomm value for this module.
And definitely it will work
Regards,
Tarun
‎2009 Mar 02 6:32 AM
hi,
To retain values after pressing ENTER
PROCESS BEFORE OUTPUT.
LOOP AT it_table INTO workarea WITH CONTROL <tablecontrol name>.
MODULE map_fields.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Module map_fields OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
"screennames = program field names.
"example ztrip-sno = screen name i,e table control field
"wa_trip-sno. = Program field, i,e work area of ur program.
"below is the example for table control which have four fields.
ztrip-sno = wa_trip-sno.
ztrip-expen = wa_trip-expen.
ztrip-curr = wa_trip-curr.
ztrip-amot = wa_trip-amot.
Hope it helps you.
Thanks & REgards
Always Learner
‎2009 Mar 02 7:03 AM
Hi ,
I tried this also but didn't help.....
please suggest....
Regards,
W. Archana
‎2009 Mar 02 7:04 AM
‎2009 Mar 02 7:12 AM
Hi,
PROCESS BEFORE OUTPUT.
LOOP AT it_table INTO workarea WITH CONTROL <tablecontrol name>.
MODULE map_fields.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP.
MODULE insert_records_create.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Module map_fields OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
"screennames = program field names.
"example ztrip-sno = screen name i,e table control field
"wa_trip-sno. = Program field, i,e work area of ur program.
"below is the example for table control which have four fields.
if it_table is not initial.
ztrip-sno = wa_trip-sno.
ztrip-expen = wa_trip-expen.
ztrip-curr = wa_trip-curr.
ztrip-amot = wa_trip-amot.
endif.
*&---------------------------------------------------------------------*
*& Form f_fill_tripdetails
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
"in PAI Program names = screennames
if sy-ucomm = 'ENTER'
wa_trip-sno = ztrip-sno.
wa_trip-expen = ztrip-expen.
wa_trip-curr = ztrip-curr.
wa_trip-amot = ztrip-amot .
append workarea to internal table. " Append internal table
endif.
Debug your program and see whether your internal table contails any data after pressing enter.
‎2009 Mar 02 7:13 AM
Hi,
Plz chk the code below.....
Flow Logic for main screen...
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE fill_dynnr.
CALL SUBSCREEN SUB1 INCLUDING sy-cprog dynnr.
Module clear_ok_code.
*
PROCESS AFTER INPUT.
CALL SUBSCREEN SUB1.
MODULE USER_COMMAND_0100.
Flow logic for the sub-screen..
PROCESS BEFORE OUTPUT.
loop with control zmeter.
module itab_display.
endloop.
PROCESS AFTER INPUT.
Loop with control zmeter.
field : zgen_read-AUFNR,
zgen_read-Z_OPEN_READ,
zgen_read-Z_CLOSE_READ.
module itab_read .
endloop.
Main Program...
REPORT Z_GENERATOR.
TABLES : Zgen_read.
CONTROLS GENERATOR_READING TYPE TABSTRIP.
CONTROLS : ZMETER TYPE TABLEVIEW USING SCREEN '0101'.
DATA ok_code type sy-ucomm.
DATA dynnr type sy-dynnr.
data : wa_zgen_read type zgen_read,
wa1_zgen_read type zgen_read,
it_zgen_read type standard table of zgen_read with header line initial size 0.
call screen 100.
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
*Check ok_code NE ' '.
Case ok_code.
when 'FC1' or 'FC2'.
generator_reading-activetab = ok_code.
when 'F3'.
LEAVE TO SCREEN 0.
when 'SAVE'.
clear wa_zgen_read.
loop at it_zgen_read into wa_zgen_read .
insert into zgen_read values wa_zgen_read .
endloop.
when 'ENTER'.
zgen_read-ZDATE_READING = wa_zgen_read-ZDATE_READING.
zgen_read-AUFNR = wa_zgen_read-AUFNR.
zgen_read-Z_OPEN_READ = wa_zgen_read-Z_OPEN_READ.
zgen_read-Z_CLOSE_READ = wa_zgen_read-Z_CLOSE_READ .
EndCase.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module ITAB_READ INPUT
&----
text
----
MODULE ITAB_READ INPUT.
wa_zgen_read-ZDATE_READING = zgen_read-ZDATE_READING.
wa_zgen_read-AUFNR = zgen_read-AUFNR.
wa_zgen_read-Z_OPEN_READ = zgen_read-Z_OPEN_READ.
wa_zgen_read-Z_CLOSE_READ = zgen_read-Z_CLOSE_READ.
append wa_zgen_read to it_zgen_read .
*Append
ENDMODULE. " ITAB_READ INPUT
&----
*& Module ITAB_DISPLAY OUTPUT
&----
text
----
MODULE ITAB_DISPLAY OUTPUT.
read table it_zgen_read into wa_zgen_read index zmeter-current_line.
*data : line_count type i.
*
*describe table it_zgen_read lines line_count.
zgen_read-ZDATE_READING = wa_zgen_read-ZDATE_READING.
zgen_read-AUFNR = wa_zgen_read-AUFNR.
zgen_read-Z_OPEN_READ = wa_zgen_read-Z_OPEN_READ.
zgen_read-Z_CLOSE_READ = wa_zgen_read-Z_CLOSE_READ .
ENDMODULE. " ITAB_DISPLAY OUTPUT
Please chk and suggest...
Regards,
W. Archana
‎2009 Mar 02 7:15 AM
hi
when 'ENTER'.
zgen_read-ZDATE_READING = wa_zgen_read-ZDATE_READING.
zgen_read-AUFNR = wa_zgen_read-AUFNR.
zgen_read-Z_OPEN_READ = wa_zgen_read-Z_OPEN_READ.
zgen_read-Z_CLOSE_READ = wa_zgen_read-Z_CLOSE_READ .
APpend wa_zgen_read to it_zgen_read.
"APpend your internal table here
‎2009 Mar 02 7:21 AM
Hi,
For what purpose are you using the sub-screen....??
Are you not displaying data in table control on the screen 0100....!!!
I hope that the above code provided by you is a bit confusing.
So instead if you can again go through the first reply by me, coz in my case its working absolutely fine (for the same requirement).
Regards,
Tarun
‎2009 Mar 02 7:21 AM
Hi,
After pressing enter my int table contains the values entered in the tabe control fields.
I did as u suggested but still didn't work ...
Regards,
Archana
‎2009 Mar 02 7:25 AM
hi,
PROCESS BEFORE OUTPUT.
loop at it_table into wa_Area with control zmeter. "---->'at it_table into wa_Area' add workarea and itable name
module itab_display.
endloop.
‎2009 Mar 02 7:36 AM
Hi Always Learner,
I tried it but getting a error "with control zmeter " missing in PBO.
regards,
Archana W.
‎2009 Mar 02 8:07 AM
PROCESS AFTER INPUT.
" PA! of subscreen.
' ----> Comment this line, instead try just with the loop "Loop with control zmeter.
loop.
field : zgen_read-AUFNR,
zgen_read-Z_OPEN_READ,
zgen_read-Z_CLOSE_READ.
module itab_read .
endloop.Always Learner
‎2009 Mar 02 8:54 AM
Hi Archana,
I understood that you are entering data in the table control and immediately when you click on SAVE data was not capturing?
If so, i hope data was not updating in the internal table itself. so you need to use
MODIFY ITAB index <tablecontrol-currentline>.
Regards,
Satya
‎2009 Mar 02 9:01 AM
Hi Satya,
No my problem is when I press 'enter' key the data is updated in the internal table but it disappears from the screen.....and even if i click the save button it gets updated in my ztable.
But I want the table control data should disappear from the screen only when i click the save button....
Regards,
W. ARchana
‎2009 Mar 02 9:27 AM
Hi,
As you said that when you give some data in table control on screen, and hit ENTER key all the data is updated in the internal table but disappears from table control.
So a simple solution to retain the data in the table control is to read the internal table into the table control before the screen renders i.e., in PBO (Process Before Output).
Initially when you execute your program your internal table is initial so records are read into table control.
When you give some records and hit ENTER, PAI is triggered and all records are appended in internal table. Now PBO will be triggered, here you need to read the internal table to get all the internal table data.
Hope this solves your problem.
Regards,
Tarun
‎2009 Mar 02 12:03 PM
Hi Tarun,
I'm using the subs creen as my table control is placed on a tab strip control.
And analysed my code step by step its in the same way as mentioned by u....
inshort my logic as below...
Main Screen :
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE fill_dynnr.
CALL SUBSCREEN SUB1 INCLUDING sy-cprog dynnr.
Module clear_ok_code.
*
PROCESS AFTER INPUT.
CALL SUBSCREEN SUB1.
MODULE USER_COMMAND_0100.
*Subscreen :
*PROCESS BEFORE OUTPUT.
loop at it_zgen_read into wa_zgen_read with control zmeter cursor
zmeter-current_line.
module itab_display. "----
> int table to table control
endloop.
PROCESS AFTER INPUT.
Loop at it_zgen_read." with control zmeter.
field : zgen_read-AUFNR,
zgen_read-Z_OPEN_READ,
zgen_read-Z_CLOSE_READ.
module itab_read . "----
> table control to Int table
endloop.
Please chk and suggest.
Regards,
W. Archana
‎2009 Mar 02 12:24 PM
Hi,
As per your code:-
loop at it_zgen_read into wa_zgen_read with control zmeter cursor
zmeter-current_line.
module itab_display. "------------> int table to table control
endloop.
In module itab_display you read the internal table into table control.
You are looping it_zgen_read into wa_zgen_read.
So records will navigate to work area line by line.
First, check the field names in the table control for the i/o fields.
Are you moving the records from the work area to the i/o fields.
Regards,
Tarun
‎2009 Mar 02 7:52 PM
Hi,
I hope the entered data was capturing in to internal table in PAI properly, but when you hit enter , program will trigger PBO again, so table control data was clearing off, there should be no data transfer back from your internal table to table control.
While moving data from the internal table to table control in PBO, you can check for the ucomm value to not move data back in case of SAVE functionality.
Regards,
~Satya
‎2009 Mar 02 3:38 AM
Hi
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 solves your problem.
Thanks & Regards,
Tarun Gambhir
‎2009 Mar 16 5:11 AM
Thank U every one . All the answers were helpful. Points are given.
Solved the issue.