‎2008 Apr 19 1:43 PM
Hi gurus,
I need to populate my Table Control from keyboard and then populate my transparent table from this data that has been typed in the TC when 'SAVE'. The internal table I created for this purpose seems to clear of data when my program goes into the loop in the PBO.
The screen contains five fields (not in the TC) and 4 inside the TC. The 9 fields consist of the internal table.
Please help
Assistance will be rewarded.
Regards
‎2008 Apr 20 12:36 PM
Hi,
I will explain it with an example.
Assume that my screen has 3 fields and a table control with 5 fields.
Screen fields: FIELD1, FIELD2, FIELD3
Table control name: CTR_TAB
Fields in table control: WA_TAB-TAB1, WA_TAB-TAB2, WA_TAB-TAB3, WA_TAB-TAB4, WA_TAB-TAB5.
All fields are editable in the screen.
My ABAP program declarations:
TYPES: begin of tt_tab,
tab1(10) type c,
tab2(10) type c,
tab3(10) type c,
tab4(10) type c,
tab5(10) type c,
field1(10) type c,
field2(10) type c,
field3(10) type c,
end of tt_tab.
DATA: it_tab type standard table of tt_tab,
wa_tab type tt_tab.
Screen flow logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
LOOP AT IT_TAB INTO WA_TAB WITH CONTROL CTR_TAB.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT IT_TAB.
MODULE UPDATE_TAB.
ENDLOOP.
MODULE USER_COMMAND_1000.
Include program for modules and subroutines:
MODULE UPDATE_TAB.
WA_TAB-FIELD1 = FIELD1.
WA_TAB-FIELD2 = FIELD2.
WA_TAB-FIELD3 = FIELD3.
Other fields will be automatically transferred to the workarea WA_TAB
since they have same name in screen and ABAP program
APPEND WA_TAB INTO IT_TAB.
ENDMODULE.
MODULE USER_COMMAND_1000.
CASE OK_CODE.
WHEN 'SAVE'.
INSERT INTO <TABLENAME> VALUES FROM IT_TAB.
ENDCASE.
ENDMODULE.
Thanks and Regards,
Lakshmi.
‎2008 Apr 19 2:01 PM
Hi,
Please check if you are populating the screen fields into your internal table in the PAI of the screen flow logic.
PBO transfers the values from your ABAP program to screen fields and PAI transfers values from the screen fields to your ABAP program. For this the screen and ABAP program should have the same field names. In case of table control this transfer happens the LOOP in the screen flow logic.
In PAI, write the following code.
PROCESS AFTER OUTPUT
LOOP AT IT_ITAB.
MODULE UPDATE_ITAB.
ENDLOOP.
MODULE USER_COMMAND.
IT_ITAB is the internal table which is having the data.
in UPDATE_ITAB move the values from screen fields to IT_ITAB and append your entries in the internal table. Then in PBO this data will reflect.
In MODULE USER_COMMAND, you have to check the OK_CODE and save the date in the transparent table.
Hope this will solve your problem.
Reward points if helpful.
Thanks and Regards,
Lakshmi.
Edited by: Santhanalakshmi V on Apr 19, 2008 6:49 PM
‎2008 Apr 19 4:31 PM
Hi Santhanalakshmi V, thanx for the quick response.
My internal table is not being populated in the PAI module. In fact, it clears as soon as it gets into the loop in the PAI Module.
Any suggestion as to what I can put in the UPDATE_ITAB Module you suggested?
I have a check PAI Module that has the following code:
MODULE check INPUT.
MODIFY it_purch INDEX tc_purch-current_line.
ENDMODULE. " check INPUT
Should I put another PAI Module in the loop? or is the check module above enough?
Here is my PAI:
PROCESS AFTER INPUT.
LOOP AT it_purch.
MODULE check.
FIELD it_purch-certno MODULE insert_purch_lines.
ENDLOOP.
MODULE user_command_1100.
I have other fields not in the TC ,but which are part of the internal table it_purch. These get their values from the previous screen. They are cleared when I try to save, then, it loops with the values on screen (in the TC) and puts them one at a time in the internal table, instead of all the entrieI've run out of ideas
‎2008 Apr 20 12:55 PM
Hello,
This is a typical problem for the scenario
Why it happens:
We have an internal table which we project on the screen as a table control...In the PBO the screen is displayed from values in the internal table....In the PAI,once you input the data..the screen does not automatically feed the values to your internal table and it remains empty..so when u press enter..it goes to PAI..then to PBO and shows data from table in PBO..so in PAI if there is no code written to accept values from user to internal table it gets erased
How to solve it:
Write a module in PAI to modify the internal table with values from table control in the screen...Please see the sample code below written in PAI...
in PAI we are looping at the table from screen
loop at int_screentable.
module f_set_data.
endloop.
module f_set_data.
*pass data from screen to work area
wa_screentable = int_screentable.
*update the current line in the internal table from screen
modify internaltable from wa_screentable index sy-tabix.
endmodule.
In PBO..you are already displaying the internal table..so need to change there
Note that in most of the cases the name of the internal table and screentable will be the same
which means internaltable = int_screentable.
in such case do the code
module f_set_data.
*pass data from screen to work area
wa_screentable = int_screentable.
*update the current line in the internal table from screen
modify int_screentable from wa_screentable index sy-tabix.
endmodule.
and yes..even if it the same table on screen and code you need to modify the currentline(sy-tabix) then only it will get reflected
Once tha values are coming in the internal table you can check the sy-ucomm for 'SAVE' and update the required table using ABAP statements like modify/insert/update(modify preferred for insertion or changing a record)
Pls check , revert and reward if helpful
Regards
Byju
‎2008 Apr 20 12:36 PM
Hi,
I will explain it with an example.
Assume that my screen has 3 fields and a table control with 5 fields.
Screen fields: FIELD1, FIELD2, FIELD3
Table control name: CTR_TAB
Fields in table control: WA_TAB-TAB1, WA_TAB-TAB2, WA_TAB-TAB3, WA_TAB-TAB4, WA_TAB-TAB5.
All fields are editable in the screen.
My ABAP program declarations:
TYPES: begin of tt_tab,
tab1(10) type c,
tab2(10) type c,
tab3(10) type c,
tab4(10) type c,
tab5(10) type c,
field1(10) type c,
field2(10) type c,
field3(10) type c,
end of tt_tab.
DATA: it_tab type standard table of tt_tab,
wa_tab type tt_tab.
Screen flow logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
LOOP AT IT_TAB INTO WA_TAB WITH CONTROL CTR_TAB.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT IT_TAB.
MODULE UPDATE_TAB.
ENDLOOP.
MODULE USER_COMMAND_1000.
Include program for modules and subroutines:
MODULE UPDATE_TAB.
WA_TAB-FIELD1 = FIELD1.
WA_TAB-FIELD2 = FIELD2.
WA_TAB-FIELD3 = FIELD3.
Other fields will be automatically transferred to the workarea WA_TAB
since they have same name in screen and ABAP program
APPEND WA_TAB INTO IT_TAB.
ENDMODULE.
MODULE USER_COMMAND_1000.
CASE OK_CODE.
WHEN 'SAVE'.
INSERT INTO <TABLENAME> VALUES FROM IT_TAB.
ENDCASE.
ENDMODULE.
Thanks and Regards,
Lakshmi.
‎2008 May 08 11:06 AM
Hi gurus,
I have deciced to reopen this discussion because I have 1 problem. Everything else is fine and thank you very much for your contributions. Let me continue from the last entry.
‎2008 May 08 11:32 AM
I have followed your advice Lakshmi and Byju and I thank you for it. Everything is fine but now on SAVE (and any other command like ENTER and even when I scroll on the Table Control) it modifies the transp. table and repeats the same records in the table control.
E.g. if you add three lines into the TC, it repeats those same records whenever you do a command.
Can you please explain what causes this?
Please refer to the SAVE command in MODULE USER_COMMAND_1000 above. I inserted a message after the insert and it pops up whenever I do any command.
Thank you in advance.
‎2008 May 08 11:59 AM
hi,
Can you send the code you wrote in PAI of your screen? it would be more helpful.
Regards,
Anu.
‎2008 May 08 3:32 PM
Hi,
Thanks for your reply.
Here are my PAI modules:
MODULE user_command_1100 INPUT.
ok_code = sy-ucomm.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'DELETE'.
Updating the database table from the internal table
UPDATE zpurch FROM TABLE it_purch.
Deleting the selected row from the internal table
DELETE it_purch WHERE mark = 'X'.
Deleting the selected row from the database table
DELETE FROM zpurch WHERE mark = 'X'.
MESSAGE s006.
WHEN 'SAVE'.
MODIFY zpurch FROM TABLE it_purch.
MESSAGE i001.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_1100 INPUT
MODULE set_purch_data INPUT.
wa_purch-bukrs = bukrs.
wa_purch-dealid = dealid.
wa_purch-dealdate = dealdate.
wa_purch-counter = counter.
wa_purch-broker = broker.
wa_purch-trans_sec = zpurch-trans_sec.
wa_purch-rec_date = zpurch-rec_date.
wa_purch-tshares = tshares.
wa_purch-username1 = username1.
wa_purch-sdate = sdate.
APPEND wa_purch TO it_purch.
ENDMODULE. " set_purch_data INPUT