Thursday, May 29, 2008

SAP ABAP BAPI to Read Customer Data

SAP ABAP BAPI to Read Customer Data

In case you wish to read the customer data you can use the following BAPI, it retrieves the Customer Master (Company Code) Data and the General Data in Customer Master.

SAP ABAP BAPI to Read Customer Master Data
CUSTOMER_READ

You need to pass the Customer Number and the Company Code. See the example given below.


REPORT ZEX_CUSTOMERREAD .

Parameters: p_bukrs like KNB1-BUKRS,
            p_kunnr like KNA1-KUNNR.


Data: ty_kna1 type kna1,
      ty_knb1 type knb1.

Data: int_kna1 like ty_kna1,
      int_knb1 like ty_knb1.

CALL FUNCTION 'CUSTOMER_READ'
  EXPORTING
    I_BUKRS         = p_bukrs
    I_KUNNR         = p_kunnr
 IMPORTING
   E_KNA1          = int_Kna1
   E_KNB1          = int_knb1
 EXCEPTIONS
   NOT_FOUND       = 1
   OTHERS          = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


No comments:

Post a Comment