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

Problem While creating Customer Using BAPI need help

Former Member
0 Likes
615

Dear Abaper


gating error while Creating customer BAPI


error like : -  No reference customer exists for sales area 1011 06 00

so need help to create Customer


*&---------------------------------------------------------------------*

*& Report  ZTEST_CUSTOMER_OTHER_WAIST

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZTEST_CUSTOMER.

 

Data : cpd like bapikna101_1 OCCURS 0 WITH HEADER LINE,

        ocpd like bapikna105  occurs 0 with header line,

        ccd like  bapikna106 occurs 0 WITH HEADER LINE,

        occd LIKE bapikna105 occurs 0 WITH HEADER LINE,

        acm LIKE  bapikna107 occurs 0 WITH HEADER LINE,

        rd LIKE bapikna102  occurs 0 WITH HEADER LINE,

        UCCD LIKE  bapikna108  occurs 0 WITH HEADER LINE.

data : return like BAPIRETURN1 occurs 0 with header line.

data : begin of it_error occurs 0,

          err_msg(73) type c,    "TO RETREIVE ERROR MESSAGES

      end of it_error.

      data : begin of it_success occurs 0,

       CUSTOMERNO like  BAPIKNA103-CUSTOMER ,

         srno(4),

       end of it_success.

data CUSTOMERNO like  BAPIKNA103-CUSTOMER.

data: tot_rec type i,     "Total Records

      gd_update type i,   "Main Table Increement Counter

      gd_lines type i,    "Success Table increement Counter

      w_textout like t100-text. "VARIABLE TO GET ERRORLOG

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS:p_file TYPE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK b1.

      "________________________________________________

" Customer Personal Data

cpd-title_p    'Company'.

cpd-firstname  =   'Sri Raghavendra Stationary & Gen. Store'.

cpd-lastname   '13-2, Main Road,Toopran-502334,Dist: Medak (A.P.)'.

cpd-middlename '.'.

cpd-secondname '.'.

*cpd-date_birth =

cpd-city       'TOOPRAN'.

*cpd-district   =

cpd-postl_cod1 '502334'.

*cpd-postl_cod2 =

*cpd-po_box     =

*cpd-po_box_cit =

cpd-street     = '   '.

*cpd-house_no   =

*cpd-building   =

*cpd-floor      =

*cpd-room_no    =

cpd-country    = 'IN'.

*cpd-countryiso =

cpd-region     = 'AP'.

cpd-tel1_numbr = '9490867337'.

*cpd-tel1_ext   =

*cpd-fax_number =

*cpd-fax_extens =

cpd-e_mail     = 'dheeraj.late1@gmail.com'.

cpd-langu_p    =

cpd-langup_iso =

cpd-currency   = 'INR'.

*cpd-currency_iso =

*cpd-currency_iso =

*cpd-title_key =

*cpd-only_change_comaddress =

APPEND CPD.

"_____________________ " Optional Customer Personal Data

*ocpd-TRANSPZONE    =

ocpd-CONTROL_ACCOUNT   = '20402010'.

"ocpd-PMNTTRMS   =

ocpd-SHIP_COND    = '01'.

ocpd-DELYG_PLNT   = '1108'.

ocpd-PART_DLV   '9'.

*ocpd-C_CTR_AREA    =

*ocpd-TAXJURCODE    =

APPEND OCPD.

"__________________ Customer Company Data,

CCD-TITLE    = 'Company'.

*CCD-TITLE_KEY   =

CCD-NAME   =   'Sri Raghavendra Stationary & Gen. Store'.

CCD-NAME_2   = '13-2, Main Road,'.

CCD-NAME_3   = 'Toopran-502334,'.

CCD-NAME_4   = 'Dist: Medak (A.P.)'.

"CCD-C_O_NAME    =

CCD-CITY   =' TOOPRAN'.

CCD-DISTRICT   = ''.

"CCD-CITY_NO   =

CCD-POSTL_COD1   = '502334'.

"CCD-POSTL_COD2    =

"CCD-PO_BOX    =

"CCD-DELIV_DIS   =

CCD-STREET   = ''.

*CCD-HOUSE_NO    =

*CCD-BUILDING    =

*CCD-FLOOR   =

*CCD-ROOM_NO   =

CCD-COUNTRY    = 'IN'.

CCD-LANGU    = 'EN'.

CCD-REGION   = 'AP'.

CCD-TEL1_NUMBR   = '9490867337'.

*CCD-TEL1_EXT    =

*CCD-FAX_NUMBER    =

*CCD-FAX_EXTENS    =

CCD-E_MAIL   = 'N@A'.

*CCD-COUNTRYISO    =

*CCD-LANGU_ISO   =

*CCD-CURRENCY    =

*CCD-CURRENCY_ISO    =

APPEND CCD.

***"" _______________Optional Customer Company Data,

*

**OCCD-TRANSPZONE  =

  OCCD-CONTROL_ACCOUNT  = '20402010'.

**OCCD-PMNTTRMS  =

  OCCD-SHIP_COND  = '01'.

  OCCD-DELYG_PLNT  = '1108'.

  OCCD-PART_DLV  '9'.

**OCCD-C_CTR_AREA  =

**OCCD-TAXJURCODE  =

  APPEND OCCD.

"___________________"Allow Consumer Maintenance

ACM-consumer_flag = 'X'.

APPEND ACM.

"______________________Reference Data

rd-SALESORG  = '1011'.

rd-DISTR_CHAN  = '06' .

rd-DIVISION  '00'.

rd-REF_CUSTMR  '142645' .

APPEND RD.

"__________________"update_credit_control_data

   uccd-x_flag = 'X'.

  APPEND UCCD.

"_________________________________

  CALL FUNCTION 'BAPI_CUSTOMER_CREATEFROMDATA1'

    EXPORTING

     pi_personaldata             = cpd

    PI_OPT_PERSONALDATA          = ocpd

     PI_COMPANYDATA               = ccd

     PI_OPT_COMPANYDATA           = occd

    PI_CONSUMEREN                 = ACM

      pi_copyreference            = RD

     PI_CREDIT_CONTROL_FLAG       = UCCD

   IMPORTING

     CUSTOMERNO                   CUSTOMERNO

     RETURN                       =   RETURN

            .

**loop at RETURN.

*

* loop at RETURN.

    READ TABLE return.

write : RETURN-MESSAGE.

 

*  ENDLOOP.

    if CUSTOMERNO <> space.

   commit work.

         add 1 to gd_update.

     commit work.

       it_success-CUSTOMERNO = CUSTOMERNO.

        " it_success-srno = tab-srno.

         append it_success.

          else.

               "__________________________

    loop at return.

    it_error-err_msg = return-message .

    append it_error.

    ENDLOOP.

    ENDIF.

1 REPLY 1
Read only

former_member185613
Contributor
0 Likes
536

Hi,

Please check if the customer 142645 exist for sales organization 1011, distribution channel 06 and division 00. If it does not exist, you will have to use a customer that exists for the sales area appearing in the error.

When using BAPI to create customer, a reference customer is required which will be used to get company code data, tax code and other reminder data for the newly created customer.

Hope this helps,

~Athreya