Monday, 22 September 2014

Workflow event Through report


REPORT  ZWF_EVENT.


DATA:
W_OBJTYPE TYPE SWR_STRUCT-OBJECT_TYP,
W_OBJKEY  TYPE SWR_STRUCT-OBJECT_KEY,
W_EVENT   TYPE SWR_STRUCT-EVENT.

W_OBJKEY = '1234'.

W_OBJTYPE = 'MTRREADDOC'.

W_EVENT = 'CREATED'.

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    OBJECT_TYPE             = W_OBJTYPE
    OBJECT_KEY              = W_OBJKEY
    EVENT                   = W_EVENT
   COMMIT_WORK             = 'X'
*   EVENT_LANGUAGE          = SY-LANGU
*   LANGUAGE                = SY-LANGU
*   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
* IMPORTING
*   RETURN_CODE             =
*   EVENT_ID                =
* TABLES
*   INPUT_CONTAINER         =
*   MESSAGE_LINES           =
*   MESSAGE_STRUCT          =
          .

Monday, 8 September 2014

Report for abap flow diagram

*&---------------------------------------------------------------------*
*& Report  ZFLOW_CHART
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZFLOW_CHART.



include lcnetdat. "allg. Datendeklarationen
include lcnetcon. "Konstanten
*----------------------------------------------------------------------*
* CLASS flow_chart DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class flow_chart definition.
public section.
 databegin of w_secs,
 progm type sy-cprog,
 type,
 name type string,
 start type i,
end type i,
end of w_secs,
 t_secs like standard table of w_secs,
begin of w_nodes,
id type i,
 type,
 name type string,
end of w_nodes,
 t_nodes like standard table of w_nodes,
begin of w_calls,
 start,
 type,
 calledby type string,
 ntype,
 name type string,
end of w_calls,
 t_calls like standard table of w_calls.
 data: l_comp type ref to cl_abap_compiler,
 t_result type scr_glrefs,
 w_result like line of t_result,
 t_secst like t_secs,
 l_match type i,
 t_ref type scr_refs,
 w_ref type line of scr_refs.
 data: t_cprog type standard table of sy-cprog,
 l_cprog type sy-cprog.
 data: t_prog type standard table of char255,
 l_prog type char255,
 l_evnt type string,
 t_stmt type standard table of sstmnt,
 l_stmt type sstmnt,
 t_strc type standard table of sstruc,
 l_strc type sstruc,
 l_tabix type i,
 t_tokn type standard table of stokes.
methods get_chart importing p_cprog type sy-cprog.
methods find_data importing p_start type string p_end type string. methods find_pattern importing p_full type string p_last type string p_type type string
  changing p_subrc type i.
methods get_data importing value(p_pos) type i value(p_ntype) type char01 value(p_name) type
string.
endclass"flow_chart DEFINITION
*----------------------------------------------------------------------*
* CLASS flow_chart IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class flow_chart implementation.
method get_chart.
call function 'RS_GET_ALL_INCLUDES'
exporting
program = p_cprog
 with_inactive_incls = 'X'
tables
 includetab = t_cprog
exceptions
 not_existent = 1
 no_program = 2
others = 3.
append p_cprog to t_cprog.
loop at t_cprog into l_cprog.
read report l_cprog into t_prog.
scan abap-source t_prog tokens into t_tokn statements into t_stmt structures into t_strc.
 w_secs-progm = l_cprog.
 w_secs-type = 'F'.
call method find_data
exporting
 p_start = 'FUNCTION'
 p_end = 'ENDFUNCTION'.
 w_secs-type = 'S'.
call method find_data
exporting
 p_start = 'FORM'
 p_end = 'ENDFORM'.
 w_secs-type = 'D'.
call method find_data
exporting
 p_start = 'MODULE'
 p_end = 'ENDMODULE'.
 w_secs-type = 'M'.
call method find_data
exporting
 p_start = 'METHOD'
 p_end = 'ENDMETHOD'.
 w_secs-type = 'E'.
