Skip to Content

The documnet deals with the creation of MS excel spreadsheet inside SAP container.

In case pf using OLE we need to download the excela nd the control goes outside SAP but in case of spreadsheet inside  SAP container the control retains with the SAP outpout screen.

Interface

  i_oi_spreadsheet,   i_oi_container_control and  i_oi_document_proxy are used.

On entering the oder/contract to the selection screen, the billing plans details are populted into the output excel spreadsheet. For which the user can edit the editable columns and save the changes into SAP. In background BAPI is called to save teh changes into SAP. The editable columns positions and the memory id name to hold the data are maintained in a custom table.

Output:

/wp-content/uploads/2013/11/output_313318.png

Code below:

   REPORT zre_upd_billn_pln_frm_xls.
*$– Include for glbal dat declaration
INCLUDE zin_billn_pln_frm_xls_top.
*$– Include for excel tool
INCLUDE yyypsdin_excel_forms.
*$– Include for selection screen
INCLUDE zin_billn_pln_frm_xls_sel.
*$– Include for Subroutines
INCLUDE zin_billn_pln_f_xls_forms.

AT SELECTION-SCREEN.
*$– Subroutine to validate the selection screen
  PERFORM f100_validate_screen.

START-OF-SELECTION.
*$– Subroutine to extract data for excel diplay
  PERFORM f100_get_data.

END-OF-SELECTION.
*Screen to display excel in container
  SET SCREEN 9000.

*$– Include for glbal dat declaration

INCLUDE zin_billn_pln_frm_xls_top.

================================================

*$– Type pool declaration
TYPE-POOLS: slis, icon.

*$– Type sdeclaration
TYPES:  BEGIN OF ty_fpla,
          fplnr TYPE fplnr,     “Billing plan number
          fptyp TYPE fptyp_fp,  “Billing plan category
          vbeln TYPE vbeln_va,
        END OF ty_fpla,

        BEGIN OF ty_fplt,
          fplnr  TYPE fplnr,     “Billing plan number
          fpltr  TYPE fpltr,     “Item for billing plan
          fpttp  TYPE fpttp,     “Date category
          ktext  TYPE mlst_ktext,“description
          fakwr TYPE fakwr,     “Value to be billed
          mlstn TYPE mlst_zaehl,“Milestone number
          afdat TYPE fkdat,     “Billing date for billing index and printout
        END OF ty_fplt,

       BEGIN OF ty_mltx,
         mltx_zaehl TYPE mlst_zaehl,  “Milestone number
         ktext   TYPE mlst_ktext,     “Description
       END OF ty_mltx,

       BEGIN OF ty_vbap,
         vbeln TYPE vbeln_va,
         posnr TYPE posnr_va,
         matnr TYPE matnr,
         waerk TYPE waerk,
       END OF ty_vbap,
       ty_t_vbap TYPE STANDARD TABLE OF ty_vbap,

       BEGIN OF ty_vbfa,
         vbelv  TYPE vbeln_von,
         posnv  TYPE posnr_von,
         vbeln  TYPE vbeln_nach,
         posnn  TYPE posnr_nach,
         vbtyp_n  TYPE vbtyp_n,
       END OF ty_vbfa,

       BEGIN OF ty_bapi,
        vbeln TYPE vbeln_va,
        vkorg TYPE vkorg,
        vtweg TYPE vtweg,
        spart TYPE spart,
         knumv TYPE  knumv,
       END OF ty_bapi,

       BEGIN OF ty_netwr,
         fplnr TYPE fplnr,  “Milestone number
         netwr TYPE netwr,     “Description
       END OF ty_netwr,

       BEGIN OF ty_netval,
         posnr TYPE posnr_va,  “item number
         netwr TYPE netwr,     “net value
       END OF ty_netval,
       ty_t_netval TYPE STANDARD TABLE OF ty_netval,

       BEGIN OF ty_konv,
         knumv TYPE  knumv,
         kposn TYPE  kposn,
         stunr TYPE  stunr,
         zaehk TYPE  dzaehk,
         kappl TYPE  kappl,
         kschl TYPE  kscha,
         kbetr TYPE kbetr,
         waers TYPE waers,
         kpein TYPE kpein,
         knumh TYPE knumh,
         kunnr TYPE kunnr,
       END OF ty_konv,

       BEGIN OF ty_fkarv,
         fkarv TYPE fkarv,
        END OF ty_fkarv,

       BEGIN OF ty_knumh,
         matnr TYPE matnr,
         knumh TYPE knumh,
        END OF ty_knumh,

         BEGIN OF ty_kschl,
          kschl TYPE kschl,
         END OF ty_kschl,

         BEGIN OF ty_alv,
          lights TYPE icon_d,     “Holding the value of the lights
          text   TYPE tdline,     “message
         END OF ty_alv,

         BEGIN OF ty_vbeln,
         vbeln TYPE vbeln_va,
         posnr TYPE posnr_va,
         END OF ty_vbeln.

*$– Internal table declaration
DATA:   t_fplt TYPE STANDARD TABLE OF XXX,
        t_fplt_init TYPE STANDARD TABLE OF XXX,
        t_zfplt TYPE STANDARD TABLE OF fpltvb,
        t_zfpla TYPE STANDARD TABLE OF fplavb,
        t_netwr TYPE STANDARD TABLE OF ty_netwr,
        t_konv TYPE STANDARD TABLE OF ty_konv,
        t_vbap TYPE STANDARD TABLE OF ty_vbap,
        t_vbfa  TYPE STANDARD TABLE OF ty_vbfa,
        t_alv   TYPE STANDARD TABLE OF ty_alv,
        t_vbeln TYPE STANDARD TABLE OF ty_vbeln,
        r_fkarv TYPE RANGE OF fkarv,
        r_kschl TYPE RANGE OF kschl,

*$– Variable declaration
        v_okcode TYPE sy-ucomm,
        v_flag_dsp TYPE flag,
        v_knumv TYPE knumv,
        v_vgbel TYPE vgbel,
        v_vbtyp TYPE vbtyp,
        v_zref  TYPE kschl,

*$–ALV data declaration
      s_fieldcat TYPE slis_fieldcat_alv,
      t_fieldcat TYPE slis_t_fieldcat_alv,

*$– Internal table declaration for the excel
      t_exceldata TYPE STANDARD TABLE OF XXXWITH HEADER LINE.

*$–Constants declaration
CONSTANTS : k_lights TYPE char6 VALUE ‘LIGHTS’,
            k_text   TYPE char4 VALUE ‘TEXT’,
            k_tab    TYPE char5 VALUE ‘T_ALV’,
            k_n      TYPE char1 VALUE ‘N’,
            k_a      TYPE char1 VALUE ‘A’.

  

*$– Include for excel tool
INCLUDE zin_excel_forms.

===================================================================

INCLUDE zin_excel_forms_top.

*———————————————————————*
*       FORM getdata                                                  *
*———————————————————————*
*       Subroutine to get data fron excel                             *
*———————————————————————*
*  –>  P_MIT_RANGE                                                   *
*  –>  P_SPALTEN                                                     *
*———————————————————————*
FORM f00_getdata USING p_mit_range p_spalten.
  DATA leer.
  DATA zeilen TYPE i.
  DATA spalte(5).
  DATA zeile(5).
  DATA spalt TYPE i.
  DATA zeil TYPE i.

  CHECK NOT v_handle IS INITIAL.

  IF NOT p_mit_range IS INITIAL.
* daten sind aus SAP in EXCEl gekommen:
    CLEAR t_ranges[].
    CLEAR t_contents[].
    CLEAR t_ran.
    CLEAR t_cont..
    CALL METHOD v_handle->get_ranges_data
      EXPORTING
        all      = ‘X’
      IMPORTING
        contents = t_cont
      CHANGING
        ranges   = t_ran.
    t_contents[] = t_cont[].
    t_ranges[] = t_ran[].
  ELSE.
* Daten wurden per copy-und-paste erzeugt
* Anzahl der Zeilen bestimmen:
    DATA lines TYPE i.
    lines = 100 .
    DO.
      CLEAR t_ranges[].
      CLEAR t_contents[].
      CLEAR t_ran.
      CLEAR t_cont..

      DATA: t_rangesdef TYPE soi_dimension_table.
      DATA: fl_rangesdef LIKE LINE OF t_rangesdef.
      REFRESH t_rangesdef.
      fl_rangesdef-row = lines.
      fl_rangesdef-column = 1.
      fl_rangesdef-rows = 1.
      fl_rangesdef-columns = p_spalten.
      APPEND fl_rangesdef TO t_rangesdef.

      CALL METHOD v_handle->get_ranges_data
        EXPORTING
          all       = space
          rangesdef = t_rangesdef
        IMPORTING
          contents  = t_cont
        CHANGING
          ranges    = t_ran.

      DESCRIBE TABLE t_cont LINES zeilen.
      IF zeilen <> p_spalten.
        MESSAGE i083(yxls).” WITH
*        ‘Sheet could not be read correctly’.
        DESCRIBE TABLE t_cont LINES zeilen.
        spalt = zeilen MOD p_spalten.
        zeil = zeilen / p_spalten.
        zeile = zeil.
        spalte = spalt.
        MESSAGE e073(yxls) WITH lines spalte.
      ENDIF.
      leer = ‘X’.
      LOOP AT t_cont INTO s_rangeitem.
        IF NOT s_rangeitem-value IS INITIAL.
          leer = space.
          EXIT.
        ENDIF.
      ENDLOOP.

      IF leer = space.“größeren Bereich nehmen
        lines = 2 * lines .
        CONTINUE.
      ENDIF.
      IF leer = ‘X’.
        EXIT.
      ENDIF.
    ENDDO.
* Hier Daten lesen:
    CLEAR t_ranges[].
    CLEAR t_contents[].
    CLEAR t_ran.
    CLEAR t_cont.

    REFRESH t_rangesdef.
    fl_rangesdef-row = 1.
    fl_rangesdef-column = 1.
    fl_rangesdef-rows = lines.
    fl_rangesdef-columns = p_spalten.
    APPEND fl_rangesdef TO t_rangesdef.

    CALL METHOD v_handle->get_ranges_data
      EXPORTING
        all       = space
        rangesdef = t_rangesdef
      IMPORTING
        contents  = t_cont
      CHANGING
        ranges    = t_ran.

    DESCRIBE TABLE t_cont LINES zeilen.
    zeilen = zeilen / p_spalten.
    IF zeilen <> lines.
      MESSAGE i083(yxls).
      DESCRIBE TABLE t_cont LINES zeilen.
      spalt = zeilen MOD p_spalten.
      zeil = zeilen / p_spalten.
      zeile = zeil.
      spalte = spalt.
      MESSAGE a073(yxls) WITH zeile spalte.
    ENDIF.
    t_ranges[] = t_ran[].
    t_contents[] = t_cont[].
  ENDIF.

ENDFORM.                               ” GETDATA

*&———————————————————————*
*&      Form  getdata_in_columns
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_MIT_RANGE  text
*      –>P_COLUMN     text
*———————————————————————-*
FORM f00_getdata_in_columns USING p_mit_range p_column.
  DATA leer.
  DATA zeilen TYPE i.
  DATA spalte(5).
  DATA zeile(5).
  DATA spalt TYPE i.
  DATA zeil TYPE i.

  CHECK NOT v_handle IS INITIAL.

  IF NOT p_mit_range IS INITIAL.
* daten sind aus SAP in EXCEl gekommen:
    CLEAR t_ranges[].
    CLEAR t_contents[].
    CLEAR t_ran.
    CLEAR t_cont..
    CALL METHOD v_handle->get_ranges_data
      EXPORTING
        all      = ‘X’
      IMPORTING
        contents = t_cont
      CHANGING
        ranges   = t_ran.
    t_contents[] = t_cont[].
    t_ranges[] = t_ran[].
  ELSE.
* Daten wurden per copy-und-paste erzeugt
* Anzahl der Zeilen bestimmen:
    DATA lines TYPE i.
    lines = 100 .
    DO.
      CLEAR t_ranges[].
      CLEAR t_contents[].
      CLEAR t_ran.
      CLEAR t_cont.

      DATA: t_rangesdef TYPE soi_dimension_table.
      DATA: s_rangesdef LIKE LINE OF t_rangesdef.
      REFRESH t_rangesdef.
      s_rangesdef-row = lines.
      s_rangesdef-column = p_column.
      s_rangesdef-rows = 1.
      s_rangesdef-columns = 1.
      APPEND s_rangesdef TO t_rangesdef.

      CALL METHOD v_handle->get_ranges_data
        EXPORTING
          all       = space
          rangesdef = t_rangesdef
        IMPORTING
          contents  = t_cont
        CHANGING
          ranges    = t_ran.

      DESCRIBE TABLE t_cont LINES zeilen.
      IF zeilen <> 1.
        MESSAGE i083(yxls).” WITH
*        ‘Sheet could not be read correctly’.
        DESCRIBE TABLE t_cont LINES zeilen.
        spalt = zeilen MOD 1.
        zeil = zeilen / 1.
        zeile = zeil.
        spalte = spalt.
        MESSAGE e073(yxls) WITH lines p_column.
      ENDIF.
      leer = ‘X’.
      LOOP AT t_cont INTO s_rangeitem.
        IF NOT s_rangeitem-value IS INITIAL.
          leer = space.
          EXIT.
        ENDIF.
      ENDLOOP.

      IF leer = space.“größeren Bereich nehmen
        lines = 2 * lines .
        CONTINUE.
      ENDIF.
      IF leer = ‘X’.
        EXIT.
      ENDIF.
    ENDDO.
* Hier Daten lesen:
    CLEAR t_ranges[].
    CLEAR t_contents[].
    CLEAR t_ran.
    CLEAR t_cont..

    REFRESH t_rangesdef.
    s_rangesdef-row = 1.
    s_rangesdef-column = p_column.
    s_rangesdef-rows = lines.
    s_rangesdef-columns = 1.
    APPEND s_rangesdef TO t_rangesdef.

    CALL METHOD v_handle->get_ranges_data
      EXPORTING
        all       = space
        rangesdef = t_rangesdef
      IMPORTING
        contents  = t_cont
      CHANGING
        ranges    = t_ran.

    DESCRIBE TABLE t_cont LINES zeilen.
    zeilen = zeilen / 1.
    IF zeilen <> lines.
      MESSAGE i083(yxls).
      DESCRIBE TABLE t_cont LINES zeilen.
      spalt = zeilen MOD 1.
      zeil = zeilen / 1.
      zeile = zeil.
      spalte = spalt.
      MESSAGE a073(yxls) WITH zeile p_column.
    ENDIF.
    t_ranges[] = t_ran[].
    t_contents[] = t_cont[].
  ENDIF.

ENDFORM.                               ” GETDATA

*———————————————————————*
*       FORM parse_contents                                           *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  P_TABELLE                                                     *
*  –>  P_SPALTEN                                                     *
*———————————————————————*
FORM f00_parse_contents TABLES p_tabelle
                    USING p_spalten
                          p_mussspalte
                          p_abzeile
                          p_all.

  DATA type.
  DATA l_row LIKE t_contents-row.
  DATA: aux_contents TYPE soi_generic_item OCCURS 1 WITH HEADER LINE.
  DATA fixpt LIKE trdir-fixpt.
  SELECT SINGLE fixpt FROM trdir INTO fixpt
  WHERE name = sy-cprog.
  IF sy-subrc NE 0.
    CLEAR fixpt.
  ENDIF.

  REFRESH p_tabelle. CLEAR p_tabelle.

  FIELD-SYMBOLS <ltl> TYPE any.

  aux_contents[] = t_contents[].

  DELETE aux_contents WHERE value IS INITIAL.

  l_row = p_abzeile – 1.
  SHIFT l_row LEFT DELETING LEADING space.
  LOOP AT aux_contents.
    v_rowpos = aux_contents-row.
    IF v_rowpos < p_abzeile.
      DELETE aux_contents.
    ELSE.
      EXIT.
    ENDIF.
  ENDLOOP.

  LOOP AT aux_contents.
    v_rowpos = aux_contents-column .
    v_row = aux_contents-row.
    ASSIGN COMPONENT v_rowpos OF STRUCTURE p_tabelle TO <ltl>.
    DESCRIBE FIELD <ltl> TYPE type.
    CASE type.
      WHEN ‘P’.
        PERFORM fill_value USING    aux_contents-value fixpt
                           CHANGING <ltl>.                 .
        aux_contents-value = <ltl>.
      WHEN ‘D’.
        DATA chardat  LIKE rvdat-extdatum.
        chardat = aux_contents-value.
        DATA datum LIKE syst-datum.
        datum = aux_contents-value.
        CALL FUNCTION ‘PERIOD_AND_DATE_CONVERT_INPUT’
          EXPORTING
            external_date              = chardat
            dialog_date_is_in_the_past = space
          IMPORTING
            internal_date              = datum
          EXCEPTIONS
            date_invalid               = 1
            no_data                    = 2
            period_invalid             = 3
            OTHERS                     = 4.
        IF sy-subrc = 0.
          aux_contents-value = datum.

          CALL FUNCTION ‘DATE_CHECK_PLAUSIBILITY’
            EXPORTING
              date                      = datum
            EXCEPTIONS
              plausibility_check_failed = 1
              OTHERS                    = 2.
          IF sy-subrc <> 0.
            MESSAGE e171(xxx)  WITH v_row v_rowpos.
          ENDIF.
        ELSE.
          IF aux_contents-value = ‘ ‘.
            aux_contents-value = ‘ ‘.
          ELSE.
            MESSAGE e171(xxx)  WITH v_row v_rowpos.
          ENDIF.
        ENDIF.
      WHEN OTHERS.

    ENDCASE.

    CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
      <ltl> = aux_contents-value.
    ENDCATCH.

    AT END OF row.
      ASSIGN COMPONENT ‘ZEILE’ OF STRUCTURE p_tabelle TO <ltl>.
      IF sy-subrc = 0.
        <ltl> = aux_contents-row.
      ENDIF.
      APPEND p_tabelle.
      CLEAR p_tabelle.
    ENDAT.
  ENDLOOP.

  CHECK NOT p_mussspalte IS INITIAL.
  CHECK p_all IS INITIAL.

  ASSIGN COMPONENT p_mussspalte OF STRUCTURE p_tabelle TO <ltl>.
  LOOP AT p_tabelle.
    IF <ltl> IS INITIAL.
      DELETE p_tabelle.
    ENDIF.
  ENDLOOP.

