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-mk02

Former Member
0 Likes
649

<b>Hi experts,

I am Trying for objects which upload flat file in to table from tc MK02

I wrote programe as below

And after running this in sm35

table get update properly but at last it not getting close properly

It means it goes to again upload to 1st screen.

Please help me out of this:</b>

report ZSANDY_MK02

no standard page heading line-size 255.

*include bdcrecx1.

INITIALIZATION.

data: begin of itab occurs 0,

lifnr like RF02K-LIFNR,

ekorg like RF02K-EKORG,

anred like LFA1-ANRED,

name1 like LFA1-NAME1,

sortl like LFA1-SORTL,

name2 like LFA1-NAME2,

stras like LFA1-STRAS,

pfach like LFA1-PFACH,

ort01 like LFA1-ORT01,

pstlz like LFA1-PSTLZ,

ort02 like LFA1-ORT02,

pstl2 like LFA1-PSTL2,

land1 like LFA1-LAND1,

spras like LFA1-SPRAS,

telx1 like LFA1-TELX1,

TELF1 LIKE LFA1-TELF1,

end of itab.

DATA: BEGIN OF BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF BDCDATA.

start-of-selection.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\SANDY\MK02.TXT'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • 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.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

  • DEST = FILLER8

GROUP = 'MK02'

  • HOLDDATE = FILLER8

KEEP = 'X'

USER = SY-UNAME

  • RECORD = FILLER1

PROG = SY-CPROG

  • IMPORTING

  • QID =

  • EXCEPTIONS

  • CLIENT_INVALID = 1

  • DESTINATION_INVALID = 2

  • GROUP_INVALID = 3

  • GROUP_IS_LOCKED = 4

  • HOLDDATE_INVALID = 5

  • INTERNAL_ERROR = 6

  • QUEUE_ERROR = 7

  • RUNNING = 8

  • SYSTEM_LOCK_ERROR = 9

  • USER_INVALID = 10

  • OTHERS = 11

.

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 itab.

perform bdc_dynpro using 'SAPMF02K' '0108'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-D0110'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-LIFNR'

ITAB-LIFNR.

perform bdc_field using 'RF02K-EKORG'

ITAB-EKORG.

perform bdc_field using 'RF02K-D0110'

'X'.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-TELX1'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'LFA1-ANRED'

ITAB-ANRED.

perform bdc_field using 'LFA1-NAME1'

itab-name1.

perform bdc_field using 'LFA1-SORTL'

ITAB-SORTL.

perform bdc_field using 'LFA1-NAME2'

ITAB-NAME2.

perform bdc_field using 'LFA1-STRAS'

ITAB-STRAS.

perform bdc_field using 'LFA1-PFACH'

ITAB-PFACH.

perform bdc_field using 'LFA1-ORT01'

ITAB-ORT01.

perform bdc_field using 'LFA1-PSTLZ'

ITAB-PSTLZ.

perform bdc_field using 'LFA1-ORT02'

ITAB-ORT02.

perform bdc_field using 'LFA1-PSTL2'

ITAB-PSTL2.

perform bdc_field using 'LFA1-LAND1'

ITAB-LAND1.

perform bdc_field using 'LFA1-SPRAS'

ITAB-SPRAS.

perform bdc_field using 'LFA1-TELX1'

itab-telx1.

perform bdc_field using 'LFA1-TELF1'

itab-telF1.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'MK02'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

DYNPROTAB = BDCDATA

  • EXCEPTIONS

  • INTERNAL_ERROR = 1

  • NOT_OPEN = 2

  • QUEUE_ERROR = 3

  • TCODE_INVALID = 4

  • PRINTING_INVALID = 5

  • POSTING_INVALID = 6

  • OTHERS = 7

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CLEAR ITAB.

REFRESH BDCDATA.

ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'

  • EXCEPTIONS

  • NOT_OPEN = 1

  • QUEUE_ERROR = 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.

----


  • 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 IS NOT INITIAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDIF.

ENDFORM.

<b>and this the in flat file;</b>

1003 3000 Dr. bondy car sandy 310 Marine Ave 654564 sandy city 90710 LOS ANGELES 70456 BA EN 88888 999991

<b>Thanks In advance

Sandy</b>

Message was edited by:

sandy reborn

1 REPLY 1
Read only

Former Member
0 Likes
457

loop at itab.

perform bdc_dynpro using 'SAPMF02K' '0108'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-D0110'.

<b>perform bdc_field using 'BDC_OKCODE'

'/00'.</b>

perform bdc_field using 'RF02K-LIFNR'

ITAB-LIFNR.

perform bdc_field using 'RF02K-EKORG'

ITAB-EKORG.

perform bdc_field using 'RF02K-D0110'

'X'.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-TELX1'.

<b>perform bdc_field using 'BDC_OKCODE'

'=UPDA'.</b>

perform bdc_field using 'LFA1-ANRED'

ITAB-ANRED.

perform bdc_field using 'LFA1-NAME1'

itab-name1.

perform bdc_field using 'LFA1-SORTL'

ITAB-SORTL.

perform bdc_field using 'LFA1-NAME2'

ITAB-NAME2.

perform bdc_field using 'LFA1-STRAS'

ITAB-STRAS.

perform bdc_field using 'LFA1-PFACH'

ITAB-PFACH.

perform bdc_field using 'LFA1-ORT01'

ITAB-ORT01.

perform bdc_field using 'LFA1-PSTLZ'

ITAB-PSTLZ.

perform bdc_field using 'LFA1-ORT02'

ITAB-ORT02.

perform bdc_field using 'LFA1-PSTL2'

ITAB-PSTL2.

perform bdc_field using 'LFA1-LAND1'

ITAB-LAND1.

perform bdc_field using 'LFA1-SPRAS'

ITAB-SPRAS.

perform bdc_field using 'LFA1-TELX1'

itab-telx1.

perform bdc_field using 'LFA1-TELF1'

itab-telF1.

BDC Ok codes should be at lost unlike which come from recording

try this and come back

regards,

pavan