loop at t_strc into l_strc where type = 'E'.
read table t_stmt into l_stmt with key number = l_strc-stmnt_from.
read table t_prog into l_prog index l_stmt-trow.
translate l_prog to upper case.
translate l_prog using '. '.
 w_secs-name = l_prog.
 w_secs-start = l_stmt-trow.
read table t_stmt into l_stmt with key number = l_strc-stmnt_to.
 w_secs-end = l_stmt-trow.
append w_secs to t_secs.
 endloop.
 endloopcreate object l_comp
exporting
 p_name = p_cprog.
call method l_comp->get_all_refs
exporting
 p_local = 'X'
importing
 p_result = t_result.
loop at t_result into w_result.
call method find_pattern
exporting
 p_full = '\PR:*\TY:*\ME:*'
 p_last = '\ME:'
 p_type = 'M'
changing
 p_subrc = l_match.
if l_match ne 0.
call method find_pattern
exporting
 p_full = '\TY:*\ME:*'
 p_last = '\ME:'
 p_type = 'C'
changing
 p_subrc = l_match.
if l_match ne 0.
call method find_pattern
exporting
 p_full = '\FU:*'
 p_last = '\FU:'
 p_type = 'F'
changing
 p_subrc = l_match.
if l_match ne 0.
call method find_pattern
exporting
 p_full = '\PR:*\FO:*'
 p_last = '\FO:'
 p_type = 'S'
changing
 p_subrc = l_match.
if l_match ne 0.
 continue.
 endif.
 endif.
 endif.
 endif.
refresh t_ref.
call method l_comp->get_single_ref
exporting
 p_full_name = w_result-full_name
 p_grade = 2
importing
 p_result = t_ref
exceptions
 syntax_error = 1
 object_not_found = 2
 ref_not_found = 3
 parameter_error = 4
others = 5. t_secst[] = t_secs[].
loop at t_ref into w_ref where grade ne 0.
loop at t_secst into w_secs where start <= w_ref-line and end >= w_ref-line and progm = w_ref-statement->source_info->name.
delete t_secst index sy-tabix.
 w_calls-type = w_secs-type.
 w_calls-calledby = w_secs-name.
append w_calls to t_calls.
 endloop.
 endloop.
clear w_calls.
 endloop.
 data: w_cald like w_calls.
loop at t_calls into w_calls.
 l_tabix = sy-tabix.
 w_nodes-type = w_calls-type.
 w_nodes-name = w_calls-calledby.
append w_nodes to t_nodes.
 w_nodes-type = w_calls-ntype.
 w_nodes-name = w_calls-name.
append w_nodes to t_nodes.
read table t_calls into w_cald with key name = w_calls-calledby ntype = w_calls-type.
if sy-subrc ne 0.
 w_calls-start = 'X'.
modify t_calls from w_calls index l_tabix transporting start.
 endif.
 endloop.
sort t_nodes.
delete adjacent duplicates from t_nodes comparing all fields.
loop at t_nodes into w_nodes.
 w_nodes-id = sy-tabix.
modify t_nodes from w_nodes index sy-tabix.
 endloop.
loop at t_nodes into w_nodes.
 net_nodes_tab-id = w_nodes-id.
 net_nodes_tab-type = 0.
case w_nodes-type.
when 'F'.
 net_nodes_tab-type = 'F'.
when 'M'.
 net_nodes_tab-type = 'I'.
when 'S'.
 net_nodes_tab-type = 'S'.
when 'C'.
 net_nodes_tab-type = '0'.
when 'E'.
 net_nodes_tab-type = 'T'.
 endcase.
append net_nodes_tab to net_nodes_tab[].
 nvals_tab-id = net_nodes_tab-id.
 nvals_tab-fl = net_const-text_index_0.
 nvals_tab-val = w_nodes-name.
append nvals_tab to nvals_tab[].
if strlen( w_nodes-name ) > 19.
 nvals_tab-fl = net_const-text_index_1.
 nvals_tab-val = w_nodes-name+19.
append nvals_tab to nvals_tab[].
endif.
 endloop.
