SAP MAC address acquisition

 

*

DATA: gt_ipconfig TYPE TABLE OF char255,

gs_ipconfig TYPE char255.

DATA: macaddress(255) TYPE c .

DATA: wa_mac(255) TYPE c .

DATA : BEGIN OF itab OCCURS 0,

       source TYPE string,

       END OF itab.

itab-source = 'ipconfig /all>c:\hello.txt'.

APPEND itab.

itab-source = 'del c:\b.bat'.

APPEND itab.

*

CALL FUNCTION 'GUI_DOWNLOAD'

  EXPORTING

    filename         = 'C:\b.bat' "file name

  TABLES

    data_tab         = itab    "inner table

  EXCEPTIONS

    file_write_error = 1

    file_not_found   = 2.

 

CALL METHOD cl_gui_frontend_services=>execute

  EXPORTING

    application            = 'c:\b.bat'

    synchronous            = 'WAIT'

  EXCEPTIONS

    cntl_error = 1

    error_no_gui = 2

    bad_parameter = 3

    file_not_found         = 4

    path_not_found         = 5

    file_extension_unknown = 6

    error_execute_failed   = 7

    synchronous_failed     = 8

    not_supported_by_gui   = 9

    OTHERS                 = 10.

CALL FUNCTION 'GUI_UPLOAD'

  EXPORTING

    filename                = 'C:\hello.txt'

  TABLES

    data_tab                = gt_ipconfig

  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 and-msgid TYPE and Sgt NUMBER msgno

* WITH side msgv1 side msgv2 side msgv3 side msgv4.

*ENDIF.

 

LOOP AT gt_ipconfig INTO gs_ipconfig.

  IF gs_ipconfig CS 'Physical Address'.

    wa_mac = gs_ipconfig+44(17).

*    APPEND wa_mac TO macaddress.

  ENDIF.

ENDLOOP.

    WRITE:/ wa_mac.

Guess you like

Origin www.cnblogs.com/jimi520/p/12103145.html