Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
Error rendering macro 'code': Invalid value specified for parameter 'lang'
 ************************************************************************
* DESCRIPTION : This report displays the data from the table *
* ZPROXY as a ALV grid and provids the *
* functionality for adding, deleting, modifying *
* rows with restrictions based on roles *
*======================================================================*
* COPIED FROM : *
* TITLE : *
* OTHER RELATED OBJ : *
*======================================================================*
* CHANGE HISTORY LOG *
*----------------------------------------------------------------------*
* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *
REPORT ZPROXY_MAINTENANCE_TOOL MESSAGE-ID 0K.
* INCLUDE ZPMT_TOP.
************************************************************************
* DESCRIPTION : This report displays the data from the table *
* ZPROXY as a ALV grid and provids the *
* functionality for adding, deleting, modifying *
* rows with restrictions based on roles *
*======================================================================*
* COPIED FROM : *
* TITLE : *
* OTHER RELATED OBJ : *
*======================================================================*
* CHANGE HISTORY LOG *
*----------------------------------------------------------------------*
* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *
*----------------------------------------------------------------------*
* 1 |11/19/2008|Ajith | G1DK910929 | Solman 8888802400 *
*----------------------------------------------------------------------*
* Tables declaration
TABLES: ZPROXY.
*types declaration
TYPES: BEGIN OF TY_OUTTAB .
        INCLUDE STRUCTURE ZPROXY.
TYPES CELLTAB TYPE LVC_T_STYL.
TYPES END OF TY_OUTTAB.
*variable declaration
DATA: V_CONT1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
V_CONT2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
V_GRID2 TYPE REF TO CL_GUI_ALV_GRID,
V_ERROR_IN_DATA TYPE C,
V_ANSWER TYPE C,
V_AUTH TYPE C,
V_AUTH1 TYPE C,
V_FLAG TYPE I VALUE 0,
V_MOD TYPE I ,
V_FLAG1 TYPE I,
V_PROXY1(10) TYPE N , " Ajith for Solman 8888802400
V_PROXY2(10) TYPE N. " Ajith for Solman 8888802400
*constants declaration
CONSTANTS: C_CHECK TYPE C VALUE 'X',
C_CONTAINER TYPE SCRFNAME VALUE 'G_CONT1',
C_CONTAINER1 TYPE SCRFNAME VALUE 'G_CONT2',
C_S VALUE 'S'.
*Internal tables declaration
DATA: I_ZPROXY TYPE TABLE OF ZPROXY,
I_ZPROXY_INIT TYPE TABLE OF ZPROXY,
I_FIELDCAT TYPE LVC_T_FCAT,
I_CELLTAB TYPE LVC_T_STYL,                                  "#EC NEEDED
I_INSERTED_ROWS TYPE LVC_T_MOCE,                            "#EC NEEDED
I_OUTTAB TYPE TABLE OF TY_OUTTAB,
I_DELETED_ROWS TYPE STANDARD TABLE OF ZPROXY.
*work area declaration
DATA: WA_ZPROXY TYPE ZPROXY,
WA_CELLTAB TYPE LVC_S_STYL,                                 "#EC NEEDED
WA_FIELDCAT TYPE LVC_S_FCAT,
WA_INSERTED_ROWS TYPE LVC_S_MOCE,
WA_OUTTAB TYPE TY_OUTTAB,
WA_LAYOUT TYPE LVC_S_LAYO,
WA_TOOLBAR TYPE STB_BUTTON.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER DEFINITION.
*Public section
  PUBLIC SECTION.
    TYPES: BEGIN OF TY_ZPROXY_KEY.
    TYPES: ZNUMBER TYPE ZPROXY-ZNUMBER. " Changes by Ajith :New key field as per 8888802400
    TYPES: ZPN TYPE ZPROXY-ZPN.
*begin AShan
    TYPES: KUNNR TYPE ZPROXY-KUNNR.
    TYPES: ZSDATE TYPE ZPROXY-ZSDATE.
    TYPES: ZEDATE TYPE ZPROXY-ZEDATE.
    TYPES: ZNAME TYPE ZPROXY-ZNAME.
*end AShan
    TYPES: END OF TY_ZPROXY_KEY.
    TYPES: ZPROXY_KEYS TYPE STANDARD TABLE OF TY_ZPROXY_KEY,
    ZPROXY_TABLE TYPE STANDARD TABLE OF ZPROXY.
    METHODS:
    HANDLER_TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
    IMPORTING
    E_OBJECT E_INTERACTIVE,                                 "#EC NEEDED
    HANDLE_USER_COMMAND FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
    IMPORTING E_UCOMM,
    HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
    IMPORTING ER_DATA_CHANGED
    E_ONF4                                                  "#EC NEEDED
    E_ONF4_BEFORE                                           "#EC NEEDED
    E_ONF4_AFTER                                            "#EC NEEDED
    E_UCOMM.                                                "#EC NEEDED
    METHODS:
    GET_INSERTED_ROWS
    EXPORTING
    INSERTED_ROWS TYPE ZPROXY_KEYS.                         "#EC CALLED
    METHODS:
    GET_DELETED_ROWS
    EXPORTING
    DELETED_ROWS TYPE ZPROXY_TABLE.                         "#EC CALLED
    METHODS:
    REFRESH_DELTA_TABLES.
*private section
  PRIVATE SECTION.
* Define internal tables to remember inserted and deleted lines,
* thus the delta between input made after the last saving.
    DATA: INSERTED_ROWS TYPE ZPROXY_KEYS,
    DELETED_ROWS TYPE STANDARD TABLE OF ZPROXY.
    METHODS:
    CHECK_DOUBLE_ENTRIES
    IMPORTING
    PR_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    METHODS:
    UPDATE_DELTA_TABLES
    IMPORTING
    PR_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    METHODS:
    GET_CELL_VALUES
    IMPORTING
    ROW_ID TYPE INT4
    PR_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL
    EXPORTING
    KEY TYPE TY_ZPROXY_KEY.
ENDCLASS. "lcl_event_receiver DEFINITION
DATA: V_EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.
* select-options for selection screen.
SELECT-OPTIONS: S_ZNUM FOR ZPROXY-ZNUMBER, " New key field as per Solman 8888802400
S_ZPN FOR ZPROXY-ZPN,
S_KUNNR FOR ZPROXY-KUNNR,
S_DATE FOR ZPROXY-ZSDATE ,
S_ZNAME FOR ZPROXY-ZNAME NO INTERVALS NO-EXTENSION,
S_STA FOR ZPROXY-ZSTATUS.
* INCLUDE ZPMT_CL_IMP.
* DESCRIPTION : This report displays the data from the table *
* ZPROXY as a ALV grid and provids the *
* functionality for adding, deleting, modifying *
* rows with restrictions based on roles *
*======================================================================*
* COPIED FROM : *
* TITLE : *
* OTHER RELATED OBJ : *
*======================================================================*
* CHANGE HISTORY LOG *
*----------------------------------------------------------------------*
* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *
*----------------------------------------------------------------------*
* 1 |11/19/2008|Ajith | G1DK910929 | Solman 8888802400 *
*----------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
  METHOD HANDLER_TOOLBAR.
* Append a new button that to the toolbar. Use E_OBJECT of
* event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
* This class has one attribute MT_TOOLBAR which is of table type
* TTB_BUTTON. The structure is STB_BUTTON
    IF V_MOD EQ 1.
      CLEAR WA_TOOLBAR.
      MOVE TEXT-T04 TO WA_TOOLBAR-FUNCTION.
      MOVE ICON_CREATE TO WA_TOOLBAR-ICON.
      MOVE TEXT-T05 TO WA_TOOLBAR-QUICKINFO.
      MOVE ' ' TO WA_TOOLBAR-TEXT.
      MOVE ' ' TO WA_TOOLBAR-DISABLED.
      MOVE 0 TO WA_TOOLBAR-BUTN_TYPE.
      INSERT WA_TOOLBAR INTO E_OBJECT->MT_TOOLBAR INDEX 8.
      CLEAR WA_TOOLBAR.
      MOVE TEXT-T01 TO WA_TOOLBAR-FUNCTION.
      MOVE ICON_SYSTEM_SAVE TO WA_TOOLBAR-ICON.
      MOVE TEXT-T02 TO WA_TOOLBAR-QUICKINFO.
      MOVE '' TO WA_TOOLBAR-TEXT.
      MOVE ' ' TO WA_TOOLBAR-DISABLED.
      MOVE 0 TO WA_TOOLBAR-BUTN_TYPE.
      INSERT WA_TOOLBAR INTO E_OBJECT->MT_TOOLBAR INDEX 11.
* APPEND wa_toolbar TO e_object->mt_toolbar.
      CLEAR WA_TOOLBAR.
      MOVE TEXT-T09 TO WA_TOOLBAR-FUNCTION.
      MOVE ICON_DELETE_ROW TO WA_TOOLBAR-ICON.
      MOVE TEXT-T10 TO WA_TOOLBAR-QUICKINFO.
      MOVE ' ' TO WA_TOOLBAR-TEXT.
      MOVE ' ' TO WA_TOOLBAR-DISABLED.
      MOVE 0 TO WA_TOOLBAR-BUTN_TYPE.
      INSERT WA_TOOLBAR INTO E_OBJECT->MT_TOOLBAR INDEX 10.
* APPEND wa_toolbar TO e_object->mt_toolbar.
    ENDIF.
    IF V_AUTH EQ 'X' OR V_AUTH1 EQ 'X'.
      CLEAR WA_TOOLBAR.
      MOVE TEXT-T11 TO WA_TOOLBAR-FUNCTION.
      MOVE ICON_TOGGLE_DISPLAY_CHANGE TO WA_TOOLBAR-ICON.
      MOVE TEXT-T12 TO WA_TOOLBAR-QUICKINFO.
      MOVE ' ' TO WA_TOOLBAR-TEXT.
      MOVE ' ' TO WA_TOOLBAR-DISABLED.
      MOVE 0 TO WA_TOOLBAR-BUTN_TYPE.
      INSERT WA_TOOLBAR INTO E_OBJECT->MT_TOOLBAR INDEX 12.
* APPEND wa_toolbar TO e_object->mt_toolbar.
    ENDIF.
  ENDMETHOD. "handler_toolbar
*---------------------------------------------------------
*Method for handling user-command
  METHOD HANDLE_USER_COMMAND.
    DATA L_VALID TYPE C.
    CASE E_UCOMM.
      WHEN 'SAVE'.                                          "text-t01.
        PERFORM F_SAVE_CHANGES.
      WHEN 'APPEND'.                                        "text-t04 .
        IF V_AUTH EQ C_CHECK OR V_AUTH1 EQ C_CHECK.
          PERFORM F_VALIDATIONS.
          IF V_ERROR_IN_DATA IS INITIAL.
            PERFORM F_ADD_BLANK_LINE.
          ENDIF.
        ELSE.
          MESSAGE TEXT-S05 TYPE C_S DISPLAY LIKE 'E'.
        ENDIF.
      WHEN 'DELETE'.                                        "text-t09.
        DATA: I_ROWS TYPE LVC_T_ROW.
        CALL METHOD V_GRID2->GET_SELECTED_ROWS
          IMPORTING
            ET_INDEX_ROWS = I_ROWS.
        PERFORM F_DELETE USING I_ROWS.
        CLEAR I_ROWS.
        REFRESH I_ROWS.
      WHEN 'CHANGE'.                                        "TEXT-T99.
        V_FLAG = V_FLAG + 1.
        V_MOD = V_FLAG MOD 2.
