Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

a problem about CS02 BDC

Hi,

I wrote a bdc about modification BOM's quantity of line item with ECM number. following is code:

report ZCS02_BDC

no standard page heading line-size 255.

  • BDC table

DATA: t_bdc LIKE bdcdata OCCURS 0 WITH HEADER LINE,

t_bdcmsg LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF t_log OCCURS 0,

information(289) TYPE c, "返回信息

END OF t_log.

DATA: v_mode TYPE c VALUE 'N'.

perform fm_set_bdc tables t_bdc using 'X' 'SAPLCSDI' '0100'.

perform fm_set_bdc:

tables t_bdc using ' ' 'BDC_CURSOR' 'RC29N-AENNR',

tables t_bdc using ' ' 'BDC_OKCODE' '/00',

tables t_bdc using ' ' 'RC29N-MATNR' '1224',

tables t_bdc using ' ' 'RC29N-STLAN' '2',

tables t_bdc using ' ' 'RC29N-AENNR' '500000000084',

tables t_bdc using ' ' 'RC29N-DATUV' '09.10.2008',

tables t_bdc using 'X' 'SAPLCSDI' '0150',

tables t_bdc using ' ' 'BDC_CURSOR' 'RC29P-MENGE(02)',

tables t_bdc using ' ' 'BDC_OKCODE' '=FCBU',

tables t_bdc using ' ' 'RC29P-MENGE(01)' '2',

tables t_bdc using ' ' 'RC29P-MENGE(02)' '3',

tables t_bdc using 'X' 'SAPLCSDI' '0130',

tables t_bdc using ' ' 'BDC_OKCODE' '/EENDE'.

CALL TRANSACTION 'CS02'

USING t_bdc

MODE 'N' "Background performance

UPDATE 'S' "local updata

MESSAGES INTO t_bdcmsg. "all message table

READ TABLE t_bdcmsg WITH KEY msgtyp = 'S'

msgid = 'V1'

msgnr = '311'.

"批导入成功的标志,可以自己debug表t_bdcmsg中去找.

IF sy-subrc EQ 0.

CONCATENATE '' '修改成功' INTO t_log.

APPEND t_log.

CLEAR t_log.

ELSE.

LOOP AT t_bdcmsg.

IF t_bdcmsg-msgtyp = 'E'

OR t_bdcmsg-msgv1 <> ''

OR t_bdcmsg-msgv2 <> ''

OR t_bdcmsg-msgv3 <> ''

OR t_bdcmsg-msgv4 <> ''.

MESSAGE ID t_bdcmsg-msgid

TYPE t_bdcmsg-msgtyp

NUMBER t_bdcmsg-msgnr

WITH t_bdcmsg-msgv1

t_bdcmsg-msgv2

t_bdcmsg-msgv3

t_bdcmsg-msgv4

INTO t_log-information.

CONCATENATE '出错:' t_log-information INTO t_log-information.

APPEND t_log.

CLEAR t_log.

ENDIF.

ENDLOOP.

ENDIF.

LOOP AT t_log. "显示出错信息

WRITE:/ t_log-information.

ENDLOOP.

*perform close_group.

FORM fm_set_bdc TABLES t_bdc STRUCTURE bdcdata

USING u_sign TYPE c

u_par1

u_par2.

CLEAR: t_bdc.

IF u_sign = 'X'.

t_bdc-program = u_par1.

t_bdc-dynpro = u_par2.

t_bdc-dynbegin = u_sign.

ELSE.

t_bdc-fnam = u_par1.

t_bdc-fval = u_par2.

ENDIF.

APPEND t_bdc.

ENDFORM. "fm_set_bdc

excuted the code,display 'error:Date 24.10.2008 copied from change number'

why didn't this warning skip in BDC?

How to solve this problem?

Best Regards.

Pangyanting

replied

Hi

I dont see any internal table in the code looping...you are executing the same values which are taken from recording..

For Example:

perform fm_set_bdc_field tables t_bdc using 'RC29N-MATNR'
'0000013107'. " this is the value given during recording

perform fm_set_bdc_field tables t_bdc using 'RC29N-MATNR'
itab-matnr. "it should be replaced like this,so the material number you want to upload will be entered in the field.

You are getting sy-subrc = 0,because it is creating with the same values again.

Further here is the sample code for BDC:

