02-07-2008 9:14 AM
Hi,
I have a requirement where in which there are many records in the o/p screen.Besides each record there is a checkbox.When the user clicks on 2 or more than 2 checkboxes and clicks on the change button,control goes to update screen which contains the fields to be changed.
After the user changes the values for these fields,when he clicks on the execute button,the changed values should get updated in the database table for only the checked records.
I have used bapi_material_savedata fm to update the database table.But this is not working.Can anyone suggest some other method to update the database tables?
02-07-2008 9:18 AM
update syntax is
· UPDATE dbtab SET f1 ... fn. or
UPDATE (dbtabname) SET f1 ... fn.
Four types of SET statements fi are supported:
1. f = g
2. f = f + g
3. f = f g
4. (source_text)
· UPDATE dbtab FROM wa. or
UPDATE (dbtabname) FROM wa.
· UPDATE dbtab FROM TABLE itab. or
UPDATE (dbtabname) FROM TABLE itab.
plz reward if useful
vivek
02-07-2008 9:20 AM
Hi,
see commit is the thing which saves the changes you made to the
database otherwise imean if u have not done the commit work what
happens is the changes will be killed once the your program life has
been killed i think you got why we will do commit work
BAPI's are the methods through which we can input the data i mean it
is an interface technique it is a direct input method.
for example you have inserted some data into one table by using this
BAPI technique but you not done the Commit BAPI then wht happens is
the changes u made to the database cannot been seen in the table these
will get effective once u have Done the Commit BAPI
i think i am clear to u
Rollback
see by taking the above example only we can know wht is Rollback it is nothing but UNDO option in ms office se untill saving if we want one step back we will do it by undo option am i right similalry untill commit ing i.e. nothing until saving the changes made u can delete the modified change i.e. u can go to the stage how it was previously ok
i think u got me
plzz reward if i am clear to u.......
see once u have done commit u cant rollback
same as once u saved one document u cant undo the document changes i think u got me
Reward if found helpfull,
Cheers,
Chaitanya.
02-07-2008 9:22 AM
hi Hema,
I am afraid a COMMIT WORK statement is missing after the BAPI call.
do like this:
CALL 'BAPI_MATERIAL_SAVEDATA'
...
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
hope this helps
ec
02-07-2008 9:32 AM
Hi Eric,
I have used BAPI_TRANSACTION_COMMIT FM after BAPI_MATERIAL_SAVEDATA FM to save the changes.But still the changes are not getting updated.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
02-07-2008 9:39 AM
than you have to check what the BAPI is doing, i. e. what are the retunr parameters.
02-07-2008 9:54 AM
Hi,
I am pasting a part of my code.Can you please check whether I have given proper data or not.
form move_mat_data .
*Header
gt_bapi_head-material = gs_output1-matnr.
gt_bapi_head-basic_view = 'X'.
gt_bapi_head-purchase_view = 'X'.
gt_bapi_head-account_view = 'X'.
gt_bapi_head-sales_view = 'X'.
**Client
*
gt_bapi_client-matl_group = gs_output1-matkl.
gt_bapi_client-base_uom = gs_output1-meins.
*
gt_bapi_clientx-matl_group = 'X'.
gt_bapi_clientx-base_uom = 'X'.
*
*Plant
gt_bapi_marc1-plant = gs_output1-werks.
gt_bapi_marc1-pur_status = gs_output1-mmsta.
gt_bapi_marc1-mrp_type = gs_output1-dismm.
gt_bapi_marc1-mrp_ctrler = gs_output1-dispo.
gt_bapi_marc1-serv_level = gs_output1-zserclass.
gt_bapi_marc1-availcheck = gs_output1-mtvfp.
gt_bapi_marcx-plant = gs_output1-werks .
gt_bapi_marcx-pur_status = 'X'.
gt_bapi_marcx-mrp_type = 'X'.
gt_bapi_marcx-mrp_ctrler = 'X'.
gt_bapi_marcx-serv_level = 'X'.
gt_bapi_marcx-availcheck = 'X'.
GT_BAPIPAREX-STRUCTURE = 'BAPI_MARC'.
GT_BAPIPAREX-VALUEPART1 = BAPI_MARC.
APPEND GT_BAPIPAREX.
*
GT_BAPIPAREXX-STRUCTURE = 'BAPI_MARCX'.
GT_BAPIPAREXX-VALUEPART1 = BAPI_MARCX.
APPEND GT_BAPIPAREXX.
Material Description
REFRESH gt_materialdesc.
gt_materialdesc-langu = gs_output1-spras.
gt_materialdesc-matl_desc = gs_output1-maktx.
append gt_materialdesc.
*Sales
gt_bapi_mvke1-sales_org = gs_output1-vkorg.
gt_bapi_mvke1-distr_chan = gs_output1-vtweg.
gt_bapi_mvke1-sal_status = gs_output1-vmsta.
gt_bapi_mvke1-valid_from = gs_output1-vmstd.
gt_bapi_mvkex-sales_org = gs_output1-vkorg.
gt_bapi_mvkex-distr_chan = 'X'.
gt_bapi_mvkex-sal_status = 'X'.
gt_bapi_mvkex-valid_from = 'X'.
endform. " move_mat_data
form extend_with_bapi .
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gt_bapi_head
PLANTDATA = gt_bapi_marc1
PLANTDATAX = gt_bapi_marcx
SALESDATA = gt_bapi_mvke1
SALESDATAX = gt_bapi_mvkex
IMPORTING
RETURN = gt_bapi_return
TABLES
MATERIALDESCRIPTION = GT_MATERIALDESC
EXTENSIONIN = GT_BAPIPAREX
EXTENSIONINX = GT_BAPIPAREXX.
.
endform. " extend_with_bapi
02-07-2008 9:23 AM
Use UPDATE statement to update Standard table. To see different syntex for the same, you can see f1 help for UPDATE.