‎2009 Feb 06 12:34 PM
Hi,
My requirements goes like this:
1. I am having a screen 100, which has a table control with NO data in it.
2. The screen has two push buttons in it (SAVE and EXIT).
3. I enter the data in the first row of the table control.
4. I select the row and click on Save button to save the data in to a Z table.
5. The problem I am facing is, the entire row gets vanished as soon as I click on Save button and
6. If I press Enter after entering the values in the first row, the entire data gets vanished.
Please help me out.
Here is the code that I have written to achieve this.
PROGRAM Z84364BNCHPROG3 .
tables: z84364_bnch_empl.
types: begin of itab_tp,
mandt type z84364_bnch_empl-mandt,
empid type z84364_bnch_empl-empid,
name1 type z84364_bnch_empl-name1,
name2 type z84364_bnch_empl-name2,
street1 type z84364_bnch_empl-street1,
street2 type z84364_bnch_empl-street2,
district type z84364_bnch_empl-district,
state type z84364_bnch_empl-state,
country type z84364_bnch_empl-country,
end of itab_tp.
data : itab type standard table of itab_tp.
data: itab_wa type itab_tp.
controls: tbcntrl type tableview using screen '0100'.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module STATUS_0100 output.
SET PF-STATUS 'TBCNTROLSTATUS'.
SET TITLEBAR 'TBS'.
DESCRIBE table itab lines tbcntrl-lines.
endmodule. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
module USER_COMMAND_0100 input.
if sy-ucomm eq 'EXIT' or sy-ucomm eq 'BACK' or Sy-ucomm eq 'CANCEL' or
sy-ucomm eq 'EXIT'.
Leave program.
endif.
if sy-ucomm eq 'SAVE'.
loop at itab into itab_wa.
modify Z84364_BNCH_EMPL from itab_wa.
endloop.
if sy-subrc eq 0.
message 'Updated the table Successfully' type 'S'.
endif.
endif.
endmodule. " USER_COMMAND_0100 INPUT
&----
*& Module cursor_setting OUTPUT
&----
text
----
module cursor_setting output.
loop at screen.
screen-input = 1.
endloop.
SET CURSOR FIELD Z84364_BNCH_EMPL-STREET1 LINE 1.
endmodule. " cursor_setting OUTPUT
SCREEN FLOW LOGIC IS SHOWN BELOW
process before output.
module status_0100.
loop with control tbcntrl.
endloop.
module cursor_setting.
process after input.
loop with control tbcntrl.
endloop.
module user_command_0100.
‎2009 Feb 06 4:47 PM
Hi,
Use this code, its working:-
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...
At screen flow-logic
PROCESS BEFORE OUTPUT.
* MODULE status_8003.
LOOP WITH CONTROL po_tb.
MODULE read_data.
ENDLOOP.
PROCESS AFTER INPUT.
* MODULE user_command_8003.
LOOP WITH CONTROL po_tb.
MODULE insert_data.
ENDLOOP.
MODULE save_data.
In PBO
*&---------------------------------------------------------------------*
*& Module READ_DATA OUTPUT
*&---------------------------------------------------------------------*
MODULE read_data OUTPUT.
READ TABLE it_zekpo INTO wa_zekpo INDEX po_tb-current_line. "po_tab is table control name
ENDMODULE. " READ_DATA OUTPUT
In PAI
*&---------------------------------------------------------------------*
*& Module INSERT_DATA INPUT
*&---------------------------------------------------------------------*
MODULE INSERT_DATA INPUT.
APPEND WA_ZEKPO TO IT_ZEKPO.
ENDMODULE. " INSERT_DATA INPUT
*&---------------------------------------------------------------------*
*& Module SAVE_DATA INPUT
*&---------------------------------------------------------------------*
MODULE SAVE_DATA INPUT.
DATA : A LIKE SY-DBCNT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'SAVE'.
MODIFY ZEKPO FROM TABLE IT_ZEKPO. "update db table from internal table
A = SY-DBCNT.
IF SY-SUBRC = 0.
MESSAGE S008 WITH A. "success message with no of records modified
ENDIF.
ENDCASE.
ENDMODULE. " SAVE_DATA INPUT
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir
‎2009 Feb 06 1:02 PM
Hi,
1. Add a vraible flag in the PBO module where you are reading the data from the table into a table control,set its value to 'X' after first read as done below
IF ( FLAG1 EQ ' ' ).
* SELECT ALL THE RECORDS FROM THE TABLE TO THE INTERNAL TABLE
SELECT QUERY
ENDIF.
FLAG1 = 'X'.This will lead to display the record in the table control ratehr than making them vanish.
PS your flow login for the sreen should be like this
PROCESS BEFORE OUTPUT.
MODULE GET_DATA. "read the dat from table into internal table ,where above code needs to be add
LOOP WITH CONTROL TABLE1.
MODULE PUT_DATA. "Actually puts the data into the table control from internal table
"code in this can be READ TABLE <ITAB> INDEX <tablecontrolname>-CURRENT_LINE.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP WITH CONTROL TABLE1.
MODULE MODIFY_DATA.
'that actually redisplay of the data from the internal table into table control
"code can be MODIFY internal table INDEX <tablecontrolname>-CURRENT_LINE.
ENDLOOP.
MODULE INPUT_DATA. "that takes care of actual insert/modif or sy-ucomm functionalityhope this might help you.
Pooja
‎2009 Feb 06 1:03 PM
hi,
process before output.
module status_0100.
loop with control tbcntrl.
MODULE map_fields. "-----------------> to display records from the program.
endloop.
module cursor_setting.
process after input.
loop with control tbcntrl.
module insert_records "---------> to insert records from the screen
endloop.
module user_command_0100.
*&---------------------------------------------------------------------*
*& Module map_fields OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE map_fields OUTPUT.
" screen names = program fields name
ztrip-pernr = ptp00-pernr.
ztrip-place = wa_trip-place.
ztrip-fdate = wa_trip-fdate.
ENDMODULE
*&---------------------------------------------------------------------*
*& Module insert_records_502 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE insert_records INPUT.
program names = screen names
wa_trip-pernr = ztrip-pernr.
wa_trip-fdate = ztrip-fdate.
wa_trip-tdate = ztrip-tdate.
wa_trip-place = ztrip-place.
wa_trip-ctry = ztrip-ctry.
wa_trip-reson = ztrip-reson.
wa_trip-sno = ztrip-sno.
append wa_trip to it_trip.
ENDMODULE. " insert_records INPUTThanks & REgards
Always Learner
‎2009 Feb 06 1:05 PM
Try this
process after input.
loop with control tab_ctrl.
module mod_tbctrl.
endloop.
module user_command_0101.
*********************************************************
module mod_tbctrl input.
modify it_xxxx from wa_xxxx index tab_ctrl-current_line.
endmodule. " mod_tbctrl INPUT
module user_command_0101
when 'MODI'.
modify Z84364_BNCH_EMPL from table it_xxxx.
endmodule.
This will help!
Regards,
Prashant
‎2009 Feb 06 1:43 PM
Thanks for the input.
Now, I made the changes given by you.
The thing is as soon as I click on Save button, the values in the table control are getting updated and I get a message saying 'Table updated'.
As soon as I see the above message, the values are vanished.
What do I do. Please help me out.
There are some other buttons with which I need to play on.
So, I need the data to stay back on the screen even after executing Save Button.
‎2009 Feb 06 2:59 PM
I hope the table control fields are mapped to the workarea of the internal table?
Is it?
Please check that.
Regards,
Prashant
‎2009 Feb 06 3:14 PM
Hi,
I did a mistake.
Intially as there will not be any entries in the table I skipped the step of assigning the internal table work area values to screen values. This made the problem as after executing the PAI module the control would go back to PBO again.
Thank you one and all for the help.
In addition to the above,
I would like to add one more functionality to my program.
The scenario goes like this.
1) As soon as the screen 100 gets displayed. I do not want any of the screen elements to be in input mode. I want to disable it except the very first row
2) I will add a button 'ADD' to my screen.
3) Once I click on the ADD button, I would like to have one more row to be in input mode.
Please let me know how to achieve this.
Points will be awarded for the best reply.
Thanks,
Babu Kilari
‎2009 Feb 06 4:47 PM
Hi,
Use this code, its working:-
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...
At screen flow-logic
PROCESS BEFORE OUTPUT.
* MODULE status_8003.
LOOP WITH CONTROL po_tb.
MODULE read_data.
ENDLOOP.
PROCESS AFTER INPUT.
* MODULE user_command_8003.
LOOP WITH CONTROL po_tb.
MODULE insert_data.
ENDLOOP.
MODULE save_data.
In PBO
*&---------------------------------------------------------------------*
*& Module READ_DATA OUTPUT
*&---------------------------------------------------------------------*
MODULE read_data OUTPUT.
READ TABLE it_zekpo INTO wa_zekpo INDEX po_tb-current_line. "po_tab is table control name
ENDMODULE. " READ_DATA OUTPUT
In PAI
*&---------------------------------------------------------------------*
*& Module INSERT_DATA INPUT
*&---------------------------------------------------------------------*
MODULE INSERT_DATA INPUT.
APPEND WA_ZEKPO TO IT_ZEKPO.
ENDMODULE. " INSERT_DATA INPUT
*&---------------------------------------------------------------------*
*& Module SAVE_DATA INPUT
*&---------------------------------------------------------------------*
MODULE SAVE_DATA INPUT.
DATA : A LIKE SY-DBCNT.
OK_CODE = SY-UCOMM.
CASE OK_CODE.
WHEN 'SAVE'.
MODIFY ZEKPO FROM TABLE IT_ZEKPO. "update db table from internal table
A = SY-DBCNT.
IF SY-SUBRC = 0.
MESSAGE S008 WITH A. "success message with no of records modified
ENDIF.
ENDCASE.
ENDMODULE. " SAVE_DATA INPUT
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir
‎2009 Feb 07 10:53 AM