Application Development and Automation 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: 
Read only

Need sample code for using BCONTACT object in ABAP

Former Member
0 Likes
859

Hello All,

This is going to be my very first venture into the realm of OO / ABAP programming. And what venture it will be! I've been assigned the task of modifying an ABAP program so that it uses the BCONTACT object in order to create a contact.

Now, I need to see how it is done in other programs. What data elements or attributes do I need to set? How do I set or populate them? Anything else that goes with it?

So, any idea where I can find such code?

Your help is greatly appreciated.

3 REPLIES 3
Read only

Former Member
0 Likes
673

no answer therefore closing the question

Read only

0 Likes
673

Hey Goharjou

Did you find how ?

I am stuck with a simillar requirement.

Please send me the sample code in case you have one

sameer.sameerahmed@gmail.com

Thanks !!

Read only

0 Likes
673

After much back and forth the following code did the job for me. Obviously, you have to make sure that you have the right objrole and objtype and other values which relate to your screen elements (whatever screen you are using). Hope this helps.

*&----


*

*& Form create contact

*&----


*

FORM create_contact.

  • contact creation

REFRESH t_objects.

w_objects-objrole = 'DEFAULT'.

w_objects-OBJTYPE = 'ISUSMORDER'.

  • w_objects-objtype = 'BUS2007'.

w_objects-objkey = t_zisu_let_ot-auftrag.

APPEND w_objects TO t_objects.

w_bcontd-ctype = '003'.

w_bcontd-cclass = '1800'.

w_bcontd-activity = '0004'.

w_bcontd-f_coming = '2'.

w_bcontd-origin = '1'.

w_bcontd-addinfo = ' '.

w_bcontd-priority = '01'.

w_bcontd-custinfo = ' '.

w_auto-bcontd = w_bcontd.

w_auto-bcontd_use = 'X'.

w_auto-bcontd_okcode = 'SAVE'.

w_auto-iobjects = t_objects.

*

CALL FUNCTION 'BCONTACT_CREATE'

EXPORTING

x_upd_online = 'X'

x_no_dialog = 'X'

x_auto = w_auto

x_prgcontext = sy-repid

x_subcontext = ' '

x_bpcconfig = ' '

x_partner = w_partner

x_altpartner = ' '

x_pcategory = ' '

IMPORTING

y_new_bpcontact = w_bpcontact

EXCEPTIONS

existing = 1

foreign_lock = 2

number_error = 3

general_fault = 4

input_error = 5

not_authorized = 6

OTHERS = 7.

IF sy-subrc = 0.

WRITE: / 'Contact ', w_bpcontact, 'a été créé'.

ELSE.

CASE sy-subrc.

WHEN 1.

WRITE: / '…’.

WHEN 2.

WRITE: / '…’.

WHEN 3.

WHEN 4.

WHEN 5.

WHEN 6.

WHEN 7.

WHEN OTHERS.

ENDCASE.

ENDIF.

COMMIT WORK.

ENDFORM. " create_contact