ENDFORM.                    ” parse_contents

DEFINE speichern.
  refresh t_data_table. clear t_data_table.
  call method v_document->save_document_to_table
    importing
      error          = v_error
      retcode        = v_retcode
    changing
      document_size  = v_filesize
      document_table = t_data_table.

  export v_filesize t_data_table to database xxxxx(&1)
  id &2.

END-OF-DEFINITION.

DEFINE speichern_sprachspezifisch.
  refresh t_data_table. clear t_data_table.
  call method v_document->save_document_to_table
    importing
      error          = v_error
      retcode        = v_retcode
    changing
      document_size  = v_filesize
      document_table = t_data_table.

  concatenate sy-langu &2 into sy-msgv1.
  export v_filesize t_data_table to database xxxxx(&1)
  id sy-msgv1.

END-OF-DEFINITION.

*———————————————————————*
*       FORM exit                                                     *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
FORM f000_exit.

  IF NOT v_document IS INITIAL.
    CALL METHOD v_document->close_document.
    FREE v_document.
  ENDIF.
  IF NOT v_control IS INITIAL.
    CALL METHOD v_control->destroy_control.
    FREE v_control.
  ENDIF.
  SET SCREEN 0.

ENDFORM.                    “exit

*———————————————————————*
*       FORM create_basic_objects                                     *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  P_GENERAL_KEY                                                 *
*  –>  P_SPECIFIC_KEY                                                *
*  –>  P_FIRST_SET                                                   *
*———————————————————————*
FORM f000_create_basic_objects USING p_general_key
                                p_specific_key
                                p_first_set.

  CHECK already_done IS INITIAL.

  SELECT SINGLE dcpfm FROM usr01
    INTO v_dcpfm
    WHERE bname = sy-uname.

  CALL METHOD c_oi_container_control_creator=>get_container_control
    IMPORTING
      control = v_control
      error   = v_error.

  CREATE OBJECT v_container
    EXPORTING
      container_name = ‘CONTAINER’.

  CALL METHOD v_control->init_control
    EXPORTING
      r3_application_name      = text-r01
      inplace_enabled          = v_inplace
      inplace_scroll_documents = ‘X’
      parent                   = v_container
      register_on_close_event  = ‘X’
      register_on_custom_event = ‘X’
      no_flush                 = ‘X’
    IMPORTING
      error                    = v_error.

  already_done = ‘X’.

  CLEAR v_item_url.
  DATA: bds_instance TYPE REF TO cl_bds_document_set.
  DATA: doc_signature TYPE sbdst_signature,
        wa_doc_signature LIKE LINE OF doc_signature,
        doc_components TYPE sbdst_components,
        doc_uris TYPE sbdst_uri,
        wa_doc_uris LIKE LINE OF doc_uris.
  DATA: doc_classname TYPE sbdst_classname VALUE ‘SOFFICEINTEGRATION’,
        doc_classtype TYPE sbdst_classtype VALUE ‘OT’,
        doc_object_key TYPE sbdst_object_key VALUE ‘SOFFICEINTEGRATION’.

  wa_doc_signature-prop_name = ‘DESCRIPTION’.
  v_document_type = v_excel.
  wa_doc_signature-prop_value = ‘RANGES’.
  APPEND wa_doc_signature TO doc_signature.
  CREATE OBJECT bds_instance.
  CALL METHOD bds_instance->get_info
    EXPORTING
      classname  = doc_classname
      classtype  = doc_classtype
      object_key = doc_object_key
    CHANGING
      components = doc_components
      signature  = doc_signature.

  CALL METHOD bds_instance->get_with_url
    EXPORTING
      classname  = doc_classname
      classtype  = doc_classtype
      object_key = doc_object_key
    CHANGING
      uris       = doc_uris
      signature  = doc_signature.

  FREE bds_instance.

  READ TABLE doc_uris INTO wa_doc_uris INDEX 1.
  IF sy-subrc <> 0.
    CLEAR wa_doc_uris.
  ENDIF.
  v_item_url = wa_doc_uris-uri.
  CALL METHOD v_control->get_document_proxy
    EXPORTING
      document_type  = v_document_type
    IMPORTING
      document_proxy = v_document
      error          = v_error.

  PERFORM excelsprache_feststellen.

  IMPORT v_filesize t_data_table FROM DATABASE xxxxx(ps)
                    ID p_specific_key.
  IF sy-subrc <> 0 .
    CONCATENATE sy-langu p_general_key INTO sy-msgv1.
    IMPORT v_filesize t_data_table FROM DATABASE xxxxx(xl)
                      ID sy-msgv1.
    IF sy-subrc <> 0.
      CONCATENATE ‘E’ p_general_key INTO sy-msgv1.
      IMPORT v_filesize t_data_table FROM DATABASE xxxxx(xl)
                        ID sy-msgv1.
      IF sy-subrc <> 0.
        IMPORT v_filesize t_data_table FROM DATABASE xxxxx(xl)
                          ID p_general_key.
      ENDIF.
    ENDIF.
  ENDIF.

  IF sy-subrc = 0.
    CALL METHOD v_document->open_document_from_table
      EXPORTING
        open_inplace   = v_inplace
        document_size  = v_filesize
        document_table = t_data_table
      IMPORTING
        error          = v_error
        retcode        = v_retcode.
  ELSE.
    CALL METHOD v_document->create_document
      EXPORTING
        open_inplace = v_inplace
      IMPORTING
        error        = v_error
        retcode      = v_retcode.
  ENDIF.
  DATA: has TYPE i.
  CALL METHOD v_document->has_spreadsheet_interface
    IMPORTING
      is_available = has.

  IF NOT has IS INITIAL.
    CALL METHOD v_document->get_spreadsheet_interface
      IMPORTING
        sheet_interface = v_handle.
    IF NOT p_first_set IS INITIAL.
      IF v_first IS INITIAL.
        SELECT SINGLE tabname memoryid FROM xxxxx

                  INTO (v_tabname, v_memoryid)
                    WHERE cprog = sy-cprog.
        IF sy-subrc NE 0.
          CLEAR: v_tabname, v_memoryid.
        ENDIF.
        IF ( NOT v_tabname IS INITIAL ) AND ( NOT v_memoryid IS INITIAL ).
          PERFORM first_set USING v_tabname
                                  v_memoryid.
          v_first = ‘X’.
        ENDIF.
      ENDIF.

    ENDIF.

  ENDIF.
ENDFORM.                    “create_basic_objects
*&———————————————————————*
*&      Form  first_set
*&———————————————————————*
*       text
*———————————————————————-*
*      –>FUV_TABNAME   text
*      –>FUV_MEMORYID  text
*———————————————————————-*
FORM first_set USING fuv_tabname TYPE tabname
                     fuv_memoryid TYPE char30.

  DATA: lt_itab TYPE TABLE OF rstrucinfo,
        ls_itab TYPE rstrucinfo,
        ls_name TYPE xxxxx,
        lt_dfies TYPE STANDARD TABLE OF dfies,
        ls_dfies TYPE dfies,
        lv_flag TYPE flag,
        lv_num TYPE i,
        lv_fieldname TYPE dfies-fieldname,
        lt_edit_col TYPE STANDARD TABLE OF ty_edit_col,
        ls_edit_col TYPE ty_edit_col,
        lv_poc TYPE yyyeno_yyy_lst_fertg,
        lt_cont                 TYPE soi_generic_table.
**
  DATA: lv_text TYPE char30,
        lv_tabix TYPE sy-tabix,
        lv_value(256) TYPE c,
        lv_field(256)  TYPE c,
        lv_edit TYPE string,
                 lv_frmla TYPE char30,
                 lv_indx TYPE char4,
                 lv_indx1 TYPE char4.
*                 lv_tabix TYPE sy-tabix..

****Dynamic Creation
  DATA: linetype TYPE string,
        itabref  TYPE REF TO data,
        line     TYPE REF TO data.

  FIELD-SYMBOLS: <fs> TYPE STANDARD TABLE,
                 <fl> TYPE any,
                 <field> TYPE any.

* CREATION OF A TABLE :
  CREATE DATA itabref TYPE STANDARD TABLE OF (fuv_tabname).
  ASSIGN itabref->* TO <fs>.

*Importing content from memory id
  IMPORT  t_exceldata[] FROM MEMORY ID fuv_memoryid.
  <fs> = t_exceldata[].

* CREATION OF A STRUCTURE :
  CREATE DATA line LIKE LINE OF <fs>.
  ASSIGN line->* TO <fl>.

*clearing intenal tables
  CLEAR:  t_cont,
          t_ran,
          t_cont[],
          t_ran[].

*initialising column and row position
  v_rowpos = v_colpos = 0.
  v_colpos = v_colpos + 1.
  v_rowpos = v_rowpos + 1.

  CLEAR : lt_dfies[], ls_dfies.
  CALL FUNCTION ‘DDIF_FIELDINFO_GET’
    EXPORTING
      tabname        = fuv_tabname
      langu          = sy-langu
    TABLES
      dfies_tab      = lt_dfies
    EXCEPTIONS
      not_found      = 1
      internal_error = 2
      OTHERS         = 3.
  IF sy-subrc EQ 0.
    DESCRIBE TABLE lt_dfies[] LINES v_columns.
  ENDIF.

  LOOP AT lt_dfies INTO ls_dfies.
    lv_text = ls_dfies-scrtext_m.
    PERFORM header USING lv_text.
    CLEAR : lv_text.
  ENDLOOP.

  LOOP AT <fs> ASSIGNING <fl>.
    v_colpos = 1.
    v_rowpos = v_rowpos + 1.
    LOOP AT lt_dfies INTO ls_dfies.
      lv_tabix = sy-tabix.
      ASSIGN COMPONENT lv_tabix“1
      OF STRUCTURE <fl> TO <field>.
      IF ls_dfies-inttype EQ ‘D’ OR ls_dfies-datatype EQ ‘CURR’
        OR ls_dfies-inttype EQ ‘P’

        WRITE <field> TO lv_value LEFT-JUSTIFIED.
        PERFORM header USING lv_value.

      ELSEIF ls_dfies-datatype EQ ‘NUMC’.
        SHIFT <field> LEFT DELETING LEADING ‘0’.
        WRITE <field> TO lv_value LEFT-JUSTIFIED.
        PERFORM header USING <field>.
      ELSE.
        PERFORM header USING <field>.
      ENDIF.
      CLEAR lv_tabix.
    ENDLOOP.
  ENDLOOP.

  s_rangei-name = text-r02.
  s_rangei-rows = v_rowpos.
  s_rangei-columns = v_columns.
  s_rangei-code = ‘1’.
  APPEND s_rangei TO t_ran.

  CALL METHOD v_handle->set_selection
    EXPORTING
      left    = 1
      top     = 1
      rows    = 1
      columns = 1.

  CALL METHOD v_handle->insert_range
    EXPORTING
      name    = s_rangei-name
      rows    = v_rowpos
      columns = v_columns
    IMPORTING
      error   = v_error
      retcode = v_retcode.

  CALL METHOD v_handle->set_ranges_data
    EXPORTING
      ranges   = t_ran
      contents = t_cont
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

* Adjust the width to the widest column
  CALL METHOD v_handle->fit_widest
    EXPORTING
      name  = s_rangei-name
    IMPORTING
      error = v_error.
*  Logic for making background colour grey for all
  v_colpos = v_colpos – 2.
  s_rangei-name = ‘COLOR’.
  s_rangei-rows = v_rowpos.                                 “1048576.
  s_rangei-columns = v_colpos.   “8.
  s_rangei-code = ‘3’.

  CALL METHOD v_handle->insert_range
    EXPORTING
      name     = s_rangei-name
      rows     = v_rowpos                                   “1048576
      columns  = v_colpos     “8
      no_flush = space
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

  CALL METHOD v_handle->set_color
    EXPORTING
      rangename = s_rangei-name
      front     = -1  “0 “-1
      back      = 15
      no_flush  = space
    IMPORTING
      error     = v_error
      retcode   = v_retcode.

*  Logic for colored header in bold
  s_rangei-name = ‘header’.
  s_rangei-rows = 1.
  s_rangei-columns = v_colpos.     “67.
  s_rangei-code = ‘2’.
  APPEND s_rangei TO t_ran.

  CALL METHOD v_handle->insert_range
    EXPORTING
      name     = s_rangei-name
      rows     = 1
      columns  = v_colpos     “67
      no_flush = space
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

  CALL METHOD v_handle->set_color
    EXPORTING
      rangename = s_rangei-name
      front     = -1
      back      = 35 “20
      no_flush  = space
    IMPORTING
      error     = v_error
      retcode   = v_retcode.

  CALL METHOD v_handle->set_font
    EXPORTING
      rangename = s_rangei-name
      family    = ‘ ‘
      size      = -1
      bold      = 1
      italic    = 0
      align     = 1
    IMPORTING
      error     = v_error
      retcode   = v_retcode.

  CLEAR: s_rangei, t_ran.

*Making editable fields colourless
  CLEAR t_soi_cell_table.
  SELECT SINGLE editable_fields FROM xxxxx INTO lv_edit
            WHERE cprog = sy-cprog.
  IF sy-subrc IS INITIAL.
    SPLIT lv_edit AT ‘-‘ INTO TABLE lt_edit_col.
    LOOP AT lt_edit_col INTO ls_edit_col.
*     Subroutine to color the cell red
      PERFORM f00_white_back USING  ls_edit_col-col.  ” 1.
    ENDLOOP.
  ENDIF.
*
  IF NOT t_soi_cell_table[] IS INITIAL.
    CALL METHOD v_handle->cell_format
      EXPORTING
        cells   = t_soi_cell_table
      IMPORTING
        error   = v_error
        retcode = v_retcode.
  ENDIF.
*  Bordering the excel
  s_rangei-name = ‘table’.
  s_rangei-rows = v_rowpos.
  s_rangei-columns = v_colpos.     “67.
  s_rangei-code = ‘2’.
  APPEND s_rangei TO t_ran.

  DATA typ TYPE i.
  FIELD-SYMBOLS <fs1> TYPE x.

  ASSIGN typ TO <fs1> CASTING.
  SET BIT 1 OF <fs1> TO 1. “thickness
  SET BIT 2 OF <fs1> TO 0.  “1. “thickness
  SET BIT 3 OF <fs1> TO 1.  “0. “horizontal lines
  SET BIT 4 OF <fs1> TO 1. “vertical lines
  SET BIT 5 OF <fs1> TO 1. “right margin
  SET BIT 6 OF <fs1> TO 1. “bottom margin
  SET BIT 7 OF <fs1> TO 1. “top margin
  SET BIT 8 OF <fs1> TO 1. “left margin
  typ = <fs1>(1).

  CALL METHOD v_handle->insert_range
    EXPORTING
      name     = s_rangei-name
      rows     = v_rowpos
      columns  = v_colpos     “67
      no_flush = space
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

  CALL METHOD v_handle->set_frame
    EXPORTING
      rangename = s_rangei-name
      typ       = typ “1
      color     = 16  “1
*     no_flush  = ‘ ‘
    IMPORTING
      error     = v_error
      retcode   = v_retcode.
ENDFORM.                    “first_set
*———————————————————————-*
*        Start new screen                                              *
*———————————————————————-*
FORM bdc_dynpro USING program dynpro.
  CLEAR t_bdcdata.
  t_bdcdata-program  = program.
  t_bdcdata-dynpro   = dynpro.
  t_bdcdata-dynbegin = ‘X’.
  APPEND t_bdcdata.
ENDFORM.                    “bdc_dynpro

*———————————————————————-*
*        Insert field                                                  *
*———————————————————————-*
FORM bdc_field USING fnam fval.
  CLEAR t_bdcdata.
  t_bdcdata-fnam = fnam.
  WRITE fval TO t_bdcdata-fval LEFT-JUSTIFIED.
  APPEND t_bdcdata.
ENDFORM.                    “bdc_field

*&———————————————————————*
*&      Form  gelbschrift
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_LOSTEILLISTE_ZEILE  text
*      –>P_10     text
*———————————————————————-*
FORM gelbschrift USING    p_zeile
                          p_spalte.

  DATA format TYPE soi_format_item.
  CALL METHOD v_handle->get_cell_format
    EXPORTING
      row     = p_zeile
      column  = p_spalte
    IMPORTING
      error   = v_error
      retcode = v_retcode
      format  = format.

  MOVE-CORRESPONDING format TO s_soi_cell_item.
  s_soi_cell_item-top = p_zeile.
  s_soi_cell_item-left = p_spalte.
  s_soi_cell_item-rows = 1.
  s_soi_cell_item-columns = 1.
  s_soi_cell_item-back = 6.
* 1 = weiß, 2 = schwarz, 3 = rot, 4 = grün, 5 = blau, 6 = gelb
  APPEND s_soi_cell_item TO t_soi_cell_table_fehlt.

ENDFORM.                    ” gelbschrift

*———————————————————————*
*       FORM rotschrift                                               *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  P_ZEILE                                                       *
*  –>  P_SPALTE                                                      *
*———————————————————————*
FORM rotschrift USING p_zeile p_spalte p_spalten.

  s_soi_cell_item-top = p_zeile.
  s_soi_cell_item-left = p_spalte.
  s_soi_cell_item-rows = 1.
  s_soi_cell_item-columns = p_spalten.
  s_soi_cell_item-back = 3.
  s_soi_cell_item-frametyp = -1.
  s_soi_cell_item-size = -1.
  s_soi_cell_item-bold = -1.
  s_soi_cell_item-italic = -1.
  s_soi_cell_item-align = -1.
  s_soi_cell_item-framecolor = -1.
  s_soi_cell_item-input = 0.
  APPEND s_soi_cell_item TO t_soi_cell_table.