REPORT  ZZPSALES_BDC1.

types: begin of itab,
       b1(4) type c,
       b2(4) type c,
       b3(2) type c,
       b4(2) type c,
       b5(10) type c,
       b6(10),
       b7(10) type C,
       b8(10) type c,
       b9(8) type c,
       b10(8) type c,
       end of itab,


       begin of itab1,
       b8(10) type c,
       i1(15) type c,
       i2(4) type c,
       i3(4) type c,
       i4(15) type c,
       end of itab1.


data: wa_itab type itab occurs 1 with header line.
data: wa_itab1 type itab1 occurs 1 with header line.

DATA: I_BDCDATA TYPE BDCDATA OCCURS 1 WITH HEADER LINE.

data: it_itab type alsmex_tabline occurs 1 with header line,
      it_itab1 type alsmex_tabline occurs 1 with header line .

parameters: file1 type rlgrap-filename default 'C:\Documents and Settings\pri\Desktop\open SO1.xls' lower case.

DATA: CNT TYPE N,
      cnt1 type n.
DATA:FNAM(20) TYPE C.
DATA: SAPDATE(10) TYPE C.
at selection-screen.

at selection-screen on value-request for file1.
*
  CALL FUNCTION 'F4_FILENAME'
*    EXPORTING
*      PROGRAM_NAME        = SYST-CPROG
**      DYNPRO_NUMBER       = SYST-DYNNR
**      FIELD_NAME          = ' '
   IMPORTING
     FILE_NAME           = file1.
*
*
*
*
start-of-selection.

 CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
   EXPORTING
     FILENAME                      = file1
     I_BEGIN_COL                   = 2
     I_BEGIN_ROW                   = 9
     I_END_COL                     = 11
     I_END_ROW                     = 10
   TABLES
     INTERN                        = it_itab
*  EXCEPTIONS
*    INCONSISTENT_PARAMETERS       = 1
*    UPLOAD_OLE                    = 2
*    OTHERS                        = 3
           .
 IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 ENDIF.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    FILENAME                      = file1
    I_BEGIN_COL                   = 1
    I_BEGIN_ROW                   = 22
    I_END_COL                     = 5
    I_END_ROW                     = 25
  TABLES
    INTERN                        = it_itab1
* EXCEPTIONS
*   INCONSISTENT_PARAMETERS       = 1
*   UPLOAD_OLE                    = 2
*   OTHERS                        = 3
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

loop at it_itab.


case it_itab-col.

when '1'.
  wa_itab-b1 = it_itab-value.
when '2'.
  wa_itab-b2 = it_itab-value.
when '3'.
  wa_itab-b3 = it_itab-value.
when '4'.
  wa_itab-b4 = it_itab-value.
when '5'.
  wa_itab-b5 = it_itab-value.
when '6'.
  wa_itab-b6 = it_itab-value.
when '7'.
  wa_itab-b7 = it_itab-value.
when '8'.
  wa_itab-b8 = it_itab-value.
when '9'.
  wa_itab-b9 = it_itab-value.
 when '10'.
  wa_itab-b10 = it_itab-value.
append wa_itab.
 endcase.
endloop.


 loop at it_itab1.
case it_itab1-col.
  when '1'.
    wa_itab1-b8 = it_itab1-value.
  when '2'.
    wa_itab1-i1 = it_itab1-value.
  when '3'.
    wa_itab1-i2 = it_itab1-value.
  when '4'.
    wa_itab1-i3 = it_itab1-value.
  when '5'.
    wa_itab1-i4 = it_itab1-value.
  append wa_itab1.
  endcase.
  endloop.


CLEAR SY-TABIX.
loop at wa_itab.


refresh i_bdcdata.

perform bdc_dynpro      using 'SAPMV45A' '0101'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBAK-AUART'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'VBAK-AUART'
                              WA_ITAB-B1.
perform bdc_field       using 'VBAK-VKORG'
                              WA_ITAB-B2.
perform bdc_field       using 'VBAK-VTWEG'
                              WA_ITAB-B3.
perform bdc_field       using 'VBAK-SPART'
                              WA_ITAB-B4.

CNT = 1.

CLEAR WA_ITAB1.
LOOP AT WA_ITAB1 WHERE B8 = WA_ITAB-B8.


perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'VBKD-BSTKD'
                              WA_ITAB-B8. "observe here, we are giving customized fields.
