*&---------------------------------------------------------------------*
*& Report Z_MASS_METER_UPLOAD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_mass_meter_upload_2.
TYPE-POOLS : truxs.
SELECTION-SCREEN BEGIN OF BLOCK abc WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS : p_file TYPE rlgrap-filename.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK abc.
TYPES : BEGIN OF ty_tab,
partner TYPE bu_partner,
name_f TYPE bu_namep_f,
name_l TYPE bu_namep_l,
mru TYPE ableinh,
city TYPE ad_city1,
street TYPE ad_street,
house_num TYPE ad_hsnm1,
haus TYPE tplma,
vstelle TYPE vstelle,
targetmrdate TYPE adatsoll,
equipment TYPE equnr,
device TYPE geraet,
register TYPE e_zwnummer,
actualmrdate TYPE adattats,
prv_reading TYPE zpf_readingresult,
readingresult TYPE zpf_readingresult,
unit_billing TYPE e_massbill,
mr_note TYPE ablhinw,
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab,
wa_tab TYPE ty_tab.
*DATA : it_datatab TYPE STANDARD TABLE OF bapieablu,
* wa_datatab TYPE bapieablu.
DATA : it_raw TYPE truxs_t_text_data,
it_data TYPE TABLE OF alsmex_tabline.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_tab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
***********************************************************************
END-OF-SELECTION.
DATA : lt_message TYPE TABLE OF bapireturn1,
lt_readings TYPE STANDARD TABLE OF bapieablu,
wa_readings TYPE bapieablu,
l_grid TYPE REF TO cl_salv_table,
lr_functions TYPE REF TO cl_salv_functions_list,
l_display TYPE REF TO cl_salv_display_settings,
gc_true TYPE sap_bool VALUE 'X'.
LOOP AT it_tab INTO wa_tab.
wa_readings-mrreason = '01'.
wa_readings-serialno = wa_tab-device.
wa_readings-register = wa_tab-register.
wa_readings-readingresult = wa_tab-readingresult.
wa_readings-targetmrdate = wa_tab-targetmrdate.
wa_readings-actualmrdate = wa_tab-actualmrdate.
wa_readings-mrdateforbilling = wa_tab-actualmrdate.
APPEND wa_readings TO lt_readings.
CLEAR wa_readings.
ENDLOOP.
CALL FUNCTION 'BAPI_MTRREADDOC_UPLOAD'
TABLES
meterreadingresults = lt_readings
return = lt_message.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = l_grid
CHANGING
t_table = lt_message.
lr_functions = l_grid->get_functions( ).
lr_functions->set_all( gc_true ).
l_display = l_grid->get_display_settings( ).
l_display->set_striped_pattern( cl_salv_display_settings=>true ).
l_grid->display( ).
*& Report Z_MASS_METER_UPLOAD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_mass_meter_upload_2.
TYPE-POOLS : truxs.
SELECTION-SCREEN BEGIN OF BLOCK abc WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS : p_file TYPE rlgrap-filename.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK abc.
TYPES : BEGIN OF ty_tab,
partner TYPE bu_partner,
name_f TYPE bu_namep_f,
name_l TYPE bu_namep_l,
mru TYPE ableinh,
city TYPE ad_city1,
street TYPE ad_street,
house_num TYPE ad_hsnm1,
haus TYPE tplma,
vstelle TYPE vstelle,
targetmrdate TYPE adatsoll,
equipment TYPE equnr,
device TYPE geraet,
register TYPE e_zwnummer,
actualmrdate TYPE adattats,
prv_reading TYPE zpf_readingresult,
readingresult TYPE zpf_readingresult,
unit_billing TYPE e_massbill,
mr_note TYPE ablhinw,
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab,
wa_tab TYPE ty_tab.
*DATA : it_datatab TYPE STANDARD TABLE OF bapieablu,
* wa_datatab TYPE bapieablu.
DATA : it_raw TYPE truxs_t_text_data,
it_data TYPE TABLE OF alsmex_tabline.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_tab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
***********************************************************************
END-OF-SELECTION.
DATA : lt_message TYPE TABLE OF bapireturn1,
lt_readings TYPE STANDARD TABLE OF bapieablu,
wa_readings TYPE bapieablu,
l_grid TYPE REF TO cl_salv_table,
lr_functions TYPE REF TO cl_salv_functions_list,
l_display TYPE REF TO cl_salv_display_settings,
gc_true TYPE sap_bool VALUE 'X'.
LOOP AT it_tab INTO wa_tab.
wa_readings-mrreason = '01'.
wa_readings-serialno = wa_tab-device.
wa_readings-register = wa_tab-register.
wa_readings-readingresult = wa_tab-readingresult.
wa_readings-targetmrdate = wa_tab-targetmrdate.
wa_readings-actualmrdate = wa_tab-actualmrdate.
wa_readings-mrdateforbilling = wa_tab-actualmrdate.
APPEND wa_readings TO lt_readings.
CLEAR wa_readings.
ENDLOOP.
CALL FUNCTION 'BAPI_MTRREADDOC_UPLOAD'
TABLES
meterreadingresults = lt_readings
return = lt_message.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = l_grid
CHANGING
t_table = lt_message.
lr_functions = l_grid->get_functions( ).
lr_functions->set_all( gc_true ).
l_display = l_grid->get_display_settings( ).
l_display->set_striped_pattern( cl_salv_display_settings=>true ).
l_grid->display( ).
No comments:
Post a Comment