* v_ucomm = e_ucomm.
        IF V_GRID2->IS_READY_FOR_INPUT( ) = 0.
          CALL METHOD V_GRID2->SET_READY_FOR_INPUT
            EXPORTING
              I_READY_FOR_INPUT = 1.
          SET HANDLER V_EVENT_RECEIVER->HANDLER_TOOLBAR FOR V_GRID2.
        ELSE.
          CALL METHOD V_GRID2->CHECK_CHANGED_DATA
            IMPORTING
              E_VALID = L_VALID.
          IF L_VALID = C_CHECK.
            CALL METHOD V_GRID2->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 0.
            SET HANDLER V_EVENT_RECEIVER->HANDLER_TOOLBAR FOR V_GRID2.
* CLEAR v_ucomm.
          ENDIF.
          CLEAR L_VALID.
        ENDIF.
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD. "handle_user_command
*---------------------------------------------------------
  METHOD HANDLE_DATA_CHANGED.
* method for handling changes in data, checking for duplicate entries, tracking the
* number of rows added and deleted
    DATA: L_INSERTED_COUNT TYPE I.                          "#EC NEEDED
    V_ERROR_IN_DATA = SPACE.
    DESCRIBE TABLE ER_DATA_CHANGED->MT_INSERTED_ROWS
    LINES L_INSERTED_COUNT.
    CALL METHOD CHECK_DOUBLE_ENTRIES( ER_DATA_CHANGED ).
    CALL METHOD UPDATE_DELTA_TABLES( ER_DATA_CHANGED ).
    IF L_INSERTED_COUNT EQ 0.
      PERFORM F_HANDLE_DATACHANGE USING ER_DATA_CHANGED.
    ENDIF.
* PERFORM f_refresh_table_display.
    IF V_ERROR_IN_DATA = C_CHECK.
      CALL METHOD ER_DATA_CHANGED->DISPLAY_PROTOCOL.
    ENDIF.
    CLEAR L_INSERTED_COUNT.
  ENDMETHOD. "handle_DATA_CHANGED
*---------------------------------------------------------
*method for retrieving the deleted rows
  METHOD GET_DELETED_ROWS.
    DELETED_ROWS = ME->DELETED_ROWS.
  ENDMETHOD. "get_deleted_rows
*---------------------------------------------------------
*method for retrieving the inserted rows
  METHOD GET_INSERTED_ROWS.
    INSERTED_ROWS = ME->INSERTED_ROWS.
  ENDMETHOD. "get_inserted_rows
*---------------------------------------------------------
  METHOD REFRESH_DELTA_TABLES.
    CLEAR ME->INSERTED_ROWS[].
    CLEAR ME->DELETED_ROWS[].
  ENDMETHOD. "refresh_delta_tables
*---------------------------------------------------------
*method for updating the delta tables
  METHOD UPDATE_DELTA_TABLES.
    DATA: WA_INS_ROW TYPE LVC_S_MOCE,
    WA_DEL_ROW TYPE LVC_S_MOCE,
    WA_KEY TYPE TY_ZPROXY_KEY,
    WA_ZPROXY TYPE ZPROXY,
    WA_OUTTAB LIKE LINE OF I_OUTTAB.
* Use protocol attributes MT_DELETED_ROWS and MT_INSERTED_ROWS
* to remember which lines where deleted or inserted. Save this
* information in your internal tables.
* deleted rows
    LOOP AT PR_DATA_CHANGED->MT_DELETED_ROWS INTO WA_DEL_ROW.
* lv_tabix = sy-tabix.
      READ TABLE I_OUTTAB INTO WA_OUTTAB INDEX WA_DEL_ROW-ROW_ID.
      IF SY-SUBRC NE 0.
        MESSAGE I000(0K) WITH TEXT-I02.
      ELSE.
***********************************************************************************************
* IF wa_outtab-zstatus IS INITIAL AND v_auth EQ c_check.
        MOVE-CORRESPONDING WA_OUTTAB TO WA_ZPROXY.
* It is not possible that the same line is deleted twice,
* so just add the new key line to 'deleted_rows'.
        APPEND WA_ZPROXY TO DELETED_ROWS.
* If this line was inserted just before it is deleted:
        DELETE ME->INSERTED_ROWS
* Start of changes by Ajith for 8888802400
* WHERE zpn = wa_outtab-zpn
        WHERE ZNUMBER = WA_OUTTAB-ZNUMBER. " New key field as per 8888802400
* End of changes by Ajith for 8888802400
*
      ENDIF.
    ENDLOOP.
    LOOP AT PR_DATA_CHANGED->MT_INSERTED_ROWS INTO WA_INS_ROW.
      CALL METHOD GET_CELL_VALUES
        EXPORTING
          ROW_ID          = WA_INS_ROW-ROW_ID
          PR_DATA_CHANGED = PR_DATA_CHANGED
        IMPORTING
          KEY             = WA_KEY.
* Just insert the new row regardless if the input is wrong
      APPEND WA_KEY TO INSERTED_ROWS.
    ENDLOOP.
    CLEAR: WA_INS_ROW,
    WA_DEL_ROW,
    WA_KEY,
    WA_ZPROXY,
    WA_OUTTAB.
  ENDMETHOD. "update_delta_tables
*---------------------------------------------------------
  METHOD GET_CELL_VALUES.
* get values of key cells of row ROW_ID
* znumber
    CALL METHOD PR_DATA_CHANGED->GET_CELL_VALUE
      EXPORTING
        I_ROW_ID    = ROW_ID
        I_FIELDNAME = TEXT-D01 "znumber , Changes by Ajith :Key field changed to znumber as per 8888802400
      IMPORTING
        E_VALUE     = KEY-ZNUMBER. " Changes by Ajith :Key field changed to znumber as per 8888802400
    IF SY-SUBRC NE 0.
      MESSAGE I000(0K) WITH TEXT-I01.
    ENDIF.
  ENDMETHOD. "get_cell_values
*---------------------------------------------------------
  METHOD CHECK_DOUBLE_ENTRIES.
    DATA: I_GOOD_CELLS TYPE ZPROXY_KEYS,
    WA_GOOD_CELLS TYPE TY_ZPROXY_KEY,
    WA_GOOD TYPE LVC_S_MODI,
    WA_ZPROXY TYPE ZPROXY,
    L_ZPN TYPE ZPROXY-ZPN,
*begin AShan
    L_KUNNR TYPE ZPROXY-KUNNR,
    V_NAME1 TYPE ZPROXY-KUNNR_NAME,
    L_ZSDATE TYPE ZPROXY-ZSDATE,
    L_ZEDATE TYPE ZPROXY-ZEDATE,
    L_ZNAME TYPE ZPROXY-ZNAME,
*end AShan
    WA_DEL_ROW TYPE LVC_S_MOCE,
    WA_OUTTAB LIKE LINE OF I_OUTTAB,
    L_REENTERED TYPE C.
* Check if there exist already other records with equal key fields.
    LOOP AT PR_DATA_CHANGED->MT_GOOD_CELLS INTO WA_GOOD.
      IF WA_GOOD-FIELDNAME EQ 'ZPN'
*begin AShan
      OR WA_GOOD-FIELDNAME EQ 'KUNNR'
      OR WA_GOOD-FIELDNAME EQ 'ZSDATE'
      OR WA_GOOD-FIELDNAME EQ 'ZEDATE'
      OR WA_GOOD-FIELDNAME EQ 'ZNAME'.
*end AShan
        CALL METHOD PR_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = WA_GOOD-ROW_ID
            I_FIELDNAME = 'ZPN'
          IMPORTING
            E_VALUE     = L_ZPN.
*begin AShan
        CALL METHOD PR_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = WA_GOOD-ROW_ID
            I_FIELDNAME = 'KUNNR'
          IMPORTING
            E_VALUE     = L_KUNNR.
* start :- code added by ashwin
        IF NOT L_KUNNR IS INITIAL.
          SELECT SINGLE NAME1
          FROM KNA1
          INTO V_NAME1
          WHERE KUNNR EQ L_KUNNR.
          IF NOT V_NAME1 IS INITIAL.
            CALL METHOD PR_DATA_CHANGED->MODIFY_CELL
              EXPORTING
                I_ROW_ID    = WA_GOOD-ROW_ID
                I_FIELDNAME = 'KUNNR_NAME'
                I_VALUE     = V_NAME1.
          ENDIF.
        ENDIF.
* End :- code added by ashwin
        CALL METHOD PR_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = WA_GOOD-ROW_ID
            I_FIELDNAME = 'ZSDATE'
          IMPORTING
            E_VALUE     = L_ZSDATE.
        CALL METHOD PR_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = WA_GOOD-ROW_ID
            I_FIELDNAME = 'ZEDATE'
          IMPORTING
            E_VALUE     = L_ZEDATE.
        CALL METHOD PR_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = WA_GOOD-ROW_ID
            I_FIELDNAME = 'ZNAME'
          IMPORTING
            E_VALUE     = L_ZNAME.
*end AShan
        IF NOT L_ZPN IS INITIAL
*begin AShan
        AND NOT L_KUNNR IS INITIAL
        AND NOT L_ZSDATE IS INITIAL
        AND NOT L_ZEDATE IS INITIAL
        AND NOT L_ZNAME IS INITIAL.
*end AShan
          READ TABLE I_GOOD_CELLS WITH KEY ZPN = L_ZPN
*begin AShan
          KUNNR = L_KUNNR
          ZSDATE = L_ZSDATE
          ZEDATE = L_ZEDATE
          ZNAME = L_ZNAME
*end AShan
          TRANSPORTING NO FIELDS.
          IF SY-SUBRC IS INITIAL.
            PERFORM F_ADD_PROTOCOL_ERROR USING
            PR_DATA_CHANGED
            TEXT-E01
            TEXT-E02
            ''
            ''
            'ZPN'
            WA_GOOD-ROW_ID.
            V_ERROR_IN_DATA = C_CHECK.
          ELSE. " Check in Database
            SELECT SINGLE *
            FROM ZPROXY
            INTO WA_ZPROXY
            WHERE ZPN = L_ZPN
*begin AShan
            AND KUNNR = L_KUNNR
            AND ZSDATE = L_ZSDATE
            AND ZEDATE = L_ZEDATE
            AND ZNAME = L_ZNAME.
*end AShan
            IF SY-SUBRC IS INITIAL.
              PERFORM F_ADD_PROTOCOL_ERROR USING
              PR_DATA_CHANGED
              TEXT-E03
              TEXT-E04
              ''
              ''
              'ZPN'
              WA_GOOD-ROW_ID.
              V_ERROR_IN_DATA = C_CHECK.
*begin AShan
              EXIT.
*end AShan
            ELSE.
              WA_GOOD_CELLS-ZPN = L_ZPN.
*begin AShan
              WA_GOOD_CELLS-KUNNR = L_KUNNR.
              WA_GOOD_CELLS-ZSDATE = L_ZSDATE.
              WA_GOOD_CELLS-ZEDATE = L_ZEDATE.
              WA_GOOD_CELLS-ZNAME = L_ZNAME.
*end AShan
              APPEND WA_GOOD_CELLS TO I_GOOD_CELLS.
              CLEAR WA_GOOD_CELLS.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDLOOP.