perform bdc_field       using 'KUAGV-KUNNR'
                              WA_ITAB-B5.
perform bdc_field       using 'KUWEV-KUNNR'
                              WA_ITAB-B6.
perform bdc_field       using 'RV45A-KETDAT'
                              '06/25/2008'.
perform bdc_field       using 'RV45A-KPRGBZ'
                              'D'.




concatenate 'RV45A-KWMENG(0' CNT ')' INTO FNAM.
perform bdc_field       using 'BDC_CURSOR'
                              FNAM.




CONCATENATE 'RV45A-MABNR(0' CNT ')' INTO FNAM.

perform bdc_field       using FNAM
                              WA_ITAB1-I1.
CONCATENATE 'RV45A-KWMENG(0' CNT ')' INTO FNAM.
perform bdc_field       using FNAM
                              WA_ITAB1-I2.



perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ITEM'.
perform bdc_field       using 'VBKD-BSTKD'
                              WA_ITAB-B8.
perform bdc_field       using 'KUAGV-KUNNR'
                              WA_ITAB-B5.
perform bdc_field       using 'KUWEV-KUNNR'
                              WA_ITAB-B6.
perform bdc_field       using 'RV45A-KETDAT'
                              '06/25/2008'.
perform bdc_field       using 'RV45A-KPRGBZ'
                              'D'.
perform bdc_field       using 'VBKD-ZTERM'
                              'N45'.
perform bdc_field       using 'VBKD-INCO1'
                              'FOB'.
perform bdc_field       using 'VBKD-INCO2'
                              'New York'.



concatenate 'RV45A-KWMENG(0' cnt ')' into fnam.
perform bdc_field       using 'BDC_CURSOR'
                              FNAM.

READ TABLE WA_ITAB1." INDEX '0' .
*
IF SY-TABIX = 1.
perform bdc_dynpro      using 'SAPMV45A' '4003'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'BDC_OKCODE'
                              '=T\06'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV45A-KWMENG'.
*perform bdc_field       using 'RV45A-KWMENG'
*                              WA_ITAB1-I2.
*perform bdc_field       using 'VBAP-VRKME'
*                              'EA'.
perform bdc_field       using 'RV45A-ETDAT'
                              wa_itab-b7.
*perform bdc_field       using 'RV45A-PRGBZ'
*                              'D'.


ENDIF.

perform bdc_dynpro      using 'SAPMV45A' '5003'.
perform bdc_field       using 'BDC_OKCODE'
                             '/00'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMV-KBETR(07)'.


perform bdc_field       using 'KOMV-KSCHL(07)'
                              WA_ITAB1-I3.
perform bdc_field       using 'KOMV-KBETR(07)'
                              WA_ITAB1-I4.


perform bdc_dynpro      using 'SAPMV45A' '5003'.
perform bdc_field       using 'BDC_OKCODE'
                              '=HEAD'.
perform bdc_field       using 'BDC_CURSOR'
                              'KOMV-KSCHL(08)'.



perform bdc_dynpro      using 'SAPMV45A' '4002'.
perform bdc_field       using 'BDC_OKCODE'
                              '=S\BACK'.
perform bdc_field       using 'BDC_CURSOR'
                              'VBKD-PRSDT'.
perform bdc_field       using 'VBAK-AUDAT'
                              '06/18/2008'.
perform bdc_field       using 'VBAK-VKBUR'
                              '0002'.
perform bdc_field       using 'VBAK-WAERK'
                              'USD'.
perform bdc_field       using 'VBKD-PRSDT'
                              '06/18/2008'.
perform bdc_field       using 'VBKD-KDGRP'
                              'A1'.



*perform bdc_dynpro      using 'SAPMV45A' '5003'.
*perform bdc_field       using 'BDC_OKCODE'
*                              '=S\BACK'.
*perform bdc_field       using 'BDC_CURSOR'
*                              'KOMV-KSCHL(08)'.

cnt = cnt + 1.

ENDLOOP.




perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '=KKNT'.
perform bdc_field       using 'VBKD-BSTKD'
                              WA_ITAB-B8.
perform bdc_field       using 'KUAGV-KUNNR'
                              WA_ITAB-B5.
perform bdc_field       using 'KUWEV-KUNNR'
                              WA_ITAB-B6.