sort t_calls by type calledby.
loop at t_calls into w_calls where start is not initial.
delete t_calls index sy-tabix.
add 1 to lines_tab-id.
read table t_nodes into w_nodes with key type = w_calls-type name = w_calls-calledby.
if sy-subrc eq 0.
 lines_tab-pre = w_nodes-id.
read table t_nodes into w_nodes with key type = w_calls-ntype name = w_calls-name.
if sy-subrc eq 0.
 lines_tab-suc = w_nodes-id.
 lines_tab-ab = net_const-aob_ea.
append lines_tab to lines_tab[].
 endif.
 endif.
call method get_data
exporting
 p_pos = 4
 p_ntype = w_calls-ntype
 p_name = w_calls-name.
 endloop.
loop at lines_tab[] into lines_tab.
 lvals_tab-id = lines_tab-id.
 lvals_tab-fl = net_const-text_index_0.
 lvals_tab-val = space.
append lvals_tab to lvals_tab[].
 endloop.
 profile-gruppe = 'SCTX'.
 profile-name = 'CONTEXT'.
 profile-index = 0.
 do.
call function 'CNET_GRAPHIC_NETWORK'
exporting
 stat = stat
 profile = profile
 wait_for_input = space
importing
 m_typ = m_typ
tables
 clusters = clusters_tab
 cvals = cvals_tab
 deletions = delete_tab
 inodes = inodes_tab
lines = lines_tab
 lvals = lvals_tab
nodes = net_nodes_tab
 nvals = nvals_tab
 positions = positions_tab.
case m_typ.
when net_const-m_typ_d.
 exit.
when net_const-m_typ_i.
 stat = net_const-stat_4.
 endcase.
 enddo.
 endmethod"get_chart
method find_data.  data: l_tokn like line of t_tokn,
 w_tokn like l_tokn,
 l_tokt like l_tokn,
 l_cls type i.
loop at t_tokn into w_tokn where str = p_start.
 l_tabix = sy-tabix - 1.
read table t_tokn into l_tokn index l_tabix.
if l_tokn-row ne w_tokn-row.
 l_tabix = sy-tabix + 2.
if p_start = 'METHOD'.
 l_cls = sy-tabix + 1.
while l_cls > 0.
 l_cls = l_cls - 1.
read table t_tokn into l_tokt index l_cls.
if l_tokt-str = 'IMPLEMENTATION'.
 l_cls = l_cls - 1.
read table t_tokn into l_tokt index l_cls.
 exit.
 endif.
 endwhile.
 endif.
read table t_tokn into w_tokn index l_tabix.
 w_secs-name = w_tokn-str.
if l_tokt-str is not initial.
concatenate l_tokt-str '->' w_secs-name into w_secs-name.
 endif.
 w_secs-start = w_tokn-row.
loop at t_tokn into w_tokn from l_tabix where str = p_end.
 w_secs-end = w_tokn-row.
append w_secs to t_secs.
 exit.
 endloop.
 endif.
 endloop.
 endmethod"find_data
*&---------------------------------------------------------------------*
*& Form find_pattern
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
method find_pattern.
 p_subrc = 4.
 w_calls-ntype = p_type.
if w_result-full_name cp p_full.
find p_last in w_result-full_name match offset l_match.
 l_match = l_match + 4.
find regex '\\..:' in w_result-full_name+l_match.
if sy-subrc ne 0.
case p_type.
when 'F'.
 w_calls-name = w_result-full_name+l_match.
when 'M'.
 w_calls-name = w_result-full_name+4.
find regex '\\..:' in w_calls-name match offset l_match.
 l_match = l_match + 4.
 w_calls-name = w_calls-name+l_match.
replace regex '\\..:' in w_calls-name with '->'.
when 'C'.
 w_calls-name = w_result-full_name+4.
replace regex '\\..:' in w_calls-name with '->'when 'S'.
 w_calls-name = w_result-full_name+l_match.
 endcase.
clear p_subrc.
 endif.
 endif.
 endmethod"find_pattern
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
method get_data.
 data: l_pos type i,
 l_calls like w_calls.
 l_pos = p_pos + 3.
