‎2013 Mar 05 11:39 AM
Hi experts...
I have a problem in my code,I am trying to modify internal table from workarea which is assigned to table control,
for the purpose when user hits 'ENTER' key i want to modify internal table and update.
i checked many posts,but still am stuck here,when i check the subrc value it gives '4'.
Am pasting my code here.
Thanks.
REPORT ztable_control.
TABLES : zemp_head_tab.
CONTROLS table TYPE TABLEVIEW USING SCREEN '0101'.
DATA : itab TYPE STANDARD TABLE OF zemp_head_tab,
wa TYPE zemp_head_tab.
CALL SCREEN '0101'.
flow logic
PROCESS BEFORE OUTPUT.
MODULE STATUS.
LOOP at ITAB INTO zemp_head_tab WITH CONTROL table.
endloop.
*
PROCESS AFTER INPUT.
loop at ITAB.
MODULE modify_itab.
endloop.
module user_command.
module modify_itab input.
MOVE-CORRESPONDING zemp_head_tab to wa.
MODIFY ITAB FROM wa index table-current_line.
IF SY-SUBRC <> 0.
ENDIF.
endmodule.
‎2013 Mar 05 12:31 PM
Hi,
What are the key fields in your table ? Check if you are not entering the same key fields in the table control.
Thanks,
Tooshar Bendale
‎2013 Mar 05 12:12 PM
Hi Askar,
You are using a standard table, when you modify, your work area and internal table key fields should match. People forget this sometimes, In case of standard table Non Numeric fields are the Key fields. check if all non-numeric fields in workarea are same as the entry which you are trying to modify in Itab
‎2013 Mar 05 12:42 PM
actually am having only 3 fields (non-numeric) and when i enter values in table control i get those values in work area,
Am i answering correct? or did i understand wrongly?
Thanks
Askar
‎2013 Mar 05 12:31 PM
Hi,
What are the key fields in your table ? Check if you are not entering the same key fields in the table control.
Thanks,
Tooshar Bendale
‎2013 Mar 05 12:45 PM
No am not entering the same values.
i checked some demo programs,there the internal table is intially updated from database table,
here in my code in modify statement i checked the table there are no values since i didnt select any values from data base,
would that be a problem??
‎2013 Mar 05 3:11 PM
You need Values in Internal Table before Modifying it.
MODIFY works different for Internal Table and Database Table, In Database Table if entry is not present during Modify it inserts it, but in case of Internal Table, It simply returns sy-subrc =4.
I think you didnt understand how Internal table works. As you said, If you are not Entering the same value into Ur Internal Table, that means your Table key is Different. Then It wont get Modified.
As I mentioned Earlier Your Non Numeric fields will be the Key Fields of Table(for Standard Table). So as in your case, You are entering different values, so The key itself becomes different, so how will it get modified?. The only solution is to use hashed table or sorted table with a non unique key.
How Modified works in case of Standr table is
If i have 3 fields (Name, City,Number) with values ABC,Bangalore,123 here ABC and Bangalore are considered as Key fields. So only if ABC and Bangalore remain the same your Modify statement will work. If any one among those two are changed its treated as a new entry.
‎2013 Mar 05 12:54 PM
Hi Askar,
unles you declare the itab as sorted or hashed and define a key and insert into this table i
simply would append your wa to itab. (You will not be able to control duplicates like this).
The problem is probably the index.
Best regards
Jonas
‎2013 Mar 05 1:36 PM
Hello Imran,
In PAI block, you are looping without control and in modify statement you are using index table-current line; which is not align.
you should use LOOP with control in PAI block also and do the according coding to modify the table.
Thanks & Regards
Ashok