You are on page 1of 4

report ZPOBDC

no standard page heading line-size 255.


TABLES:ekko,ekpo.
data: bdcdata TYPE bdcdata OCCURS 0 WITH HEADER LINE.
data:msgtab TYPE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF it_EKKO OCCURS 0,
BSART TYPE EKKO-BSART,
LIFNR TYPE EKKO-LIFNR,
EKORG TYPE EKKO-EKORG,
EKGRP TYPE EKKO-EKGRP,
BEDAT TYPE EKKO-BEDAT,
END OF it_EKKO.
DATA: BEGIN OF IT_EKPO OCCURS 0,
EMATN TYPE EKPO-EMATN,
WERKS TYPE EKPO-WERKS,
MENGE TYPE EKPO-MENGE,
NETpR TYPE EKPO-NETpR,
END OF IT_EKPO.
loop at msgtab.
WRITE: / msgtab-msgtyp,msgtab-msgid.
ENDLOOP.
*include bdcrecx1.
start-of-selection.
PERFORM gui_upload.
PERFORM bdcdata.
*perform open_group.
*perform bdc_transaction using 'ME21'.
*
*perform close_group.

*&---------------------------------------------------------------------*
*&
Form gui_upload
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM gui_upload .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME
= 'D:/HEADERPO.txt'
FILETYPE
= 'ASC'
HAS_FIELD_SEPARATOR
= '|'
*
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
= it_ekko
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 'GUI_UPLOAD'
EXPORTING
FILENAME
FILETYPE
HAS_FIELD_SEPARATOR
HEADER_LENGTH
READ_BY_LINE
DAT_MODE
CODEPAGE
IGNORE_CERR
REPLACEMENT
CHECK_BOM
VIRUS_SCAN_PROFILE
IMPORTING
FILELENGTH
HEADER
TABLES
DATA_TAB
EXCEPTIONS
FILE_OPEN_ERROR
FILE_READ_ERROR
NO_BATCH
GUI_REFUSE_FILETRANSFER
INVALID_TYPE
NO_AUTHORITY
UNKNOWN_ERROR
BAD_DATA_FORMAT
HEADER_NOT_ALLOWED
SEPARATOR_NOT_ALLOWED

= 'D:/ITEMPO.txt'
= 'ASC'
= '|'
= 0
= 'X'
= ' '
= ' '
= ABAP_TRUE
= '#'
= ' '
=
=
=
= it_ekpo
=
=
=
=
=
=
=
=
=
=

1
2
3
4
5
6
7
8
9
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.
ENDFORM.
" gui_upload
*&---------------------------------------------------------------------*
*&
Form bdcdata
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM bdcdata .
loop at it_ekko.
CLEAR bdcdata.
REFRESH bdcdata.
perform bdc_dynpro
using 'SAPMM06E' '0100'.
perform bdc_field
using 'BDC_CURSOR'
'RM06E-BEDAT'.
perform bdc_field
using 'BDC_OKCODE'
'/00'.
perform bdc_field
using 'EKKO-LIFNR'
*
'5550'.
it_ekko-lifnr.
perform bdc_field
using 'RM06E-BSART'
*
'ec'.
it_ekko-bsart.
perform bdc_field
using 'RM06E-BEDAT'
*
'26.06.2011'.
it_ekko-bedat.
perform bdc_field
using 'EKKO-EKORG'
*
'3000'.
it_ekko-ekorg.
perform bdc_field
using 'EKKO-EKGRP'
*
'013'.
it_ekko-ekgrp.
perform bdc_field
using 'RM06E-LPEIN'
'T'.
*call TRANSACTION 'me21' USING BDCDATA MODE 'A' UPDATE 'S'.
*ENDLOOP.
loop at it_ekpo.
perform bdc_dynpro
using 'SAPMM06E' '0120'.
perform bdc_field
using 'BDC_CURSOR'
'EKPO-WERKS(01)'.
perform bdc_field
using 'BDC_OKCODE'
'/00'.
perform bdc_field
using 'EKPO-EMATN(01)'
*
'100-400'.
it_ekpo-ematn.
perform bdc_field
using 'EKPO-MENGE(01)'

*
perform bdc_field
*

using

perform bdc_field
*

using

perform bdc_dynpro
perform bdc_field

using
using

perform bdc_field

using

perform bdc_field

using

'5'.
it_ekpo-menge.
'EKPO-NETPR(01)'
'100'.
it_ekpo-netpr.
'EKPO-WERKS(01)'
'3200'.
it_ekpo-werks.
'SAPMM06E' '0120'.
'BDC_CURSOR'
'RM06E-EBELP'.
'BDC_OKCODE'
'=BU'.
'RM06E-EBELP'
'10'.

ENDLOOP.
ENDLOOP.
call TRANSACTION 'me21' USING BDCDATA MODE 'A' UPDATE 'S' MESSAGES INTO msgtab.
ENDFORM.
" bdcdata
*----------------------------------------------------------------------*
*
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.