Skip to Content
0
Former Member
Jul 18, 2007 at 03:04 PM

Rfc error

43 Views

hi,

can any body Debug this code.

Customer record is not inserting into table KNA1.

FUNCTION ZRFC_CUSTOMER_UPDATE.

*"----


""Global Interface:

*" EXPORTING

*" VALUE(RFCRC) LIKE SY-SUBRC

*" VALUE(ERROR_TEXT) LIKE T100-TEXT

*" TABLES

*" CUSTOMER_T STRUCTURE BRFCKNA1

*" EXCEPTIONS

*" UPDATE_ERROR

*"----


DATA UPDATE_VIA_CALL_TRANSACTION VALUE 'X'.

LOOP AT CUSTOMER_T.

IF UPDATE_VIA_CALL_TRANSACTION = 'X'.

  • update via CALL TRANSACTION

  • PERFORM BDC_INIT.

PERFORM BDC_NEXT_DYNPRO USING 'SAPMF02D' 101.

PERFORM BDC_SET_FIELD USING 'RF02D-KUNNR' CUSTOMER_T-KUNNR.

PERFORM BDC_SET_FIELD USING 'RF02D-D0110' 'X'.

PERFORM BDC_NEXT_DYNPRO USING 'SAPMF02D' 110.

PERFORM BDC_SET_FIELD USING 'KNA1-ANRED' CUSTOMER_T-ANRED.

PERFORM BDC_SET_FIELD USING 'KNA1-NAME1' CUSTOMER_T-NAME1.

PERFORM BDC_SET_FIELD USING 'KNA1-PFACH' CUSTOMER_T-PFACH.

PERFORM BDC_SET_FIELD USING 'KNA1-STRAS' CUSTOMER_T-STRAS.

PERFORM BDC_SET_FIELD USING 'KNA1-PSTLZ' CUSTOMER_T-PSTLZ.

PERFORM BDC_SET_FIELD USING 'KNA1-ORT01' CUSTOMER_T-ORT01.

PERFORM BDC_SET_FIELD USING 'KNA1-TELF1' CUSTOMER_T-TELF1.

PERFORM BDC_SET_FIELD USING 'KNA1-TELFX' CUSTOMER_T-TELFX.

PERFORM BDC_SET_FIELD USING 'BDC_OKCODE' '=UPDA'.

PERFORM BDC_CALL USING 'XD02' CHANGING ERROR_TEXT.

ELSE.

  • update via SAP SQL

UPDATE KNA1 SET

ANRED = CUSTOMER_T-ANRED

NAME1 = CUSTOMER_T-NAME1

PFACH = CUSTOMER_T-PFACH

STRAS = CUSTOMER_T-STRAS

PSTLZ = CUSTOMER_T-PSTLZ

ORT01 = CUSTOMER_T-ORT01

TELF1 = CUSTOMER_T-TELF1

TELFX = CUSTOMER_T-TELFX

WHERE KUNNR = CUSTOMER_T-KUNNR.

ENDIF.

  • exception handling

IF SY-SUBRC NE 0.

RFCRC = SY-SUBRC.

  • raise update_error.

ENDIF.

ENDLOOP.

ENDFUNCTION.

*----


*

  • Start new screen

*

*----


*

FORM BDC_NEXT_DYNPRO USING program dynpro.

CLEAR BDC_CALL.

BDC_CALL-program = program.

BDC_CALL-dynpro = dynpro.

BDC_CALL-dynbegin = 'X'.

APPEND BDC_CALL.

ENDFORM. "BDC_NEXT_DYNPRO

*----


*

  • Insert field

*

*----


*

FORM BDC_SET_FIELD USING fnam fval.

IF fval <> space.

CLEAR BDC_CALL.

BDC_CALL-fnam = fnam.

BDC_CALL-fval = fval.

APPEND BDC_CALL.

ENDIF.

ENDFORM. "BDC_SET_FIELD