Project Object – Vendor Contacts (create and edit)
Hi community!
I have come across the need to have a vendor contact created (you know, those contacts you find in XK01/2/3), and, to my disbelief, really the only possible way to do this programatically, is with a batch input!!
Well, not anymore. I have created a class that allows you to create and edit vendor contacts (deleting might be easy as well, but I haven’t looked into it yet). Also, it should be fairly easy to extend this to create customer contacts as well. If that’s what you need, go ahead and try to do it 🙂 Ideally, there should be a generic “contact” class, and a subclass for vendor and customer contacts.
The most basic way to create a vendor contact is to use static method CREATE_CONTACT and populate vendor number (LIFNR) and last name (NAME1) in structure IM_HEADER_CONTACT_DATA. After that, it’s up to you to figure out how to use it 🙂
You will find the nugget for the class under folder PURCHASE_TO_PAY/VENDOR_CONTACT of project object, here.
If you have any questions, feel free to ask, but don’t expect 24/7 technical support, that doesn’t come for free 😉
Best regards,
Bruno
DISCLAIMER
This is not, by any means, a finished “commercial product”. It still definitely needs a lot of work to be a final stable solution. However, it should be a great starting point to whatever you need. If you do some work on it and feel like sharing an improved version of this, please let me know.
Thanks.
Hello Bruno,
I have similar requirement and thanks for sharing the code to create/edit Vendor contacts. But when I look at the code, its all in XML tags and how can I copy the code into ABAP editor?
If possible can you post the regular ABAP code without the XML/HTML tags.
Thanks,
SG
Hi Suresh,
Sorry for the delay in my reply.
First of all, to be able to upload the code into your system, you need to install SAPlink Project | Assembla.
The most recent version of SAPlink can be found here:
trunk/build | SVN | Assembla
The most recent version of the SAPlink plugins can be found here:
https://www.assembla.com/code/saplink-plugins/subversion/nodes/127/build
After that, you click on the nugget file NUGG_VENDOR_CONTACT_V6.nugg
and you click on RAW, right above the file's contents.
Here, you use your browsers functionality to save the file (with Chrome, I use "Save as" in the menu. Save the file as a ".nugg" file in your PC. Then you can upload it to your SAP system using SAPlink.
Navigate to the package you have used to upload the classes and activate everything. You should be ready to use them at this point 🙂
Kind regards,
Bruno
Hi Bruno,
Thanks for the detailed message.
But when I click the link for the SAP link Project | Assembla, the system points to the below webpage.
Home | SAPlink Project | Assembla.
I click on "Try Assembla for Free", this opens another webpage "Get Started for Free in 60 Seconds | Assembla Plans". Please let me know which one do I choose to install "Assembla".
I did download the "nugg.zip" file and i found the "zsaplink_installer.txt". I also find another file as "SAPlink_Daily.nugg".
What do I need to do with the zsaplink_installer?
Appreciate your advice.
Thanks,
Suresh Ganti
Hi Suresh!
Assembla is the host where SAPlink is stored. You don't need Assembla 🙂
To install SAPlink, follow the instructions here:
http://wiki.scn.sap.com/wiki/display/ABAP/SAPlink+User+Documentation
Since you already have the files, start with step 3.
It's a lot of work to install this tool, but I believe it is worth it, because this tool will help you back up all your work into nugget files, and upload them again if you lose your work or if you want to upload it to a different system.
Usually I create a standalone package for each development I create, and then I can use the feature that downloads all objects from a certain package. It's the easiest way to use this tool, in my opinion.
Best regards,
Bruno
Hi Bruno,
Thank again for your help. I was able to install the ZSAPLINK and also install all corresponding classes.
May be I am asking you a very layman question, i.e. how do I even test if I'm able to create an contact by just providing an vendor number?
Thanks,
Suresh Ganti
Hi again Suresh,
No worries about the questions 🙂
I have provided some documentation in the class, check it out in SE24.
You should be able to create a vendor contact simply by providing a vendor number AND a last name. That's the minimum data necessary to create a vendor contact.
Most of the other stuff works too 😀 But not everything works, I developed what was necessary for my requirement, and now I'm working on other stuff. But if you need something that isn't working, that is a good starting point and maybe I can help you 🙂
Good luck!
Bruno
Hi Suresh,
Any news? Did you succeed in getting it to work?
Let me know!
Kind regards,
Bruno
PS: I also found out that if you navigate to Project Objects root folder (link below) you have the option to download everything to a zip file, on the right side of the page. It might be an easier option to download the code 🙂
EsperancaB/sap_project_object · GitHub
Bruno,
I did not test my vendor create yesterday, but when I tried to execute the method "CREATE_CONTACT", the importing parameter "IM_HEADER_CONTACT_DATA" has KUNNR and where can I enter the vendor number and last name?
Appreciate your help.
Thanks,
Suresh Ganti
Hi Suresh,
That field is in there because I used KNVK structure for the importing parameter, but you do not need to use this field.
The only 2 mandatory fields are vendor number (LIFNR) and last name (NAME1). Please test this method with these 2 fields populated and it should work 🙂
When you get it to work, you can start populating the rest of the fields. If you find something that doesn't work let me know, I can look into it.
Best regards,
Bruno
Thanks for your prompt reply. Can we create contacts with sepcific types like A002 which is our PO contact and A004 for Credit contact?
Can I pass contact department ABTNR into the importing structure.
Thanks,
Suresh Ganti
Hi again,
Contact department (field ABTNR in parameter im_header_contact) is working (as should work every other field in this structure).
I don't know what you mean by contact type?
Regards,
Bruno
Hello Bruno,
I am not sure if you have received my email, but I was able to create an Vendor contact using the method "Create_Contact". I was creating an executable program with a selection screen were the end user can pass the Vendor number and contact name, so the program can create the vendor contact.
But when I try to create an object reference to the class ZCL_VENDOR_CONTACT, the program does not allow because the Class is defined as Private and I guess we cannot create an instance for Private classes.
How do we overcome this situation?
Thanks,
SG
Hi Suresh!
That is true, instantiation of this object is private. Generally, I use the factory pattern, the vendor contact object is returned in method "create_contact". This means that instead of doing:
DATA vendor_contact TYPE REF TO zcl_vendor_contact.
CREATE OBJECT vendor_contact.
You should do:
DATA vendor_contact TYPE REF TO zcl_vendor_contact.
vendor_contact = zcl_vendor_contact=>create_contact( ... ).
I hope this is clear.
Thanks!
Bruno
And by the way, no, I did not receive your email.
Where did you find my email address?
Thanks,
Bruno
Hi Bruno,
Thanks for your class and methods, I have installed the Nuggets and used your class to successfully create Vendor contact.
One thing which was not there at the time of creation is Fax number, which I added into the class and it works.
Hi Bruno, thanks for your contribution.
I could now create the vendor successfully , but still do not understand how it is the edit of the vendor. Whats is the method? Or the key??
Best Regards!!
Hola Jose!
It is actually quite simple. There are 2 static methods, "CREATE_CONTACT" and "READ_CONTACT". If you want to edit an existing contact, you should use static method "READ_CONTACT" which will return an instance of ZCL_VENDOR_CONTACT.
Once you have the instance object, you can use the public instance methods like "SET_PRIVATE_ADDRESS" and "SET_BUSINESS_ADDRESS" to edit the data.
I'm glad you found the class helpful (it is certainly much better than a batch input) and I hope my reply was helpful was well.
Best regards,
Bruno
Hi Bruno,
I installed your nugget well (even if the instructions ENDMETHOD are in double, and occur error during the activation).
I try to delete some contact person for a customer.
How can I use your class for this need ?
Thanks in advance for your help.
Best regards,
Pierre
Hello, Bruno,
this class is just what I’ve been looking for. Thank you so much for providing it.
Unfortunately I still have problems with the installation of the communication data.
FAX, phone and email address is not correctly created.
I have called the method CREATE_CONTACT with the parameter im_header_contact_data and then proceeded to the object with set_business_address.
Can you tell me what I am doing wrong?
Regards Michael
Hi Michael,
It's been way too long since I've done this and I've never looked into it since. I'm not even a programmer anymore... I'm afraid you'll have to do some debugging and try to understand where it might be failing. It could be that things are done differently in your system. This was developed for a fairly old system (still on release 7.31).
Good luck, sorry I'm not much help anymore.