ENDFORM.                    “rotschrift
*&———————————————————————*
*&      Form  format_init
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM format_init.
* Etwaige rote Felder zurücksetzen:
  LOOP AT t_soi_cell_table INTO s_soi_cell_item.
    s_soi_cell_item-back = 0.
    MODIFY t_soi_cell_table FROM s_soi_cell_item.
  ENDLOOP.
  IF NOT t_soi_cell_table[] IS INITIAL.
    CALL METHOD v_handle->cell_format
      EXPORTING
        cells   = t_soi_cell_table
      IMPORTING
        error   = v_error
        retcode = v_retcode.
  ENDIF.

  REFRESH t_soi_cell_table.

ENDFORM.                    ” format_init

*———————————————————————*
*       FORM sperre_abwarten                                          *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  P_VBELN                                                       *
*———————————————————————*
FORM sperre_abwarten USING p_vbeln.
  DO 100000 TIMES.
    CALL FUNCTION ‘SD_SALES_DOCUMENT_ENQUEUE’
      EXPORTING
        vbeln           = p_vbeln
        i_crm_lock_mode = space
      EXCEPTIONS
        foreign_lock    = 2
        system_failure  = 3.
    IF sy-subrc = 0.
      CALL FUNCTION ‘DEQUEUE_EVVBAKE’
        EXPORTING
          mode_vbak = ‘E’
          vbeln     = p_vbeln.

      EXIT.
    ELSE.
      WAIT UP TO 1 SECONDS.
    ENDIF.
  ENDDO.

ENDFORM.                    ” sperre_abwarten

*&———————————————————————*
*&      Form  header
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_0566   text
*———————————————————————-*
FORM header USING    value(p_header).

  s_rangeitem-row = v_rowpos.
  s_rangeitem-column = v_colpos.
  IF NOT p_header IS INITIAL.
    MOVE p_header TO s_rangeitem-value.” LEFT-JUSTIFIED.
  ELSE.
    CLEAR s_rangeitem-value.
  ENDIF.
  v_colpos = v_colpos + 1.
  SHIFT s_rangeitem-value LEFT DELETING LEADING ‘=’.
  SHIFT s_rangeitem-value LEFT DELETING LEADING space.  

IF s_rangeitem-value = ‘00.00.0000’

    s_rangeitem-value = ‘ ‘

  ENDIF. 

  “Das wird nämlich notfalls falsch interpretiert.
  IF s_rangeitem-value CO ‘0123456789.,- ‘ AND s_rangeitem-value CA ‘-‘.
    IF sy-fdpos GT 0.
      s_rangeitem-value+sy-fdpos = space.
      CONCATENATE ‘-‘ s_rangeitem-value INTO s_rangeitem-value.
    ENDIF.
  ENDIF.
  APPEND s_rangeitem TO t_cont..

ENDFORM.                    ” header
*———————————————————————*
*       FORM header_mit=                                              *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  VALUE(P_HEADER)                                               *
*———————————————————————*
FORM header_with_equals_sign USING    value(p_header).

  s_rangeitem-row = v_rowpos.
  s_rangeitem-column = v_colpos.
  IF NOT p_header IS INITIAL.
    WRITE p_header TO s_rangeitem-value LEFT-JUSTIFIED.
  ELSE.
    CLEAR s_rangeitem-value.
  ENDIF.
  v_colpos = v_colpos + 1.
  APPEND s_rangeitem TO t_cont..

ENDFORM.                    ” header

*&———————————————————————*
*&      Form  set_cell_value
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_AUFTRAGSTRUKTUR_ZEILE  text
*      –>P_1      text
*      –>P_ZBEDARF_BEDNR  text
*———————————————————————-*
FORM set_cell_value USING    p_zeile
                             p_spalte
                             p_wert.

  CLEAR t_ranges[].
  CLEAR t_contents[].
  CLEAR t_ran.
  CLEAR t_cont..

  WRITE p_wert TO t_contents-value.
  t_contents-row = ‘1’.
  t_contents-column = ‘1’.
  APPEND t_contents.

  CALL METHOD v_handle->set_selection
    EXPORTING
      left    = p_spalte
      top     = p_zeile
      rows    = 1
      columns = 1.
  s_rangei-name = ‘range1’.
  s_rangei-rows = 1.
  s_rangei-columns = 1.
  APPEND s_rangei TO t_ran.
  CALL METHOD v_handle->insert_range
    EXPORTING
      name    = s_rangei-name
      rows    = 1
      columns = 1
    IMPORTING
      error   = v_error
      retcode = v_retcode.

  CALL METHOD v_handle->set_ranges_data
    EXPORTING
      contents = t_contents[]
      ranges   = t_ran
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

ENDFORM.                    ” set_cell_value

*———————————————————————*
*       FORM set_value                                                *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  P_ZEILE                                                       *
*  –>  P_SPALTE                                                      *
*  –>  P_WERT                                                        *
*  –>  P_MODUS                                                       *
*———————————————————————*
FORM set_value USING p_zeile
                     p_spalte
                     p_wert
                     p_modus.
  DATA: charfeld(255).
  WRITE p_zeile TO t_contents-row.
  SHIFT t_contents-row LEFT DELETING LEADING space.
  WRITE p_spalte TO t_contents-column.
  SHIFT t_contents-column LEFT DELETING LEADING space.

  READ TABLE t_contents
  WITH KEY row = t_contents-row
       column = t_contents-column.
  IF sy-subrc NE 0.
    CLEAR t_contents.
  ENDIF.

  WRITE p_wert TO charfeld LEFT-JUSTIFIED.
  CASE p_modus.
    WHEN ‘ADD’.
      CONCATENATE t_contents-value charfeld
      INTO t_contents-value SEPARATED BY ‘/’.
      SHIFT t_contents-value LEFT DELETING LEADING ‘/’.
    WHEN OTHERS.
      t_contents-value = charfeld.
  ENDCASE.

  MODIFY t_contents INDEX sy-tabix.

ENDFORM.                    “set_value

*———————————————————————*
*       FORM set_single_value                                         *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  P_ZEILE                                                       *
*  –>  P_SPALTE                                                      *
*  –>  P_WERT                                                        *
*  –>  P_MODUS                                                       *
*———————————————————————*
FORM set_single_value USING p_zeile
                     p_spalte
                     p_wert.
  DATA: charfeld(255).

  CLEAR t_ranges[].
  CLEAR t_contents[].
  CLEAR t_ran.
  CLEAR t_cont..

  WRITE p_zeile TO t_contents-row.
  SHIFT t_contents-row LEFT DELETING LEADING space.
  WRITE p_spalte TO t_contents-column.
  SHIFT t_contents-column LEFT DELETING LEADING space.
  WRITE p_wert TO charfeld LEFT-JUSTIFIED.
  t_contents-value = charfeld.

* Positionieren:
  CALL METHOD v_handle->set_selection
    EXPORTING
      left    = p_spalte
      top     = p_zeile
      rows    = 1
      columns = 1.

* Range einsetzen:
  CONCATENATE ‘XZ’
              t_contents-row
              ‘S’
              t_contents-column
  INTO s_rangei-name.
  CALL METHOD v_handle->insert_range
    EXPORTING
      name    = s_rangei-name
      rows    = 1
      columns = 1
    IMPORTING
      error   = v_error
      retcode = v_retcode.

* Range übertragen:
  s_rangei-columns = s_rangei-rows = ‘0001’.
  APPEND s_rangei TO t_ran.
  APPEND t_contents TO t_cont..
  CALL METHOD v_handle->set_ranges_data
    EXPORTING
      ranges   = t_ran
      contents = t_cont
      no_flush = space
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

ENDFORM.                    “set_single_value
*&———————————————————————*
*&      Form  t_feldkatalog_fuellen
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM t_feldkatalog_fuellen USING p_key.

  REFRESH t_feldkatalog. CLEAR t_feldkatalog.

ENDFORM.                    ” t_feldkatalog_fuellen
*&———————————————————————*
*&      Form  parse_contents_t_feldkatalog
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_LOSTEILLISTE  text
*      –>P_t_feldkatalog  text
*———————————————————————-*
FORM parse_contents_t_feldkatalog TABLES   p_tabelle
                                CHANGING p_fehler.

  DATA zeile TYPE i.
  DATA spalte TYPE i.
  DATA fertig.
  DATA type .
  DATA eindeutig TYPE i.

* Excel-Spaltenköpfe auslesen:
  CLEAR v_colpos.
  LOOP AT t_feldkatalog WHERE excelpos IS INITIAL.
    CLEAR eindeutig.
    LOOP AT t_contents
    WHERE value = t_feldkatalog-excelname.
      t_feldkatalog-excelpos = t_contents-column.
      MODIFY t_feldkatalog.
      v_colpos = t_contents-row + 1.
      eindeutig = eindeutig + 1.
    ENDLOOP.
    IF sy-subrc = 4 AND t_feldkatalog-muss = ‘X’.
      ” Fehlermeldung:
      MESSAGE i084(xxx) WITH t_feldkatalog-excelname.
      p_fehler = ‘X’.
    ENDIF.
    IF eindeutig > 1.
      MESSAGE i085(xxx) WITH t_feldkatalog-excelname.
      p_fehler = ‘X’.
    ENDIF.
  ENDLOOP.

  CHECK p_fehler IS INITIAL.

  REFRESH p_tabelle. CLEAR p_tabelle.

  FIELD-SYMBOLS <ltl> TYPE any.

  DO.

    LOOP AT t_feldkatalog WHERE NOT excelpos IS INITIAL.
      t_contents-row = v_colpos.
      SHIFT t_contents-row LEFT DELETING LEADING space.
      t_contents-column = t_feldkatalog-excelpos.
      SHIFT t_contents-column LEFT DELETING LEADING space.

      READ TABLE t_contents
      WITH KEY row = t_contents-row
           column = t_contents-column.
      IF sy-subrc <> 0.
        fertig = ‘X’.
        EXIT.
      ENDIF.

      ASSIGN COMPONENT t_feldkatalog-sapname
      OF STRUCTURE p_tabelle TO <ltl>.

      DESCRIBE FIELD <ltl> TYPE type.
      CASE type.
        WHEN ‘P’.
          IF t_contents-value CO ‘ ,0123456789’.
            TRANSLATE t_contents-value USING ‘,.’.
          ENDIF.
        WHEN ‘D’.
          DATA chardat LIKE rvdat-extdatum.
          chardat = t_contents-value.
          DATA datum LIKE syst-datum.
          CALL FUNCTION ‘PERIOD_AND_DATE_CONVERT_INPUT’
            EXPORTING
              external_date              = chardat
              dialog_date_is_in_the_past = space
            IMPORTING
              internal_date              = datum
            EXCEPTIONS
              date_invalid               = 1
              no_data                    = 2
              period_invalid             = 3
              OTHERS                     = 4.
          IF sy-subrc EQ 0.
            t_contents-value = datum.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.

      CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
        <ltl> = t_contents-value.
      ENDCATCH.

    ENDLOOP.

    IF NOT p_tabelle IS INITIAL.
      ASSIGN COMPONENT ‘ZEILE’ OF STRUCTURE p_tabelle TO <ltl>.
      IF sy-subrc = 0.
        <ltl> = v_colpos.
      ENDIF.
      APPEND p_tabelle.
      CLEAR p_tabelle.
      v_colpos = v_colpos + 1.
    ELSE.
      EXIT.
    ENDIF.

    IF fertig = ‘X’.
      EXIT.
    ENDIF.
  ENDDO.

ENDFORM.                    ” parse_contents_t_feldkatalog
*&———————————————————————*
*&      Form  leerzeile
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM leerzeile USING spalten.

  v_colpos = 1.
  v_rowpos = v_rowpos + 1.

  DO spalten TIMES.
    PERFORM header USING space.
  ENDDO.

ENDFORM.                    ” leerzeile
*&———————————————————————*
*&      Form  excelsprache_feststellen
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM excelsprache_feststellen.

  CHECK v_excelsprache IS INITIAL.

  CALL METHOD v_control->get_document_proxy
    EXPORTING
      document_type  = v_document_type
    IMPORTING
      document_proxy = v_dummydocument
      error          = v_error.
  CLEAR v_retcode.
  WHILE v_retcode <> ‘OK’.
    CALL METHOD v_dummydocument->create_document
      EXPORTING
        open_inplace = v_inplace
      IMPORTING
        retcode      = v_retcode
        error        = v_error.
    IF v_retcode <> ‘OK’.
      CALL FUNCTION ‘POPUP_TO_INFORM’
        EXPORTING
          titel = text-x01
          txt1  = text-x02
          txt2  = text-x03
          txt3  = text-x04
          txt4  = text-x05.
    ENDIF.
  ENDWHILE.

  DATA: has TYPE i.
  DATA: dummyhandle TYPE REF TO i_oi_spreadsheet.
  CALL METHOD v_dummydocument->has_spreadsheet_interface
    IMPORTING
      is_available = has.

  IF NOT has IS INITIAL.
    CALL METHOD v_dummydocument->get_spreadsheet_interface
      IMPORTING
        sheet_interface = dummyhandle.
    CALL METHOD dummyhandle->get_sheets
      EXPORTING
        no_flush = space
      IMPORTING
        sheets   = t_sheets
        error    = v_error
        retcode  = v_retcode.
    LOOP AT t_sheets INTO s_sheets.
      CASE s_sheets.
        WHEN ‘Sheet1’.
          v_excelsprache = ‘E’.
        WHEN OTHERS.
          v_excelsprache = ‘D’.
      ENDCASE.
    ENDLOOP.
  ENDIF.
  CALL METHOD v_dummydocument->close_document.
  FREE v_dummydocument.

ENDFORM.                    ” excelsprache_feststellen

*&———————————————————————*
*&      Form  get_sheets
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM get_sheets.

  CALL METHOD v_handle->get_sheets
    EXPORTING
      no_flush = space
    IMPORTING
      sheets   = t_sheets
      error    = v_error
      retcode  = v_retcode.

ENDFORM.                    ” get_sheets
*&———————————————————————*
*&      Form  set_print_area
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_LINES  text
*———————————————————————-*
FORM set_print_area USING    p_lines.

  REFRESH t_ran. REFRESH t_cont..

  s_rangei-name = text-r03.
  s_rangei-rows = 1.
  s_rangei-columns = 1.
  s_rangei-code = ‘1’.
  APPEND s_rangei TO t_ran.

  CALL METHOD v_handle->set_selection
    EXPORTING
      left    = 7
      top     = 2
      rows    = 1
      columns = 1.

  CALL METHOD v_handle->insert_range
    EXPORTING
      name    = s_rangei-name
      rows    = 1
      columns = 1
    IMPORTING
      error   = v_error
      retcode = v_retcode.

  v_rowpos = v_colpos = 1.
  PERFORM header USING p_lines.

  CALL METHOD v_handle->set_ranges_data
    EXPORTING
      ranges   = t_ran
      contents = t_cont
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

  CALL METHOD v_document->execute_macro
    EXPORTING
      macro_string = text-r04
      no_flush     = space
    IMPORTING
      error        = v_error
      retcode      = v_retcode.

  REFRESH t_cont..
  v_rowpos = v_colpos = 1.
  PERFORM header USING space.
  CALL METHOD v_handle->set_ranges_data
    EXPORTING
      ranges   = t_ran
      contents = t_cont
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

ENDFORM.                    ” set_print_area

*———————————————————————*
*       FORM set_sheet                                                *
*———————————————————————*
*       ……..                                                      *
*———————————————————————*
*  –>  P_SHEET                                                       *
*———————————————————————*
FORM set_sheet USING p_sheet.

  READ TABLE t_sheets INTO s_sheets
  WITH KEY sheet_name = p_sheet.
  IF sy-subrc <> 0.
    MESSAGE i086(yxls) WITH p_sheet.
    EXIT.
  ENDIF.

  CALL METHOD v_handle->select_sheet
    EXPORTING
      name     = s_sheets-sheet_name
      no_flush = space
    IMPORTING
      error    = v_error
      retcode  = v_retcode.

ENDFORM.                    ” get_sheets
*&———————————————————————*
*&      Form  parse
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_0413   text
*      <–P_BUYER  text
*———————————————————————-*
FORM parse USING    p_row
                    p_column
           CHANGING p_field.

  CLEAR p_field.
  READ TABLE t_contents WITH KEY
  row = p_row
  column = p_column.
  CHECK sy-subrc = 0.
  p_field = t_contents-value.

ENDFORM.                    ” parse
*&———————————————————————*
*&      Form  format_zahl
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_LISTE_AEWERT  text
*      <–P_STRING  text
*———————————————————————-*
FORM format_zahl USING    value(p_wert)
                 CHANGING p_string.

  IF p_wert < 0.
    p_wert = – p_wert.
    WRITE p_wert TO p_string.
    CONCATENATE ‘-‘ p_string INTO p_string.
  ELSE.
    WRITE p_wert TO p_string.
  ENDIF.

ENDFORM.                    ” format_zahl

*&———————————————————————*
*&      Form  fill_value
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_TEXT     text
*      –>P_FIXPT    text
*      –>P_VALUE    text
*———————————————————————-*
FORM fill_value  USING    p_text
                          p_fixpt
                 CHANGING p_value.
  DATA: x TYPE f,
        lv_var1 TYPE char5,
        lv_var2 TYPE char8,
        lv_curr TYPE yyyeqt_sellprice,
        lv_dcfm  TYPE char1,
        lv_decm TYPE char1,
        lv_text TYPE char256.

  CONSTANTS:
