Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI- BAPI_VENDOR_EDIT for Vendor Update

vinay_pasalkar
Participant
0 Kudos

Hi,

I want to update the field LFA1-STGDL in SAP Vendor master.

This can be done through BDC however I want to Use BAPI for the same.

I searched SDN & got information that BAPI- Vendor_Update is not released & should not be used.

( This is an update Task FM So it is called by SAP standard program at the end of control and after the COMMIT WORK to update the database.

If we use an update task FM you will not perform any check and will not execute the other FM that the standard programs call. In fact using this FM you would have only executed an open-sql update statement.

)

When I used BAPI_VENDOR_EDIT, it takes us to XK02 screen.

 

CALL

FUNCTION 'BAPI_VENDOR_EDIT'
EXPORTING
vendorno = wa_lfa1-lifnr
IMPORTING
return = wa_return.

Could you please let me know how can we use the BAPI in our program to update the field LFA1-STGDL.

Thanks

Vinay

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You can't update the field by using BAPI_VENDOR_EDIT. Since inside the BAPI calling the statement call transaction 'XK02'. I think inside the program it will directly call the screen in change mode! you have to enter the values manually!


If you want to update the one filed go for the below logic!



call function 'ENQUEUE_EXLFA1'
         exporting
           lifnr          =  lfa1-lifnr
         exceptions
           foreign_lock   = 1
           system_failure = 2.



update lfa1 set STGDL = 'XXXX'

             WHERE LIFNR =  lfa1-lifnr


call function 'DEQUEUE_ALL'.



8 REPLIES 8

Former Member
0 Kudos

Hi Vinay,

        I got the same scenario which is relevant to your doubt.

My scenario is as follows.

I want to create vender master record in FK01. When we run PRAA tcode a standard BDC recording will get created in SM35. When we execute that recording, Email address should get updated in email id field in FK01 tcode.

In standard it is not updating.

So i created an implicit enhancement inside the standard report of tcode PRAA and appended the mail id into the standard BDC recording.

Same way you also try.  Hope it helps.

And my doubt is, why you want to use BAPI. And also where you are calling that BAPI and in which program.

Former Member
0 Kudos

Hi

Can you help me, how is possible update vendor data using net. connector with RFC function (or some another way to update vendors data from 3th party program). Up to now I read only data from LFA1 using net. connector (using RFC function RFC_READ_TABLE) and now I need update vendor data (e.g. NAME1, NAME2, ADRNR etc. from LFA1)

Our SAP system contains very much duplicate record (many LIFNR has the same STCD2, STCEG etc. but different NAME1 who contains typist's error or something like this. 6000 vendors has 1700 duplicates and incomplete record). Our Administrator don't know how set up SAP so that impossible create duplicite vendors! Because our system SAP contains very, very, very much elementary error, this system is not helpfull for our company.

Thank you

0 Kudos

Hi,

The Vendor data can be updated using a BAPI which will be using any of the FM's (Vendor_Update or BAPI_VENDOR_EDIT ) mentioned above.

The BAPI will be called remotely.

In order to avoid creating duplicate record, you can use any customer exit in SAP & put a validation on the same in order to avoid duplicate entries.

Thanks

Vinay

0 Kudos

I found link (http://www.stechno.net/sap-functions.html). On this site is overview SAP function, tables (relationship of tables etc.).

When I look BAPI_VENDOR_EDIT there is check RFC (this function is possible call remotely). But description on this function is "Change Vendor Master Online". On another site (http://www.se80.co.uk/sapfms/b/bapi/bapi_vendor_edit.htm) is description, but I not see how is possible change some value of LFA1.

Former Member
0 Kudos

Hi,

You can't update the field by using BAPI_VENDOR_EDIT. Since inside the BAPI calling the statement call transaction 'XK02'. I think inside the program it will directly call the screen in change mode! you have to enter the values manually!


If you want to update the one filed go for the below logic!



call function 'ENQUEUE_EXLFA1'
         exporting
           lifnr          =  lfa1-lifnr
         exceptions
           foreign_lock   = 1
           system_failure = 2.



update lfa1 set STGDL = 'XXXX'

             WHERE LIFNR =  lfa1-lifnr


call function 'DEQUEUE_ALL'.



0 Kudos

Hi All, I used the FM - VENDOR_UPDATE & applied the error handling techniques in the code so that user will get to know the status if the Vendor data has been updated or not.

Also try to lock the record before updating it will reduce the possibility of 'No data update' due to lock issues.

Thanks

0 Kudos
kiran kumar

Your sequence look like very good and very possible.

Never mind when I can update only one parameter at time (in c# I create loop cycle for update next parameters)

Because I don't work with SAP, that I have a minimal knowledge from SAP. When I programing "RFC_READ_TABLE" I fond way how it testing in SAP and I found very usefull site where was description this function (http://www.stechno.net/sap-functions.html?view=sapfunc&id=RFC_READ_TABLE). When I validate setting in SAP, then I used this setting in my program - and my program work fine.

When I look on your example, I know how write first part (without set up exceptions, when I look on the http://www.se80.co.uk/sapfms/e/enqu/enqueue_exlfa1.htm I think, this exceptions parameter is set up default)

IRfcFunction updateOneParameter = rfcRep.CreateFunction("ENQUEUE_EXLFA1");

updateOneParameter.SetValue("lifnr", 123456);

updateOneParameter.Invoke(rfcDest);

but I don't know use or coding second part (if I update record in SQL, that was very easy "UPDATE lfa1 SET STGDL='XXXX' WHERE lifnr=123456")

according site (http://www.se80.co.uk/sapfms/d/dequ/dequeue_all.htm) I think this part look like:

IRfcFunction executeUpdateOneParameter = rfcRep.CreateFunction("DEQUEUE_ALL");

IRfcTable setValueForUpdate = executeUpdateOneParameter.GetTable("DEQUEUE_ALL");

executeUpdateOneParameter.Insert(1);

executeUpdateOneParameter.SetValue(?????, "UPDATE lfa1 SET STGDL='XXXX' WHERE lifnr=123456");

executeUpdateOneParameter.Invoke(rfcDest);

update lfa1 set STGDL = 'XXXX' WHERE LIFNR =  lfa1-lifnr

call function 'DEQUEUE_ALL'.

you can help me with this part

thank you very much

0 Kudos

Hi Vinay,

I want to update the LFB1-pernr field and few z fields added in LFA1 table.

How can I use VENDOR_update FM?

Do I need to pass all the structures even though i want to update lfa1 and lfb1 only?

please help

its urgent

thanks