*.........................
* Check if any new entries already exist in gt_outtab.
* At this point, i_good_cells contains only lines with Key fields
*.........................
    CLEAR WA_GOOD_CELLS.
    LOOP AT I_GOOD_CELLS INTO WA_GOOD_CELLS.
      CLEAR WA_OUTTAB.
      READ TABLE I_OUTTAB INTO WA_OUTTAB WITH KEY
      ZPN = WA_GOOD_CELLS-ZPN
*begin AShan
      KUNNR = WA_GOOD_CELLS-KUNNR
      ZSDATE = WA_GOOD_CELLS-ZSDATE
      ZEDATE = WA_GOOD_CELLS-ZEDATE
      ZNAME = WA_GOOD_CELLS-ZNAME.
*end AShan
      IF SY-SUBRC IS INITIAL.
* Check if this entry was deleted before, i.e. it is in the table
* of deleted rows. If so, the entry does not exist twice. The user
* has deleted a line and then reentered it.
        L_REENTERED = SPACE.
        LOOP AT PR_DATA_CHANGED->MT_DELETED_ROWS INTO WA_DEL_ROW.
          READ TABLE I_OUTTAB INTO WA_OUTTAB INDEX WA_DEL_ROW-ROW_ID.
          IF SY-SUBRC NE 0.
            MESSAGE I000(0K) WITH TEXT-I02.
          ELSEIF
          WA_OUTTAB-ZPN EQ WA_GOOD_CELLS-ZPN.
            L_REENTERED = C_CHECK.
          ENDIF.
        ENDLOOP.
        IF L_REENTERED NE C_CHECK.
          PERFORM F_ADD_PROTOCOL_ERROR USING
          PR_DATA_CHANGED
          TEXT-E01
          TEXT-E02
          ''
          ''
          'ZPN'
          WA_GOOD-ROW_ID.
          V_ERROR_IN_DATA = C_CHECK.
        ENDIF.
      ENDIF.
    ENDLOOP.
    CLEAR: I_GOOD_CELLS ,
    WA_GOOD_CELLS ,
    WA_GOOD ,
    WA_ZPROXY ,
    L_ZPN,
    WA_DEL_ROW ,
    WA_OUTTAB ,
    L_REENTERED .
    REFRESH I_GOOD_CELLS.
  ENDMETHOD. "check_double_entries
*---------------------------------------------------------
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
* INCLUDE ZPMT_FORMS.
*-----------------------------------------------------------------
* START-OF-SELECTION.
*-----------------------------------------------------------------
START-OF-SELECTION.
**Authority Check for bookkeeper.
* AUTHORITY-CHECK OBJECT 'ZPMT'
* ID 'ZSTATUS' FIELD WA_OUTTAB-ZSTATUS
* ID 'ACTVT' FIELD '02'
* ID 'ACTVT' FIELD '01'
* ID 'ACTVT' FIELD '03'
* ID 'ACTVT' FIELD '06'.
* IF SY-SUBRC EQ 0.
* V_AUTH = C_CHECK.
* ENDIF.
*
**Authority check for manager
* IF NOT V_AUTH EQ C_CHECK.
* AUTHORITY-CHECK OBJECT 'ZPMT'
* ID 'ZSTATUS' FIELD WA_OUTTAB-ZSTATUS
* ID 'ACTVT' FIELD '01'
* ID 'ACTVT' FIELD '03'
* ID 'ACTVT' FIELD '06'.
* IF SY-SUBRC EQ 0.
* V_AUTH1 = C_CHECK.
* ENDIF.
* ENDIF.
*selecting record from database table zproxy
  SELECT *
  FROM ZPROXY
  INTO TABLE I_ZPROXY
  WHERE ZNUMBER IN S_ZNUM " Changes by Ajith for 8888802400
  AND ZPN IN S_ZPN
  AND KUNNR IN S_KUNNR
  AND ZSDATE IN S_DATE
  AND ZEDATE IN S_DATE
  AND ZNAME IN S_ZNAME
  AND ZSTATUS IN S_STA.
  IF SY-SUBRC EQ 0.
    SORT I_ZPROXY BY ZPN.
    LOOP AT I_ZPROXY INTO WA_ZPROXY.
* Begin of change - Jaya - 8888801423 - G1DK912332 - 3rd Feb'09
      IF WA_ZPROXY-ZSTATUS EQ 0.
        WA_ZPROXY-ZSTATN = TEXT-T19.
      ELSEIF WA_ZPROXY-ZSTATUS EQ 1.
        WA_ZPROXY-ZSTATN = TEXT-T20.
      ELSEIF WA_ZPROXY-ZSTATUS EQ 2.
        WA_ZPROXY-ZSTATN = TEXT-T21.
      ENDIF.
      MODIFY I_ZPROXY FROM WA_ZPROXY INDEX SY-TABIX TRANSPORTING ZSTATN.
*End of change - Jaya - 8888801423 - G1DK912332 - 3rd Feb'09
      MOVE-CORRESPONDING WA_ZPROXY TO WA_OUTTAB.
      APPEND WA_OUTTAB TO I_OUTTAB.
      CLEAR:WA_OUTTAB,
      WA_ZPROXY.
    ENDLOOP.
*if data fetch is successful them move the data to internal table else inform the user
  ELSE.
    MESSAGE TEXT-S01 TYPE C_S.
  ENDIF.
  I_ZPROXY_INIT[] = I_ZPROXY[].
*-----------------------------------------------------------------
* END-OF-SELECTION.
*--------------------------------------------------------------
END-OF-SELECTION.
  PERFORM BUILD_LAYOUT.
*calling screen 0100
  CALL SCREEN '0100'.
* REQUEST NUMBER : G1DK908576 *
* DESCRIPTION : This report displays the data from the table *
* ZPROXY as a ALV grid and provids the *
* functionality for adding, deleting, modifying *
* rows with restrictions based on roles *
*======================================================================*
* COPIED FROM : *
* TITLE : *
* OTHER RELATED OBJ : *
*======================================================================*
* CHANGE HISTORY LOG *
*----------------------------------------------------------------------*
* MOD. NO.| DATE | NAME | CORRECTION NUMBER | CHANGE REFERENCE# *
*----------------------------------------------------------------------*
* 1 |11/19/2008|Ajith | G1DK910929 | Solman 8888802400 *
* 2 |09-Feb-09 |Jaya | G1DK912687 | Solman 8888802775 *
*----------------------------------------------------------------------*
*& Module STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
* Form for PBO Module of screen 0100
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  DATA :I_EXCLUDE TYPE TABLE OF UI_FUNC,                    "#EC *
  L_EXCLUDE TYPE UI_FUNC.                                   "#EC *
  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR 'MAIN100'.
  IF V_CONT1 IS INITIAL.
    CREATE OBJECT V_CONT1
    EXPORTING
    CONTAINER_NAME = C_CONTAINER.
    CREATE OBJECT V_CONT2
    EXPORTING
    CONTAINER_NAME = C_CONTAINER1.
    CREATE OBJECT V_GRID2
    EXPORTING
    I_PARENT = V_CONT1
    I_APPLOGPARENT = V_CONT2.
    CREATE OBJECT V_EVENT_RECEIVER.
    PERFORM F_SET_REGISTER_EDIT_EVENT USING V_GRID2.
    IF V_AUTH EQ C_CHECK OR V_AUTH1 EQ C_CHECK.
      SET HANDLER V_EVENT_RECEIVER->HANDLE_USER_COMMAND FOR V_GRID2.
      SET HANDLER V_EVENT_RECEIVER->HANDLER_TOOLBAR FOR V_GRID2.
      SET HANDLER V_EVENT_RECEIVER->HANDLE_DATA_CHANGED FOR V_GRID2.
    ENDIF.
**User can exclude buttons as required
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
    APPEND L_EXCLUDE TO I_EXCLUDE.
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
    APPEND L_EXCLUDE TO I_EXCLUDE.
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
    APPEND L_EXCLUDE TO I_EXCLUDE.
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
* APPEND l_exclude TO i_exclude.
* l_exclude = cl_gui_alv_grid=>mc_fc_refresh.
* APPEND l_exclude TO i_exclude.
* l_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
    APPEND L_EXCLUDE TO I_EXCLUDE.
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
    APPEND L_EXCLUDE TO I_EXCLUDE.
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_GRAPH.
    APPEND L_EXCLUDE TO I_EXCLUDE.
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
    APPEND L_EXCLUDE TO I_EXCLUDE.
    L_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW. " Changed by Ajith for 8888802400 as duplicate entries of
    APPEND L_EXCLUDE TO I_EXCLUDE. " znumber is not possible
    CLEAR L_EXCLUDE.
* build field catalog
    PERFORM F_BUILD_FIELD_CATELOG.
    IF V_AUTH EQ C_CHECK OR V_AUTH1 EQ C_CHECK.
* setting the fields editable or display only
      PERFORM F_SET_EDITABLE.
    ENDIF.
* creating the alv list for data present in database
    CALL METHOD V_GRID2->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        I_STRUCTURE_NAME              = 'ZPROXY'
        I_SAVE                        = 'A'
        IS_LAYOUT                     = WA_LAYOUT
        IT_TOOLBAR_EXCLUDING          = I_EXCLUDE
      CHANGING
        IT_OUTTAB                     = I_OUTTAB[]
        IT_FIELDCATALOG               = I_FIELDCAT
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        OTHERS                        = 4.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
* Set editable cells to ready for input initially
    CALL METHOD V_GRID2->SET_READY_FOR_INPUT
      EXPORTING
        I_READY_FOR_INPUT = 0.
  ENDIF.
ENDMODULE. " STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1000 INPUT
*&---------------------------------------------------------------------*
* PAI Module for screen 0100
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
  DATA: L_VALID(1) TYPE C.
  CASE SY-UCOMM.
    WHEN 'EXIT'.
      PERFORM F_EXIT_PROGRAM.
    WHEN 'BACK'.
      PERFORM F_BACK_PROGRAM.
    WHEN 'SAVE'.
      PERFORM F_SAVE_CHANGES.
    WHEN 'CHANGE'.
      IF V_AUTH EQ C_CHECK OR V_AUTH1 EQ C_CHECK.
        V_FLAG = V_FLAG + 1.
        V_MOD = V_FLAG MOD 2.
        IF V_GRID2->IS_READY_FOR_INPUT( ) = 0.
          CALL METHOD V_GRID2->SET_READY_FOR_INPUT
            EXPORTING
              I_READY_FOR_INPUT = 1.
          SET HANDLER V_EVENT_RECEIVER->HANDLER_TOOLBAR FOR V_GRID2.
        ELSE.
          CALL METHOD V_GRID2->CHECK_CHANGED_DATA
            IMPORTING
              E_VALID = L_VALID.
          IF L_VALID = C_CHECK.
            CALL METHOD V_GRID2->SET_READY_FOR_INPUT
              EXPORTING
                I_READY_FOR_INPUT = 0.
            SET HANDLER V_EVENT_RECEIVER->HANDLER_TOOLBAR FOR V_GRID2.
          ENDIF.
          CLEAR L_VALID.
        ENDIF.
      ELSE.
        MESSAGE TEXT-S06 TYPE 'E'.
      ENDIF.
  ENDCASE.