loop at t_calls into l_calls where calledby = p_name and type = p_ntype.
delete t_calls index sy-tabix.
read table t_nodes into w_nodes with key type = l_calls-type name = l_calls-calledby.
if sy-subrc eq 0.
add 1 to lines_tab-id.
 lines_tab-pre = w_nodes-id.
read table t_nodes into w_nodes with key type = l_calls-ntype name = l_calls-name.
if sy-subrc eq 0.
 lines_tab-suc = w_nodes-id.
 lines_tab-ab = net_const-aob_ea.
append lines_tab to lines_tab[].
 endif.
 endif.
call method get_data
exporting
 p_pos = l_pos
 p_ntype = l_calls-ntype
 p_name = l_calls-name.
 endloop.
 endmethod"get_data
endclass"flow_chart IMPLEMENTATION
parameters: p_cprog type sy-cprog.
start-of-selection.
 data: l_chart type ref to flow_chart.
create object l_chart.
call method l_chart->get_chart
exporting
 p_cprog = p_cprog.

Wednesday, 20 August 2014

WORK FLOW THROUGH REPORT

*&---------------------------------------------------------------------*
*& Report  ZVWORKFLOW_MAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZVWORKFLOW_MAIL.


TABLES SSCRFIELDS.

*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : P_MDT AS CHECKBOX,
             P_MDLOAD AS CHECKBOX,
             P_MUPLAD AS CHECKBOX .
SELECTION-SCREEN:PUSHBUTTON /60(10) BUTTON1 USER-COMMAND but1,
                 PUSHBUTTON 75(10) BUTTON2 USER-COMMAND but2.
SELECTION-SCREEN END OF BLOCK b1.

*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*
INITIALIZATION.
  button1 = 'SEND'.
  button2 = 'CANCEL'.






**  *--------------------------------------------------------------*
*At Selection-Screen
*--------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sscrfields.
    WHEN 'BUT1'.
      PERFORM mail.
      MESSAGE 'Mail Sent Succesfully' TYPE 'I'.
    WHEN 'BUT2'.
      MESSAGE 'Your Action Cancelled' TYPE 'I'.
  ENDCASE.







*&---------------------------------------------------------------------*
*&      Form  mail
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM mail .


IF p_mdt = 'X'.


DATA : lt_container TYPE TABLE OF swr_cont,
       ls_container TYPE swr_cont.

*test to get the value throught the pgm

ls_container-element = 'FLAG1'.
ls_container-value   = 'X'.
APPEND ls_container TO lt_container.

ls_container-element = 'FLAG2'.
ls_container-value   = 'Y'.
APPEND ls_container TO lt_container.

DATA : P_TASK TYPE swr_struct-task.
P_TASK = 'WS90000032'.




*****This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IF P_MDLOAD = 'X'.
  P_TASK = 'WS90000051'.



***
****This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
  ENDIF.
  IF P_MUPLAD = 'X'.

P_TASK = 'WS90000052'.




*This function Module is to start the process
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task                      = p_task
*   LANGUAGE                  = SY-LANGU
*   DO_COMMIT                 = 'X'
*   USER                      = SY-UNAME
*   START_ASYNCHRONOUS        = ' '
*   DESIRED_START_DATE        =
*   DESIRED_START_TIME        =
*   DESIRED_START_ZONLO       = SY-ZONLO
*   IFS_XML_CONTAINER         =
* IMPORTING
*   RETURN_CODE               =
*   WORKITEM_ID               =
*   NEW_STATUS                =
 TABLES
   input_container           = lt_container
*   MESSAGE_LINES             =
*   MESSAGE_STRUCT            =
*   AGENTS                    =
          .
*This is to run the work flow

CALL FUNCTION 'EWW_WORKFLOW_START'
  EXPORTING
    x_task                = p_task