*             lk_poc TYPE symsgv VALUE ‘Current POC’,
*             lk_poc_upld TYPE symsgv VALUE ‘POC to be uploaded’,
             lk_special TYPE string VALUE ‘~`!@#$%^&*()_=[]{}|\;:”<>?/’.
  sy-msgv1 = p_text.

  lv_text = p_text.

  TRANSLATE lv_text TO UPPER CASE.
*check for special caracter entered in decimal field
  IF lv_text CA lk_special.
    MESSAGE e104(rsisw) WITH v_row v_rowpos.
    EXIT.
  ENDIF.
*check for character values enterd in decimal field

  IF lv_text CA sy-abcde.
    MESSAGE e171(xxx)  WITH v_row v_rowpos.
    EXIT.
  ENDIF.

  DESCRIBE FIELD p_value DECIMALS lv_decm.
  IF lv_decm LE 2.
    CASE v_dcpfm.           “numeric format defined in user profile
      WHEN ‘ ‘.                        ”    N.NNN,NN
        TRANSLATE sy-msgv1 USING ‘. ,.’.
        CONDENSE sy-msgv1 NO-GAPS.
*        dec_point = ‘,’.
*        delimiter = ‘.’.
      WHEN ‘X’.                        ”    N,NNN.NN
        TRANSLATE sy-msgv1 USING ‘, ‘.
        CONDENSE sy-msgv1 NO-GAPS.
*        dec_point = ‘.’.
*        delimiter = ‘,’.
      WHEN ‘Y’.                        “N NNN NNN,NN
        TRANSLATE sy-msgv1 USING ‘,.’.
        CONDENSE sy-msgv1 NO-GAPS.
*        dec_point = ‘,’.
*        delimiter = ‘ ‘.
      WHEN OTHERS.
    ENDCASE.
  ENDIF.

  CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
    p_value =  sy-msgv1.
  ENDCATCH.
  CHECK p_fixpt = space.
  CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
    DATA decimals TYPE i.
    x = sy-msgv1.
    DESCRIBE FIELD p_value DECIMALS decimals.
    DO decimals TIMES.
      x = 10 * x.
    ENDDO.
    p_value = x.
  ENDCATCH.

ENDFORM.                    ” FILL_VALUE
*&———————————————————————*
*&      Form  F00_WHITE_BACK
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_LS_EXCELDATA_ZEILE  text
*      –>P_LS_EDIT_COL_COL  text
*      –>P_1      text
*———————————————————————-*
FORM f00_white_back  USING     p_ls_edit_col TYPE n.

  DATA: lv_tabix TYPE sy-tabix,
        linetype TYPE string,
        itabref  TYPE REF TO data,
        line     TYPE REF TO data.

* CREATION OF A TABLE :
  CREATE DATA itabref TYPE STANDARD TABLE OF (v_tabname).
  ASSIGN itabref->* TO <fs>.

*Importing content from memory id
  IMPORT  t_exceldata[] FROM MEMORY ID v_memoryid.
  <fs> = t_exceldata[].

* CREATION OF A STRUCTURE :
  CREATE DATA line LIKE LINE OF <fs>.
  ASSIGN line->* TO <fl>.
* loop at t_exceldata.
  LOOP AT <fs> ASSIGNING <fl>.
    lv_tabix = sy-tabix.
*   POC, forcasst date and actual date editable
    s_soi_cell_item-top = lv_tabix + 1.
    s_soi_cell_item-left = p_ls_edit_col.
    s_soi_cell_item-rows = 1.
    s_soi_cell_item-columns = 1.
    s_soi_cell_item-back = 2.
    s_soi_cell_item-frametyp = -1.
    s_soi_cell_item-size = -1.
    s_soi_cell_item-bold = -1.
    s_soi_cell_item-italic = -1.
    s_soi_cell_item-align = -1.
    s_soi_cell_item-framecolor = -1.
    APPEND s_soi_cell_item TO t_soi_cell_table.
  ENDLOOP.
ENDFORM.                    ” F00_WHITE_BACK

*&———————————————————————*
*&  Include           YYYPSDIN_EXCEL_FORMS_TOP
*&———————————————————————*

=============================================================
*$– Declaration for Tables.
TABLES usr01.

*$– Declaration for Type Pool.
TYPE-POOLS: vrm, sbdst, soi.

*$– Declaration for Types
TYPES: BEGIN OF ty_edit_col,
        col(2) TYPE n,
       END OF ty_edit_col.

*$– Declaration for Tables.
DATA:   t_ran                  TYPE soi_range_list,
        t_cont                 TYPE soi_generic_table,
        t_data_table           TYPE sbdst_content,
        t_soi_cell_table_fehlt TYPE soi_cell_table,
        t_soi_cell_table       TYPE soi_cell_table,
        t_sheets               TYPE soi_sheets_table,

        t_ranges      TYPE soi_range_item   OCCURS 1 WITH HEADER LINE,
        t_contents    TYPE soi_generic_item OCCURS 1 WITH HEADER LINE,
        t_bdcdata     TYPE bdcdata          OCCURS 0 WITH HEADER LINE,
        t_message_tab TYPE TABLE OF bdcmsgcoll       WITH HEADER LINE,

        BEGIN OF t_feldkatalog OCCURS 0,
        sapname(20),
*        sappos TYPE i,
        excelname(40),
        excelpos TYPE i,
        muss,
        END OF t_feldkatalog.

*$– Declaration for Work area.
DATA: s_rangeitem       TYPE soi_generic_item,
      s_rangei          TYPE soi_range_item,
      s_soi_cell_item   TYPE soi_cell_item,
      s_sheets          TYPE soi_sheets.

**$– Declaration for Variable .
DATA :  v_retcode           TYPE soi_ret_string,
        v_container         TYPE REF TO cl_gui_custom_container,
        v_error             TYPE REF TO i_oi_error,
        v_control           TYPE REF TO i_oi_container_control,
        v_document          TYPE REF TO i_oi_document_proxy,
        v_handle            TYPE REF TO i_oi_spreadsheet,
        v_dummydocument     TYPE REF TO i_oi_document_proxy,
        v_inplace           VALUE ‘X’,
        v_excel(80)         VALUE ‘Excel.Sheet’,
        v_item_url(256)     TYPE c,
        okcode(15)          TYPE c,
        already_done        TYPE flag,
        newname(40)         TYPE c,
        v_document_type(80) TYPE c,
        v_filesize          TYPE i,
        v_first             TYPE flag,
        v_tabname           TYPE char30,
        v_memoryid          TYPE char30,
        v_excelsprache      TYPE sylangu,
        v_columns           TYPE i,
        v_rowpos            TYPE i,
        v_colpos            TYPE i,
        v_colpos_org        TYPE i,
        v_colpos_tmp        TYPE i,
        tc_table_line       TYPE i,
        v_row               type i.

DATA: V_dcpfm TYPE xudcpfm.

FIELD-SYMBOLS: <fs> TYPE STANDARD TABLE,
         <fl> TYPE any,
         <field> TYPE any.

*&  Include           ZIN_BILLN_PLN_FRM_XLS_SEL
============================================================

selection-screen begin of block b1 with frame.
parameters p_vbeln type vbak-vbeln matchcode object VMVAA memory id AUN.
selection-screen end of block b1.

*&———————————————————————*
*&  Include           ZIN_BILLN_PLN_F_XLS_FORMS
*&———————————————————————*

==================================================
*&———————————————————————*
*&      Form  F100_GET_DATA
*&———————————————————————*
*       Subroutine to retrieve data for excel output display
*———————————————————————-*
FORM f100_get_data .
  SELECT SINGLE vbtyp
         FROM vbak INTO v_vbtyp
           WHERE vbeln = p_vbeln.
*subroutine to check authorization and status
  PERFORM f200_sales_document_status USING v_vbtyp.
* subroutine to extract data to be displayed
  PERFORM f200_sales_document_data USING v_vbtyp.
*                                   CHANGING t_fplt.

  IF t_fplt[] IS NOT INITIAL.
    t_fplt_init[] = t_fplt[].
    t_exceldata[] = t_fplt[].
    EXPORT t_exceldata[] TO MEMORY ID ‘XXXXXXXXXXXX’.
    REFRESH t_exceldata[].
  ELSE.
    MESSAGE ‘This sales document has no billing plan’(001) TYPE ‘I’.
    PERFORM f000_deq_doc.
    LEAVE TO TRANSACTION ‘XXXXX’.
  ENDIF.
ENDFORM.                    ” F100_GET_DATA
*&———————————————————————*
*&      Module  STATUS_9000  OUTPUT
*&———————————————————————*
*       Module for PF status and titlebar of screen
*———————————————————————-*
MODULE 9000_status OUTPUT.
  SET PF-STATUS ‘Y000’.
  SET TITLEBAR ‘9000_DYNPRO_TITLE’.

ENDMODULE.                 ” STATUS_9000  OUTPUT
*&———————————————————————*
*&      Module  USER_COMMAND_9000  INPUT
*&———————————————————————*
*       Module to implement user interaction with the output screen
*———————————————————————-*
MODULE 9000_user_command INPUT.
  DATA: lv_update TYPE flag,
        lv_text       TYPE char256.
  CONCATENATE text-101 text-102 INTO lv_text SEPARATED BY space.
  CASE v_okcode.
    WHEN ‘BACK’.
      CALL FUNCTION ‘POPUP_TO_CONFIRM’
        EXPORTING
          titlebar              = text-100
          text_question         = lv_text
          default_button        = ‘2’
          display_cancel_button = ‘ ‘
          start_column          = 15
          start_row             = 6
        IMPORTING
          answer                = v_okcode
        EXCEPTIONS
          text_not_found        = 1
          OTHERS                = 2.
      IF sy-subrc = 0.
        IF v_okcode = ‘1’.
          PERFORM f000_exit.
          PERFORM f000_deq_doc.
          LEAVE TO TRANSACTION ‘XXXXX’.
        ENDIF.
      ENDIF.

    WHEN ‘SAVE’.
*     Subroutine to get excel content
      PERFORM f00_getdata USING space v_columns.
*     Subroutine to parse excel content
      PERFORM f00_parse_contents TABLES t_exceldata
                          USING v_columns
                                1
                                2
                                ‘X’.
*     Subroutine to check modified data consistency
      PERFORM f200_check_t_exceldata.
      IF t_soi_cell_table[] IS INITIAL.
      ELSE.
        EXIT.
      ENDIF.
*     Subroutine to update valid modified excel data to SAP
      PERFORM f200_check_data CHANGING lv_update.

    WHEN ‘EXIT’.
      CALL FUNCTION ‘POPUP_TO_CONFIRM’
        EXPORTING
          titlebar              = text-100
          text_question         = lv_text
          default_button        = ‘2’
          display_cancel_button = ‘ ‘
          start_column          = 15
          start_row             = 6
        IMPORTING
          answer                = v_okcode
        EXCEPTIONS
          text_not_found        = 1
          OTHERS                = 2.

      IF sy-subrc = 0.
        IF v_okcode = ‘1’.
          PERFORM f000_exit.
          PERFORM f000_deq_doc.
          LEAVE TO TRANSACTION ‘XXXXXX’.
        ENDIF.
      ENDIF.

    WHEN ‘CANCEL’.
      CALL FUNCTION ‘POPUP_TO_CONFIRM’
        EXPORTING
          titlebar              = text-100
          text_question         = lv_text
          default_button        = ‘2’
          display_cancel_button = ‘ ‘
          start_column          = 15
          start_row             = 6
        IMPORTING
          answer                = v_okcode
        EXCEPTIONS
          text_not_found        = 1
          OTHERS                = 2.

      IF sy-subrc = 0.
        IF v_okcode = ‘1’.
          PERFORM f000_exit.
          PERFORM f000_deq_doc.
          LEAVE TO TRANSACTION ‘XXXXX’.
        ENDIF.
      ENDIF.
    WHEN ‘CHK’.
*     Subroutine to get excel content
      PERFORM f00_getdata USING space v_columns.
*     Subroutine to parse excel content
      PERFORM f00_parse_contents TABLES t_exceldata
                          USING v_columns
                                1
                                2
                                ‘X’.
*     Subroutine to check modified data consistency
      PERFORM f200_check_t_exceldata.
      IF t_soi_cell_table[] IS INITIAL.
      ELSE.
        EXIT.
      ENDIF.

    WHEN .
*     Subroutine to get excel content
      PERFORM f00_getdata USING space v_columns.
*     Subroutine to parse excel content
      PERFORM f00_parse_contents TABLES t_exceldata
                          USING v_columns
                                1
                                2
                                ‘X’.
*     Subroutine to check modified data consistency
      PERFORM f200_check_t_exceldata.

    WHEN ‘ENTE’.
*     Subroutine to get excel content
      PERFORM f00_getdata USING space v_columns.
*     Subroutine to parse excel content
      PERFORM f00_parse_contents TABLES t_exceldata
                          USING v_columns
                                1
                                2
                                ‘X’.
*     Subroutine to check modified data consistency
      PERFORM f200_check_t_exceldata.
  ENDCASE.
  CLEAR v_okcode.
ENDMODULE.                 ” USER_COMMAND_9000  INPUT
*&———————————————————————*
*&      Module  9000_CREATE_BASIC_OBJECTS  OUTPUT
*&———————————————————————*
*       Module to create object for excel display
*———————————————————————-*
MODULE 9000_create_basic_objects OUTPUT.
  DATA  :
        ls_fplt TYPE xxxx,
        lt_excel TYPE STANDARD TABLE OF xxxx,       

        ls_excel TYPE xxxx,
        ls_zfplt TYPE fpltvb,
        lv_row TYPE i,
        lv_protect TYPE c,
        lv_col TYPE i,
        lv_vbeln TYPE vbeln_va,

        lv_posnr TYPE posnr_va,
        lv_color TYPE i.
* create object for excel display
  PERFORM f000_create_basic_objects USING ‘ZRE_UPD_BILLN_PLN_FRM_XLS’
                                           space
                                           ‘X’.

*  whole line in grey color if status = reached (is date has passed: FPLT-afdat < SYSDAT).
*  perform f200_status_reached_grey.
  CLEAR t_soi_cell_table.
  lt_excel[] = t_exceldata[].
  IF v_flag_dsp = ‘X’.
    DELETE lt_excel INDEX 1.
  ENDIF.

  LOOP AT lt_excel INTO ls_excel.
    lv_row = sy-tabix + 1.
    IF lv_vbeln <> ls_excel-vbeln OR lv_posnr <> ls_excel-posnr.
      lv_vbeln = ls_excel-vbeln.
      lv_posnr = ls_excel-posnr.
      IF lv_color = 19.
        lv_color = 34.
      ELSE.
        lv_color = 19.
      ENDIF.
    ENDIF.
    lv_col = 1.
    DO 13 TIMES. “chang no of iterations from 14 to 13
      CLEAR s_soi_cell_item.
      s_soi_cell_item-top = lv_row.
      s_soi_cell_item-left = lv_col.
      s_soi_cell_item-rows = 1.
      s_soi_cell_item-columns = 1.
      s_soi_cell_item-back = lv_color.
      s_soi_cell_item-frametyp = -1.
      s_soi_cell_item-size = -1.
      s_soi_cell_item-bold = -1.
      s_soi_cell_item-italic = -1.
      s_soi_cell_item-align = -1.
      s_soi_cell_item-framecolor = -1 .“lv_color.
      s_soi_cell_item-input = 1 .
      APPEND s_soi_cell_item TO t_soi_cell_table.
      lv_col = lv_col + 1.
    ENDDO.
  ENDLOOP.

  IF  v_flag_dsp IS NOT INITIAL.
    LOOP AT t_zfplt INTO ls_zfplt.

      CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT’
        EXPORTING
          input  = ls_zfplt-fplnr
        IMPORTING
          output = ls_zfplt-fplnr
        EXCEPTIONS
          OTHERS = 1.
      IF sy-subrc = 0.
        READ TABLE t_fplt INTO ls_fplt WITH KEY fplnr = ls_zfplt-fplnr
                                                fpltr = ls_zfplt-fpltr
                                                BINARY SEARCH.

        IF sy-subrc IS INITIAL.
          IF ls_zfplt-afdat < sy-datum.
            lv_row = sy-tabix + 1.
            CLEAR s_soi_cell_item.
            s_soi_cell_item-top = lv_row  .
            s_soi_cell_item-left = 14.
            s_soi_cell_item-rows = 1.
            s_soi_cell_item-columns = 1.
            s_soi_cell_item-back = 15.
            s_soi_cell_item-frametyp = -1.
            s_soi_cell_item-size = -1.
            s_soi_cell_item-bold = -1.
            s_soi_cell_item-italic = -1.
            s_soi_cell_item-align = -1.
            s_soi_cell_item-framecolor = -1.
            s_soi_cell_item-input = 1 .
            APPEND s_soi_cell_item TO t_soi_cell_table.
            CLEAR s_soi_cell_item.
            s_soi_cell_item-top = lv_row  .
            s_soi_cell_item-left = 15.
            s_soi_cell_item-rows = 1.
            s_soi_cell_item-columns = 1.
            s_soi_cell_item-back = 15.
            s_soi_cell_item-frametyp = -1.
            s_soi_cell_item-size = -1.
            s_soi_cell_item-bold = -1.
            s_soi_cell_item-italic = -1.
            s_soi_cell_item-align = -1.
            s_soi_cell_item-framecolor = -1.
            s_soi_cell_item-input = 1 .
            APPEND s_soi_cell_item TO t_soi_cell_table.
          ELSE.
            CLEAR s_soi_cell_item.
            s_soi_cell_item-top = lv_row  .
            s_soi_cell_item-left = 14.
            s_soi_cell_item-rows = 1.
            s_soi_cell_item-columns = 1.
            s_soi_cell_item-back = 2.
            s_soi_cell_item-frametyp = -1.
            s_soi_cell_item-size = -1.
            s_soi_cell_item-bold = -1.
            s_soi_cell_item-italic = -1.
            s_soi_cell_item-align = -1.
            s_soi_cell_item-framecolor = -1.
            s_soi_cell_item-input = 0.
            APPEND s_soi_cell_item TO t_soi_cell_table.

**        Addition to check milestone no initial for date to be freezed/unfreezed
            IF ls_fplt-mlst_zaehl IS INITIAL.

              CLEAR s_soi_cell_item.
              s_soi_cell_item-top = lv_row  .
              s_soi_cell_item-left = 15.
              s_soi_cell_item-rows = 1.
              s_soi_cell_item-columns = 1.
              s_soi_cell_item-back = 2.
              s_soi_cell_item-frametyp = -1.
              s_soi_cell_item-size = -1.
              s_soi_cell_item-bold = -1.
              s_soi_cell_item-italic = -1.
              s_soi_cell_item-align = -1.
              s_soi_cell_item-framecolor = -1.
              s_soi_cell_item-input = 0.
              APPEND s_soi_cell_item TO t_soi_cell_table.
            ELSE.
*         for milsetone no filled in, date will be freezed
              CLEAR s_soi_cell_item.
              s_soi_cell_item-top = lv_row  .
              s_soi_cell_item-left = 15.
              s_soi_cell_item-rows = 1.
              s_soi_cell_item-columns = 1.
              s_soi_cell_item-back = 15.
              s_soi_cell_item-frametyp = -1.
              s_soi_cell_item-size = -1.
              s_soi_cell_item-bold = -1.
              s_soi_cell_item-italic = -1.
              s_soi_cell_item-align = -1.
              s_soi_cell_item-framecolor = -1.
              s_soi_cell_item-input = 1.
              APPEND s_soi_cell_item TO t_soi_cell_table.

            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ELSE.
    v_flag_dsp = ‘X’.
    LOOP AT t_zfplt INTO ls_zfplt.
      READ TABLE t_fplt INTO ls_fplt WITH KEY fplnr = ls_zfplt-fplnr
                                              fpltr = ls_zfplt-fpltr
                                              BINARY SEARCH.

      IF sy-subrc IS INITIAL.
        IF ls_zfplt-afdat < sy-datum.
          lv_row = sy-tabix + 1.
          CLEAR s_soi_cell_item.
          s_soi_cell_item-top = lv_row  .
          s_soi_cell_item-left = 14.
          s_soi_cell_item-rows = 1.
          s_soi_cell_item-columns = 1.
          s_soi_cell_item-back = 15.
          s_soi_cell_item-frametyp = -1.
          s_soi_cell_item-size = -1.
          s_soi_cell_item-bold = -1.
          s_soi_cell_item-italic = -1.
          s_soi_cell_item-align = -1.
          s_soi_cell_item-framecolor = -1.
          s_soi_cell_item-input = 1 .
          APPEND s_soi_cell_item TO t_soi_cell_table.

          CLEAR s_soi_cell_item.
          s_soi_cell_item-top = lv_row  .
          s_soi_cell_item-left = 15.
          s_soi_cell_item-rows = 1.
          s_soi_cell_item-columns = 1.
          s_soi_cell_item-back = 15.
          s_soi_cell_item-frametyp = -1.
          s_soi_cell_item-size = -1.
          s_soi_cell_item-bold = -1.
          s_soi_cell_item-italic = -1.
          s_soi_cell_item-align = -1.
          s_soi_cell_item-framecolor = -1.
          s_soi_cell_item-input = 1 .
          APPEND s_soi_cell_item TO t_soi_cell_table.

        ELSE.
          lv_row = sy-tabix + 1.
          CLEAR s_soi_cell_item.
          s_soi_cell_item-top = lv_row  .
          s_soi_cell_item-left = 14.
          s_soi_cell_item-rows = 1.
          s_soi_cell_item-columns = 1.
          s_soi_cell_item-back = 2.
          s_soi_cell_item-frametyp = -1.
          s_soi_cell_item-size = -1.
          s_soi_cell_item-bold = -1.
          s_soi_cell_item-italic = -1.
          s_soi_cell_item-align = -1.
          s_soi_cell_item-framecolor = -1.
          APPEND s_soi_cell_item TO t_soi_cell_table.

**        Addition to check milestone no initial for date to be freezed/unfreezed
          IF ls_fplt-mlst_zaehl IS INITIAL.

            CLEAR s_soi_cell_item.
            s_soi_cell_item-top = lv_row  .
            s_soi_cell_item-left = 15.
            s_soi_cell_item-rows = 1.
            s_soi_cell_item-columns = 1.
            s_soi_cell_item-back = 2.
            s_soi_cell_item-frametyp = -1.
            s_soi_cell_item-size = -1.
            s_soi_cell_item-bold = -1.
            s_soi_cell_item-italic = -1.
            s_soi_cell_item-align = -1.
            s_soi_cell_item-framecolor = -1.
            APPEND s_soi_cell_item TO t_soi_cell_table.
          ELSE.
*         for milsetone no filled in, date will be freezed
            CLEAR s_soi_cell_item.
            s_soi_cell_item-top = lv_row  .
            s_soi_cell_item-left = 15.
            s_soi_cell_item-rows = 1.
            s_soi_cell_item-columns = 1.
            s_soi_cell_item-back = 15.
            s_soi_cell_item-frametyp = -1.
            s_soi_cell_item-size = -1.
            s_soi_cell_item-bold = -1.
            s_soi_cell_item-italic = -1.
            s_soi_cell_item-align = -1.
            s_soi_cell_item-framecolor = -1.
            s_soi_cell_item-input = 1.
            APPEND s_soi_cell_item TO t_soi_cell_table.

          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.
  IF NOT t_soi_cell_table[] IS INITIAL.
    CALL METHOD v_handle->cell_format
      EXPORTING
        cells   = t_soi_cell_table
      IMPORTING
        error   = v_error
        retcode = v_retcode.
  ENDIF.

*for width and zoom
  s_rangei-name = ‘Data’(r02).
  s_rangei-rows = v_rowpos.
  s_rangei-columns = v_columns.
  s_rangei-code = ‘1’.
  APPEND s_rangei TO t_ran.
  CALL METHOD v_handle->insert_range
    EXPORTING
      name    = s_rangei-name
      rows    = v_rowpos
      columns = v_columns
    IMPORTING
      error   = v_error
      retcode = v_retcode.
  CALL METHOD v_handle->fit_widest
    EXPORTING
      name  = s_rangei-name
    IMPORTING
      error = v_error.

  CALL METHOD v_handle->set_zoom
    EXPORTING
      zoom    = 85
    IMPORTING
      error   = v_error
      retcode = v_retcode.

  CLEAR: s_rangei, t_ran.
  CALL METHOD v_handle->get_protection
    EXPORTING
      sheetname = ‘Sheet1’(009)
    IMPORTING
      error     = v_error
      retcode   = v_retcode
      protect   = lv_protect.
* If not protected, protect the sheet
  IF lv_protect NE ‘X’.
    CALL METHOD v_handle->protect
      EXPORTING
        protect = ‘X’
      IMPORTING
        error   = v_error
        retcode = v_retcode.
  ENDIF.
ENDMODULE.                 ” 9000_CREATE_BASIC_OBJECTS  OUTPUT
*&———————————————————————*
*&      Form  F200_CHECK_DATA
*&———————————————————————*
*       Subroutine to check the original and modified excel data
*———————————————————————-*
*       <–  fcv_update        flag for updation
*———————————————————————-*
FORM f200_check_data CHANGING fcv_update  TYPE flag.
  MOVE t_exceldata[] TO t_fplt[].
  IF t_fplt[] <> t_fplt_init[].
    fcv_update = ‘X’.
    PERFORM f300_save_data.
    CLEAR fcv_update.
  ELSE.
    MESSAGE s067(va).
  ENDIF.
ENDFORM.                    ” F200_CHECK_DATA
*&———————————————————————*
*&      Form  F200_SAVE_DATA
*&———————————————————————*
*       Subroutine to save updated dat of excel into SAP
*———————————————————————-*
FORM f300_save_data .
  DATA: lt_zfplt_new  TYPE STANDARD TABLE OF fpltvb,
        lt_zfplt_read TYPE STANDARD TABLE OF fpltvb,
        lt_fplt_bapi  TYPE STANDARD TABLE OF fplavb,
        lt_zfplt_tmp  TYPE STANDARD TABLE OF fpltvb,
        lt_zfplt_tmp1 TYPE STANDARD TABLE OF xxxx,
        lt_netwr_new  TYPE STANDARD TABLE OF ty_netwr,
        ls_zfplt_new  TYPE fpltvb,
        ls_fplt       TYPE xxxx,
        ls_fplt1      TYPE xxxx,
        ls_fplt_bapi  TYPE fplavb,
        lv_flag       TYPE flag,
        ls_bapiret2   TYPE bapiret2,
        lv_fplnr      TYPE fplnr,
        ls_zfplt_tmp  TYPE fpltvb,
        ls_alv        TYPE ty_alv,
        lv_tdline     TYPE tdline,
        lv_fakwr      TYPE fakwr,
        ls_netwr      TYPE ty_netwr,
        lv_tabix      TYPE sy-tabix,
        ls_netwr_new  TYPE ty_netwr,

        lt_bapi_so      TYPE STANDARD TABLE OF ty_bapi,
        lt_bapi_so_tmp  TYPE STANDARD TABLE OF ty_bapi,
        lt_tab          TYPE STANDARD TABLE OF xxxx,
        ls_tab          TYPE xxxx,
        ls_bapi_so      TYPE ty_bapi,

        lt_bapiret2     TYPE STANDARD TABLE OF bapiret2,
        lt_cond         TYPE STANDARD TABLE OF bapicond WITH HEADER LINE,
        lt_cond_so      TYPE STANDARD TABLE OF bapicond WITH HEADER LINE,
        lt_cond_inx     TYPE STANDARD TABLE OF bapicondx WITH HEADER LINE,
        lt_cond_inx_so  TYPE STANDARD TABLE OF bapicondx WITH HEADER LINE,
        ls_hdr          TYPE bapisdhd1,
        ls_hdr_so       TYPE bapisdh1,
        ls_hdr_inx      TYPE bapisdhd1x,
        ls_hdr_inx_so   TYPE bapisdh1x,
        ls_cond         TYPE bapicond,
        ls_cond_inx     TYPE bapicondx,
        lv_vkorg        TYPE vkorg,
        lv_vtweg        TYPE vtweg,
        lv_spart        TYPE spart,

        lt_netval   TYPE STANDARD TABLE OF ty_netval,
        lt_vbap_tmp TYPE STANDARD TABLE OF ty_vbap,
        lt_vbap     TYPE STANDARD TABLE OF ty_vbap,
        lt_knumh    TYPE STANDARD TABLE OF ty_knumh,
        ls_knumh    TYPE ty_knumh,
        ls_vbfa     TYPE ty_vbfa,
        ls_vbap     TYPE ty_vbap,
        ls_netval   TYPE ty_netval,

        lr_posnr TYPE RANGE OF posnr_va,
        ls_posnr LIKE LINE OF lr_posnr,
        lr_matnr TYPE   RANGE OF matnr,
        lr_matnr1 TYPE   RANGE OF matnr,
        ls_matnr LIKE LINE OF lr_matnr,

        ls_konv   TYPE ty_konv.

  FIELD-SYMBOLS: <zfplt> TYPE fpltvb,
                 <fplt> TYPE XXXXX.

  DATA: lt_kschl TYPE STANDARD TABLE OF ty_kschl,
        ls_kschl TYPE ty_kschl,
        ls_vbeln TYPE ty_vbeln,
        ls_vbeln_tmp TYPE ty_vbeln,
        ls_r_kschl   LIKE LINE OF r_kschl.

  DATA:ls_options TYPE ctu_params.

  ls_options-dismode = k_n.
  ls_options-updmode = k_a.
  ls_options-defsize = abap_true.
  ls_options-racommit = abap_true.

  lt_zfplt_new[] = t_zfplt[].
  CLEAR t_zfplt[].
  SELECT vbeln
         posnr
         matnr
         waerk
    FROM vbap
    INTO TABLE lt_vbap
    WHERE vbeln = p_vbeln.
  IF sy-subrc = 0.
    SORT lt_vbap BY vbeln posnr.
  ENDIF.
  LOOP AT lt_zfplt_new ASSIGNING <zfplt>.
    lv_tabix = sy-tabix.
    CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT’
      EXPORTING
        input  = <zfplt>-fplnr
      IMPORTING
        output = lv_fplnr
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc = 0.
*    12-06-2013
      READ TABLE t_fplt INTO ls_fplt WITH KEY fplnr = lv_fplnr
                                              fpltr = <zfplt>-fpltr.
*                                              BINARY SEARCH.
      IF sy-subrc IS INITIAL .

        APPEND <zfplt> TO t_zfplt[].

        IF <zfplt>-fakwr <> ls_fplt-fakwr_upld OR <zfplt>-afdat <> ls_fplt-afdat_upld.
          <zfplt>-fakwr = ls_fplt-fakwr_upld.
          <zfplt>-afdat = ls_fplt-afdat_upld.
          <zfplt>-updkz = ‘U’.
          ls_posnr-option = ‘I’.
          ls_posnr-sign = ‘EQ’.
          ls_posnr-low = ls_fplt-posnr.
          APPEND ls_posnr TO lr_posnr.
          CLEAR ls_posnr.

          CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
            EXPORTING
              input  = ls_fplt-vbeln
            IMPORTING
              output = ls_fplt-vbeln
            EXCEPTIONS
              OTHERS = 1.
          IF sy-subrc = 0.
            ls_vbeln-vbeln = ls_fplt-vbeln.
            ls_vbeln-posnr = ls_fplt-posnr.
            APPEND ls_vbeln TO t_vbeln.
            CLEAR ls_vbeln.
          ENDIF.

*       filling range for materials modified
          READ TABLE lt_vbap INTO ls_vbap WITH KEY vbeln = p_vbeln
                                                   posnr = ls_fplt-posnr
                                                   BINARY SEARCH.
          ls_matnr-option = ‘EQ’.
          ls_matnr-sign = ‘I’.
          ls_matnr-low = ls_vbap-matnr.
          APPEND ls_matnr TO lr_matnr.
          CLEAR ls_matnr.

*       getting posnr of SO for contract
          READ TABLE t_vbap INTO ls_vbap INDEX lv_tabix.
          APPEND ls_vbap TO lt_vbap_tmp.
          CLEAR ls_vbap.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.
  CLEAR lv_tabix.
  DELETE ADJACENT DUPLICATES FROM lr_posnr.
  SORT t_vbeln BY vbeln posnr.
  DELETE ADJACENT DUPLICATES FROM t_vbeln COMPARING vbeln posnr.
  DELETE ADJACENT DUPLICATES FROM lr_posnr.
*only for read*
  lt_zfplt_read = lt_zfplt_new.
  SORT lt_zfplt_read BY fareg.
  CLEAR lv_fakwr.
  LOOP AT t_exceldata INTO ls_fplt.
    ls_fplt1 = ls_fplt.
    AT END OF fplnr.
      CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
        EXPORTING
          input  = ls_fplt1-fplnr
        IMPORTING
          output = ls_fplt1-fplnr
        EXCEPTIONS
          OTHERS = 1.
      IF sy-subrc = 0.
        ls_netwr_new-fplnr = ls_fplt1-fplnr.
      ENDIF.
      IF ls_fplt1-fkarv NOT IN r_fkarv.
        ls_netwr_new-netwr = lv_fakwr + ls_fplt1-fakwr_upld.
      ELSE.
        ls_netwr_new-netwr = lv_fakwr.
      ENDIF.
      APPEND ls_netwr_new TO lt_netwr_new.

      ls_netval-posnr = ls_fplt1-posnr.
      ls_netval-netwr = ls_netwr_new-netwr.
      APPEND ls_netval TO lt_netval.
      CLEAR: ls_netval, ls_netwr_new.

      CLEAR lv_fakwr.
      lv_flag = abap_true.
    ENDAT.
    IF lv_flag = abap_true.
      CLEAR lv_flag.
    ELSE.
      IF ls_fplt-fkarv NOT IN r_fkarv.
        lv_fakwr = lv_fakwr + ls_fplt-fakwr_upld.
      ENDIF.
    ENDIF.
  ENDLOOP.

  SORT lt_zfplt_read BY fplnr updkz.

  LOOP AT lt_zfplt_new ASSIGNING <zfplt>.

    CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
      EXPORTING
        input  = <zfplt>-fplnr
      IMPORTING
        output = lv_fplnr
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc = 0.
*    12-06-2013
      READ TABLE t_fplt ASSIGNING <fplt> WITH KEY fplnr = lv_fplnr
                                              fpltr = <zfplt>-fpltr
                                              BINARY SEARCH.

      IF sy-subrc IS INITIAL AND <fplt>-status <> ‘Reached’.
        IF <zfplt>-fkarv = ‘ZF’ AND <zfplt>-fareg = ‘3’.
          READ TABLE lt_zfplt_read WITH KEY fplnr = <zfplt>-fplnr
                                           updkz = ‘U’
                                           BINARY SEARCH
                                           TRANSPORTING NO FIELDS.
          IF sy-subrc IS INITIAL.
            READ TABLE t_netwr INTO ls_netwr WITH KEY fplnr = <zfplt>-fplnr BINARY SEARCH.
            IF sy-subrc IS INITIAL.
              READ TABLE lt_netwr_new INTO ls_netwr_new WITH KEY fplnr = <zfplt>-fplnr BINARY SEARCH.
              <zfplt>-fakwr = <zfplt>-fakwr + ( ls_netwr-netwr – ls_netwr_new-netwr ).
              <zfplt>-updkz = ‘U’.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.

  SORT lt_netval BY posnr.
  SORT lt_zfplt_read BY updkz.
  READ TABLE lt_zfplt_read  WITH KEY updkz = ‘U’ BINARY SEARCH TRANSPORTING NO FIELDS.
  IF sy-subrc IS NOT INITIAL.
    EXIT.
  ENDIF.
***********addition for pricing condition value change**********

  SELECT low FROM XXXX INTO TABLE lt_kschl
    WHERE objnr = sy-repid
      AND name = ‘KSCHL’
      AND type = ‘P’
      AND numb = ‘0001’.
  IF sy-subrc IS INITIAL.

    LOOP AT lt_kschl INTO ls_kschl.
      CLEAR ls_r_kschl.
      ls_r_kschl-sign = ‘I’.
      ls_r_kschl-option = ‘EQ’.
      ls_r_kschl-low = ls_kschl-kschl.
      APPEND ls_r_kschl TO r_kschl.
    ENDLOOP.

  ENDIF.

  lt_fplt_bapi = t_zfpla.
  SORT lt_fplt_bapi BY vbeln.
  DELETE ADJACENT DUPLICATES FROM lt_fplt_bapi COMPARING vbeln.
  IF v_vbtyp = ‘G’.
    CLEAR ls_fplt_bapi.
    ls_fplt_bapi-vbeln = p_vbeln.
    APPEND ls_fplt_bapi TO lt_fplt_bapi.
    SORT lt_fplt_bapi BY vbeln.
  ELSEIF v_vbtyp = ‘C’.
    CLEAR ls_fplt_bapi.
    ls_fplt_bapi-vbeln = v_vgbel.
    APPEND ls_fplt_bapi TO lt_fplt_bapi.
    SORT lt_fplt_bapi BY vbeln.
  ENDIF.
  SELECT vbeln
         vkorg
         vtweg
         spart
         knumv
    FROM vbak
    INTO TABLE lt_bapi_so
    FOR ALL ENTRIES IN lt_fplt_bapi
      WHERE vbeln = lt_fplt_bapi-vbeln.

  lt_bapi_so_tmp = lt_bapi_so.
  SORT lt_bapi_so_tmp BY knumv.
  DELETE ADJACENT DUPLICATES FROM lt_bapi_so_tmp COMPARING knumv.
  SELECT knumv
         kposn
         stunr
         zaehk
         kappl
         kschl
         kbetr
         waers
         kpein
         knumh
         kunnr
    FROM konv
    INTO TABLE t_konv
    FOR ALL ENTRIES IN lt_bapi_so_tmp
    WHERE knumv = lt_bapi_so_tmp-knumv
      AND kappl = ‘V’
      AND kschl IN r_kschl
      AND kinak = ‘ ‘.
  IF sy-subrc IS INITIAL.
    CLEAR lt_bapi_so_tmp.
    SORT t_konv BY knumv kposn stunr zaehk DESCENDING.

    READ TABLE lt_bapi_so INTO ls_bapi_so WITH KEY vbeln = p_vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      lv_vkorg = ls_bapi_so-vkorg.
      lv_vtweg = ls_bapi_so-vtweg.
      lv_spart = ls_bapi_so-spart.
      v_knumv  = ls_bapi_so-knumv.
      lt_bapi_so_tmp = lt_bapi_so.
      IF v_vbtyp = ‘G’.
        DELETE lt_bapi_so WHERE vbeln = p_vbeln.
      ENDIF.
      CLEAR ls_bapi_so.
    ENDIF.

    SORT lt_netval BY posnr.
    LOOP AT r_kschl INTO ls_r_kschl.
      LOOP AT t_vbeln INTO ls_vbeln_tmp.
        ls_vbeln = ls_vbeln_tmp.
        IF v_vbtyp = ‘G’.
*          AT END OF vbeln.
          READ TABLE t_konv INTO ls_konv WITH KEY knumv = v_knumv
                                                  kposn = ls_vbeln-posnr
                                                  BINARY SEARCH.
          IF sy-subrc IS INITIAL.
            ls_cond-itm_number = ls_vbeln-posnr.
            ls_cond-cond_st_no = ls_konv-stunr.
            ls_cond-cond_count = ls_konv-zaehk.
            ls_cond-cond_type = ls_r_kschl-low.
            READ TABLE lt_netval INTO ls_netval WITH KEY posnr = ls_vbeln-posnr BINARY SEARCH.
            IF sy-subrc = 0.
              ls_cond-cond_value = ls_netval-netwr.
            ELSE.
              ls_cond-cond_value = ls_konv-kbetr.
            ENDIF.
            ls_cond-currency = ls_konv-waers.
            ls_cond-cond_p_unt = ls_konv-kpein.
            ls_cond-applicatio = ‘V’.
            APPEND ls_cond TO lt_cond.

            ls_cond_inx-itm_number = ls_vbeln-posnr.
            ls_cond_inx-cond_st_no = ls_konv-stunr.
            ls_cond_inx-cond_count = ls_konv-zaehk.
            ls_cond_inx-cond_type = ls_r_kschl-low.
            ls_cond_inx-updateflag = ‘U’.
            ls_cond_inx-cond_value = ‘X’.
            APPEND ls_cond_inx TO lt_cond_inx.
            CLEAR: ls_cond_inx, ls_netval.
          ENDIF.

*        condition record for SO
          IF lt_bapi_so IS NOT INITIAL.
            READ TABLE t_vbfa INTO ls_vbfa WITH KEY vbeln =  ls_vbeln-vbeln
                                                    posnv = ls_vbeln-posnr.
            IF sy-subrc = 0.
              READ TABLE lt_bapi_so INTO ls_bapi_so WITH KEY vbeln = ls_vbfa-vbeln BINARY SEARCH.
              IF sy-subrc = 0.
                READ TABLE t_konv INTO ls_konv WITH KEY kposn = ls_vbfa-posnn
                                                        knumv = ls_bapi_so-knumv
                                                        BINARY SEARCH.
                IF sy-subrc = 0.
                  ls_cond-itm_number = ls_konv-kposn.
                  ls_cond-cond_st_no = ls_konv-stunr.
                  ls_cond-cond_count = ls_konv-zaehk.
                  ls_cond-cond_type = ls_r_kschl-low.
                  READ TABLE lt_netval INTO ls_netval WITH KEY posnr = ls_vbeln-posnr BINARY SEARCH.
                  IF sy-subrc = 0.
                    ls_cond-cond_value = ls_netval-netwr.
                  ELSE.
                    ls_cond-cond_value = ls_konv-kbetr.
                  ENDIF.
                  ls_cond-currency = ls_konv-waers.
                  ls_cond-cond_p_unt = ls_konv-kpein.
                  ls_cond-applicatio = ‘V’.
                  APPEND ls_cond TO lt_cond_so.

                  ls_cond_inx-itm_number = ls_konv-kposn.
                  ls_cond_inx-cond_st_no = ls_konv-stunr.
                  ls_cond_inx-cond_count = ls_konv-zaehk.
                  ls_cond_inx-cond_type = ls_r_kschl-low.
                  ls_cond_inx-updateflag = ‘U’.
                  ls_cond_inx-cond_value = ‘X’.
                  APPEND ls_cond_inx TO lt_cond_inx_so.

*                 bapi to update SO condition records
                  ls_hdr_so-sales_org = ls_bapi_so-vkorg.
                  ls_hdr_so-distr_chan = ls_bapi_so-vtweg.
                  ls_hdr_so-division = ls_bapi_so-spart.

                  ls_hdr_inx_so-updateflag = ‘U’.
                  CALL FUNCTION ‘BAPI_SALESORDER_CHANGE’
                    EXPORTING
                      salesdocument    = ls_bapi_so-vbeln
                      order_header_in  = ls_hdr_so
                      order_header_inx = ls_hdr_inx_so
                    TABLES
                      return           = lt_bapiret2
                      conditions_in    = lt_cond_so
                      conditions_inx   = lt_cond_inx_so
                    EXCEPTIONS
                      OTHERS           = 1.
                  IF sy-subrc = 0.
                    LOOP AT lt_bapiret2 INTO ls_bapiret2.
                      IF ls_bapiret2-type = ‘E’ OR ls_bapiret2-type = ‘A’.
                        ls_alv-lights = ‘@0A@’. “red
                        ls_alv-text = ls_bapiret2-message.
                        APPEND ls_alv TO t_alv.
                        CLEAR ls_alv.
                      ENDIF.
                    ENDLOOP.
                  ELSE.
                    ls_alv-lights = ‘@0A@’. “red
                    MESSAGE i897(cj) WITH ‘BAPI_SALESORDER_CHANGE’ ls_bapi_so-vbeln sy-subrc INTO ls_alv-text.
                    APPEND ls_alv TO t_alv.
                    CLEAR  ls_alv.
                  ENDIF.
                  CLEAR: ls_cond_inx, ls_netval,ls_cond, ls_vbfa.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.
*          ENDAT.
        ELSE.” for vbtyp = ‘C’–>order
          READ TABLE t_konv INTO ls_konv WITH KEY knumv = v_knumv
                                                  kposn = ls_vbeln-posnr
                                                  BINARY SEARCH.
          IF sy-subrc IS INITIAL.
            ls_cond-itm_number = ls_vbeln-posnr.
            ls_cond-cond_st_no = ls_konv-stunr.
            ls_cond-cond_count = ls_konv-zaehk.
            ls_cond-cond_type = ls_r_kschl-low.

            READ TABLE lt_netval INTO ls_netval WITH KEY posnr = ls_vbeln-posnr BINARY SEARCH.
            IF sy-subrc = 0.
              ls_cond-cond_value = ls_netval-netwr.
            ELSE.
              ls_cond-cond_value = ls_konv-kbetr.
            ENDIF.
            ls_cond-currency = ls_konv-waers.
            ls_cond-cond_p_unt = ls_konv-kpein.
            ls_cond-applicatio = ‘V’.
            APPEND ls_cond TO lt_cond_so.

            ls_cond_inx-itm_number = ls_vbeln-posnr.
            ls_cond_inx-cond_st_no = ls_konv-stunr.
            ls_cond_inx-cond_count = ls_konv-zaehk.
            ls_cond_inx-cond_type = ls_r_kschl-low.
            ls_cond_inx-updateflag = ‘U’.
            ls_cond_inx-cond_value = ‘X’.
            APPEND ls_cond_inx TO lt_cond_inx_so.
            CLEAR: ls_cond_inx, ls_netval,ls_cond.
          ENDIF.

*        condition record for Contract
          IF lt_bapi_so IS NOT INITIAL.
            READ TABLE t_vbfa INTO ls_vbfa WITH KEY vbeln = p_vbeln
                                                    posnn = ls_vbeln-posnr.
            IF sy-subrc = 0.
              READ TABLE lt_bapi_so INTO ls_bapi_so WITH KEY vbeln = ls_vbfa-vbelv BINARY SEARCH.
              IF sy-subrc = 0.
                READ TABLE t_konv INTO ls_konv WITH KEY kposn = ls_vbfa-posnv
                                                        knumv = ls_bapi_so-knumv
                                                        BINARY SEARCH.
                IF sy-subrc = 0.
                  IF sy-subrc = 0.
                    ls_cond-itm_number = ls_vbfa-posnv.
                  ENDIF.
                  ls_cond-cond_st_no = ls_konv-stunr.
                  ls_cond-cond_count = ls_konv-zaehk.
                  ls_cond-cond_type = ls_r_kschl-low.
                  READ TABLE lt_netval INTO ls_netval WITH KEY posnr = ls_vbeln-posnr BINARY SEARCH.
                  IF sy-subrc = 0.
                    ls_cond-cond_value = ls_netval-netwr.
                  ELSE.
                    ls_cond-cond_value = ls_konv-kbetr.
                  ENDIF.
                  ls_cond-currency = ls_konv-waers.
                  ls_cond-cond_p_unt = ls_konv-kpein.
                  ls_cond-applicatio = ‘V’.
                  APPEND ls_cond TO lt_cond.

                  ls_cond_inx-itm_number = ls_vbfa-posnv.
                  ls_cond_inx-cond_st_no = ls_konv-stunr.
                  ls_cond_inx-cond_count = ls_konv-zaehk.
                  ls_cond_inx-cond_type = ls_r_kschl-low.
                  ls_cond_inx-updateflag = ‘U’.
                  ls_cond_inx-cond_value = ‘X’.
                  APPEND ls_cond_inx TO lt_cond_inx.
                  CLEAR: ls_cond_inx, ls_netval,ls_cond.
                ENDIF.
              ENDIF.
            ENDIF.
          ENDIF.

        ENDIF.
      ENDLOOP.
    ENDLOOP.

    DELETE lt_bapi_so WHERE vbeln = v_vgbel.
    IF v_vbtyp = ‘C’.
      LOOP AT lt_bapi_so INTO ls_bapi_so.
        ls_hdr_so-sales_org = ls_bapi_so-vkorg.
        ls_hdr_so-distr_chan = ls_bapi_so-vtweg.
        ls_hdr_so-division = ls_bapi_so-spart.

        ls_hdr_inx_so-updateflag = ‘U’.
        CALL FUNCTION ‘BAPI_SALESORDER_CHANGE’
          EXPORTING
            salesdocument    = ls_bapi_so-vbeln
            order_header_in  = ls_hdr_so
            order_header_inx = ls_hdr_inx_so
          TABLES
            return           = lt_bapiret2
            conditions_in    = lt_cond_so
            conditions_inx   = lt_cond_inx_so
          EXCEPTIONS
            OTHERS           = 1.
        IF sy-subrc = 0.
          LOOP AT lt_bapiret2 INTO ls_bapiret2.
            IF ls_bapiret2-type = ‘E’ OR ls_bapiret2-type = ‘A’.
              ls_alv-lights = ‘@0A@’. “red
              ls_alv-text = ls_bapiret2-message.
              APPEND ls_alv TO t_alv.
              CLEAR ls_alv.
            ENDIF.
          ENDLOOP.
        ELSE.
          ls_alv-lights = ‘@0A@’. “red
          MESSAGE i897(cj) WITH ‘BAPI_SALESORDER_CHANGE’ ls_bapi_so-vbeln sy-subrc INTO ls_alv-text.
          APPEND ls_alv TO t_alv.
          CLEAR  ls_alv.
        ENDIF.

      ENDLOOP.
    ENDIF.

    IF v_vbtyp = ‘G’.
      ls_hdr-sales_org = lv_vkorg.
      ls_hdr-distr_chan = lv_vtweg.
      ls_hdr-division = lv_spart.

      ls_hdr_inx-updateflag = ‘U’.
      CALL FUNCTION ‘SD_SALESDOCUMENT_CHANGE’
        EXPORTING
          salesdocument    = p_vbeln
          order_header_in  = ls_hdr
          order_header_inx = ls_hdr_inx
        TABLES
          return           = lt_bapiret2
          conditions_in    = lt_cond
          conditions_inx   = lt_cond_inx
        EXCEPTIONS
          OTHERS           = 1.

      IF sy-subrc = 0.
        LOOP AT lt_bapiret2 INTO ls_bapiret2.
          IF ls_bapiret2-type = ‘E’ OR ls_bapiret2-type = ‘A’.
            ls_alv-lights = ‘@0A@’. “red
            ls_alv-text = ls_bapiret2-message.
            APPEND ls_alv TO t_alv.
            CLEAR ls_alv.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ELSEIF v_vbtyp = ‘C’ AND v_vgbel IS NOT INITIAL.
      ls_hdr-sales_org = lv_vkorg.
      ls_hdr-distr_chan = lv_vtweg.
      ls_hdr-division = lv_spart.

      ls_hdr_inx-updateflag = ‘U’.
      CALL FUNCTION ‘SD_SALESDOCUMENT_CHANGE’
        EXPORTING
          salesdocument    = v_vgbel
          order_header_in  = ls_hdr
          order_header_inx = ls_hdr_inx
        TABLES
          return           = lt_bapiret2
          conditions_in    = lt_cond
          conditions_inx   = lt_cond_inx
        EXCEPTIONS
          OTHERS           = 1.

      IF sy-subrc = 0.
        LOOP AT lt_bapiret2 INTO ls_bapiret2.
          IF ls_bapiret2-type = ‘E’ OR ls_bapiret2-type = ‘A’.
            ls_alv-lights = ‘@0A@’. “red
            ls_alv-text = ls_bapiret2-message.
            APPEND ls_alv TO t_alv.
            CLEAR ls_alv.
          ENDIF.
        ENDLOOP.
      ELSE.
        ls_alv-lights = ‘@0A@’. “red
        MESSAGE i897(cj) WITH ‘BAPI_SALESORDER_CHANGE’ ls_bapi_so-vbeln sy-subrc INTO ls_alv-text.
        APPEND ls_alv TO t_alv.
        CLEAR  ls_alv.
      ENDIF.
    ENDIF.
  ENDIF.

*& Verify the updated data in database for Billing plan date and amount.
  lt_zfplt_tmp[] = lt_zfplt_new[].
  DELETE lt_zfplt_tmp[] WHERE updkz <>‘U’.
  IF lt_zfplt_tmp[] IS NOT INITIAL.
    SELECT fplnr
            fpltr
            fpttp
            tetxt
            fakwr
            mlstn
            afdat
           FROM fplt
           INTO CORRESPONDING FIELDS OF TABLE lt_zfplt_tmp1
           FOR ALL ENTRIES IN lt_zfplt_tmp
              WHERE fplnr = lt_zfplt_tmp-fplnr
                AND fpltr = lt_zfplt_tmp-fpltr.
    IF sy-subrc IS INITIAL.
      LOOP AT lt_zfplt_tmp INTO ls_zfplt_tmp.
        READ TABLE lt_zfplt_new INTO ls_zfplt_new
                                WITH KEY fplnr = ls_zfplt_tmp-fplnr
                                         fpltr = ls_zfplt_tmp-fpltr
                                         BINARY SEARCH.
        IF sy-subrc IS INITIAL.

*         popup for status display
          IF ls_zfplt_tmp-fakwr <> ls_zfplt_new-fakwr OR ls_zfplt_tmp-afdat <> ls_zfplt_new-afdat.
*              error message
            CLEAR ls_alv.
            ls_alv-lights = ‘@0A@’. “red
            CONCATENATE ‘Updation not possible for item’(006)
                        ls_zfplt_tmp-fpltr‘ of Billing plan’(007)
                        ls_zfplt_tmp-fplnr INTO  lv_tdline
                        SEPARATED BY space.
            ls_alv-text = lv_tdline.
            APPEND ls_alv TO t_alv.

          ELSE.
            CLEAR ls_alv.
            ls_alv-lights = ‘@08@’. “green
            CONCATENATE ‘Data updated successfully for item’(008)
                        ls_zfplt_tmp-fpltr‘ of Billing plan’(007)
                        ls_zfplt_tmp-fplnr INTO  lv_tdline
                        SEPARATED BY space.
            ls_alv-text = lv_tdline.
            APPEND ls_alv TO t_alv.
          ENDIF.
          CLEAR lv_tdline.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDIF.

*BDC for VK11 or VK 12 to craete condition records material wise
  SORT t_alv.
  CLEAR : ls_alv.
  READ TABLE t_alv INTO ls_alv WITH KEY lights = ‘@0A@’.
  IF sy-subrc NE 0.
    CALL FUNCTION XXXXXXXXXXXXXXXXXX

      EXPORTING
        objnr      = lk_objnr
      TABLES
        all_values = lt_tab
      EXCEPTIONS
        OTHERS     = 1.

    IF sy-subrc = 0.
      SORT lt_tab BY  objnr
                      name
                      type
                      numb.
      READ TABLE lt_tab INTO ls_tab WITH KEY objnr = lk_objnr
                                            name  = lk_kschl
                                            type  = lk_seltyp
                                            numb  = ‘0002’
                                            BINARY SEARCH.
      IF sy-subrc = 0.
        v_zref = ls_tab-low.
        REFRESH t_bdcdata.
        IF v_vbtyp = ‘C’.
          SORT lt_vbap BY matnr.
          SELECT matnr
                 knumh
            FROM a909
            INTO TABLE lt_knumh
            WHERE kappl = ‘V’
              AND kschl = v_zref
              AND aubel = p_vbeln
              AND matnr IN lr_matnr
              AND datbi GE sy-datum
              AND datab LE sy-datum.
          IF sy-subrc = 0.
            SORT lt_knumh BY matnr.
*   update condition record – transaction VK12

            LOOP AT lr_posnr INTO ls_posnr.
              READ TABLE lt_vbap INTO ls_vbap WITH KEY posnr = ls_posnr-low BINARY SEARCH.

              IF sy-subrc = 0.
                READ TABLE lt_knumh INTO ls_knumh WITH KEY matnr = ls_vbap-matnr BINARY SEARCH.
                IF sy-subrc = 0.
                  READ TABLE lt_netval INTO ls_netval WITH KEY posnr = ls_vbap-posnr BINARY SEARCH.
                  IF sy-subrc = 0.

                    PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’     ‘0100’.
                    PERFORM f000_bdc_field       USING ‘RV13A-KSCHL’  v_zref.
                    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’   ‘/00’.

                    PERFORM f000_bdc_dynpro      USING ‘SAPLV14A’     ‘0100’.
                    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’   ‘=WEIT’.

                    PERFORM f000_bdc_dynpro      USING ‘RV13A909’     ‘1000’.
                    PERFORM f000_bdc_field       USING ‘F001’         p_vbeln.
                    PERFORM f000_bdc_field       USING ‘F002-LOW’     ls_vbap-matnr.
                    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’   ‘=ONLI’.

                    PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’         ‘1909’.
                    PERFORM f000_bdc_field       USING ‘KONP-KBETR(01)’   ls_netval-netwr.
                    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’       ‘/00’.

                    PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’ ‘1909’.
                    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’  ‘=SICH’.

                    CALL TRANSACTION ‘VK12’
                      USING t_bdcdata
                      OPTIONS FROM ls_options
                      MESSAGES INTO t_message_tab.
                    PERFORM f000_trap_bdc_err.
                  ENDIF.
                ELSE.
                  CLEAR ls_matnr.
                  ls_matnr-option = ‘EQ’.
                  ls_matnr-sign = ‘I’.
                  ls_matnr-low = ls_vbap-matnr.
                  APPEND ls_matnr TO lr_matnr1.
                  CLEAR ls_matnr.
*   create condition record – transaction VK11
                  PERFORM f000_bdc_recording_vk11 USING lr_matnr1
                                                    p_vbeln
                                                    lt_netval
                                                    lt_vbap.
                ENDIF.
              ELSE.

*   create condition record – transaction VK11
                PERFORM f000_bdc_recording_vk11 USING lr_matnr
                                                  p_vbeln
                                                  lt_netval
                                                  lt_vbap.
              ENDIF.
            ENDLOOP.
          ELSE.
*   create condition record – transaction VK11
            PERFORM f000_bdc_recording_vk11 USING lr_matnr
                                                 p_vbeln
                                              lt_netval
                                                  lt_vbap.

          ENDIF.
        ELSE. ” for contract
          SELECT matnr
                 knumh
            FROM a909
            INTO TABLE lt_knumh
            FOR ALL ENTRIES IN lt_bapi_so
            WHERE kappl = ‘V’
              AND kschl = v_zref
              AND aubel = lt_bapi_so-vbeln
              AND matnr IN lr_matnr
              AND datbi GE sy-datum
              AND datab LE sy-datum.
          IF sy-subrc = 0.
            SORT lt_knumh BY matnr.
*   update condition record – transaction VK12

            LOOP AT lr_posnr INTO ls_posnr.
              READ TABLE lt_vbap INTO ls_vbap WITH KEY posnr = ls_posnr-low BINARY SEARCH.

              IF sy-subrc = 0.
                READ TABLE lt_knumh INTO ls_knumh WITH KEY matnr = ls_vbap-matnr BINARY SEARCH.
                IF sy-subrc = 0.
                  READ TABLE t_vbeln INTO ls_vbeln WITH KEY posnr = ls_posnr-low.
                  IF sy-subrc = 0.
                    READ TABLE t_vbfa INTO ls_vbfa WITH KEY vbelv = p_vbeln
                                                            posnv = ls_posnr-low
                                                            vbeln = ls_vbeln-vbeln.
                    IF sy-subrc = 0.
                      READ TABLE lt_netval INTO ls_netval WITH KEY posnr = ls_vbap-posnr BINARY SEARCH.
                      IF sy-subrc = 0.
                        REFRESH t_bdcdata.
                        PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’ ‘0100’.
                        PERFORM f000_bdc_field       USING ‘RV13A-KSCHL’  v_zref.
                        PERFORM f000_bdc_field       USING ‘BDC_OKCODE’
                                                      ‘/00’.

                        PERFORM f000_bdc_dynpro      USING ‘SAPLV14A’ ‘0100’.
                        PERFORM f000_bdc_field       USING ‘BDC_OKCODE’   ‘=WEIT’.

                        PERFORM f000_bdc_dynpro      USING ‘RV13A909’ ‘1000’.
                        PERFORM f000_bdc_field       USING ‘F001’   ls_vbeln-vbeln.
                        PERFORM f000_bdc_field       USING ‘F002-LOW’   ls_vbap-matnr.
                        PERFORM f000_bdc_field       USING ‘BDC_OKCODE’    ‘=ONLI’.

                        PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’ ‘1909’.
                        PERFORM f000_bdc_field       USING ‘KONP-KBETR(01)’   ls_netval-netwr.
                        PERFORM f000_bdc_field       USING ‘BDC_OKCODE’
                                                      ‘/00’.

                        PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’ ‘1909’.
                        PERFORM f000_bdc_field       USING ‘BDC_OKCODE’  ‘=SICH’.

                        CALL TRANSACTION ‘VK12’
                          USING t_bdcdata
                          OPTIONS FROM ls_options
                          MESSAGES INTO t_message_tab.
                        PERFORM f000_trap_bdc_err.
                      ENDIF.
                    ENDIF.
                  ENDIF.
                ELSE.
                  CLEAR ls_matnr.
                  ls_matnr-option = ‘EQ’.
                  ls_matnr-sign = ‘I’.
                  ls_matnr-low = ls_vbap-matnr.
                  APPEND ls_matnr TO lr_matnr1.
                  CLEAR ls_matnr.
                  READ TABLE t_vbeln INTO ls_vbeln WITH KEY posnr = ls_posnr-low.
                  IF sy-subrc = 0.
*   create condition record – transaction VK11
                    PERFORM f000_bdc_recording_vk11 USING lr_matnr1
                                                      ls_vbeln-vbeln
                                                      lt_netval
                                                      lt_vbap.
                  ENDIF.
                ENDIF.
              ELSE.

*   create condition record – transaction VK11
                READ TABLE t_vbfa INTO ls_vbfa WITH KEY vbelv = p_vbeln
                                                        posnv = ls_posnr-low.
                IF sy-subrc = 0.
                  PERFORM f000_bdc_recording_vk11 USING lr_matnr
                                                    ls_vbfa-vbeln
                                                    lt_netval
                                                    lt_vbap.
                ENDIF.
              ENDIF.
              wait up to 3 seconds.
            ENDLOOP.
          ELSE.
*   create condition record – transaction VK11
            READ TABLE t_vbfa INTO ls_vbfa WITH KEY vbelv = p_vbeln
                                                                  posnv = ls_posnr-low.
            IF sy-subrc = 0.
              PERFORM f000_bdc_recording_vk11 USING lr_matnr
                                                    ls_vbfa-vbeln
                                                lt_netval
                                                    lt_vbap.

            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      COMMIT WORK AND WAIT.
    ENDIF.
  ENDIF.

  SORT t_alv.
  CLEAR : ls_alv.
  READ TABLE t_alv INTO ls_alv WITH KEY lights = ‘@0A@’.
  IF sy-subrc NE 0.
    CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
      EXPORTING
        wait   = ‘X’
      IMPORTING
        return = ls_bapiret2
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc = 0.
*    do nothing
    ENDIF.

*&– Update Billing Plan only if Sales document is saved successfully.
*Calling Bapi for changing billing plan date and amount
    CALL FUNCTION ‘BILLING_SCHEDULE_SAVE’
      TABLES
        fpla_new = t_zfpla
        fpla_old = t_zfpla
        fplt_new = lt_zfplt_new
        fplt_old = t_zfplt
      EXCEPTIONS
        OTHERS   = 1.
    IF sy-subrc <> 0.
      CLEAR  ls_alv.
      ls_alv-lights = ‘@0A@’. “red
      MESSAGE i897(cj) WITH ‘BILLING_SCHEDULE_SAVE’ lv_fplnr sy-subrc INTO ls_alv-text.
      APPEND ls_alv TO t_alv.
      CLEAR  ls_alv.
    ENDIF.
  ENDIF.
  t_zfplt[] = lt_zfplt_new[].
  MOVE t_exceldata[]  TO t_fplt_init.
* Subroutine for pop up display with messages
  PERFORM f000_popup_display.
ENDFORM.                    ” F200_SAVE_DATA
*&———————————————————————*
*&      Form  F200_BDC_RECORDING
*&———————————————————————*
*       Subroutine for DBC of VA02 and VA42
*———————————————————————-*
*  –>  lv_tcode        Transaction code
*———————————————————————-*
FORM f300_bdc_recording  USING lv_tcode   TYPE sy-tcode.

  DATA:ls_options TYPE ctu_params,
        ls_notes TYPE bal_s_msg.

  ls_options-dismode = ‘N’.
  ls_options-updmode = ‘A’.
  ls_options-defsize = ‘X’.

  IF lv_tcode =  ‘VA02’.
    PERFORM f000_bdc_dynpro      USING ‘SAPMV45A’ ‘0102’.
    PERFORM f000_bdc_field       USING ‘BDC_CURSOR’
                                  ‘VBAK-VBELN’.
    PERFORM f000_bdc_field       USING ‘VBAK-VBELN’
                                  p_vbeln. “’30’.
    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’
                                  ‘/00’.
    PERFORM f000_bdc_dynpro      USING ‘SAPMV45A’ ‘4001’.
    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’
                                  ‘/EBAC1’.

    CALL TRANSACTION ‘VA02’
      USING t_bdcdata
      OPTIONS FROM ls_options
      MESSAGES INTO t_message_tab.

  ELSEIF lv_tcode = ‘VA42’.

    PERFORM f000_bdc_dynpro      USING ‘SAPMV45A’ ‘0102’.
    PERFORM f000_bdc_field       USING ‘BDC_CURSOR’
                                  ‘VBAK-VBELN’.

    PERFORM f000_bdc_field       USING ‘VBAK-VBELN’
                                  p_vbeln.
    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’
                                  ‘/00’.
    PERFORM f000_bdc_dynpro      USING ‘SAPMV45A’ ‘4001’.
    PERFORM f000_bdc_field       USING ‘BDC_OKCODE’
                              ‘/EBAC1’.
    CALL TRANSACTION ‘VA42’
        USING t_bdcdata
      OPTIONS FROM ls_options
*        MODE ‘N’
        MESSAGES INTO t_message_tab.
  ENDIF.

  LOOP AT t_message_tab WHERE msgtyp = ‘E’.
    ls_notes-msgty = ‘E’.
    ls_notes-msgid = sy-msgid.
    ls_notes-msgno = sy-msgno.
    ls_notes-msgv1 = sy-msgv1.
    ls_notes-msgv2 = sy-msgv2.
    ls_notes-msgv3 = sy-msgv3.
    ls_notes-msgv4 = sy-msgv4.

    CALL FUNCTION ‘BAL_MSG_DISPLAY_ABAP’
      EXPORTING
        i_s_msg = ls_notes
      EXCEPTIONS
        OTHERS  = 1.
    IF sy-subrc = 0.
      CLEAR ls_notes.
    ENDIF.
  ENDLOOP.
ENDFORM.                    ” F200_BDC_RECORDING
*———————————————————————-*
*        Start new screen                                              *
*———————————————————————-*
FORM f000_bdc_dynpro USING program dynpro.
  CLEAR t_bdcdata.
  t_bdcdata-program  = program.
  t_bdcdata-dynpro   = dynpro.
  t_bdcdata-dynbegin = ‘X’.
  APPEND t_bdcdata.
ENDFORM.                    “bdc_dynpro

*———————————————————————-*
*        Insert field                                                  *
*———————————————————————-*
FORM f000_bdc_field USING fnam fval.
  CLEAR t_bdcdata.
  t_bdcdata-fnam = fnam.
  WRITE fval TO t_bdcdata-fval LEFT-JUSTIFIED.
  APPEND t_bdcdata.
ENDFORM.                    “bdc_field
*&———————————————————————*
*&      Form  F200_SALES_DOCUMENT_STATUS
*&———————————————————————*
*       Subroutine to check authorozation and document status
*———————————————————————-*
*  –>  fuv_vbtyp        Document Category
*———————————————————————-*
FORM f200_sales_document_status USING fuv_vbtyp TYPE vbtyp.
  DATA: lv_tcode TYPE sy-tcode.

  IF fuv_vbtyp = ‘C’.
    lv_tcode = ‘VA02’.
  ELSEIF fuv_vbtyp = ‘G’.
    lv_tcode = ‘VA42’.
  ENDIF.

*   bdc to check all authorizations for the transaction
  PERFORM f300_bdc_recording USING lv_tcode.
  CALL FUNCTION ‘ENQUEUE_EVVBAKE’
    EXPORTING
      mode_vbak      = ‘E’
      mandt          = sy-mandt
      vbeln          = p_vbeln
    EXCEPTIONS
      foreign_lock   = 1
      system_failure = 2
      OTHERS         = 3.
  IF sy-subrc <> 0.
* Implement suitable error handling here
    IF sy-subrc = 1.
      MESSAGE e601(mc) WITH .
      EXIT.
    ENDIF.
  ENDIF.

ENDFORM.                    ” F200_SALES_DOCUMENT_STATUS
*&———————————————————————*
*&      Form  F200_SALES_DOCUMENT_DATA
*&———————————————————————*
*       Subroutine to extract relevent data to be diplaye din excel
*———————————————————————-*
*      –>fuv_vbtyp  Document Category
*      <–fct_fplt   Billing plan internal table
*———————————————————————-*
FORM f200_sales_document_data  USING    fuv_vbtyp  TYPE vbtyp.
  TYPES: BEGIN OF l_ty_vbeln,
          vbeln TYPE vbeln_va,
         END OF l_ty_vbeln.
  DATA: lt_vbeln TYPE STANDARD TABLE OF l_ty_vbeln,
        ls_vbeln1 TYPE l_ty_vbeln,
        lt_fpla TYPE STANDARD TABLE OF ty_fpla,
        lr_vbeln    TYPE RANGE OF vbeln,    “dummy
        lr_fplnr    TYPE RANGE OF fplnr,    “dummy.
        ls_vbeln    LIKE LINE OF lr_vbeln.

  IF fuv_vbtyp = ‘C’.
**    added for point 16 of test excel
    SELECT SINGLE vgbel FROM vbak INTO v_vgbel WHERE vbeln = p_vbeln.
    IF sy-subrc = 0.
      IF v_vgbel IS NOT INITIAL.

        CALL FUNCTION ‘ENQUEUE_EVVBAKE’
          EXPORTING
            mode_vbak      = ‘E’
            mandt          = sy-mandt
            vbeln          = v_vgbel
          EXCEPTIONS
            foreign_lock   = 1
            system_failure = 2
            OTHERS         = 3.
        IF sy-subrc = 1.
          MESSAGE e601(mc) WITH .
          EXIT.
        ENDIF.
      ENDIF.
    ENDIF.
    SELECT fplnr
           fptyp
           vbeln
           FROM fpla
           INTO TABLE lt_fpla
            WHERE fplnr IN lr_fplnr
              AND vbeln = p_vbeln.
    IF sy-subrc IS INITIAL.
      SORT lt_fpla BY fplnr.
*****
      ls_vbeln-sign = ‘I’.
      ls_vbeln-option = ‘EQ’.
      ls_vbeln-low = p_vbeln.
      APPEND ls_vbeln TO lr_vbeln.

      ls_vbeln-sign = ‘I’.
      ls_vbeln-option = ‘EQ’.
      ls_vbeln-low = v_vgbel.
      APPEND ls_vbeln TO lr_vbeln.

      SELECT   vbeln
               posnr
               matnr
               waerk
          FROM vbap
          INTO TABLE t_vbap
            WHERE vbeln IN lr_vbeln.
      IF sy-subrc IS INITIAL.
        SORT t_vbap BY vbeln posnr.
      ENDIF.
*     data rerieval from VBFA table
      SELECT  vbelv
              posnv
              vbeln
              posnn
              vbtyp_n
        FROM vbfa INTO
        TABLE t_vbfa
          WHERE vbelv IN lr_vbeln
            AND vbeln = p_vbeln.
      IF sy-subrc = 0.
*          do nothing
      ENDIF.
*     Subroutine to get Billing plan detail
      PERFORM f300_billing_plan_data USING   fuv_vbtyp  lt_fpla.
    ENDIF.
  ELSEIF fuv_vbtyp = ‘G’.
    SELECT vbeln
           FROM vbak
           INTO TABLE lt_vbeln
            WHERE vbeln IN lr_vbeln
              AND vgbel = p_vbeln.
    IF sy-subrc IS INITIAL.
      IF lt_vbeln IS NOT INITIAL.
        LOOP AT lt_vbeln  INTO ls_vbeln1.
          CALL FUNCTION ‘ENQUEUE_EVVBAKE’
            EXPORTING
              mode_vbak      = ‘E’
              mandt          = sy-mandt
              vbeln          = ls_vbeln1-vbeln
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.
          IF sy-subrc = 1.
            MESSAGE e601(mc) WITH .
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
      SELECT fplnr
             fptyp
             vbeln
             FROM fpla
             INTO TABLE lt_fpla
             FOR ALL ENTRIES IN lt_vbeln
              WHERE fplnr IN lr_fplnr
                AND vbeln = lt_vbeln-vbeln.
      IF sy-subrc IS INITIAL.
        SORT lt_fpla BY fplnr.
        ls_vbeln1-vbeln = p_vbeln.
        APPEND ls_vbeln1 TO lt_vbeln.
        SELECT vbeln
               posnr
               matnr
               waerk
          FROM vbap
          INTO TABLE t_vbap
          FOR ALL ENTRIES IN lt_vbeln
            WHERE vbeln = lt_vbeln-vbeln.
        IF sy-subrc IS INITIAL.
          SORT t_vbap BY vbeln posnr.
        ENDIF.

*     data rerieval from VBFA table
        SELECT  vbelv
                posnv
                vbeln
                posnn
                vbtyp_n
          FROM vbfa INTO
          TABLE t_vbfa
            WHERE vbelv = p_vbeln.
        IF sy-subrc = 0.
*          do nothing
        ENDIF.
*     Subroutine to get Billing plan detail
        PERFORM f300_billing_plan_data USING   fuv_vbtyp lt_fpla.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    ” F200_SALES_DOCUMENT_DATA
*&———————————————————————*
*&      Form  F300_BILLING_PLAN_DATA
*&———————————————————————*
*     Subroutine to get Billing plan detail
*———————————————————————-*
*      –>fut_fpla  Internal table FPLA
*———————————————————————-*
FORM f300_billing_plan_data  USING  fuv_vbtyp  TYPE vbtyp
                                    fut_fpla  TYPE STANDARD TABLE.
  DATA:   ls_fpla TYPE ty_fpla,
          lt_zfplt TYPE STANDARD TABLE OF fpltvb,
          ls_zfplt TYPE fpltvb,
          ls_fplt TYPE XXXXX,
          lt_fplt TYPE STANDARD TABLE OF XXXXX,
          lt_mltx TYPE STANDARD TABLE OF ty_mltx,
          ls_mltx TYPE ty_mltx,
          lt_vbap TYPE STANDARD TABLE OF ty_vbap,
          ls_vbap TYPE ty_vbap,
          lv_index TYPE sy-tabix,
          lv_index_so TYPE sy-tabix,
          lv_netwr TYPE netwr,
          ls_netwr TYPE ty_netwr,
          lv_fplnr TYPE fplnr,
          lt_fkarv TYPE STANDARD TABLE OF ty_fkarv,
          ls_fkarv TYPE ty_fkarv,
          ls_r_fkarv LIKE LINE OF r_fkarv.

  FIELD-SYMBOLS: <fplt> TYPE XXXXX,
                 <vbap> TYPE ty_vbap.

  SELECT low FROM  XXXXXINTO TABLE lt_fkarv
      WHERE objnr = sy-repid
        AND name = ‘FKARV’.
  IF sy-subrc IS INITIAL.

    LOOP AT lt_fkarv INTO ls_fkarv.
      CLEAR ls_r_fkarv.
      ls_r_fkarv-sign = ‘I’.
      ls_r_fkarv-option = ‘EQ’.
      ls_r_fkarv-low = ls_fkarv-fkarv.
      APPEND ls_r_fkarv TO r_fkarv.
    ENDLOOP.
  ENDIF.
**  logic for order posnr and contract posnr in separate internal tables
  LOOP AT t_vbap ASSIGNING <vbap> WHERE vbeln = p_vbeln.
    ls_vbap-vbeln = <vbap>-vbeln.
    ls_vbap-posnr = <vbap>-posnr.
    ls_vbap-matnr = <vbap>-matnr.
    APPEND ls_vbap TO lt_vbap.
    CLEAR ls_vbap.
  ENDLOOP.
  DELETE t_vbap WHERE vbeln = p_vbeln.

  lv_index = 1.
  lv_index_so = 1.
  LOOP AT fut_fpla INTO ls_fpla.
    CLEAR: lt_zfplt.
    CALL FUNCTION ‘BILLING_SCHEDULE_READ’
      EXPORTING
        fplnr  = ls_fpla-fplnr
      TABLES
        zfpla  = t_zfpla
        zfplt  = lt_zfplt
      EXCEPTIONS
        OTHERS = 1.
    IF sy-subrc = 0.

      LOOP AT lt_zfplt INTO ls_zfplt.
        APPEND ls_zfplt TO t_zfplt.
        ls_fplt-fplnr = ls_zfplt-fplnr.
        ls_fplt-fpltr = ls_zfplt-fpltr.
        ls_fplt-mlst_zaehl = ls_zfplt-mlstn.  “milestone no
        ls_fplt-fakwr = ls_zfplt-fakwr.
        ls_fplt-mlstn = ls_zfplt-mlbez. “usage
        ls_fplt-afdat = ls_zfplt-afdat.
        ls_fplt-waers = ls_zfplt-waers.
        ls_fplt-fkarv = ls_zfplt-fkarv.

        READ TABLE lt_vbap INTO ls_vbap INDEX lv_index.
        IF sy-subrc IS INITIAL.
          IF lv_fplnr IS NOT INITIAL.
            IF lv_fplnr = ls_fpla-fplnr.
              ls_fplt-posnr = ls_vbap-posnr.
            ELSE.
              lv_index = lv_index + 1.
              READ TABLE lt_vbap INTO ls_vbap INDEX lv_index.
              ls_fplt-posnr = ls_vbap-posnr.
              lv_fplnr = ls_fpla-fplnr.
            ENDIF.

          ELSE.
            ls_fplt-posnr = ls_vbap-posnr.
            lv_fplnr = ls_fpla-fplnr.
          ENDIF.
        ENDIF.

        ls_fplt-fakwr_upld = ls_zfplt-fakwr.
        ls_fplt-afdat_upld = ls_zfplt-afdat.
        IF fuv_vbtyp = ‘C’.
          ls_fplt-vbeln = p_vbeln.
          ls_fplt-contract = v_vgbel.
        ELSE.
          ls_fplt-vbeln = ls_fpla-vbeln.
          ls_fplt-contract = p_vbeln.
        ENDIF.
        APPEND ls_fplt TO t_fplt.

        IF ls_zfplt-fkarv NOT IN r_fkarv.
          lv_netwr = lv_netwr + ls_zfplt-fakwr.
        ENDIF.
      ENDLOOP.
    ENDIF.
    ls_netwr-fplnr = ls_fpla-fplnr.
    ls_netwr-netwr = lv_netwr.
    APPEND ls_netwr TO t_netwr.
    CLEAR: ls_netwr, lv_netwr.
*    endif.
  ENDLOOP.

  SORT lt_mltx BY mltx_zaehl.
  SORT lt_fplt BY mlst_zaehl.
  DELETE ADJACENT DUPLICATES FROM lt_fplt COMPARING mlst_zaehl.
  SELECT mltx_zaehl
         ktext
         FROM mltx
         INTO TABLE lt_mltx
         FOR ALL ENTRIES IN lt_fplt
         WHERE mltx_zaehl = lt_fplt-mlst_zaehl.
  IF sy-subrc IS INITIAL.
    LOOP AT t_fplt ASSIGNING <fplt>.
      READ TABLE lt_mltx INTO ls_mltx WITH KEY mltx_zaehl = <fplt>-mlst_zaehl
                                      BINARY SEARCH.
      IF sy-subrc IS INITIAL.
        <fplt>-ktext = ls_mltx-ktext.
      ENDIF.
      IF <fplt>-afdat < sy-datum.
        <fplt>-status = ‘Reached’(010).
      ENDIF.
    ENDLOOP.
  ENDIF.
  SORT t_fplt BY contract vbeln posnr fplnr fpltr afdat.

ENDFORM.                    ” F300_BILLING_PLAN_DATA
*&———————————————————————*
*&      Form  CHECK_T_EXCELDATA
*&———————————————————————*
*       Subroutine to check consistency of modified output excel data
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM f200_check_t_exceldata .
  DATA: ls_exceldata TYPEXXXXX ,
        lv_ln1       TYPE sy-tabix,
        lv_ln2       TYPE sy-tabix,
        ls_fplt      TYPE XXXXX
        lv_var       TYPE char30.

  REFRESH t_soi_cell_table.

  DESCRIBE TABLE t_exceldata LINES lv_ln1.
  DESCRIBE TABLE t_fplt_init LINES lv_ln2.
  IF lv_ln1 <> lv_ln2.
    MESSAGE ‘The file structure can not be modified (change, rename, add or delete columns) at the moment of the excel save’(004) TYPE ‘E’.
    t_exceldata[] = t_fplt_init[].
    EXIT.
  ENDIF.

  LOOP AT t_exceldata INTO ls_exceldata.
    READ TABLE t_fplt INTO ls_fplt INDEX sy-tabix.
    IF ls_exceldata-vbeln EQ space.                ” Billing plan No
*     Subroutine to color the cell red
      PERFORM rotschrift USING ls_exceldata-zeile 1 1.
    ENDIF.

    IF ls_exceldata-fplnr EQ space.                ” billing Item category
*     Subroutine to color the cell red
      PERFORM rotschrift USING ls_exceldata-zeile 3 1.

    ENDIF.

    IF ls_exceldata-fpltr EQ space.                ” Description
*     Subroutine to color the cell red
      PERFORM rotschrift USING ls_exceldata-zeile 4 1.

    ENDIF.

    IF ls_exceldata-fakwr_upld <> ls_exceldata-fakwr.
      lv_var = ls_exceldata-fakwr_upld.
      IF lv_var CA sy-abcde.                ” Milestone No
*     Subroutine to color the cell red
        PERFORM rotschrift USING ls_exceldata-zeile 14 1.
      ENDIF.
    ENDIF.

    IF ls_exceldata-afdat_upld <> ls_fplt-afdat_upld.

      lv_var = ls_exceldata-afdat_upld.
      IF lv_var CA sy-abcde .
        PERFORM rotschrift USING ls_exceldata-zeile 15 1.
        MESSAGE i171(xxx)  WITH ls_exceldata-zeile   15.

      ELSEIF  ls_exceldata-afdat_upld IS INITIAL.
        PERFORM rotschrift USING ls_exceldata-zeile 15 1.
        MESSAGE i172(xxx)  WITH ls_exceldata-zeile   15.
      ENDIF.
    ENDIF.
  ENDLOOP.

* Set background color where the problem is:
  IF NOT t_soi_cell_table[] IS INITIAL.
    CALL METHOD v_handle->cell_format
      EXPORTING
        cells   = t_soi_cell_table
      IMPORTING
        error   = v_error
        retcode = v_retcode.
  ENDIF.
ENDFORM.                    ” CHECK_T_EXCELDATA
*&———————————————————————*
*&      Form  F000_POPUP_DISPLAY
*&———————————————————————*
*       Subroutine for pop up display of all messages
*———————————————————————-*
FORM f000_popup_display .
*Field catalogue for ALV display
  CLEAR s_fieldcat.
  s_fieldcat-fieldname = k_lights.
  s_fieldcat-seltext_l = ‘Status’(009).
  s_fieldcat-tabname = k_tab.
  s_fieldcat-col_pos = 1.
  s_fieldcat-outputlen = 4.
  APPEND s_fieldcat TO t_fieldcat.

  CLEAR s_fieldcat.
  s_fieldcat-fieldname = k_text.
  s_fieldcat-seltext_l = ‘Message’(010).
  s_fieldcat-tabname = k_tab.
  s_fieldcat-col_pos = 2.
  s_fieldcat-outputlen = 132.
  APPEND s_fieldcat TO t_fieldcat.

  ” Function Mododule to give pop-up message with all releavant values
  CALL FUNCTION ‘REUSE_ALV_POPUP_TO_SELECT’
    EXPORTING
      i_title               = text-011
      i_screen_start_column = 5
      i_screen_start_line   = 5
      i_screen_end_column   = 100
      i_screen_end_line     = 20
      i_tabname             = k_tab
      i_allow_no_selection  = ‘X’
      it_fieldcat           = t_fieldcat
      i_callback_program    = sy-repid
    TABLES
      t_outtab              = t_alv[]
    EXCEPTIONS
      program_error         = 1.
  IF sy-subrc = 0.
    PERFORM f000_deq_doc.
    LEAVE TO TRANSACTION ‘XXXXX’.
  ENDIF.
  PERFORM f000_deq_doc.
  LEAVE TO TRANSACTION ‘XXXXX’.
ENDFORM.                    ” F000_POPUP_DISPLAY
*&———————————————————————*
*&      Form  F100_VALIDATE_SCREEN
*&———————————————————————*
*       Subroutine to validate selection screen
*———————————————————————-*
FORM f100_validate_screen .
  DATA lv_vbeln TYPE vbeln_va.
  SELECT SINGLE vbeln FROM vbak
              INTO lv_vbeln
              WHERE vbeln = p_vbeln.
  IF sy-subrc NE 0.
    MESSAGE ‘Please enter valid Sales document’(005) TYPE ‘I’.
  ENDIF.
ENDFORM.                    ” F100_VALIDATE_SCREEN
*&———————————————————————*
*&      Form  BDC_RECORDING_VK11
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_LR_MATNR  text
*      –>P_LT_NETVAL  text
*———————————————————————-*
FORM f000_bdc_recording_vk11  USING     fu_lr_matnr  TYPE ANY TABLE
                                        fu_ls_vbeln  TYPE vbeln_va
                                        fu_lt_netval TYPE  ty_t_netval
                                        fu_lt_vbap   TYPE ty_t_vbap.

*       Range decalaration
  DATA:  lr_matnr  TYPE RANGE OF matnr,
*       Local work area declaration
        ls_matnr  LIKE LINE OF lr_matnr,
        ls_vbap   TYPE ty_vbap,
        ls_netval TYPE ty_netval,
        ls_options TYPE ctu_params,
*       Local variable declaration
        lv_indx   TYPE char2,
        lv_fnam   TYPE fnam_____4.

  ls_options-dismode = ‘N’.
  ls_options-updmode = ‘A’.
  ls_options-defsize = ‘X’.

  lr_matnr = fu_lr_matnr.

  PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’     ‘0100’.
  PERFORM f000_bdc_field       USING ‘BDC_OKCODE’   ‘=ANTA’.
  PERFORM f000_bdc_field       USING ‘RV13A-KSCHL’  v_zref.

  PERFORM f000_bdc_dynpro      USING ‘SAPLV14A’       ‘0100’.
  PERFORM f000_bdc_field       USING ‘BDC_OKCODE’     ‘=WEIT’.

  PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’       ‘1909’.

  PERFORM f000_bdc_field       USING ‘BDC_OKCODE’    ‘/00’.
  PERFORM f000_bdc_field       USING ‘KOMG-AUBEL’    fu_ls_vbeln.

  CLEAR lv_indx.
  LOOP AT lr_matnr INTO ls_matnr.
    lv_indx = sy-tabix.

    READ TABLE fu_lt_vbap INTO ls_vbap WITH KEY matnr = ls_matnr-low BINARY SEARCH.
    IF sy-subrc = 0.
      READ TABLE fu_lt_netval INTO ls_netval WITH KEY posnr = ls_vbap-posnr BINARY SEARCH.
      IF sy-subrc = 0.
        CLEAR lv_fnam.
        CONCATENATE ‘KOMG-MATNR(‘ lv_indx ‘)’ INTO lv_fnam.
        PERFORM f000_bdc_field       USING lv_fnam  ls_matnr-low.
        CLEAR lv_fnam.
        CONCATENATE ‘KONP-KBETR(‘ lv_indx ‘)’ INTO lv_fnam.
        PERFORM f000_bdc_field       USING lv_fnam  ls_netval-netwr.
        CLEAR lv_fnam.
        CONCATENATE ‘KONP-KONWA(‘ lv_indx ‘)’ INTO lv_fnam.
        PERFORM f000_bdc_field       USING lv_fnam  ls_vbap-waerk.
      ENDIF.
    ENDIF.
  ENDLOOP.

  PERFORM f000_bdc_dynpro      USING ‘SAPMV13A’ ‘1909’.
  PERFORM f000_bdc_field       USING ‘BDC_OKCODE’         ‘=SICH’.
  CALL TRANSACTION ‘VK11’
    USING t_bdcdata
    OPTIONS FROM ls_options
    MESSAGES INTO t_message_tab.
  PERFORM f000_trap_bdc_err.
ENDFORM.                    ” BDC_RECORDING_VK11
*&———————————————————————*
*&      Form  F000_TRAP_BDC_ERR
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM f000_trap_bdc_err .
  DATA: lv_msg TYPE text72,
        ls_alv TYPE ty_alv.

  LOOP AT t_message_tab WHERE msgtyp = ‘E’.
    CALL FUNCTION ‘FORMAT_MESSAGE’
      EXPORTING
        id        = sy-msgid
        lang      = sy-langu“‘-D’
        no        = sy-msgno
        v1        = sy-msgv1
        v2        = sy-msgv2
        v3        = sy-msgv3
        v4        = sy-msgv4
      IMPORTING
        msg       = lv_msg
      EXCEPTIONS
        not_found = 1
        OTHERS    = 2.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

    CLEAR ls_alv.
    ls_alv-lights = ‘@0A@’. “red
    MOVE lv_msg TO ls_alv-text.
    APPEND ls_alv TO t_alv.
  ENDLOOP.
ENDFORM.                    ” F000_TRAP_BDC_ERR
*&———————————————————————*
*&      Form  F000_DEQ_DOC
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM f000_deq_doc .

  CALL FUNCTION ‘DEQUEUE_ALL’
    EXPORTING
      _synchron = ‘X’.
ENDFORM.                    ” F000_DEQ_DOC

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply