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

Changing customer master using sd_customer_maintain_all function module.

Former Member
0 Likes
5,343

Hi all,

I will be thankful if somebody can explain me how to change customer master using function module -sd_customer_maintain_all.

Thanks.

3 REPLIES 3
Read only

Former Member
0 Likes
1,622

Hi Sandeep,

Eg:

CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'
EXPORTING
i_kna1 = i_kna1 " General part
i_knb1 = i_knb1 " Company code details
i_knvv = i_knvv " Sales area info
i_bapiaddr1 = i_bapiaddr1 " Address
pi_postflag = pi_postflag " X=Post document
IMPORTING
e_kunnr = e_kunnr. "Customer.

Refer to foll links:

http://abaplovers.blogspot.com/2008/03/create-customer-sdcustomermaintainall.html

Regards,

Sunil

Read only

Former Member
0 Likes
1,622

Hi

I use the function SD_CUSTOMER_MAINTAIN_ALL for change a customer data. But I have a problem.

I pass the parameters I_KNA1 and I_BAPIADDR1, becouse in my program is posible change the general information, and the direction information.

And pass one 'X' in I_MAINTAIN_ADDRESS_BY_KNA1, and other one in PI_POSTFLAG.

When execute the program. the direction information is changed, but the general information is deleted.

Example code:

SELECT SINGLE * FROM KNA1 WHERE KUNNR = IM_CUSTOMER-KUNNR.

IF SY-SUBRC = 0.

SELECT SINGLE * FROM KNA1 WHERE KUNNR = IM_CUSTOMER-KUNNR.

MOVE-CORRESPONDING KNA1 TO I_KNA1.

I_KNA1-MANDT = SY-MANDT.

I_KNA1-KUNNR = IM_CUSTOMER-KUNNR.

IF NOT IM_CUSTOMER-NAME1 IS INITIAL.

I_KNA1-NAME1 = IM_CUSTOMER-NAME1.

ENDIF.

IF NOT IM_CUSTOMER-NAME2 IS INITIAL.

I_KNA1-NAME2 = IM_CUSTOMER-NAME2.

ENDIF.

IF NOT IM_CUSTOMER-NAME3 IS INITIAL.

I_KNA1-NAME3 = IM_CUSTOMER-NAME3.

ENDIF.

IF NOT IM_CUSTOMER-SORT1 IS INITIAL.

I_KNA1-SORTL = IM_CUSTOMER-SORT1.

ENDIF.

IF NOT IM_CUSTOMER-TEL_NUMBER IS INITIAL.

I_KNA1-TELF1 = IM_CUSTOMER-TEL_NUMBER.

ENDIF.

SELECT SINGLE KTOKD FROM KNA1 INTO I_KNA1-KTOKD

WHERE KUNNR = IM_CUSTOMER-KUNNR.

IF NOT IM_CUSTOMER-STREET IS INITIAL OR

NOT IM_CUSTOMER-HOUSE_NUM1 IS INITIAL OR

NOT IM_CUSTOMER-HOUSE_NUM2 IS INITIAL OR

NOT IM_CUSTOMER-CITY1 IS INITIAL OR

NOT IM_CUSTOMER-POST_CODE1 IS INITIAL OR

NOT IM_CUSTOMER-COUNTRY IS INITIAL OR

NOT IM_CUSTOMER-REGION IS INITIAL.

  • Pass address values

SELECT SINGLE ADRNR FROM KNA1 INTO I_BAPIADDR1-ADDR_NO

WHERE KUNNR = IM_CUSTOMER-KUNNR.

I_BAPIADDR1-STREET = IM_CUSTOMER-STREET.

I_BAPIADDR1-HOUSE_NO = IM_CUSTOMER-HOUSE_NUM1.

I_BAPIADDR1-HOUSE_NO2 = IM_CUSTOMER-HOUSE_NUM2.

I_BAPIADDR1-CITY = IM_CUSTOMER-CITY1.

I_BAPIADDR1-POSTL_COD1 = IM_CUSTOMER-POST_CODE1.

I_BAPIADDR1-COUNTRY = IM_CUSTOMER-COUNTRY.

I_BAPIADDR1-REGION = IM_CUSTOMER-REGION.

ENDIF.

  • Call the standart BAPI, to change customer data

CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'

EXPORTING

I_KNA1 = I_KNA1

I_BAPIADDR1 = I_BAPIADDR1

I_MAINTAIN_ADDRESS_BY_KNA1 = 'X'

PI_POSTFLAG = 'X'

  • PI_CAM_CHANGED = 'X'

IMPORTING

E_KUNNR = E_KUNNR

O_KNA1 = O_KNA1

E_SD_CUST_1321_DONE = E_SD_CUST_1321_DONE.

IF SY-SUBRC = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = IT_RETURN1.

ENDIF.

thanks for the answers

Read only

0 Likes
1,622

Hi, I have the same problem, when I try to update some customer information, the other general are deleted. The parameters are the same. X' in I_MAINTAIN_ADDRESS_BY_KNA1, and other one in PI_POSTFLAG.

Thanks for answers or suggestions.