on 04-24-2011 2:11 PM
Hi All,
I tried executing the below code for Avl table when a data in any row is modified. When i executed i found that the modified data is not over written rather a new row is being created in the DB table. Can any one guide me how to go about this please. And also please guide me how to work with delete and insert row using r_param.
DATA : WA_PARAM LIKE LINE OF R_PARAM->T_MODIFIED_CELLS.
DATA : WA_PARAM_DEL LIKE LINE OF R_PARAM->T_DELETED_ROWS.
DATA LS_ASSESSTMENT_MASTER TYPE TABLE OF IF_V_MASTERS=>ELEMENT_ASSESSTMENT_MASTER.
DATA : T_MOD TYPE STANDARD TABLE OF ZACTIVITY,
WA_MOD LIKE LINE OF T_MOD,
WA_TABLE LIKE LINE OF LS_ASSESSTMENT_MASTER.
CHECK R_PARAM->T_MODIFIED_CELLS IS NOT INITIAL.
LO_ND_ASSESSTMENT_MASTER->GET_STATIC_ATTRIBUTES_TABLE(
IMPORTING
TABLE = LS_ASSESSTMENT_MASTER ).
OOP AT R_PARAM->T_MODIFIED_CELLS INTO WA_PARAM.
READ TABLE LS_ASSESSTMENT_MASTER INTO WA_TABLE INDEX WA_PARAM-INDEX.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING WA_TABLE TO WA_MOD.
APPEND WA_MOD TO T_MOD.
ENDIF.
ENDLOOP.
Hi vadiv,
Change the APPEND WA_MOD TO T_MOD to MODIFY WA_MOD TO T_MOD , your code will run, I think there is no other issue pertaining to the code.
regards,
Monishankar C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vadiv,
You can use like this :-
FIELD-SYMBOLS: <WA_ROW> LIKE LINE OF R_PARAM->T_MODIFIED_CELLS.
DATA: INDEX_VALUE TYPE I.
LOOP AT R_PARAM->T_MODIFIED_CELLS ASSIGNING <WA_ROW>.
INDEX_VALUE = <WA_ROW>-INDEX.
READ TABLE LS_ASSESSTMENT_MASTER INTO WA_TABLE INDEX WA_PARAM-INDEX.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING WA_TABLE TO WA_MOD.
APPEND WA_MOD TO T_MOD.
ENDIF.
ENDLOOP.
reply in case of any issue.
regards,
Monishankar C
ENDLOOP.
Hi Monish,
Thanks for your reply. If u see in the above code i have done the same thing. When i do this the new row value gets added as i do a append the older value does not get replaced. When i try a modify there it throws a run time error like "ABAP error while processing the internal table". Could you suggest me some other solution to solve my issue please.
Hi ,
The reason which I can guess for your APPEND statement not working is that your ZACTIVITY table has more than one columns as table keys.
So when you try to append the internal table with a workarea with any change in any one of the keys, a new row will be added in the internal table.
So instead of APPEND , use MODIFY.
LOOP AT R_PARAM->T_MODIFIED_CELLS ASSIGNING <WA_ROW>.
INDEX_VALUE = <WA_ROW>-INDEX.
READ TABLE LS_ASSESSTMENT_MASTER INTO WA_TABLE INDEX WA_PARAM-INDEX.
IF SY-SUBRC EQ 0.
MOVE-CORRESPONDING WA_TABLE TO WA_MOD.
MODIFY TABLE T_MOD from WA_MOD.
ENDIF.
ENDLOOP.
But Please explain what you are trying to do here.
You want the changed rows in a different internal table?
Hi All,
Thanks for your reply. I tried with the Modify code and it is throwing the error like 'ABAP error problem while processing the internal table.' Actually what i am trying to do is i have an alv table with editable field for displaying the data from my DB. If i modify the data it should get updated in the database. So i am calling the modified cells to collect the modified content and trying to insert in the database.
Hi vadiv,
I think you are making some mistake in ABAP coding. No issue with the logic.
Do as follows:-
1. In the event handler you are getting the index -- working fine.
2. Read the table ASSESSTMENT_MASTER using that index.
3. Now here just declare this T_MOD as type of your standard table. Dont populate values in it before this step.
Put the new entries in T_MOD using append.
APPEND WA_MOD TO T_MOD.
4.Update database table from T_MOD.
MODIFY DATABASE TABLE FROM TABLE T_MOD.
In case of any error check with debugger whether the key fields are contradicting each other.
Regards,
Monishankar C
You can also use update operation.
UPDATE T-MOD SET FIELD NAME = FIELD VALUE
WHERE PRIMARY FILED NAME = FIELDV VALUE.
APPEND WILL ALWAYS ADD NEW ROWS TO TABLE . OkAY
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This is not all coding so it's rather hard to say what is going on in here. My guess would be to replace this APPEND with MODIFY, since I assume that this T_MOD table is later used to fill ALV data context.
Best Regards
Marcin Cholewczuk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.