Application Development 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: 

INSERT STATEMENT ERROR

Former Member
0 Kudos

HI,

I try to insert the data in database

but one error will coming

''The work area "CUSTOMER_T" is not long enough .'' .

FUNCTION ZRFC_CUSTOMER_INSERT.

*"----


""Local Interface:

*" EXPORTING

*" VALUE(RFCRC) LIKE SY-SUBRC

*" VALUE(ERROR_TEXT) TYPE T100-TEXT

*" TABLES

*" CUSTOMER_T STRUCTURE BRFCKNA1 OPTIONAL

*" EXCEPTIONS

*" INSERT_ERROR

*"----


DATA INSERT_VIA_CALL_TRANSACTION VALUE 'X'.

LOOP AT CUSTOMER_T.

IF INSERT_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-KUNNR' CUSTOMER_T-KUNNR.

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.

INSERT INTO KNA1 VALUES CUSTOMER_T.

*INSERT INTO KNA1 KUNNR,ANRED,NAME1,PFACH,STRAS,PSTLZ,ORT01,

  • TELF1,TELFX VALUES

KNA1-KUNNR = CUSTOMER_T-KUNNR,

KNA1-ANRED = CUSTOMER_T-ANRED,

KNA1-NAME1 = CUSTOMER_T-NAME1,

KAN1-PFACH = CUSTOMER_T-PFACH,

KAN1-STRAS = CUSTOMER_T-STRAS,

KAN1-PSTLZ = CUSTOMER_T-PSTLZ,

KAN1-ORT01 = CUSTOMER_T-ORT01,

KAN1-TELF1 = CUSTOMER_T-TELF1,

KAN1-TELFX = CUSTOMER_T-TELFX.

ENDIF.

  • exception handling

IF SY-SUBRC NE 0.

RFCRC = SY-SUBRC.

  • raise update_error.

ENDIF.

ENDLOOP.

*

ENDFUNCTION.

*----


*

  • Start new screen

*

*----


FORM BDC_INIT.

CLEAR BDC_CALL.

APPEND BDC_CALL.

ENDFORM. "BDC_INIT

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

<b>Change the Structure of CUSTOMER_T to KNA1 from BRFCKNA1</b>

Vasanth

3 REPLIES 3

varma_narayana
Active Contributor
0 Kudos

Hi...

Syntax for INSERT

INSERT <dbtable> from <WA>.

INSERT <dbtable> from table <ITAB> accepting duplicate keys.

In both cases the WA or ITAB must have the Same structure as DBtable.

Then it works.

<b>Reward if helpful.</b>

Former Member
0 Kudos

Hello,

<b>Change the Structure of CUSTOMER_T to KNA1 from BRFCKNA1</b>

Vasanth

Former Member
0 Kudos

In the interface of your function module, under the tables tab change the definition for the table customer_t as type KNA1 instead of BRFCKNA1.

Manoj