Skip to Content
0
Former Member
Mar 01, 2008 at 02:49 PM

Urgent help in coding of creating New Business partner?

25 Views

Hi Friends,

I need urgent help on this.Please give me the solution.

This is the coding which i written for creating new BP.

FUNCTION ZCTS_NEW_CONTACT.

*"----


""Local interface:

*" IMPORTING

*" VALUE(BUSINESSPARTNER) LIKE BAPIBUS1006_HEAD-BPARTNER

*" VALUE(CNEWINFO) TYPE ZCTS_CONTACTS

*" VALUE(CDATA) LIKE BAPIBUS1006_CENTRAL STRUCTURE

*" BAPIBUS1006_CENTRAL

*" VALUE(BUSPART1) LIKE BAPIBUS1006_RELHEAD-BUSINESSPARTNER1

*" VALUE(BUSPART2) LIKE BAPIBUS1006_RELHEAD-BUSINESSPARTNER2

*" VALUE(RELCAT) LIKE BAPIBUS1006_RELHEAD-RELATIONSHIPCATEGORY

*" EXPORTING

*" VALUE(MESG) TYPE CHAR100

*"----


DATA: lt_return like bapiret2 occurs 0 with Header line.

DATA: CTPERS LIKE BAPIBUS1006_CENTRAL_PERSON OCCURS 0 WITH HEADER LINE.

DATA : PARTN_GRP TYPE BAPIBUS1006_HEAD-PARTN_GRP.

DATA : PARTN_CAT TYPE BAPIBUS1006_HEAD-PARTN_CAT.

DATA: BEGIN OF ADADD.

INCLUDE STRUCTURE BAPIBUS1006_ADDRESS.

DATA: END OF ADADD.

DATA: BEGIN OF ADTEL OCCURS 0.

INCLUDE STRUCTURE BAPIADTEL.

DATA: END OF ADTEL.

DATA: BEGIN OF ADSMP OCCURS 0.

INCLUDE STRUCTURE BAPIADSMTP.

DATA: END OF ADSMP.

CTPERS-FIRSTNAME = CNEWINFO-FNAME.

CTPERS-LASTNAME = CNEWINFO-LNAME.

PARTN_CAT = 1.

PARTN_GRP = 002.

ADADD-CITY = CNEWINFO-CITY .

  • telephone info **

ADTEL-TELEPHONE = CNEWINFO-PHONE.

ADTEL-CONSNUMBER = '001'.

APPEND ADTEL.

ADTEL-TELEPHONE = CNEWINFO-MOBILE.

ADTEL-CONSNUMBER = '002'.

APPEND ADTEL.

  • email information **

ADSMP-E_MAIL = CNEWINFO-EMAIL .

APPEND ADSMP.

CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'

EXPORTING

PARTNERCATEGORY = PARTN_CAT

CENTRALDATA = CDATA

PARTNERGROUP = PARTN_GRP

CENTRALDATAPERSON = CTPERS

ADDRESSDATA = ADADD

IMPORTING

BUSINESSPARTNER = BUsinessPartner

TABLES

TELEFONDATA = ADTEL

E_MAILDATA = ADSMP

RETURN = lt_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

*PARTN_CAT = 1.

*PARTN_GRP = 002.

*ADADD-CITY = CNEWINFO-CITY .

*

  • telephone info **

  • ADTEL-TELEPHONE = CNEWINFO-PHONE.

  • ADTEL-CONSNUMBER = '001'.

  • APPEND ADTEL.

  • *

    *

    • ADTEL-TELEPHONE = CNEWINFO-MOBILE.

    • ADTEL-CONSNUMBER = '002'.

    • APPEND ADTEL.

    *

    *

    • email information **

  • ADSMP-E_MAIL = CNEWINFO-EMAIL .

  • APPEND ADSMP.

  • *

    CALL FUNCTION 'BAPI_BUPR_PFCT_CREATEFROMDATA'

    EXPORTING

    BUSINESSPARTNER1 = BUSPART1

    BUSINESSPARTNER2 = BUSPART2

    RELATIONSHIPCATEGORY = RELCAT

    TABLES

    RETURN = lt_return.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

    EXPORTING

    WAIT = 'X'.

    LOOP AT lt_return WHERE TYPE = 'E'.

    MESG = ' NOT CREATED NEW CONTACT'(020).

    EXIT.

    ENDLOOP.

    ENDFUNCTION.

    Early reply is highly appriciable.

    Regards,

    BONA