perform bdc_field       using 'RV45A-KETDAT'
                              '06/30/2008'.
perform bdc_field       using 'RV45A-KPRGBZ'
                              'D'.
perform bdc_field       using 'VBKD-ZTERM'
                              'N45'.
perform bdc_field       using 'VBKD-INCO1'
                              'FOB'.
perform bdc_field       using 'VBKD-INCO2'
                              'New York'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV45A-MABNR(02)'.


perform bdc_dynpro      using 'SAPMV45A' '4002'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV45A-TXT_VBELN'.
perform bdc_field       using 'DKACB-FMORE'
                              'X'.
perform bdc_dynpro      using 'SAPLKACB' '0002'.
perform bdc_field       using 'BDC_CURSOR'
                              'COBL-PS_POSID'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ENTE'.
perform bdc_field       using 'COBL-PS_POSID'
                              WA_ITAB-B9.




perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '=KFPL'.
perform bdc_field       using 'VBKD-BSTKD'
                              WA_ITAB-B8.
perform bdc_field       using 'KUAGV-KUNNR'
                              WA_ITAB-B5.
perform bdc_field       using 'KUWEV-KUNNR'
                              WA_ITAB-B6.
perform bdc_field       using 'RV45A-KETDAT'
                              '06/30/2008'.
perform bdc_field       using 'RV45A-KPRGBZ'
                              'D'.
perform bdc_field       using 'VBKD-ZTERM'
                              'N45'.
perform bdc_field       using 'VBKD-INCO1'
                              'FOB'.
perform bdc_field       using 'VBKD-INCO2'
                              'New York'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV45A-MABNR(02)'.


perform bdc_dynpro      using 'SAPLCNMS' '1300'.
perform bdc_field       using 'BDC_CURSOR'
                              'MLSTS-AUFNR'.
perform bdc_field       using 'BDC_OKCODE'
                              '=GO'.
perform bdc_field       using 'MLSTS-SELPS'
                              'X'.
perform bdc_field       using 'MLSTS-PSPNR'
                              WA_ITAB-B10.


perform bdc_dynpro      using 'SAPLCNMS' '1310'.
perform bdc_field       using 'BDC_OKCODE'
                              '=MRKS'.
perform bdc_dynpro      using 'SAPLCNMS' '1310'.
perform bdc_field       using 'BDC_OKCODE'
                              '=GET'.


perform bdc_dynpro      using 'SAPLV60F' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '=S\BACK'.
perform bdc_field       using 'BDC_CURSOR'
                              'FPLA-BEDAT'.
perform bdc_field       using 'FPLA-BEDAT'
                              '06/30/2008'.
perform bdc_field       using 'FPLA-BEDAR'
                              '07'.


perform bdc_dynpro      using 'SAPMV45A' '4001'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SICH'.

perform bdc_field       using 'VBKD-BSTKD'
                              WA_ITAB-B8.
perform bdc_field       using 'KUAGV-KUNNR'
                              WA_ITAB-B5.
perform bdc_field       using 'KUWEV-KUNNR'
                              WA_ITAB-B6.
perform bdc_field       using 'RV45A-KETDAT'
                              '06/30/2008'.
perform bdc_field       using 'RV45A-KPRGBZ'
                              'D'.
perform bdc_field       using 'VBKD-ZTERM'
                              'N45'.
perform bdc_field       using 'VBKD-INCO1'
                              'FOB'.
perform bdc_field       using 'VBKD-INCO2'
                              'New York'.
perform bdc_field       using 'BDC_CURSOR'
                              'RV45A-MABNR(02)'.


perform bdc_dynpro      using 'SAPLSPO2' '0101'.
perform bdc_field       using 'BDC_OKCODE'
                              '=OPT1'.



CALL TRANSACTION 'VA01' USING i_bdcdata MODE 'A'.

endloop.



FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR i_bdcdata.
  i_bdcdata-program  = PROGRAM.
  i_bdcdata-dynpro   = DYNPRO.
  i_bdcdata-dynbegin = 'X'.
  APPEND i_bdcdata.
ENDFORM.

*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
  IF FVAL <> SPACE.
    CLEAR i_bdcdata.
    i_bdcdata-fnam = FNAM.
    i_bdcdata-fval = FVAL.
    APPEND i_bdcdata.
  ENDIF.
ENDFORM.

Regards,

Vishwa.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question