ENDMODULE. " USER_COMMAND_1000 INPUT
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* form for building the ALV Grid layout
*----------------------------------------------------------------------*
FORM BUILD_LAYOUT .
  WA_LAYOUT-STYLEFNAME = 'CELLTAB'.
  WA_LAYOUT-CWIDTH_OPT = 'X'. "8888801423 - Manju - 22/jan/2009
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form F_SAVE_CHANGES
*&---------------------------------------------------------------------*
* Form for saving the changes
*----------------------------------------------------------------------*
FORM F_SAVE_CHANGES .
  REFRESH I_ZPROXY[].
  LOOP AT I_OUTTAB INTO WA_OUTTAB.
    MOVE-CORRESPONDING WA_OUTTAB TO WA_ZPROXY .
    APPEND WA_ZPROXY TO I_ZPROXY.
    CLEAR : WA_OUTTAB,
    WA_ZPROXY.
  ENDLOOP.
  SORT I_ZPROXY_INIT BY ZPN.
  SORT I_ZPROXY BY ZPN.
  IF I_ZPROXY_INIT[] = I_ZPROXY[].
    MESSAGE TEXT-S02 TYPE C_S.
  ELSE.
** Update the change pointer tables for sending IDocs to POS
    PERFORM TRIGGER_POS_UPDATE. " Jaya Singh -- 8888802775 -- G1DK912687
    DATA: L_VALID TYPE C,
    L_REFRESH TYPE C VALUE SPACE.
* Check if any errors exist in protocol by using method
* CHECK_CHANGED_DATA of your ALV Grid instance.
    CALL METHOD V_GRID2->CHECK_CHANGED_DATA
      IMPORTING
        E_VALID   = L_VALID
      CHANGING
        C_REFRESH = L_REFRESH.
* perform validations on the key fields to check whether it is blank or not
    PERFORM F_VALIDATIONS.
    IF L_VALID IS INITIAL
    OR V_ERROR_IN_DATA = C_CHECK.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          TITEL = TEXT-E05
          TXT1  = TEXT-E06
          TXT2  = ''.
      CLEAR: L_VALID,
      L_REFRESH.
    ELSE.
      IF V_FLAG1 NE 1.
        CLEAR: V_ANSWER.
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
            TEXT_QUESTION  = TEXT-T07
          IMPORTING
            ANSWER         = V_ANSWER
          EXCEPTIONS
            TEXT_NOT_FOUND = 1
            OTHERS         = 2.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        IF ( V_ANSWER = '1' ). " yes
*START: Insert - Manjunatha Kodagi - 8888801423 - 23/Jan/2009
          IF V_AUTH EQ C_CHECK OR V_AUTH1 EQ C_CHECK.
* setting the fields editable or display only based on the authorization.
            PERFORM F_SET_EDITABLE.
          ENDIF.
* END: Insert - Manjunatha Kodagi - 8888801423 - 23/Jan/2009
* Update database table.
          PERFORM F_UPDATE_DATABASE.
          CLEAR V_ANSWER.
          I_ZPROXY_INIT[] = I_ZPROXY[]. " update PBO data !!!
*START: Insert - Manjunatha Kodagi - 8888801423 - 23/Jan/2009
          CALL METHOD V_GRID2->REFRESH_TABLE_DISPLAY.
* END: Insert - Manjunatha Kodagi - 8888801423 - 23/Jan/2009
        ELSEIF V_ANSWER EQ 'A'.
          MESSAGE TEXT-S03 TYPE C_S.
        ENDIF.
      ELSE.
        PERFORM F_UPDATE_DATABASE.
        CLEAR V_ANSWER.
        I_ZPROXY_INIT[] = I_ZPROXY[]. " update PBO data !!!
        CLEAR V_FLAG1.
      ENDIF.
    ENDIF.
  ENDIF.
  CLEAR L_VALID.
ENDFORM. " F_SAVE_CHANGES
*&---------------------------------------------------------------------*
*& Form F_EXIT_PROGRAM
*&---------------------------------------------------------------------*
FORM F_EXIT_PROGRAM .
  REFRESH I_ZPROXY[].
  LOOP AT I_OUTTAB INTO WA_OUTTAB.
    MOVE-CORRESPONDING WA_OUTTAB TO WA_ZPROXY .
    APPEND WA_ZPROXY TO I_ZPROXY.
    CLEAR : WA_OUTTAB,
    WA_ZPROXY.
  ENDLOOP.
  SORT I_ZPROXY_INIT BY ZPN.
  SORT I_ZPROXY BY ZPN.
  IF I_ZPROXY_INIT NE I_ZPROXY .
    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
        TEXT_QUESTION  = TEXT-T13
      IMPORTING
        ANSWER         = V_ANSWER
      EXCEPTIONS
        TEXT_NOT_FOUND = 1
        OTHERS         = 2.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.
  IF ( V_ANSWER = '1' ).
    V_FLAG1 = 1.
    PERFORM F_SAVE_CHANGES.
    LEAVE PROGRAM.
    SET SCREEN 0.
    LEAVE SCREEN..
  ELSEIF V_ANSWER = '2' .
    CLEAR:I_ZPROXY_INIT,
    I_ZPROXY,
    I_OUTTAB,
    I_INSERTED_ROWS,
    I_FIELDCAT,
    I_EXCLUDE,
    I_DELETED_ROWS,
    I_CELLTAB.
    REFRESH :I_ZPROXY_INIT,
    I_ZPROXY,
    I_OUTTAB,
    I_INSERTED_ROWS,
    I_FIELDCAT,
    I_EXCLUDE,
    I_DELETED_ROWS,
    I_CELLTAB.
    CLEAR: V_CONT1 ,
    V_CONT2 ,
    V_GRID2 ,
    V_ERROR_IN_DATA ,
    V_ANSWER ,
    V_AUTH ,
    V_FLAG ,
    V_MOD .
    CLEAR ZPROXY.
                                                            "#EC NEEDED
    LEAVE PROGRAM.
    SET SCREEN 0.
    LEAVE SCREEN..
  ELSEIF V_ANSWER EQ 'A'.
    CLEAR: V_CONT1 ,
    V_CONT2 ,
    V_GRID2 ,
    V_ERROR_IN_DATA ,
    V_ANSWER ,
    V_AUTH ,
    V_FLAG ,
    V_MOD .
    MESSAGE TEXT-S03 TYPE C_S.
  ELSE.
    LEAVE PROGRAM.
    SET SCREEN 0.
    LEAVE SCREEN.
  ENDIF.
ENDFORM. " F_EXIT_PROGRAM
*&---------------------------------------------------------------------*
*& Form F_BUILD_FIELD_CATELOG
*&---------------------------------------------------------------------*
* Preparing the field catalogue
*----------------------------------------------------------------------*
FORM F_BUILD_FIELD_CATELOG .
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      I_STRUCTURE_NAME = 'zproxy'
    CHANGING
      CT_FIELDCAT      = I_FIELDCAT[].
  LOOP AT I_FIELDCAT INTO WA_FIELDCAT." WHERE key NE c_check.
* The key field znumber cannot be modified.
    IF ( NOT WA_FIELDCAT-FIELDNAME EQ TEXT-D02 ) . " Changes by Ajith for 8888802400 .
      WA_FIELDCAT-EDIT = C_CHECK.
      IF WA_FIELDCAT-FIELDNAME EQ 'ZSTATUS'.
        WA_FIELDCAT-OUTPUTLEN = 10.
        WA_FIELDCAT-LZERO = C_CHECK.
      ELSEIF WA_FIELDCAT-FIELDNAME EQ 'ZTEXT'.
        WA_FIELDCAT-OUTPUTLEN = 33.
      ELSEIF WA_FIELDCAT-FIELDNAME EQ 'KUNNR'.
        WA_FIELDCAT-LOWERCASE = SPACE.
      ELSEIF WA_FIELDCAT-FIELDNAME EQ 'KUNNR_NAME'. " Perform added by ashwin for solman 8888802637
        WA_FIELDCAT-LZERO = C_CHECK.
      ENDIF.
      MODIFY I_FIELDCAT FROM WA_FIELDCAT.
    ENDIF. "wa_fieldcat-fieldname EQ text-D02 " Changes by Ajith for 8888802400
  ENDLOOP.
ENDFORM. " F_BUILD_FIELD_CATELOG
*&---------------------------------------------------------------------*
*& Form f_refresh_table_display
*&---------------------------------------------------------------------*
FORM F_REFRESH_TABLE_DISPLAY.
**--
  DATA : LI_STABLE TYPE LVC_S_STBL.
  LI_STABLE-ROW = C_CHECK.
  LI_STABLE-COL = C_CHECK.
**-- if alv is container/grid is already created then refresh it.
  CALL METHOD V_GRID2->REFRESH_TABLE_DISPLAY
    EXPORTING
      IS_STABLE      = LI_STABLE
      I_SOFT_REFRESH = C_CHECK
    EXCEPTIONS
      FINISHED       = 1
      OTHERS         = 2.
  CLEAR : LI_STABLE.
ENDFORM. " f_refresh_table_display
*&---------------------------------------------------------------------*
*& Form F_ADD_BLANK_LINE
*&---------------------------------------------------------------------*
* Add a blank line
*----------------------------------------------------------------------*
FORM F_ADD_BLANK_LINE .
  DATA: LI_CELLTAB TYPE LVC_T_STYL.
  DATA: LWA_OUTTAB TYPE TY_OUTTAB.
  PERFORM F_CHANGE_STYLE USING 'ZPN'
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING 'KUNNR'
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING 'KUNNR_NAME' " Perform added by ashwin for solman 8888802637
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING 'ZSDATE'
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING 'ZEDATE'
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING 'ZNAME'
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING 'ZTEXT'
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING TEXT-T17
  CHANGING LI_CELLTAB.
  PERFORM F_CHANGE_STYLE USING 'ZSTATN'
  CHANGING LI_CELLTAB.
  INSERT LINES OF LI_CELLTAB INTO TABLE LWA_OUTTAB-CELLTAB.
* setting the proxy status to default value 0 / not approved
  LWA_OUTTAB-ZSTATUS = '0'.
  LWA_OUTTAB-ZSTATN = TEXT-T08.
* Start of changes by Ajith for Solman 8888802400
* Get a unique key for Internal Unique number
  PERFORM GET_UNIQUE_KEY.
  CONCATENATE V_PROXY1 V_PROXY2 INTO LWA_OUTTAB-ZNUMBER. " Concatenate 10 digit unique numbers to get Internal Unique Number
* End of changes by Ajith for Solman 8888802400
  APPEND LWA_OUTTAB TO I_OUTTAB.
  CLEAR:LWA_OUTTAB,
  LI_CELLTAB.
  REFRESH:LI_CELLTAB.
  CALL METHOD V_GRID2->CHECK_CHANGED_DATA.
  PERFORM F_REFRESH_TABLE_DISPLAY.
* Set editable cells to ready for input initially
  CALL METHOD V_GRID2->SET_READY_FOR_INPUT
    EXPORTING
      I_READY_FOR_INPUT = 1.
* add an entry in insterted rows table as it is not happening
* automatically.
  CLEAR WA_INSERTED_ROWS.
  DESCRIBE TABLE I_OUTTAB LINES WA_INSERTED_ROWS-ROW_ID.
  WA_INSERTED_ROWS-COL_ID = -1.
  APPEND WA_INSERTED_ROWS TO I_INSERTED_ROWS.
