‎2010 Oct 22 10:06 AM
Hi folks,
I want to read the description-texts from maintenance-positions, modify them a little and then write the new values back. I arranged a User-selection using select options and I can process those objects and read their descriptions, but I don't know how to write back the new values to database-table MPOS.
Here is what I have:
DATA tmpos LIKE mpos OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK txt WITH FRAME TITLE text-001.
SELECT-OPTIONS:
t_warpl FOR tmpos-warpl.
SELECTION-SCREEN END OF BLOCK txt.
SELECT * FROM mpos into table tmpos
WHERE warpl IN t_warpl.
LOOP AT tmpos.
WRITE / tmpos-pstxt.
tmpos-pstxt = 'TEST'.
modify table tmpos.
ENDLOOP.
It seems I just modify the temporal table, but not the one in db.
Can you help me out?
Thanx and have a nice day!
‎2010 Oct 22 10:13 AM
Hi,
This is a very basic question.
in your abap editor press F1 on modify keyword and check documentation for Modify dbtab.
‎2010 Oct 22 10:10 AM
Hi,
yes yor are right, you are not modifying the dbtable but the internal table.. I won't suggest updating any db table directly but then if the requirement is like that then you can try this command. I would suggest check for FM'S or Bapi's to update.. Please check the functionlaity and do it.
LOOP AT tmpos.
WRITE / tmpos-pstxt.
tmpos-pstxt = 'TEST'.
modify table tmpos.
ENDLOOP.
modify mpos from table tmpos.
if sy-subrc eq 0.
commitwork.
endif.
Regards,
Nagaraj
‎2010 Oct 22 10:21 AM
Hi,
you can also use function module MAINTENANCE_ITEM_POST.
Regards,
Adrian
‎2010 Oct 22 10:13 AM
Hi,
This is a very basic question.
in your abap editor press F1 on modify keyword and check documentation for Modify dbtab.
‎2010 Oct 22 10:16 AM
HI,
Can u elaborate what is your requirement because ur passing the description HARDCODED in the loop
LOOP AT tmpos.
WRITE / tmpos-pstxt.
tmpos-pstxt = 'TEST'. "I did n't get ur changing this description with a hardcoded value
modify table tmpos.
ENDLOOP.The solution for this is update the PSTXT in the loop of tmpos
Regards,
Madhukar Shetty
‎2010 Oct 22 10:18 AM
Hello Nagaraj,
you mean commit work (with backspace in between I think).
Looks promising, but doesn't update the db.
sy-subrc is 0, I checked that with an additional Write-command, but if I enter the corresponding maintenance-position I can still see the old text, instead of TEST.
Thank you!
‎2010 Oct 22 10:28 AM
Hi,
First check what adrian suggested the FM,. Please try the below code.Put a break point and see whether pstxt value is chnaged in the loop.
LOOP AT tmpos.
WRITE / tmpos-pstxt.
tmpos-pstxt = 'TEST'.
modify tmpos transporting pstxt.
ENDLOOP.
modify mpos from table tmpos.
if sy-subrc eq 0.
commit work.
endif.
Regards,
Nagaraj
‎2010 Oct 22 10:49 AM
Hi Andreas,
It is not advisable to update the standard SAP tables by using MODIFY or UPDATE statements in the program. It is dangerous and can cause data inconsistency.
Check if any standard FM or BAPI is available to change the text.
Regards,
Immanuel.
‎2010 Oct 22 10:32 AM
Hi Andreas,
Please use update statement after modifying your internal table.
Check below code. Takecare while updating the database tabels.
LOOP AT tmpos.
WRITE / tmpos-pstxt.
tmpos-pstxt = 'TEST'.
* modify table tmpos.
MODIFY tmpos TRANSPORTING pstxt.
ENDLOOP.
UPDATE mpos FROM TABLE tmpos.Thanks,
Kavitha.