REPORT zgm_bdc_mm01 NO STANDARD PAGE HEADING LINE-SIZE 255.
TYPES : BEGIN OF ty_mat,
mbrsh(1) TYPE c,
mtart(4) TYPE c,
maktx(40) TYPE c,
meins(3) TYPE c,
matkl(9) TYPE c,
END OF ty_mat.
DATA: it_mat TYPE STANDARD TABLE OF ty_mat,
wa_mat TYPE ty_mat.
DATA: it_bdcdata TYPE STANDARD TABLE OF bdcdata,
wa_bdcdata TYPE bdcdata.
DATA: wa_opt TYPE ctu_params.
DATA : filename TYPE string.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_file TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
wa_opt-nobinpt = 'X'.
wa_opt-updmode = 'A'.
*upload data form presentation server to internal table
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = p_file.
START-OF-SELECTION.
filename = p_file.
IF filename IS NOT INITIAL.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_mat
* CHANGING
* ISSCANPERFORMED = ' '
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.
* Implement suitable error handling here
ENDIF.
ENDIF.
END-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'
'=ENTR'.
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(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(02)'
'X'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'MAKT-MAKTX'
wa_mat-maktx.
PERFORM bdc_field USING 'BDC_CURSOR'
'MARA-MATKL'.
PERFORM bdc_field USING 'MARA-MEINS'
wa_mat-meins.
PERFORM bdc_field USING 'MARA-MATKL'
wa_mat-matkl.
PERFORM bdc_field USING 'MARA-MTPOS_MARA'
'NORM'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM bdc_field USING 'MAKT-MAKTX'
wa_mat-maktx.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
CALL TRANSACTION 'MM01' USING it_bdcdata OPTIONS FROM wa_opt.
CLEAR wa_mat.
REFRESH it_bdcdata.
ENDLOOP.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR wa_bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
No comments:
Post a Comment