ENDFORM. " F_ADD_BLANK_LINE
*&---------------------------------------------------------------------*
*& Form F_CHANGE_STYLE
*&---------------------------------------------------------------------*
* For changing the style of ALV grid fileds
*----------------------------------------------------------------------*
FORM F_CHANGE_STYLE USING P_FIELD TYPE LVC_S_STYL-FIELDNAME
CHANGING P_LI_CELLTAB TYPE LVC_T_STYL .
  DATA: LWA_CELL_STYLE TYPE LVC_S_STYL.
  DELETE P_LI_CELLTAB WHERE FIELDNAME = P_FIELD.
  LWA_CELL_STYLE-FIELDNAME = P_FIELD.
  IF P_FIELD EQ 'ZSTATN'.
    LWA_CELL_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
  ELSEIF ( P_FIELD EQ 'ZSTATUS' AND V_AUTH1 EQ C_CHECK ).
    LWA_CELL_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
  ELSEIF ( P_FIELD EQ 'KUNNR_NAME' ). " Perform added by ashwin for solman 8888802637
    LWA_CELL_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED." Perform added by ashwin for solman 8888802637
  ELSE.
    LWA_CELL_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
  ENDIF.
  INSERT LWA_CELL_STYLE INTO TABLE P_LI_CELLTAB.
ENDFORM. " F_CHANGE_STYLE
*&---------------------------------------------------------------------*
*& Form F_UPDATE_DATABASE
*&---------------------------------------------------------------------*
* Updating the database with inserted or deleted rows
*----------------------------------------------------------------------*
FORM F_UPDATE_DATABASE .
  DATA: "LI_del_rows TYPE TABLE OF zproxy,
  LWA_DEL_ROWS TYPE ZPROXY,
  LI_MOD_ROWS TYPE TABLE OF ZPROXY,
* lwa_mod_rows TYPE zproxy,
  L_RETURN TYPE FLAG,
* l_ins_keys TYPE v_event_receiver->zproxy_keys,
* l_ins_key TYPE v_event_receiver->ty_zproxy_key,
* li_zproxy TYPE STANDARD TABLE OF zproxy,
  LI_ZPROXY_1 TYPE STANDARD TABLE OF ZPROXY,
* li_zproxy_2 TYPE STANDARD TABLE OF zproxy,
  LWA_ZPROXY TYPE ZPROXY,
  LWA_ZPROXY1 TYPE ZPROXY,
  LWA_ZPROXY2 TYPE ZPROXY.
*
* LOOP AT i_outtab INTO wa_outtab.
* MOVE-CORRESPONDING wa_outtab TO lwa_mod_rows .
* APPEND lwa_mod_rows TO li_mod_rows.
* CLEAR: lwa_mod_rows,
* wa_outtab.
* ENDLOOP.
* Deleted rows should be detected and deleted from the database.
* 1.Delete Lines:
* CALL METHOD v_event_receiver->get_deleted_rows
* IMPORTING
* deleted_rows = LI_del_rows.
  DELETE ADJACENT DUPLICATES FROM I_DELETED_ROWS COMPARING ZPN.
  LOOP AT I_DELETED_ROWS INTO LWA_DEL_ROWS.
    PERFORM F_ENQUEUE_OBECT USING LWA_DEL_ROWS-ZNUMBER " changes by Ajith for Solman 8888802400
    CHANGING L_RETURN.
    IF L_RETURN IS INITIAL.
      DELETE ZPROXY FROM LWA_DEL_ROWS.
      PERFORM F_DEQUEUE_OBECT USING LWA_DEL_ROWS-ZNUMBER. " changes by Ajith for Solman 8888802400
      CLEAR L_RETURN.
    ENDIF.
  ENDLOOP.
*Insert rows
  LOOP AT I_OUTTAB INTO WA_OUTTAB.
    SELECT SINGLE * FROM ZPROXY INTO LWA_ZPROXY WHERE ZNUMBER = WA_OUTTAB-ZNUMBER. " changes by Ajith for Solman 8888802400
    IF SY-SUBRC EQ 0.
      MOVE-CORRESPONDING WA_OUTTAB TO LWA_ZPROXY2.
      APPEND LWA_ZPROXY2 TO LI_MOD_ROWS.
    ELSE.
      MOVE-CORRESPONDING WA_OUTTAB TO LWA_ZPROXY1.
      APPEND LWA_ZPROXY1 TO LI_ZPROXY_1.
    ENDIF.
  ENDLOOP.
* Manju
  IF LI_ZPROXY_1[] IS NOT INITIAL.
    INSERT ZPROXY FROM TABLE LI_ZPROXY_1.
  ENDIF.
* Manju
  MODIFY ZPROXY FROM TABLE LI_MOD_ROWS[].
  CALL METHOD V_EVENT_RECEIVER->REFRESH_DELTA_TABLES.
  MESSAGE TEXT-S04 TYPE C_S.
  CLEAR: LWA_DEL_ROWS,
  LI_MOD_ROWS ,
  LWA_ZPROXY ,
  LWA_ZPROXY1 ,
  LWA_ZPROXY2.
  REFRESH: LI_ZPROXY_1,
  LI_MOD_ROWS.
ENDFORM. " F_UPDATE_DATABASE
*&---------------------------------------------------------------------*
*& Form F_HANDLE_DATACHANGE
*&---------------------------------------------------------------------*
* Form for validating entered data
*----------------------------------------------------------------------*
FORM F_HANDLE_DATACHANGE USING P_WA_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
  DATA: LI_MOD_CELLS TYPE LVC_T_MODI,
  LI_ALV_TABLE TYPE STANDARD TABLE OF TY_OUTTAB.
  DATA: L_ZPN TYPE ZPROXY-ZPN,
  L_KUNNR1 TYPE KUNNR,                                      "#EC NEEDED
  L_KUNNR TYPE KUNNR,
* lwa_status TYPE zstatus,
  L_EDATE TYPE DATS,
  L_SDATE TYPE DATS,
  L_EDATE1 TYPE CHAR10,
  L_SDATE1 TYPE CHAR10.
  DATA: LI_CELLTAB TYPE LVC_T_STYL.
  DATA: LWA_CELLTAB TYPE LVC_S_STYL,
  L_MODE TYPE RAW4,
  L_MODE1 TYPE RAW4.
  L_MODE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
  L_MODE1 = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
  FIELD-SYMBOLS: <LFS_IALV_TABLE> LIKE LI_ALV_TABLE,
  <LFS_ALV_TABLE_ORI> TYPE TY_OUTTAB,
  <LFS_MOD_CELLS> TYPE LVC_S_MODI,
  <LFS_ALV_TABLE> TYPE TY_OUTTAB.
* Old data
  LI_ALV_TABLE = I_OUTTAB.
* Get changed cells.
  LI_MOD_CELLS = P_WA_DATA_CHANGED->MT_MOD_CELLS.
* Assigning Changed Rows.
  ASSIGN P_WA_DATA_CHANGED->MP_MOD_ROWS->* TO <LFS_IALV_TABLE>.
* Find which row n column the data is changed.
  LOOP AT LI_MOD_CELLS ASSIGNING <LFS_MOD_CELLS>.
    LOOP AT <LFS_IALV_TABLE> ASSIGNING <LFS_ALV_TABLE>.
      CASE <LFS_MOD_CELLS>-FIELDNAME.
* validating Proxy Number
        WHEN 'ZPN'.
* v_flag = 1.
          IF <LFS_MOD_CELLS>-VALUE IS NOT INITIAL.
            SELECT SINGLE ZPN
            FROM ZPROXY
            INTO L_ZPN
            WHERE ZPN EQ <LFS_MOD_CELLS>-VALUE
*begin AShan
            AND KUNNR EQ <LFS_ALV_TABLE>-KUNNR
            AND ZSDATE EQ <LFS_ALV_TABLE>-ZSDATE
            AND ZEDATE EQ <LFS_ALV_TABLE>-ZEDATE
            AND ZNAME EQ <LFS_ALV_TABLE>-ZNAME.
*end AShan
            IF SY-SUBRC IS INITIAL .
              PERFORM F_ADD_PROTOCOL_ERROR USING
              P_WA_DATA_CHANGED
              TEXT-E07
              <LFS_MOD_CELLS>-VALUE
              TEXT-E08
              ''
              <LFS_MOD_CELLS>-FIELDNAME
              <LFS_MOD_CELLS>-ROW_ID.
              V_ERROR_IN_DATA = C_CHECK.
            ENDIF.
            CLEAR L_ZPN.
*begin AShan
            IF <LFS_MOD_CELLS>-VALUE = TEXT-T18.
              READ TABLE I_OUTTAB ASSIGNING <LFS_ALV_TABLE_ORI> INDEX
              <LFS_MOD_CELLS>-ROW_ID.
              IF SY-SUBRC EQ 0.
                <LFS_ALV_TABLE_ORI>-ZPN = <LFS_MOD_CELLS>-VALUE.
                <LFS_ALV_TABLE_ORI>-ZSTATUS = 1.
                <LFS_ALV_TABLE_ORI>-ZSTATN = TEXT-T15.
                PERFORM F_POPULATE_VALUES USING P_WA_DATA_CHANGED
                <LFS_MOD_CELLS>-ROW_ID
                <LFS_MOD_CELLS>-TABIX
                <LFS_ALV_TABLE_ORI>.
              ENDIF.
            ENDIF.
*end AShan
          ENDIF.
* validating Customer
        WHEN 'KUNNR'.
          L_KUNNR = <LFS_MOD_CELLS>-VALUE.
          TRANSLATE L_KUNNR TO UPPER CASE.               "#EC TRANSLANG
          IF <LFS_MOD_CELLS>-VALUE IS NOT INITIAL.
* Conversion Exit for KUNNR
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = L_KUNNR
              IMPORTING
                OUTPUT = L_KUNNR.
            SELECT SINGLE KUNNR
            FROM KNA1
            INTO L_KUNNR1
            WHERE KUNNR = L_KUNNR.
            CLEAR: L_KUNNR1,
            L_KUNNR.
            IF SY-SUBRC IS NOT INITIAL.
              PERFORM F_ADD_PROTOCOL_ERROR USING
              P_WA_DATA_CHANGED
              TEXT-E09
              <LFS_MOD_CELLS>-VALUE
              TEXT-E10
              ''
              <LFS_MOD_CELLS>-FIELDNAME
              <LFS_MOD_CELLS>-ROW_ID.
              V_ERROR_IN_DATA = C_CHECK.
              CLEAR: L_KUNNR1,
              L_KUNNR.
            ENDIF.
          ENDIF.
* validating Proxy Status
        WHEN 'ZSTATUS'.
          DATA L_STATUS TYPE ZPROXY-ZSTATUS.
          L_STATUS = <LFS_MOD_CELLS>-VALUE.
          READ TABLE I_OUTTAB ASSIGNING <LFS_ALV_TABLE_ORI> INDEX
          <LFS_MOD_CELLS>-ROW_ID.
          <LFS_ALV_TABLE_ORI>-ZSTATUS = L_STATUS.
          IF L_STATUS EQ 0.
* <lfs_alv_table_ori>-zstatn = text-t14.
            <LFS_ALV_TABLE_ORI>-ZSTATN = TEXT-T19. " Jaya - Solman 8888801423 - 3rd Feb'09
          ELSEIF L_STATUS EQ 1.
* <lfs_alv_table_ori>-zstatn = text-t15.
            <LFS_ALV_TABLE_ORI>-ZSTATN = TEXT-T20. " Jaya - Solman 8888801423 - 3rd Feb'09
          ELSEIF L_STATUS EQ 2.
* <lfs_alv_table_ori>-zstatn = text-t16.
            <LFS_ALV_TABLE_ORI>-ZSTATN = TEXT-T21. " Jaya - Solman 8888801423 - 3rd Feb'09
          ENDIF.
          IF <LFS_ALV_TABLE_ORI>-ZSTATUS EQ 0.