*   X_START_DATE          = NO_DATE
*   X_START_TIME          = NO_TIME
* IMPORTING
*   Y_WORKFLOW_ID         =
* TABLES
*   X_CONTAINER           =
*   X_AGENTS              =
* EXCEPTIONS
*   INVALID_TASK          = 1
*   NO_ACTIVE_PLVAR       = 2
*   START_FAILED          = 3
*   GENERAL_ERROR         = 4
*   OTHERS                = 5
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
  ENDIF.
ENDFORM.                    " mail
*

Wednesday, 6 August 2014

MR ORDER DOWNLOAD

*&---------------------------------------------------------------------*
*& 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( ).

Meter Reading Upload

*&---------------------------------------------------------------------*
*& Report  ZVMASS_METER_UPLOAD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZVMASS_METER_UPLOAD.



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,
        ABLBELNR TYPE ABLBELNR,
        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_raw  TYPE truxs_t_text_data,
       it_data TYPE TABLE OF alsmex_tabline.

 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'.                                                   "include for data declerations


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  PERFORM GET_FILE.                                                               " Subroutine to Get file name

  PERFORM EXCEL_ITAB.                                                             "Subroutine to retrive data from excel to interanal tab
  PERFORM MR_UPLOAD.                                                              "Subroutine to upload data










*&---------------------------------------------------------------------*
*&      Form  excel_itab
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM EXCEL_ITAB .
  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.

  LOOP AT IT_TAB INTO WA_TAB.


    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = WA_TAB-ABLBELNR
      IMPORTING
        OUTPUT = WA_TAB-ABLBELNR.

    WA_READINGS-MRIDNUMBER = WA_TAB-ABLBELNR .

    WA_READINGS-MRREASON         = '01'."wa_tab-MrReason.
    WA_READINGS-SERIALNO         = WA_TAB-DEVICE."serialno.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = WA_TAB-REGISTER
      IMPORTING
        OUTPUT = WA_TAB-REGISTER.
    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."mrdateforbilling.
    APPEND WA_READINGS TO LT_READINGS.
    CLEAR WA_READINGS.
  ENDLOOP.

ENDFORM.                    " excel_itab
*&---------------------------------------------------------------------*
*&      Form  mr_upload
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MR_UPLOAD .
  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( ).
ENDFORM.                    " mr_upload
*&---------------------------------------------------------------------*
*&      Form  get_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_FILE .
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      FIELD_NAME = 'P_FILE'
    IMPORTING
      FILE_NAME  = P_FILE.
ENDFORM.                    " get_file

ISU_MASTERDATA_TEMPLATE_UPLOAD program

*****&---------------------------------------------------------------------*
*& Report  ZMDT_REPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZMDT_REPORT11.

TYPE-POOLS: TRUXS,SLIS.

DATA IT_CONTAINER TYPE CCMCONT_T.
DATA WA_CONTAINER LIKE LINE OF IT_CONTAINER.
DATA IT_NEW_KEYS_TAB TYPE ISU_PROD_NEWOBJECT_KEYS_TAB.
DATA WA_NEW_KEYS_TAB LIKE LINE OF IT_NEW_KEYS_TAB.
DATA IT_DONE_NODE_TAB TYPE ISU_EPDNODE_TAB.
DATA: IT_TEMP11 TYPE ISU_PROD_NEWOBJECT_KEYS_TAB,
      WA_TEMP11 LIKE LINE OF IT_TEMP11.

DATA: IT_RAW TYPE TRUXS_T_TEXT_DATA,
      IT_DATA TYPE TABLE OF ALSMEX_TABLINE.

DATA : LT_GRID TYPE REF TO CL_SALV_TABLE.
DATA : LT_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST,
        LT_DISPLAY TYPE REF TO CL_SALV_DISPLAY_SETTINGS.
CONSTANTS :GC_TRUE TYPE SAP_BOOL VALUE 'X'.


PARAMETERS: P_FILE TYPE  RLGRAP-FILENAME.

DATA : L_LOGID TYPE GUID_32,
L_SCRIPT_INFO_TAB TYPE ISU_SCRIPT_INFO_TAB,
L_IDE_STARTED TYPE EBA_FLAG,
L_MDG_COMPLETED TYPE EBA_FLAG.

