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

BDC

Former Member
0 Likes
452

This is lalitha

In the below prg i have got an error

DATA : BEGIN OF ITAB, OCCURS 1 WITH HEADERLINE,

F1 TYPE LIFNR,

F2 TYPE EKORG,

F3 TYPE KTOKK,

F4 TYPE NAME1,

F5 TYPE SORTL,

F6 TYPE LAND1,

F7 TYPE SPRAS,

F8 TYPE WERKS,

END OF ITAB.

**********STEP 5 : DEF TARGET INTERNAL TABLE********

DATA: JTAB TYPE BDCDATA OCCURS 1 WITH header line.

*********STEP 6 UPLOAD FLAG FILE INTO SOURCE INTERNALTABLES**********

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\VENDOR.BDC.TXT'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

************STEP 7 COMBINING THE DATA FROM SOURCE INTERNAL PERFORM

*BDCFIELD TO PERFORM BDC TRANSACTION ************

DATA: JTAB .

REFRESH BDCDATA .

LOOP AT ITAB .

perform bdc_field using 'BDC_CURSOR'

'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-LIFNR'

ITAB-F1.

perform bdc_field using 'RF02K-EKORG'

ITAB-F2.

perform bdc_field using 'RF02K-KTOKK'

ITAB-F3.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFA1-NAME1'

ITAB-F4.

perform bdc_field using 'LFA1-SORTL'

ITAB-F5.

perform bdc_field using 'LFA1-LAND1'

ITAB-F6.

perform bdc_field using 'LFA1-SPRAS'

ITAB-F7.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR'

'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFM1-WAERS'

ITAB-F8.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

**********STEP 8 CALL TRANSACTION

CALL TRANSACTION 'MK01' USING BDCDATA MODE A .

ENDLOOP .

*********START NEW SCREEN*********

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

IF FVAL <> NODATA.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM.

The error is itab is not an internal table the "occursn" specification is missing .

in the above prg if i give " data: begin of itab occurs 1 with headerline .

The sys is asking to place a comma (,) after itab .

How can i solve my error.

4 REPLIES 4
Read only

naimesh_patel
Active Contributor
0 Likes
429

Data definiation of the ITAB should be like this:

*DATA : BEGIN OF ITAB OCCURS 1 WITH HEADERLINE,  
DATA : BEGIN OF ITAB OCCURS 1,    " << WITH HEADERLINE is not required when you use the OCCURS 1
F1 TYPE LIFNR,
F2 TYPE EKORG,
F3 TYPE KTOKK,
F4 TYPE NAME1,
F5 TYPE SORTL,
F6 TYPE LAND1,
F7 TYPE SPRAS,
F8 TYPE WERKS,
END OF ITAB.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
429

HI lalitha,

u have done a mistake in writing source code so it is giving error.

DATA : <b>BEGIN OF ITAB, OCCURS</b> 1 WITH HEADERLINE,

F1 TYPE LIFNR,

F2 TYPE EKORG,

F3 TYPE KTOKK,

F4 TYPE NAME1,

F5 TYPE SORTL,

F6 TYPE LAND1,

F7 TYPE SPRAS,

F8 TYPE WERKS,

END OF ITAB.

u have given a comma after itab remove comma ur error is solved.

DATA : BEGIN OF ITAB OCCURS 1 WITH HEADERLINE,

F1 TYPE LIFNR,

F2 TYPE EKORG,

F3 TYPE KTOKK,

F4 TYPE NAME1,

F5 TYPE SORTL,

F6 TYPE LAND1,

F7 TYPE SPRAS,

F8 TYPE WERKS,

END OF ITAB.

<b>reward if useful</b>.

Regards,

Sunil kumar.

Read only

Former Member
0 Likes
429

if you are using occurs 1 i think it is not required to use header line.

regards,

sunil kumar.

Read only

Former Member
0 Likes
429

refer this small code

REPORT ZBDCVENDOR

no standard page heading line-size 255 .

DATA: BEGIN OF ITAB OCCURS 2,

LIFNR_001(016) TYPE C,

EKORG_002(004) TYPE C,

KTOKK_003(004) TYPE C,

ANRED_004(015) TYPE C,

NAME1_005(035) TYPE C,

SORTL_006(010) TYPE C,

LAND1_007(003) TYPE C,

SPRAS_008(002) TYPE C,

WAERS_009(005) TYPE C,

END OF ITAB.

DATA BDC LIKE BDCDATA OCCURS 2 WITH HEADER LINE.

start-of-selection.

*perform open_dataset using dataset.

perform open_group.

PERFORM READ_DATA.

LOOP AT ITAB.

CLEAR BDC.

REFRESH BDC.

perform BDC_DYNPRO using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR' 'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'RF02K-LIFNR' ITAB-LIFNR_001.

perform bdc_field using 'RF02K-EKORG' ITAB-EKORG_002.

perform bdc_field using 'RF02K-KTOKK' ITAB-KTOKK_003.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR' 'LFA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'LFA1-ANRED' ITAB-ANRED_004.

perform bdc_field using 'LFA1-NAME1' ITAB-NAME1_005.

perform bdc_field using 'LFA1-SORTL' ITAB-SORTL_006.

perform bdc_field using 'LFA1-LAND1' ITAB-LAND1_007.

perform bdc_field using 'LFA1-SPRAS' ITAB-SPRAS_008.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR' 'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR' 'LFBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE' '=ENTR'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR' 'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_field using 'LFM1-WAERS' ITAB-WAERS_009.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR' 'RF02K-LIFNR'.

perform bdc_field using 'BDC_OKCODE' '=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE' '=YES'.

*perform bdc_transaction using 'XK01'.

ENDLOOP.

perform close_group.

*********************************************

  • FIRST FM -- OPEN GROUP

*********************************************

FORM OPEN_GROUP.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = 'TEST'

KEEP = 'X'

USER = 'SAPUSER'.

ENDFORM. "OPEN GROUP

**********************************************

  • SECOND FM -- READ_DATA

*********************************************

FORM READ_DATA.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'H:\EMP.TXT'

FILETYPE = 'ASC'

TABLES

DATA_TAB = ITAB.

ENDFORM. "READ DATA

*********************************************

  • THIRD FM -- BDC_DYNPRO

*********************************************

FORM BDC_DYNPRO USING P_PROG

P_SCR.

BDC-PROGRAM = P_PROG.

BDC-DYNPRO = P_SCR.

BDC-DYNBEGIN = 'X'.

APPEND BDC.

ENDFORM. "BDC_DYNPRO

*********************************************

  • FOURTH FM -- BDC_FILED

*********************************************

FORM BDC_FIELD USING P_FNAM

P_FVAL.

CLEAR BDC.

BDC-FNAM = P_FNAM.

BDC-FVAL = P_FVAL.

APPEND BDC.

ENDFORM. "BDC_FIELD

*********************************************

  • FIFTH FM -- CLOSE_GROUP

*********************************************

FORM CLOSE_GROUP.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDFORM. " CLOSE_GROUP