*****For making the rows editable uf the status is changed to 0.
            SELECT SINGLE ZPN INTO L_ZPN FROM ZPROXY WHERE ZPN EQ <LFS_ALV_TABLE_ORI>-ZPN
*begin AShan
            AND KUNNR EQ <LFS_ALV_TABLE_ORI>-KUNNR
            AND ZSDATE EQ <LFS_ALV_TABLE_ORI>-ZSDATE
            AND ZEDATE EQ <LFS_ALV_TABLE_ORI>-ZEDATE
            AND ZNAME EQ <LFS_ALV_TABLE_ORI>-ZNAME.
*end AShan
            IF SY-SUBRC NE 0.
              READ TABLE I_OUTTAB INTO WA_OUTTAB INDEX
              <LFS_MOD_CELLS>-ROW_ID.
              IF WA_OUTTAB-ZSTATUS IS INITIAL
              AND V_AUTH = C_CHECK.
                LWA_CELLTAB-FIELDNAME = 'ZPN'.
                LWA_CELLTAB-STYLE = L_MODE1.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                CLEAR LWA_CELLTAB.
                LWA_CELLTAB-FIELDNAME = TEXT-T17.
                LWA_CELLTAB-STYLE = L_MODE1.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                LWA_CELLTAB-FIELDNAME = 'KUNNR'.
                LWA_CELLTAB-STYLE = L_MODE1.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                CLEAR LWA_CELLTAB.
                LWA_CELLTAB-FIELDNAME = 'ZSDATE'.
                LWA_CELLTAB-STYLE = L_MODE1.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                CLEAR LWA_CELLTAB.
                LWA_CELLTAB-FIELDNAME = 'ZEDATE'.
                LWA_CELLTAB-STYLE = L_MODE1.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                CLEAR LWA_CELLTAB.
                LWA_CELLTAB-FIELDNAME = 'ZNAME'.
                LWA_CELLTAB-STYLE = L_MODE1.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                CLEAR LWA_CELLTAB.
                LWA_CELLTAB-FIELDNAME = 'ZTEXT'.
                LWA_CELLTAB-STYLE = L_MODE1.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                CLEAR LWA_CELLTAB.
                LWA_CELLTAB-FIELDNAME = 'ZSTATN'.
                LWA_CELLTAB-STYLE = L_MODE.
                INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
                CLEAR LWA_CELLTAB.
              ENDIF.
              <LFS_ALV_TABLE_ORI>-CELLTAB = LI_CELLTAB .
              CLEAR LI_CELLTAB.
              REFRESH LI_CELLTAB.
              CLEAR: WA_OUTTAB.
              PERFORM F_REFRESH_TABLE_DISPLAY.
            ENDIF.
            CLEAR L_ZPN.
          ENDIF.
*begin AShan
          <LFS_ALV_TABLE_ORI>-ZPN = <LFS_ALV_TABLE>-ZPN.
          <LFS_ALV_TABLE_ORI>-KUNNR = <LFS_ALV_TABLE>-KUNNR.
          <LFS_ALV_TABLE_ORI>-ZSDATE = <LFS_ALV_TABLE>-ZSDATE.
          <LFS_ALV_TABLE_ORI>-ZEDATE = <LFS_ALV_TABLE>-ZEDATE.
          <LFS_ALV_TABLE_ORI>-ZNAME = <LFS_ALV_TABLE>-ZNAME.
          <LFS_ALV_TABLE_ORI>-ZTEXT = <LFS_ALV_TABLE>-ZTEXT.
*end AShan
          PERFORM F_POPULATE_VALUES USING P_WA_DATA_CHANGED
          <LFS_MOD_CELLS>-ROW_ID
          <LFS_MOD_CELLS>-TABIX
          <LFS_ALV_TABLE_ORI>.
          CLEAR L_STATUS.
* validating start date
        WHEN 'ZSDATE'.
          IF <LFS_MOD_CELLS>-VALUE IS NOT INITIAL.
            L_SDATE1 = <LFS_MOD_CELLS>-VALUE.
* conversion exit for date
            CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'
              EXPORTING
                INPUT  = L_SDATE1
              IMPORTING
                OUTPUT = L_SDATE.
* REPLACE ALL OCCURRENCES OF '.' IN l_sdate WITH '/'.
            READ TABLE I_OUTTAB ASSIGNING <LFS_ALV_TABLE_ORI> INDEX
            <LFS_MOD_CELLS>-ROW_ID.
            IF SY-SUBRC IS INITIAL
            AND <LFS_ALV_TABLE_ORI>-ZEDATE IS NOT INITIAL.
              IF L_SDATE GT <LFS_ALV_TABLE_ORI>-ZEDATE.
* conversion exit for date
                CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
                  EXPORTING
                    INPUT  = <LFS_ALV_TABLE_ORI>-ZEDATE
                  IMPORTING
                    OUTPUT = L_EDATE1.
                CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
                  EXPORTING
                    INPUT  = L_SDATE
                  IMPORTING
                    OUTPUT = L_SDATE1.
* REPLACE ALL OCCURRENCES OF '.' IN l_edate1 WITH '/'.
                PERFORM F_ADD_PROTOCOL_ERROR USING
                P_WA_DATA_CHANGED
                TEXT-E14
                L_SDATE1
                TEXT-E15
                L_EDATE1
                <LFS_MOD_CELLS>-FIELDNAME
                <LFS_MOD_CELLS>-ROW_ID.
                V_ERROR_IN_DATA = C_CHECK.
                CLEAR: L_SDATE,
                L_SDATE1,
                L_EDATE1.
              ENDIF.
            ENDIF.
          ENDIF.
* validating end date
        WHEN 'ZEDATE'.
          IF <LFS_MOD_CELLS>-VALUE IS NOT INITIAL.
            L_EDATE1 = <LFS_MOD_CELLS>-VALUE.
* conversion exit for date
            CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'
              EXPORTING
                INPUT  = L_EDATE1
              IMPORTING
                OUTPUT = L_EDATE.
* REPLACE ALL OCCURRENCES OF '.' IN l_edate WITH '/'.
            READ TABLE I_OUTTAB ASSIGNING <LFS_ALV_TABLE_ORI> INDEX
            <LFS_MOD_CELLS>-ROW_ID.
            IF SY-SUBRC IS INITIAL
            AND <LFS_ALV_TABLE_ORI>-ZSDATE IS NOT INITIAL .
              IF L_EDATE LT <LFS_ALV_TABLE_ORI>-ZSDATE.
* conversion exit for date
                CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
                  EXPORTING
                    INPUT  = <LFS_ALV_TABLE_ORI>-ZSDATE
                  IMPORTING
                    OUTPUT = L_SDATE1.
* REPLACE ALL OCCURRENCES OF '.' IN l_sdate1 WITH '/'.
                CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
                  EXPORTING
                    INPUT  = L_EDATE
                  IMPORTING
                    OUTPUT = L_EDATE1.
                PERFORM F_ADD_PROTOCOL_ERROR USING
                P_WA_DATA_CHANGED
                TEXT-E16
                L_EDATE1
                TEXT-E17
                L_SDATE1
                <LFS_MOD_CELLS>-FIELDNAME
                <LFS_MOD_CELLS>-ROW_ID.
                V_ERROR_IN_DATA = C_CHECK.
                CLEAR: L_EDATE,
                L_EDATE1,
                L_SDATE1.
              ENDIF.
            ENDIF.
          ENDIF.
        WHEN 'ZSTATN'.
          READ TABLE I_OUTTAB ASSIGNING <LFS_ALV_TABLE_ORI> INDEX
          <LFS_MOD_CELLS>-ROW_ID.
          L_STATUS = <LFS_ALV_TABLE_ORI>-ZSTATUS .
          IF L_STATUS EQ 0.
            <LFS_ALV_TABLE_ORI>-ZSTATN = TEXT-T14.
          ELSEIF L_STATUS EQ 1.
            <LFS_ALV_TABLE_ORI>-ZSTATN = TEXT-T15.
          ELSEIF L_STATUS EQ 2.
            <LFS_ALV_TABLE_ORI>-ZSTATN = TEXT-T16.
          ENDIF.
*begin AShan
          <LFS_ALV_TABLE_ORI>-ZPN = <LFS_ALV_TABLE>-ZPN.
          <LFS_ALV_TABLE_ORI>-KUNNR = <LFS_ALV_TABLE>-KUNNR.
          <LFS_ALV_TABLE_ORI>-ZSDATE = <LFS_ALV_TABLE>-ZSDATE.
          <LFS_ALV_TABLE_ORI>-ZEDATE = <LFS_ALV_TABLE>-ZEDATE.
          <LFS_ALV_TABLE_ORI>-ZNAME = <LFS_ALV_TABLE>-ZNAME.
          <LFS_ALV_TABLE_ORI>-ZTEXT = <LFS_ALV_TABLE>-ZTEXT.
*end AShan
          PERFORM F_POPULATE_VALUES USING P_WA_DATA_CHANGED
          <LFS_MOD_CELLS>-ROW_ID
          <LFS_MOD_CELLS>-TABIX
          <LFS_ALV_TABLE_ORI>.
          CLEAR L_STATUS.
      ENDCASE.
    ENDLOOP.
  ENDLOOP.
  CLEAR WA_OUTTAB.
  REFRESH LI_CELLTAB.
  LOOP AT I_OUTTAB INTO WA_OUTTAB.
    IF WA_OUTTAB-CELLTAB IS INITIAL.
      LWA_CELLTAB-FIELDNAME = 'ZSTATN'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      IF V_AUTH1 EQ C_CHECK.
        LWA_CELLTAB-FIELDNAME = 'ZSTATUS'.
        LWA_CELLTAB-STYLE = L_MODE.
        INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      ENDIF.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      INSERT LINES OF LI_CELLTAB INTO TABLE WA_OUTTAB-CELLTAB.
      MODIFY I_OUTTAB INDEX SY-TABIX FROM WA_OUTTAB TRANSPORTING CELLTAB.
      REFRESH LI_CELLTAB.
      PERFORM F_REFRESH_TABLE_DISPLAY.
    ENDIF.
* IF sy-subrc IS INITIAL.
* PERFORM f_refresh_table_display.
* ENDIF.
  ENDLOOP.
  CLEAR : LI_MOD_CELLS,
  LI_ALV_TABLE.
  REFRESH : LI_MOD_CELLS,
  LI_ALV_TABLE.
ENDFORM. " F_HANDLE_DATACHANGE
*&---------------------------------------------------------------------*
*& Form F_ENQUEUE_OBECT
*&---------------------------------------------------------------------*
* form for locking
*----------------------------------------------------------------------*
FORM F_ENQUEUE_OBECT USING P_ZNUMBER TYPE ZPROXY-ZNUMBER " changes by Ajith for Solman 8888802400
CHANGING P_L_RETURN TYPE FLAG.
  CALL FUNCTION 'ENQUEUE_EZPROXY'
    EXPORTING
      MODE_ZPROXY    = 'E'
      ZNUMBER        = P_ZNUMBER " changes by Ajith for Solman 8888802400
    EXCEPTIONS
      FOREIGN_LOCK   = 1
      SYSTEM_FAILURE = 2
      OTHERS         = 3.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    P_L_RETURN = SY-SUBRC.
  ENDIF.