DATA:   LV_LOGNUM TYPE BALOGNR,
       LT_LOGKEYS TYPE  BAPIALF OCCURS 0 WITH HEADER LINE,
       LT_LOGDATA TYPE TABLE OF BAPIALG,
       WA_LOGDATA TYPE BAPIALG.
TYPES : BEGIN OF TY_LOG,
       TYPE TYPE BAPI_MTYPE,
       MESSAGE TYPE BAPI_MSG,
      LINE_COLOR(4TYPE C,
     END OF TY_LOG.
DATA : IT_FINAL_LOG TYPE TABLE OF TY_LOG,
      WA_FINAL_LOG TYPE TY_LOG.

TYPES : BEGIN OF TY_MDATA,
AB  TYPE  CHAR255,
ABLEINH  TYPE   CHAR255,
ADDRNUMBER  TYPE  CHAR255,
AKLASSE  TYPE   CHAR255,
ANLAGE  TYPE  CHAR255,
CITY1  TYPE   CHAR255,
DATEFROM  TYPE  CHAR255,
DEVLOC  TYPE  CHAR255,
EADAT  TYPE   CHAR255,
EINZDAT  TYPE   CHAR255,
HAUS  TYPE  CHAR255,
HOUSE_NUM1  TYPE  CHAR255,
INT_UI  TYPE  CHAR255,
KOFIZ_SD  TYPE  CHAR255,
KONDIGRE  TYPE  CHAR255,
KTOKL  TYPE   CHAR255,
MATNR  TYPE   CHAR18,
NAME_FIRST  TYPE  CHAR255,
NAME_LAST  TYPE   CHAR255,
PARTNER  TYPE   CHAR255,
PERVERBR  TYPE  CHAR255,
POST_CODE1  TYPE  CHAR255,
SERNR  TYPE   CHAR18,
STREET  TYPE  CHAR255,
TARIFART  TYPE  CHAR255,
TARIFTYP  TYPE  CHAR255,
TYPE  TYPE  CHAR255,
VKBEZ  TYPE   CHAR255,
VKONT  TYPE   CHAR255,
VKTYP  TYPE   CHAR255,
VSTELLE  TYPE   CHAR255,
XSEXF  TYPE   CHAR255,
XSEXM  TYPE   CHAR255,
XSEXU  TYPE   CHAR255,
ZWNUMMERE  TYPE   CHAR255,
ZWSTANDCE  TYPE   CHAR255,
        END OF  TY_MDATA.

DATA : IT_MDATA TYPE TABLE OF TY_MDATA,
      WA_MDATA TYPE TY_MDATA.

*****************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

  PERFORM get_file.
  PERFORM excel_itab.





  PERFORM UPLOAD_DATA.
  PERFORM DISPLAY_LOG.

*&---------------------------------------------------------------------*
*&      Form  EXCEL_UPLOAD
*&---------------------------------------------------------------------*
*       text
*---------------------------  -------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
  " EXCEL_UPLOAD
*&---------------------------------------------------------------------*
*&      Form  UPLOAD_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM UPLOAD_DATA .

  LOOP AT IT_MDATA INTO WA_MDATA.

    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        DATE_EXTERNAL                  = WA_MDATA-AB
*       ACCEPT_INITIAL_DATE            =
     IMPORTING
       DATE_INTERNAL                  = WA_MDATA-AB.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'AB'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-AB .
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'ABLEINH'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-ABLEINH.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'ADDRNUMBER'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-ADDRNUMBER.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'AKLASSE'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-AKLASSE.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'ANLAGE'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-ANLAGE.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'CITY1'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-CITY1.
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        DATE_EXTERNAL                  = WA_MDATA-DATEFROM
*   ACCEPT_INITIAL_DATE            =
     IMPORTING
       DATE_INTERNAL                  = WA_MDATA-DATEFROM.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'DATEFROM'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-DATEFROM .
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'DEVLOC'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-DEVLOC.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        DATE_EXTERNAL                  = WA_MDATA-EADAT
*   ACCEPT_INITIAL_DATE            =
     IMPORTING
       DATE_INTERNAL                  = WA_MDATA-EADAT.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'EADAT'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-EADAT.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        DATE_EXTERNAL                  = WA_MDATA-EINZDAT
*   ACCEPT_INITIAL_DATE            =
     IMPORTING
       DATE_INTERNAL                  = WA_MDATA-EINZDAT.
    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'EINZDAT'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-EINZDAT.
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'HAUS'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-HAUS.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'HOUSE_NUM1'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-HOUSE_NUM1.
    APPEND WA_CONTAINER TO IT_CONTAINER.



    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'INT_UI'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-INT_UI .
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'KOFIZ_SD'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-KOFIZ_SD .
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'KONDIGRE'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-KONDIGRE.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'KTOKL'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-KTOKL.
    APPEND WA_CONTAINER TO IT_CONTAINER.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = WA_MDATA-MATNR
      IMPORTING
        OUTPUT = WA_MDATA-MATNR.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'MATNR'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-MATNR .
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'NAME_FIRST'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-NAME_FIRST .
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'NAME_LAST'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-NAME_LAST.
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'PARTNER'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-PARTNER. .
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'PERVERBR'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-PERVERBR.
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'POST_CODE1'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-POST_CODE1.
    APPEND WA_CONTAINER TO IT_CONTAINER.



    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT  = WA_MDATA-SERNR
      IMPORTING
        OUTPUT = WA_MDATA-SERNR.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'SERNR'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-SERNR.
    APPEND WA_CONTAINER TO IT_CONTAINER.



    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'STREET'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-STREET .
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'TARIFART'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-TARIFART.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'TARIFTYP'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-TARIFTYP.
    APPEND WA_CONTAINER TO IT_CONTAINER.



    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'TYPE'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-TYPE .
    APPEND WA_CONTAINER TO IT_CONTAINER.

****
    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'VKBEZ'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-VKBEZ.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'VKONT'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-VKONT .
    APPEND WA_CONTAINER TO IT_CONTAINER.



    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'VKTYP'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-VKTYP .
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'VSTELLE'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-VSTELLE.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'XSEXF'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-XSEXF.
    APPEND WA_CONTAINER TO IT_CONTAINER.

    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'XSEXM'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-XSEXM.
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'XSEXU'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-XSEXU .
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'ZWNUMMERE'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-ZWNUMMERE.
    APPEND WA_CONTAINER TO IT_CONTAINER.


    CLEAR WA_CONTAINER.
    WA_CONTAINER-ELEMENT = 'ZWSTANDCE'.
    WA_CONTAINER-ELEMLENGTH = '255'.
    WA_CONTAINER-TYPE = 'C'.
    WA_CONTAINER-VALUE = WA_MDATA-ZWSTANDCE .
    APPEND WA_CONTAINER TO IT_CONTAINER.

    REFRESH IT_NEW_KEYS_TAB.

    CALL FUNCTION 'ISU_PRODUCT_IMPLEMENT'
      EXPORTING
        X_PRODID              = 'ZNEWCUST_TC'
        X_CONTAINER           = IT_CONTAINER
        X_RAISE_NO_EVENT      = ' '
        X_NO_BPCONTACT        = ' '
        X_CONTRACTDATA        = ' '
        X_NO_ENV_SELECT       = ' '
        X_INDUSTRY            = ' '
      IMPORTING
        Y_LOGID               = L_LOGID
        Y_SCRIPT_INFO_TAB     = L_SCRIPT_INFO_TAB
        Y_IDE_STARTED         = L_IDE_STARTED
        Y_MDG_COMPLETED       = L_MDG_COMPLETED
      CHANGING
        XY_NEW_KEYS_TAB       = IT_NEW_KEYS_TAB
        XY_DONE_NODE_TAB      = IT_DONE_NODE_TAB
      EXCEPTIONS
        GENERAL_FAULT         = 1
        INPUT_ERROR           = 2
        AMBIGUOUS_ENVIRONMENT = 3
        OTHERS                = 4.

    LOOP AT IT_NEW_KEYS_TAB INTO WA_NEW_KEYS_TAB.
      CLEAR WA_TEMP11.
      MOVE-CORRESPONDING WA_NEW_KEYS_TAB TO WA_TEMP11.
      APPEND WA_TEMP11 TO IT_TEMP11.
    ENDLOOP.

    REFRESH IT_CONTAINER.
    REFRESH IT_DONE_NODE_TAB.



*  Fetching the log number from log id.
    SELECT SINGLE LOGNUMBER
    INTO LV_LOGNUM
    FROM BALHDR
    WHERE
    EXTNUMBER = L_LOGID.

    LT_LOGKEYS-LOGNUMBER = LV_LOGNUM.
    APPEND LT_LOGKEYS.

    CALL FUNCTION 'BAPI_APPLICATIONLOG_GETDETAIL'
      EXPORTING
        LANGUAGE   = SY-LANGU
        TEXTFORMAT = 'ASC'"gc_textformat
      TABLES
        LOGKEYS    = LT_LOGKEYS
        LOGDATA    = LT_LOGDATA.


  ENDLOOP.
   LOOP AT LT_LOGDATA INTO WA_LOGDATA.
      CLEAR WA_FINAL_LOG.
      WA_FINAL_LOG-TYPE = WA_LOGDATA-TYPE.
      WA_FINAL_LOG-MESSAGE = WA_LOGDATA-MESSAGE.

      IF  WA_FINAL_LOG-TYPE NE 'S'.
        WA_FINAL_LOG-LINE_COLOR = 'C310'.
      ENDIF.
      APPEND WA_FINAL_LOG TO IT_FINAL_LOG.
    ENDLOOP.
    REFRESH LT_LOGDATA.







ENDFORM.                    " UPLOAD_DATA
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
" pushbutt
*&---------------------------------------------------------------------*
*&      Form  display_log
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY_LOG .
  DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
        GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,
        GD_LAYOUT    TYPE SLIS_LAYOUT_ALV,
        GD_REPID     LIKE SY-REPID.
  FIELDCATALOG-FIELDNAME   = 'TYPE'.
  FIELDCATALOG-SELTEXT_M   = 'Message Type'.
  FIELDCATALOG-COL_POS     = 1.
  APPEND FIELDCATALOG TO FIELDCATALOG.
  CLEAR  FIELDCATALOG.

  FIELDCATALOG-FIELDNAME   = 'MESSAGE'.
  FIELDCATALOG-SELTEXT_M   = 'Message'.
  FIELDCATALOG-COL_POS     = 2.
  APPEND FIELDCATALOG TO FIELDCATALOG.
  CLEAR  FIELDCATALOG.

  GD_LAYOUT-NO_INPUT          = 'X'.
  GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.



  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
     I_CALLBACK_PROGRAM                =  SY-REPID
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
     IS_LAYOUT                         = GD_LAYOUT
     IT_FIELDCAT                       = FIELDCATALOG[]
        TABLES
      T_OUTTAB                          = IT_FINAL_LOG
* EXCEPTIONS
*   PROGRAM_ERROR                     = 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.


ENDFORM.                    " display_log
*&---------------------------------------------------------------------*
*&      Form  get_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_file .
CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      FIELD_NAME = 'P_FILE'
    IMPORTING
      FILE_NAME  = P_FILE.
ENDFORM.                    " get_file
*&---------------------------------------------------------------------*
*&      Form  excel_itab
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM excel_itab .
 CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*    I_FIELD_SEPERATOR        = ' '
      I_LINE_HEADER            =  'X'
      I_TAB_RAW_DATA           =  IT_RAW       " WORK TABLE
      I_FILENAME               =  P_FILE
    TABLES
      I_TAB_CONVERTED_DATA     = IT_MDATA "it_TEMP[]    "ACTUAL DATA
   EXCEPTIONS
      CONVERSION_FAILED        = 1
      OTHERS                   = 2.
ENDFORM.                    " excel_itab