cancel
Showing results for 
Search instead for 
Did you mean: 

How to use R_PARAM->T_MODIFIED_CELLS

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi All,

Thanks for your replyies. I want to pass the values that the WA_PARAM in the below code is holding to a variable from which i can do further process. can any one suggest me on how to do that please.

LOOP AT R_PARAM->T_MODIFIED_CELLS INTO WA_PARAM.

marcin_cholewczuk
Active Contributor
0 Kudos

Hi,

To be honest I don't quite understand what you mean. Something like this?


DATA ls_tmp LIKE wa_param.
ls_tmp = wa_param.

but that would be rather..... very basic question.

Best regards

Marcin Cholewczuk

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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?

Former Member
0 Kudos

Hi vadiv,

sorry I have replied to you wrongly in a hurry.

In case case you want to modify a internal table from work area

MODIFY TABLE T_MOD FROM WA_MOD.

In case of any issue put a debugger and check the entries in the internal table.

I hope this will work .

Regards,

Monishankar C

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Answers (2)

Answers (2)

former_member199125
Active Contributor
0 Kudos

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

marcin_cholewczuk
Active Contributor
0 Kudos

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