ENDFORM. " F_ENQUEUE_OBECT
*&---------------------------------------------------------------------*
*& Form F_DEQUEUE_OBECT
*&---------------------------------------------------------------------*
* form for unlocking
*----------------------------------------------------------------------*
FORM F_DEQUEUE_OBECT USING P_ZNUMBER TYPE ZPROXY-ZNUMBER. " changes by Ajith for Solman 8888802400
  CALL FUNCTION 'DEQUEUE_EZPROXY'
    EXPORTING
      MODE_ZPROXY = 'E'
      ZNUMBER     = P_ZNUMBER.
ENDFORM. " F_DEQUEUE_OBECT
*&---------------------------------------------------------------------*
*& Form F_ADD_PROTOCOL_ERROR
*&---------------------------------------------------------------------*
* Form for adding errors to protocol stack
*----------------------------------------------------------------------*
FORM F_ADD_PROTOCOL_ERROR USING P_WA_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL
P_MSGV1 TYPE ANY
P_MSGV2 TYPE ANY
P_MSGV3 TYPE ANY
P_MSGV4 TYPE ANY
P_FIELDNAME TYPE ANY
P_ROW_ID TYPE ANY.
  CALL METHOD P_WA_DATA_CHANGED->ADD_PROTOCOL_ENTRY
    EXPORTING
      I_MSGID     = '0K'
      I_MSGNO     = '000'
      I_MSGTY     = 'E'
      I_MSGV1     = P_MSGV1
      I_MSGV2     = P_MSGV2
      I_MSGV3     = P_MSGV3
      I_MSGV4     = P_MSGV4
      I_FIELDNAME = P_FIELDNAME
      I_ROW_ID    = P_ROW_ID.
ENDFORM. " F_ADD_PROTOCOL_ERROR
*&---------------------------------------------------------------------*
*& Form F_SET_REGISTER_EDIT_EVENT
*&---------------------------------------------------------------------*
FORM F_SET_REGISTER_EDIT_EVENT USING PW_GRID TYPE REF TO
CL_GUI_ALV_GRID.
  CALL METHOD PW_GRID->REGISTER_EDIT_EVENT
    EXPORTING
      I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER
    EXCEPTIONS
      ERROR      = 1
      OTHERS     = 2.
  CALL METHOD PW_GRID->REGISTER_EDIT_EVENT
    EXPORTING
      I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
    EXCEPTIONS
      ERROR      = 1
      OTHERS     = 2.
ENDFORM. " F_SET_REGISTER_EDIT_EVENT
*&---------------------------------------------------------------------*
*& Form F_SET_EDITABLE
*&---------------------------------------------------------------------*
* setting the fields to editable mode
*----------------------------------------------------------------------*
FORM F_SET_EDITABLE .
  DATA: LI_CELLTAB TYPE LVC_T_STYL.
  DATA: LWA_CELLTAB TYPE LVC_S_STYL,
  L_MODE TYPE RAW4,
  L_MODE1 TYPE RAW4.
  L_MODE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
  L_MODE1 = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
  CLEAR WA_OUTTAB.
*START: Insert - Manjunatha Kodagi - 8888801423 - 23/Jan/2009
* Change the wa_outtab-celltab entries to initial
  LOOP AT I_OUTTAB INTO WA_OUTTAB.
    IF WA_OUTTAB-CELLTAB IS NOT INITIAL.
      REFRESH WA_OUTTAB-CELLTAB.
      MODIFY I_OUTTAB FROM WA_OUTTAB.
    ENDIF.
  ENDLOOP.
* END: Insert - Manjunatha Kodagi - 8888801423 - 23/Jan/2009
  LOOP AT I_OUTTAB INTO WA_OUTTAB .
**Begin of change - Jaya - 8888801423 - 28/Jan/2009
* lwa_celltab-fieldname = 'ZPN'.
* lwa_celltab-style = l_mode.
* INSERT lwa_celltab INTO TABLE li_celltab.
**End of change - Jaya - 8888801423 - 28/Jan/2009
    CLEAR LWA_CELLTAB.
    LWA_CELLTAB-FIELDNAME = 'KUNNR_NAME'. " Perform added by ashwin for solman 8888802637
    LWA_CELLTAB-STYLE = L_MODE.
    INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
    CLEAR LWA_CELLTAB.
* IF wa_outtab-zstatus IS NOT INITIAL. "8888801423 - Manju - 21/Jan/2009
    IF WA_OUTTAB-ZSTATUS <> '0'. "8888801423 - Manju - 21/Jan/2009
      IF ( V_AUTH EQ C_CHECK ).
        LWA_CELLTAB-FIELDNAME = TEXT-T17.
        LWA_CELLTAB-STYLE = L_MODE1.
        INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      ELSEIF ( V_AUTH1 EQ C_CHECK ).
        LWA_CELLTAB-FIELDNAME = TEXT-T17.
        LWA_CELLTAB-STYLE = L_MODE.
        INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      ENDIF.
**Begin of change - Jaya - 8888801423 - 28/Jan/2009
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZPN'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
**End of change - Jaya - 8888801423 - 28/Jan/2009
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'KUNNR'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZSDATE'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZEDATE'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZNAME'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZTEXT'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZSTATN'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
* ELSEIF wa_outtab-zstatus IS INITIAL. "8888801423 - Manju - 21/Jan/2009
    ELSEIF WA_OUTTAB-ZSTATUS = '0'. "8888801423 - Manju - 21/Jan/2009
      IF ( V_AUTH EQ C_CHECK ).
        LWA_CELLTAB-FIELDNAME = TEXT-T17.
        LWA_CELLTAB-STYLE = L_MODE1.
        INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      ELSEIF ( V_AUTH1 EQ C_CHECK ).
        LWA_CELLTAB-FIELDNAME = TEXT-T17.
        LWA_CELLTAB-STYLE = L_MODE.
        INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      ENDIF.
**Begin of change - Jaya - 8888801423 - 28/Jan/2009
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZPN'.
      LWA_CELLTAB-STYLE = L_MODE1.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
**End of change - Jaya - 8888801423 - 28/Jan/2009
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'KUNNR'.
      LWA_CELLTAB-STYLE = L_MODE1.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZSDATE'.
      LWA_CELLTAB-STYLE = L_MODE1.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZEDATE'.
      LWA_CELLTAB-STYLE = L_MODE1.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZNAME'.
      LWA_CELLTAB-STYLE = L_MODE1.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZTEXT'.
      LWA_CELLTAB-STYLE = L_MODE1.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZSTATN'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
    ELSEIF V_AUTH NE C_CHECK.
      LWA_CELLTAB-FIELDNAME = TEXT-T17.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'KUNNR'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZSDATE'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZEDATE'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZNAME'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZTEXT'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
      LWA_CELLTAB-FIELDNAME = 'ZSTATN'.
      LWA_CELLTAB-STYLE = L_MODE.
      INSERT LWA_CELLTAB INTO TABLE LI_CELLTAB.
      CLEAR LWA_CELLTAB.
    ENDIF.
    INSERT LINES OF LI_CELLTAB INTO TABLE WA_OUTTAB-CELLTAB.
    MODIFY I_OUTTAB FROM WA_OUTTAB.
    CLEAR LI_CELLTAB.
    REFRESH LI_CELLTAB.
    CLEAR: WA_OUTTAB.
  ENDLOOP.
ENDFORM. " F_SET_EDITABLE
*&---------------------------------------------------------------------*
*& Form F_POPULATE_VALUES
*&---------------------------------------------------------------------*
* populate values in respective fields
*----------------------------------------------------------------------*
FORM F_POPULATE_VALUES USING P_WA_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL
P_ROW_ID TYPE ANY
P_TABIX TYPE ANY
P_ALV_TABLE_ORI TYPE TY_OUTTAB.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'ZPN'
      I_VALUE     = P_ALV_TABLE_ORI-ZPN.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'KUNNR'
      I_VALUE     = P_ALV_TABLE_ORI-KUNNR.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'ZSDATE'
      I_VALUE     = P_ALV_TABLE_ORI-ZSDATE.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'ZEDATE'
      I_VALUE     = P_ALV_TABLE_ORI-ZEDATE.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'ZNAME'
      I_VALUE     = P_ALV_TABLE_ORI-ZNAME.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'ZTEXT'
      I_VALUE     = P_ALV_TABLE_ORI-ZTEXT.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'ZSTATUS'
      I_VALUE     = P_ALV_TABLE_ORI-ZSTATUS.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'ZSTATN'
      I_VALUE     = P_ALV_TABLE_ORI-ZSTATN.
  CALL METHOD P_WA_DATA_CHANGED->MODIFY_CELL
    EXPORTING
      I_ROW_ID    = P_ROW_ID
      I_TABIX     = P_TABIX
      I_FIELDNAME = 'CELLTAB'
      I_VALUE     = P_ALV_TABLE_ORI-CELLTAB.
ENDFORM. " F_POPULATE_VALUES
*&---------------------------------------------------------------------*
*& Form F_VALIDATIONS
*&---------------------------------------------------------------------*
* Validation for Primary fields
*----------------------------------------------------------------------*
FORM F_VALIDATIONS .
  DATA: L_MSG TYPE CHAR200.
  CLEAR: WA_OUTTAB,
  V_ERROR_IN_DATA.
  LOOP AT I_OUTTAB INTO WA_OUTTAB.
    IF WA_OUTTAB-ZPN IS INITIAL
    OR WA_OUTTAB-KUNNR IS INITIAL
    OR WA_OUTTAB-ZSDATE IS INITIAL
    OR WA_OUTTAB-ZEDATE IS INITIAL
    OR WA_OUTTAB-ZNAME IS INITIAL .
      IF WA_OUTTAB-ZPN IS INITIAL.
        MOVE TEXT-E07 TO L_MSG.
      ENDIF.
      IF WA_OUTTAB-KUNNR IS INITIAL.
        CONCATENATE L_MSG TEXT-E09 ',' INTO L_MSG SEPARATED BY SPACE.
      ENDIF.
      IF WA_OUTTAB-ZSDATE IS INITIAL.
        CONCATENATE L_MSG TEXT-E14 ',' INTO L_MSG SEPARATED BY SPACE.
      ENDIF.
      IF WA_OUTTAB-ZEDATE IS INITIAL.
        CONCATENATE L_MSG TEXT-E16 ',' INTO L_MSG SEPARATED BY SPACE.
      ENDIF.
      IF WA_OUTTAB-ZNAME IS INITIAL.
        CONCATENATE L_MSG TEXT-E22 INTO L_MSG SEPARATED BY SPACE.
      ENDIF.
      CONCATENATE TEXT-E18 L_MSG TEXT-E24 INTO L_MSG SEPARATED BY SPACE.
      MESSAGE L_MSG TYPE C_S DISPLAY LIKE 'E'.
      V_ERROR_IN_DATA = C_CHECK.
    ENDIF.
  ENDLOOP.
  CLEAR L_MSG.
ENDFORM. " F_VALIDATIONS
**&---------------------------------------------------------------------*
**& Form F_DELETE
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
** -->P_LT_ROWS text
**----------------------------------------------------------------------*
FORM F_DELETE USING P_LT_ROWS TYPE ANY TABLE.
  DATA: LWA_DEL_ROW TYPE LVC_S_ROW,
* lt_key TYPE STANDARD TABLE OF zproxy_key,
  LWA_ZPROXY TYPE ZPROXY,
  LWA_OUTTAB LIKE LINE OF I_OUTTAB,
  LI_DEL_ROWS TYPE STANDARD TABLE OF ZPROXY.
