BDC-CALL
report ZDSN
no standard page heading line-size 255.
*----------------------------------------------------------------------*
* data definition
*----------------------------------------------------------------------*
* Batchinputdata of single transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
* error session opened (' ' or 'X')
DATA: e_group_opened.
* message texts
TABLES: t100.
types: begin of ty_mat,
matnr(18) type c,
mbrsh(1) type c,
mtart(4) type c,
maktx(40) type c,
meins(3) type c,
end of ty_mat.
data: it_mat type table of ty_mat,
wa_mat type ty_mat.
parameters: p_file type IBIPPARMS-PATH.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = p_file
.
data:lv_FILE TYPE STRING.
lv_FILE = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'x'
tables
data_tab = it_mat
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.
*include bdcrecx1.
start-of-selection.
loop at it_mat into wa_mat.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
wa_mat-matnr.
perform bdc_field using 'RMMG1-MBRSH'
wa_mat-mbrsh.
perform bdc_field using 'RMMG1-MTART'
wa_mat-mtart.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
wa_mat-maktx.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
wa_mat-meins.
perform bdc_transaction using 'MM01'.
endloop.
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
FORM bdc_transaction USING tcode.
DATA: l_mstring(480).
DATA: l_subrc LIKE sy-subrc.
REFRESH messtab.
CALL TRANSACTION tcode USING bdcdata
MODE 'a'
UPDATE 's'
messages INTO messtab.
WRITE: / 'CALL_TRANSACTION',
tcode,
'returncode:'(i05),
l_subrc,
'RECORD:',
sy-INDEX.
LOOP AT messtab.
message id messtab-msgid
type messtab-msgtyp
number messtab-msgnr
into l_mstring
WITH MESSTAB-MSGV1
MESSTAB-MSGV2
MESSTAB-MSGV3
MESSTAB-MSGV4.
WRITE: / messtab-msgtyp, l_mstring(250).
ENDLOOP.
REFRESH bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* 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 <> space.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
ENDFORM.
no standard page heading line-size 255.
*----------------------------------------------------------------------*
* data definition
*----------------------------------------------------------------------*
* Batchinputdata of single transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
* error session opened (' ' or 'X')
DATA: e_group_opened.
* message texts
TABLES: t100.
types: begin of ty_mat,
matnr(18) type c,
mbrsh(1) type c,
mtart(4) type c,
maktx(40) type c,
meins(3) type c,
end of ty_mat.
data: it_mat type table of ty_mat,
wa_mat type ty_mat.
parameters: p_file type IBIPPARMS-PATH.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = p_file
.
data:lv_FILE TYPE STRING.
lv_FILE = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'x'
tables
data_tab = it_mat
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.
*include bdcrecx1.
start-of-selection.
loop at it_mat into wa_mat.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
wa_mat-matnr.
perform bdc_field using 'RMMG1-MBRSH'
wa_mat-mbrsh.
perform bdc_field using 'RMMG1-MTART'
wa_mat-mtart.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
wa_mat-maktx.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
wa_mat-meins.
perform bdc_transaction using 'MM01'.
endloop.
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
FORM bdc_transaction USING tcode.
DATA: l_mstring(480).
DATA: l_subrc LIKE sy-subrc.
REFRESH messtab.
CALL TRANSACTION tcode USING bdcdata
MODE 'a'
UPDATE 's'
messages INTO messtab.
WRITE: / 'CALL_TRANSACTION',
tcode,
'returncode:'(i05),
l_subrc,
'RECORD:',
sy-INDEX.
LOOP AT messtab.
message id messtab-msgid
type messtab-msgtyp
number messtab-msgnr
into l_mstring
WITH MESSTAB-MSGV1
MESSTAB-MSGV2
MESSTAB-MSGV3
MESSTAB-MSGV4.
WRITE: / messtab-msgtyp, l_mstring(250).
ENDLOOP.
REFRESH bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* 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 <> space.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
ENDFORM.
Comments
Post a Comment