Posted: Thu Sep 18, 2008 11:19 am Post subject: Create customer using FM 'SD_CUSTOMER_MAINTAIN_ALL'
Code:
FUNCTION z_bapi_customer_create.
*"----------------------------------------------------------------------
*"*"Interface local:
*" IMPORTING
*" VALUE(I_KNA1) LIKE KNA1 STRUCTURE KNA1 OPTIONAL
*" VALUE(I_KNB1) LIKE KNB1 STRUCTURE KNB1 OPTIONAL
*" VALUE(I_KNVV) LIKE KNVV STRUCTURE KNVV OPTIONAL
*" EXPORTING
*" VALUE(E_KUNNR) LIKE KNA1-KUNNR
*" REFERENCE(O_KNA1) LIKE KNA1 STRUCTURE KNA1
*" REFERENCE(RETURN) LIKE BAPIRETURN1 STRUCTURE BAPIRETURN1
*" TABLES
*" T_XKNVI STRUCTURE FKNVI OPTIONAL
*" T_XKNB5 STRUCTURE FKNB5 OPTIONAL
*"----------------------------------------------------------------------
*
*-(1) initial routines ------------------------------------------------*
*
* (i) data declaration: fields, items, tables:
*
DATA: subrc LIKE sy-subrc,
credit_control_flag LIKE bapikna108-x_flag VALUE 'X',
postflag LIKE wdl_flag-xflag.
*
* (ii) reset exporting data and sy-subrc
*
CLEAR: return,
sy-subrc.
*
* (iii) fill temporary interface data i_bapikna1_0x, i_bapikna10x
* (in the following: importing data unchanged, work only with
* temporary interface data)
*
*
* (iv) reset data of function kernel
*
CLEAR: i_kna1,
i_knb1,
i_knvv.
REFRESH:
* t_xknbk,
t_xknvi,
* t_xknvk,
* t_xknvp,
t_xknb5.
.
*
*-(2) work routines ---------------------------------------------------*
*
* (i) call "check function"
*
*
* (ii) fill exporting data of "kernel function"
*
*
* (iii) call "kernel function" post synchron (postflag = X)
*
*
* (iv) insert the credit control data
*
IF credit_control_flag = 'X'
AND sy-subrc = 0.
* CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_KNKA_K'
* EXPORTING
* PI_REF_CUSTOMER = E_KUNNR
* PI_CUSTOMER = E_KUNNR
* EXCEPTIONS
* KNKA_INSERT_ERROR = 23
* KNKK_INSERT_ERROR = 24.
CALL FUNCTION 'CREDITCONTROL_INSERT_DEFAULT' IN UPDATE TASK
EXPORTING
kunnr = e_kunnr
kkber = i_knvv-kkber
knrze = i_knb1-knrze.
ENDIF.
*
* (v) return-value "kernel function"
*
* (1) reset data of function kernel
*
CLEAR: i_kna1,
i_knb1,
i_knvv.
* I_BAPIADDR1_01,
* I_BAPIADDR2_01.
*
* (2) error-handling
* return value sy-subrc, only in case sy-subrc = 0
* the exporting data customer_number (customerno)
* will be changed
*
subrc = sy-subrc.
CLEAR sy-subrc.
*
*-(3) set return values and leave the function ------------------------*
* customerno (key-field of BO KNA1), pe_customer, return
*
PERFORM returnsubrc_1
USING subrc
e_kunnr
CHANGING e_kunnr
return.
IF subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.