*begin AShan
* DATA l_line TYPE i.
  DATA L_STATUS_FLAG TYPE FLAG.
*end AShan
* Use protocol attributes MT_DELETED_ROWS and MT_INSERTED_ROWS
* to remember which lines where deleted or inserted. Save this
* information in your internal tables.
* deleted rows
*begin AShan
* LOOP AT p_lt_rows INTO lwa_del_row.
** lv_tabix = sy-tabix.
* READ TABLE i_outtab INTO lwa_outtab INDEX lwa_del_row-index.
* IF NOT lwa_outtab-zstatus IS INITIAL.
* l_line = l_line + 1.
* ENDIF.
* ENDLOOP.
*
* IF l_line GT 1.
* MESSAGE text-s08 TYPE c_s.
* CLEAR l_line.
* ELSE.
*end AShan
  LOOP AT P_LT_ROWS INTO LWA_DEL_ROW.
* lv_tabix = sy-tabix.
    READ TABLE I_OUTTAB INTO LWA_OUTTAB INDEX LWA_DEL_ROW-INDEX.
    IF SY-SUBRC NE 0.
      MESSAGE I000(0K) WITH TEXT-I02.
    ELSE.
*begin AShan
* IF NOT lwa_outtab-zstatus IS INITIAL
      IF LWA_OUTTAB-ZSTATUS EQ 0
*end AShan
      AND ( V_AUTH EQ C_CHECK OR V_AUTH1 EQ C_CHECK ).
        MOVE-CORRESPONDING LWA_OUTTAB TO LWA_ZPROXY.
        APPEND LWA_ZPROXY TO LI_DEL_ROWS.
        CLEAR LWA_ZPROXY.
* It is not possible that the same line is deleted twice,
* so just add the new key line to 'deleted_rows'.
*begin AShan
      ELSEIF LWA_OUTTAB-ZSTATUS GE 1
      AND L_STATUS_FLAG IS INITIAL.
        MOVE 'X' TO L_STATUS_FLAG.
*end AShan
      ENDIF.
    ENDIF.
  ENDLOOP.
*begin AShan
* ENDIF.
  IF NOT L_STATUS_FLAG IS INITIAL.
    MESSAGE TEXT-S08 TYPE C_S.
  ENDIF.
*end AShan
  LOOP AT LI_DEL_ROWS INTO LWA_ZPROXY.
* Begin of changes by Ajith for 8888802400
* DELETE i_outtab WHERE zpn = lwa_zproxy-zpn.
    DELETE I_OUTTAB WHERE ZNUMBER = LWA_ZPROXY-ZNUMBER. " Key field changed
* End of changes by Ajith for 8888802400
  ENDLOOP.
  DELETE ADJACENT DUPLICATES FROM LI_DEL_ROWS COMPARING ZPN.
  INSERT LINES OF LI_DEL_ROWS INTO TABLE I_DELETED_ROWS.
  PERFORM F_REFRESH_TABLE_DISPLAY.
  CLEAR LI_DEL_ROWS.
*begin AShan
  CLEAR L_STATUS_FLAG.
*end AShan
  REFRESH LI_DEL_ROWS.
ENDFORM. " F_DELETE
*&---------------------------------------------------------------------*
*& Form F_BACK_PROGRAM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM F_BACK_PROGRAM .
  REFRESH I_ZPROXY[].
  LOOP AT I_OUTTAB INTO WA_OUTTAB.
    MOVE-CORRESPONDING WA_OUTTAB TO WA_ZPROXY .
    APPEND WA_ZPROXY TO I_ZPROXY.
    CLEAR : WA_OUTTAB,
    WA_ZPROXY.
  ENDLOOP.
  SORT I_ZPROXY_INIT BY ZPN.
  SORT I_ZPROXY BY ZPN.
  IF I_ZPROXY_INIT NE I_ZPROXY .
    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
        TEXT_QUESTION  = TEXT-T13
      IMPORTING
        ANSWER         = V_ANSWER
      EXCEPTIONS
        TEXT_NOT_FOUND = 1
        OTHERS         = 2.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.
  IF ( V_ANSWER = '1' ).
    V_FLAG1 = 1.
    PERFORM F_SAVE_CHANGES.
    SET SCREEN 0.
    LEAVE SCREEN.
    CALL SELECTION-SCREEN '1000'.
  ELSEIF V_ANSWER = '2' .
    CLEAR:I_ZPROXY_INIT,
    I_ZPROXY,
    I_OUTTAB,
    I_INSERTED_ROWS,
    I_FIELDCAT,
    I_EXCLUDE,
    I_DELETED_ROWS,
    I_CELLTAB.
    REFRESH :I_ZPROXY_INIT,
    I_ZPROXY,
    I_OUTTAB,
    I_INSERTED_ROWS,
    I_FIELDCAT,
    I_EXCLUDE,
    I_DELETED_ROWS,
    I_CELLTAB.
    CLEAR: V_CONT1 ,
    V_CONT2 ,
    V_GRID2 ,
    V_ERROR_IN_DATA ,
    V_ANSWER ,
    V_AUTH ,
    V_FLAG ,
    V_MOD ,
    V_PROXY1, " Changes by Ajith for 8888802400
    V_PROXY2. " Changes by Ajith for 8888802400
    CLEAR ZPROXY.
                                                            "#EC NEEDED
    SET SCREEN 0.
    LEAVE SCREEN.
    CALL SELECTION-SCREEN '1000'.
  ELSEIF V_ANSWER EQ 'A'.
    CLEAR: V_CONT1 ,
    V_CONT2 ,
    V_GRID2 ,
    V_ERROR_IN_DATA ,
    V_ANSWER ,
    V_AUTH ,
    V_FLAG ,
    V_MOD .
    MESSAGE TEXT-S03 TYPE C_S.
  ELSE.
    SET SCREEN 0.
    LEAVE SCREEN.
    CALL SELECTION-SCREEN '1000'.
  ENDIF.
ENDFORM. " F_BACK_PROGRAM
* Start of changes by Ajith for Solman 8888802400
*&---------------------------------------------------------------------*
*& Form GET_UNIQUE_KEY
*&---------------------------------------------------------------------*
* Get unique key
*----------------------------------------------------------------------*
FORM GET_UNIQUE_KEY .
* Local variable declaration
  DATA : L_ZNUMBER TYPE ZPROXY-ZNUMBER,
  L_ZNUMBER1 TYPE ZPROXY-ZNUMBER.
  CLEAR : V_PROXY1,
  V_PROXY2,
  L_ZNUMBER,
  L_ZNUMBER1.
  PERFORM RANDOM_NUMBER_GEN CHANGING V_PROXY1. " Get the unique number first half
  PERFORM RANDOM_NUMBER_GEN CHANGING V_PROXY2. " Get the unique number second half
  CONCATENATE V_PROXY1 V_PROXY2 INTO L_ZNUMBER.
* Check if the key already exists in the table
  SELECT SINGLE ZNUMBER
  FROM ZPROXY
  INTO L_ZNUMBER1
  WHERE ZNUMBER EQ L_ZNUMBER.
  IF SY-SUBRC EQ 0.
    PERFORM GET_UNIQUE_KEY. " If entry exists generate a new key
  ENDIF.
ENDFORM. " GET_UNIQUE_KEY
*&---------------------------------------------------------------------*
*& Form RANDOM_NUMBER_GEN
*&---------------------------------------------------------------------*
* To generate a random number half to form unique number
*----------------------------------------------------------------------*
FORM RANDOM_NUMBER_GEN CHANGING P_V_PROXY1.
* Local variable declaration
  DATA : L_PROXY TYPE I.
  DO.
    CALL METHOD CL_ABAP_RANDOM=>SEED " Generate random number
    RECEIVING
    SEED = L_PROXY
    .
    MOVE L_PROXY TO P_V_PROXY1.
    IF P_V_PROXY1+9(1) IS INITIAL OR P_V_PROXY1(1) EQ 0. " Check if 10 digit number is not generated
      CONTINUE. " Continue generating a new number
    ELSE.
      EXIT. " Exit loop
    ENDIF.
  ENDDO.
ENDFORM. " RANDOM_NUMBER_GEN
* End of changes by Ajith for Solman 8888802400
*&---------------------------------------------------------------------*
*& Form TRIGGER_POS_UPDATE
*&---------------------------------------------------------------------*
* To send the update to ZPROXY table to POS via FM
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM TRIGGER_POS_UPDATE .
  DATA WA_ZPROXY_OLD LIKE ZPROXY.
  DATA WA_ZPROXY_NEW LIKE ZPROXY.
  DATA: I_CDTXT TYPE STANDARD TABLE OF CDTXT,
  WA_CDTXT TYPE CDTXT .
  DATA OBJECTID LIKE CDHDR-OBJECTID OCCURS 0 WITH HEADER LINE.
  DATA: I_XZPROXY TYPE STANDARD TABLE OF ZPROXY,
  I_YZPROXY TYPE STANDARD TABLE OF ZPROXY.
  DATA : WA_XZPROXY TYPE ZPROXY,
  WA_YZPROXY TYPE ZPROXY.
  CLEAR: WA_ZPROXY_NEW ,WA_ZPROXY_OLD.
  LOOP AT I_ZPROXY INTO WA_ZPROXY_NEW.
    SELECT SINGLE *
    FROM ZPROXY
    INTO WA_ZPROXY_OLD
    WHERE ZNUMBER = WA_ZPROXY_NEW-ZNUMBER. "Get actual(unchanged) data from table
    IF SY-SUBRC NE 0
    OR WA_ZPROXY_OLD <> WA_ZPROXY_NEW. " if data has been modified
      REFRESH I_CDTXT.
      CLEAR WA_CDTXT.
      WA_CDTXT-TEILOBJID = WA_ZPROXY_NEW(23). "assign key field
      WA_CDTXT-TEXTART = ''.
      WA_CDTXT-TEXTSPR = SY-LANGU.
      WA_CDTXT-UPDKZ = 'U'. " UPDATE
      APPEND WA_CDTXT TO I_CDTXT.
      REFRESH : I_XZPROXY, I_YZPROXY.
      CLEAR : WA_XZPROXY , WA_YZPROXY.
      OBJECTID = WA_ZPROXY_NEW-ZNUMBER. "Assign key field for modification
      WA_XZPROXY = WA_ZPROXY_NEW.
      APPEND WA_XZPROXY TO I_XZPROXY. "table with modified values
      WA_YZPROXY = WA_ZPROXY_OLD.
      APPEND WA_YZPROXY TO I_YZPROXY. "table with original values
      CALL FUNCTION 'ZZPROXY_WRITE_DOCUMENT' "call FM to update CDHDR and CDPOS tables
      EXPORTING
      OBJECTID = OBJECTID
      TCODE = SY-TCODE
      UTIME = SY-UZEIT
      UDATE = SY-DATUM
      USERNAME = SY-UNAME
* PLANNED_CHANGE_NUMBER = ' '
* OBJECT_CHANGE_INDICATOR = 'U'
* PLANNED_OR_REAL_CHANGES = ' '
* NO_CHANGE_POINTERS = ' '
* upd_icdtxt_zzproxy = 'X'
      UPD_ZPROXY = 'U'
      TABLES
      ICDTXT_ZZPROXY = I_CDTXT[]
      XZPROXY = I_XZPROXY[]
      YZPROXY = I_YZPROXY[] .
    ENDIF.
  ENDLOOP.
ENDFORM. " TRIGGER_POS_UPDATE
  • No labels