Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Disable Save button in Zprogram

Former Member
0 Likes
3,291

Hi Experts,

I have a zprogram development. However the save button in the tool bar is causing an error when pressed.

Does anyone know how to disable it?

The error I am getting is "Selection Screen 4000 contains no objects".

I have looked at other threads and the main solution seems to be to use the FM RS_SET_SELSCREEN_STATUS. However this is not working for me.

Here is my sample code of anyone can help:

REPORT  ztufi091                                .

*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&                                                                     *
*&                            *
*& ...................................                                 *
*&
* *Purpose of the program is to allow users to enter an order number/range and a corresponding operation number.
*If the selected combo does not already exist in zscrap_table, the program proved two alv tables where the user can place 1/multiple reason codes and quantities against the entered order/operation combo.
*&---------------------------------------------------------------------*               .
break mhurley.
TABLES:     ekko,afko,zscrap_table, aufk,caufv,jest.
TYPES:  BEGIN OF stu,
qty TYPE zscrap_table-qty,
index TYPE lvc_index,
  END OF stu.
TYPES:  BEGIN OF tab_qty,
grund TYPE co_agrnd,
grdtx TYPE co_grdtx,
qty type BMENG,
index TYPE lvc_index,
END OF tab_qty.
TYPES:  BEGIN OF tab_calc,
grund  TYPE co_agrnd,
grdtx TYPE co_grdtx,
index TYPE lvc_index,
qty TYPE bmeng,
END OF tab_calc.

DATA:gt_params TYPE TABLE OF rsparams.
DATA: BEGIN OF it_final OCCURS 0,
      orders TYPE zscrap_table-orders,
      END OF it_final.
DATA: BEGIN OF it_final_1 OCCURS 0,
orders TYPE zscrap_table-orders,
END OF it_final_1.
DATA: BEGIN OF it_final_afvc OCCURS 0,
      vornr TYPE afvc-vornr,
      ltxa1 TYPE afvc-ltxa1,
      END OF it_final_afvc.
DATA: it_return LIKE ddshretval OCCURS 0 WITH HEADER LINE,
gs_final LIKE it_final,
c_afvc(4) TYPE n,
c_orders(12) TYPE n .
DATA:
fs_itab TYPE stu,
tab_qty TYPE TABLE OF tab_qty,
gs_tab_qty TYPE tab_qty,
gt_scrap_tab TYPE TABLE OF tab_calc,
gs_scrap_tab TYPE tab_calc,
gv_check type c,
gs_itab LIKE fs_itab,
t_itab LIKE TABLE OF fs_itab.
DATA:
t_fcat TYPE lvc_t_fcat,
wa_fcat TYPE lvc_s_fcat.

DATA : r_container TYPE REF TO cl_gui_custom_container,
       r_alv_grid TYPE REF TO cl_gui_alv_grid,
       r_container_qty TYPE REF TO cl_gui_custom_container,
       r_alv_grid_qty TYPE REF TO cl_gui_alv_grid.
DATA: lt_index_rows TYPE lvc_t_row,
gt_test TYPE lvc_t_fcat,
lt_row_no TYPE lvc_t_roid.

DATA : gt_zscrap TYPE TABLE OF zscrap_table,
gs_zscrap TYPE zscrap_table.

DATA : s_tab LIKE STANDARD TABLE OF zalv_fieldcat,
s_tab_holder LIKE STANDARD TABLE OF zalv_fieldcat,
s_tab_input LIKE STANDARD TABLE OF zalv_fieldcat,
s_tab_1 LIKE STANDARD TABLE OF zalv_fieldcat,
s_tab_check LIKE STANDARD TABLE OF zalv_fieldcat,
gs_final_afvc TYPE afvc-ltxa1,
gs_tab_input TYPE zalv_fieldcat ,
pt_fieldcat TYPE lvc_t_fcat.
TYPE-POOLS: slis.
TYPE-POOLS: icon.
TABLES sscrfields.
TYPES: BEGIN OF t_aufpl,
aufpl TYPE afko-aufpl,
END OF t_aufpl.
TYPES: BEGIN OF t_text,
grund TYPE co_agrnd,
grdtx TYPE co_grdtx,
END OF t_text.
DATA:
r_ucomm LIKE sy-ucomm,
                  rs_selfield TYPE slis_selfield.

TYPES: BEGIN OF t_ekko,
aufpl TYPE afko-aufpl,
vornr TYPE afvc-vornr,
END OF t_ekko.
TYPES: BEGIN OF s_tab,
orders TYPE afko-aufnr,
operation TYPE afvc-vornr,
END OF s_tab.
TYPES: BEGIN OF t_afvc,
vornr TYPE afvc-vornr,
ltxa1 TYPE afvc-ltxa1,
END OF t_afvc.

DATA : gs_count TYPE p,
gs_count_alv TYPE p,
count_tab TYPE p,
count_tab_qty TYPE p,
gs_grund TYPE co_agrnd,
gs_grdtx TYPE co_grdtx,
gt_text TYPE TABLE OF  t_text,
gs_aufk TYPE aufk,
gs_aufk_1 TYPE werks.
DATA :   test_tab TYPE TABLE OF zalv_fieldcat,
test_tab1 TYPE bmeng.
DATA :   qty_tab_input TYPE TABLE OF qty,
it_aufk TYPE TABLE OF aufk,
gs_jest TYPE jest,
it_jest TYPE TABLE OF jest,
gt_objnr TYPE TABLE OF objnr,
gs_objnr TYPE objnr.
*Create selection screen
SELECTION-SCREEN BEGIN OF BLOCK block1.
PARAMETERS:  order LIKE afko-aufnr.
PARAMETERS:
oper(10) TYPE c .
*screen-input = '0'.


*--------Disable Save Button----
DATA iucomm   TYPE TABLE OF string.

*AT SELECTION-SCREEN OUTPUT.
  APPEND:
    'E'    TO iucomm, "To disable back required
    'SPOS' TO iucomm, " To disable Save as variant
    'GET'  TO iucomm, " To remove get variant
    'ECAN' TO iucomm, " To remove cancel
    'ONLI' TO iucomm, " To remove execute
    'PRIN' TO iucomm. " To remove print
*  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
*    EXPORTING
*      PF-STATUS  = sy-pfkey
*    TABLES
*      p_exclude = iucomm.
*-----
*DATA: it_ucomm TYPE TABLE OF sy-ucomm.
*
*APPEND 'SPOS' TO it_ucomm.
*
**call transactionn
*
*  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
*
*    EXPORTING
*
*      p_status  = sy-pfkey
*
*    TABLES
*
*      p_exclude = it_ucomm.

SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (20) w_button USER-COMMAND but1.
SELECTION-SCREEN END OF LINE.
*Select orders for display in order dropdown on selection screen:
*Select all orders from table jest which have stat = 'I0045' (TECO ORDERS) (into table gt_objnr)
*Select all orders from jest (into table it_jest)
*Compare the results and delete all records which have an objnr value in common.
*Finally select all orders from table aufk (into table it_aufk) which have an objnr value in table it_jest.
*Returned vales are displayed in dropdown
*AT SELECTION-SCREEN OUTPUT.
* LOOP AT SCREEN.
*IF screen-name EQ 'oper'.
*  screen-input = '0'.
*modify screen.
* ENDIF.
*AT SELECTION-SCREEN output.
* loop at screen.
*    if screen-name eq 'OPER'.
*      screen-input = '0'.
*      If order NE '0'.
*      modify screen.
*      endif.
*    endif.
*  endloop.
* ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR order.
  CLEAR gt_objnr.
  CLEAR it_jest.
  CLEAR it_final.
  CLEAR it_aufk.
  SELECT objnr FROM jest INTO TABLE gt_objnr
  WHERE stat = 'I0045'.
  DELETE ADJACENT DUPLICATES FROM gt_objnr.
  SELECT * FROM jest INTO TABLE it_jest.
  SORT it_jest.
  DELETE ADJACENT DUPLICATES FROM it_jest.
  LOOP AT gt_objnr INTO gs_objnr.
    DELETE it_jest WHERE objnr = gs_objnr.
  ENDLOOP.
  LOOP AT it_jest INTO gs_jest.
    SELECT * FROM aufk INTO gs_aufk
    WHERE objnr = gs_jest-objnr.
      APPEND gs_aufk TO it_aufk.
    ENDSELECT.
  ENDLOOP.
  LOOP AT it_aufk INTO gs_aufk.
    SELECT aufnr FROM afko
    INTO gs_final WHERE aufnr = gs_aufk-aufnr.
      APPEND gs_final TO it_final.
    ENDSELECT.
  ENDLOOP.
  DELETE ADJACENT DUPLICATES FROM it_final.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*     DDIC_STRUCTURE = ' '
      retfield       = 'order'   "field of internal table
      value_org      = 'S'
    TABLES
      value_tab      = it_final
*     FIELD_TAB      =
      return_tab     = it_return.
*RETURN_TAB             = num_s.
  WRITE it_return-fieldval TO order.
  REFRESH it_final.
*  format order (add leading zeroes)
  c_orders = order.
  order = c_orders.
*Populate operation dropdown
AT SELECTION-SCREEN ON VALUE-REQUEST FOR oper.
*AT SELECTION-SCREEN output.

  DATA: BEGIN OF help_item OCCURS 0,
  posnr TYPE vbap-posnr,
  matnr TYPE vbap-matnr,
  arktx TYPE vbap-arktx,
  END OF help_item.

  DATA: dynfields TYPE TABLE OF dynpread WITH HEADER LINE.
 
*   loop at screen.
**    if screen-name eq 'OPER'.
*if screen-name eq 'SSCRFIELDS-UCOMM' and ORDER NE '0'.
*      screen-input = '1'.
**clear screen-input.
**      If order NE '0'.
*      modify screen.
**      endif.
*    endif.
*  endloop.

  dynfields-fieldname = 'ORDER'.
  APPEND dynfields.
*if user manually enters order data rather then selecting from dropdown,the below code will pick it up
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-cprog
      dynumb               = sy-dynnr
      translate_to_upper   = 'X'
    TABLES
      dynpfields           = dynfields
    EXCEPTIONS
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      invalid_parameter    = 7
      undefind_error       = 8
      double_conversion    = 9
      stepl_not_found      = 10
      OTHERS               = 11.

  READ TABLE dynfields WITH KEY fieldname = 'ORDER'.
  order = dynfields-fieldvalue.
*  *  format order (add leading zeroes)
  c_orders = order.
  order = c_orders.
  IF c_orders NE ''.
    CLEAR it_final.
    CLEAR it_return.
*    clear gv_check.
    SELECT aufpl FROM afko
    INTO TABLE it_final
    WHERE aufnr = c_orders.
    READ TABLE it_final INTO gs_final INDEX 1.
    SELECT vornr ltxa1 FROM afvc
    INTO TABLE it_final_afvc
    WHERE aufpl = gs_final-orders.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
*       DDIC_STRUCTURE = ' '
        retfield       = 'operation'   "field of internal table
        value_org      = 'S'
      TABLES
        value_tab      = it_final_afvc
*       FIELD_TAB      =
        return_tab     = it_return.
    READ TABLE it_final_afvc INTO gs_final_afvc WITH KEY ltxa1 = it_return-fieldval.
    c_afvc = gs_final_afvc.
*      READ TABLE it_itab into wa_itab with TABLE KEY city = pa_city
*                           Country = pa_country.
    WRITE c_afvc TO oper.
* clear gv_check.
    REFRESH it_final.
  ELSE.
*  *Error message if order field is empty
    MESSAGE 'Order field empty.Order field must be populated  ' TYPE 'S'.
  ENDIF.
*--------------------------------------------------------------*
*At Selection-Screen
*--------------------------------------------------------------*
AT SELECTION-SCREEN.
  CASE sscrfields-ucomm.
*  If button pressed
    WHEN 'BUT1' or 'TEST' .

    s_tab_holder[] = s_tab[].
 

*    Check if data entered already exists in zscrap_table.
PERFORM data_check.
      PERFORM data_retrieval.
      IF order EQ '' AND oper EQ ''.
      ELSE.
        PERFORM data_retrieval.
      ENDIF.

  ENDCASE.
*  If f8 run
  IF sscrfields-ucomm = 'ONLI'.
    IF order EQ '' AND oper EQ ''.
    ELSE.
*      Check if data entered already exists in zscrap_table.
      PERFORM data_retrieval.
    ENDIF.
  ENDIF.

*--------------------------------------------------------------*
*Initialization
*--------------------------------------------------------------*
INITIALIZATION.
*PERFORM initializa_layout.
  w_button = 'Record Scrap'.

************************************************************************
*INITIALIZATION.
INITIALIZATION.
* Add title to button
  w_button = 'Record Scrap'.

  DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
  it_aufpl TYPE TABLE OF t_aufpl,
  wa_aufpl TYPE t_aufpl,
        wa_ekko TYPE t_ekko.
  DATA: it_afvc TYPE t_afvc,
  it_scrap_tab TYPE STANDARD TABLE OF s_tab,
  f4_tab TYPE TABLE OF t_afvc.
  TYPE-POOLS: vrm.
  DATA: name  TYPE vrm_id,
        list  TYPE vrm_values,
        value LIKE LINE OF list.
*--------------------------------------------
  DATA : dynpread TYPE TABLE OF dynpread WITH HEADER LINE.
  REFRESH dynpread.
  CLEAR dynpread.
  dynpread-fieldname = 'OPER'.
  APPEND dynpread.
  CLEAR dynpread.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-repid
      dynumb               = sy-dynnr
    TABLES
      dynpfields           = dynpread
    EXCEPTIONS
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      invalid_parameter    = 7
      undefind_error       = 8
      double_conversion    = 9
      stepl_not_found      = 10
      OTHERS               = 11.
  IF sy-subrc IS INITIAL.
    READ TABLE dynpread WITH KEY fieldname = 'OPER'.
    IF sy-subrc IS INITIAL.
      SELECT aufpl ltxa1  FROM afvc
            INTO TABLE f4_tab
             WHERE aufpl = dynpread-fieldvalue." AND kzloesch <> 'X'.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield    = 'FETXT'
          dynpprog    = sy-repid
          dynpnr      = sy-dynnr
          dynprofield = 'P_FETXT'
          value_org   = 'S'
        TABLES
          value_tab   = f4_tab.
    ENDIF.
  ENDIF.
*ALV data declarations
  DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
        gd_tab_group TYPE slis_t_sp_group_alv,
        gd_layout    TYPE slis_layout_alv,
        ls_layout TYPE lvc_s_layo ,
        gd_repid     LIKE sy-repid,
        gt_events     TYPE slis_t_event,
        gd_prntparams TYPE slis_print_alv.
  ls_layout-sel_mode = 'A'.

*Start-of-selection.
START-OF-SELECTION.

  PERFORM vornr.
END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Form  DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM data_check.
*If order NE '0'.
*     SELECT vornr ltxa1 FROM afvc
*    INTO TABLE it_final_afvc
*    WHERE aufpl = order.
*    If sy-subrc EQ '4'.
*    endif.
*    ELSEIF order EQ '0'.
*    SELECT vornr ltxa1 FROM afvc
*    INTO TABLE it_final_afvc
*    WHERE aufpl = c_orders.
* If sy-subrc EQ '4'.
*    endif.
*endif.
ENDFORM.
FORM data_retrieval.
  IF order NE '' AND oper NE '' OR order NE '' AND oper EQ '0000'.
 
  
*    *Check if order/operation combo already exist
    SELECT orders operation
       FROM zscrap_table
       INTO TABLE it_scrap_tab
       WHERE orders = order AND operation = oper.
    IF sy-subrc EQ '4' and gv_check NE 'X'.
   
*      DATA: it_ucomm TYPE TABLE OF sy-ucomm.
*
*APPEND 'SPOS' TO it_ucomm.
*
*  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
*
*    EXPORTING
*
*      p_status  = '%_CS'
*
*    TABLES
*
*      p_exclude = it_ucomm.
      PERFORM alv_display.
      CALL SELECTION-SCREEN 4000 .

      clear gv_check.
      clear s_tab.
    ELSEIF gt_scrap_tab IS INITIAL AND sy-subrc EQ '0' and screen-name NE '%_17NNS0002384344_%_%_%_%_%_%_'.
*If order/operation combo already exist display error message
      CALL FUNCTION 'POPUP_TO_CONFIRM'
         EXPORTING
*     TITLEBAR                    = ' '
*     DIAGNOSE_OBJECT             = ' '
           text_question               ='Values have been previously recorded for this operation – Use Change transaction'
*     TEXT_BUTTON_1               = 'Ja'(001)
*     ICON_BUTTON_1               = ' '
*     TEXT_BUTTON_2               = 'Nein'(002)
*     ICON_BUTTON_2               = ' '
*     DEFAULT_BUTTON              = '1'
*     DISPLAY_CANCEL_BUTTON       = 'X'
*     USERDEFINED_F1_HELP         = ' '
*     START_COLUMN                = 25
*     START_ROW                   = 6
*     POPUP_TYPE                  =
*     IV_QUICKINFO_BUTTON_1       = ' '
*     IV_QUICKINFO_BUTTON_2       = ' '
*   IMPORTING
*     ANSWER                      =
*   TABLES
*     PARAMETER                   =
*   EXCEPTIONS
*     TEXT_NOT_FOUND              = 1
*     OTHERS                      = 2
                 .
*      CALL TRANSACTION 'Z_SCRAP_CREATE'.
LEAVE TO SCREEN 1000.
    ENDIF.
  ENDIF.
ENDFORM.                    " DATA_RETRIEVAL

*&---------------------------------------------------------------------*
*&      Form  ALV_Display
*&---------------------------------------------------------------------*
*       Retrieve data form VORN tabled
*----------------------------------------------------------------------*
FORM alv_display.

  SELECT werks FROM aufk INTO gs_aufk_1
  WHERE aufnr = order.
  ENDSELECT.
  SELECT grund grdtx FROM trugt INTO CORRESPONDING FIELDS OF TABLE s_tab
   WHERE werks = gs_aufk_1 and SPRAS NE 'D'.
   If gv_check NE 'X'.
   gv_check = 'X'.
   endif.
*Loop at s_tab into gs_tab_input.
*gs_tab_input-werks = '0'.
*append gs_tab_input to s_tab_1.
*endloop.
*clear s_tab.
*s_tab[] = s_tab_1.

ENDFORM.                    " DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*&      Form  VORNR
*&---------------------------------------------------------------------*
*       Retrieve data form VORN table
*----------------------------------------------------------------------*
FORM vornr.

  DATA:
  t1 TYPE c,
  t2 TYPE c,
  t3 TYPE c.
  SELECT SINGLE vornr ltxa1
   FROM afvc
    INTO it_afvc
    WHERE aufpl = oper.
  t1 = it_afvc.
  t2 = it_afvc.
  CONCATENATE t1 t2 INTO t3.
ENDFORM.                    " DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*&      Form  dropdown
*&---------------------------------------------------------------------*
*       Retrieve data form VORN table
*----------------------------------------------------------------------*
FORM dropdown.

 
  SELECT aufpl
     FROM afko
     INTO TABLE it_aufpl
     WHERE aufnr = order.
  LOOP AT it_aufpl INTO wa_aufpl.
    value-key =  wa_aufpl-aufpl.
    value-text = wa_aufpl-aufpl.
    APPEND value TO list.
  ENDLOOP.
  name = 'oper'.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = name
      values = list.
ENDFORM.                    " DATA_RETRIEVAL

*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
FORM top-of-page.
*ALV Header declarations
  DATA: t_header TYPE slis_t_listheader,
        wa_header TYPE slis_listheader,
        t_line LIKE wa_header-info,
        ld_lines TYPE i,
        ld_linesc(10) TYPE c.
* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'Operation Level Scrap Quantities'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.
* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date
  APPEND wa_header TO t_header.
  CLEAR: wa_header.
* Total No. of Records Selected
  DESCRIBE TABLE it_ekko LINES ld_lines.
  ld_linesc = ld_lines.
  CONCATENATE 'Total No.of Records Selected: ' ld_linesc
                    INTO t_line SEPARATED BY space.
  wa_header-typ  = 'A'.
  wa_header-info = t_line.
  APPEND wa_header TO t_header.
  CLEAR: wa_header, t_line.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = t_header.
*           i_logo             = 'Z_LOGO'.
ENDFORM.                    "top-of-page
*
*
*------------------------------------------------------------------*
*       FORM USER_COMMAND                                          *
*------------------------------------------------------------------*
*       --> R_UCOMM                                                *
*       --> RS_SELFIELD                                            *
*------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.
* Check function code
  CASE r_ucomm.
    WHEN '&IC1'.
*   Check field clicked on within ALVgrid report
      IF rs_selfield-fieldname = 'aufnr'.
*     Read data table, using index of row user clicked on
        READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
*     Set parameter ID for transaction screen field
        SET PARAMETER ID 'BES' FIELD wa_ekko-vornr.
*     Sxecute transaction ME23N, and skip initial data entry screen
        CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
      ENDIF.
  ENDCASE.
ENDFORM.                    "user_command

**&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*&      Form  END_OF_PAGE
*&---------------------------------------------------------------------*
FORM end_of_page.
  DATA: listwidth TYPE i,
        ld_pagepos(10) TYPE c,
        ld_page(10)    TYPE c.
  WRITE: sy-uline(50).
  SKIP.
  WRITE:/40 'Page:', sy-pagno .
ENDFORM.                    "END_OF_PAGE

*&---------------------------------------------------------------------*
*&      Form  END_OF_LIST
*&---------------------------------------------------------------------*
FORM end_of_list.
  DATA: listwidth TYPE i,
        ld_pagepos(10) TYPE c,
        ld_page(10)    TYPE c.
  SKIP.
  WRITE:/40 'Page:', sy-pagno .
ENDFORM.                    "END_OF_LIST

*----------------------------------------------------------------------*
*   INCLUDE TABLECONTROL_FORMS                                         *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  USER_OK_TC                                               *
*&---------------------------------------------------------------------*
FORM user_ok_tc USING    p_tc_name TYPE dynfnam
                         p_table_name
                         p_mark_name
                CHANGING p_ok      LIKE sy-ucomm.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
  DATA: l_ok              TYPE sy-ucomm,
        l_offset          TYPE i.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
*&SPWIZARD: Table control specific operations                          *
*&SPWIZARD: evaluate TC name and operations                            *
  SEARCH p_ok FOR p_tc_name.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
  l_offset = strlen( p_tc_name ) + 1.
  l_ok = p_ok+l_offset.
*&SPWIZARD: execute general and TC specific operations                 *
  CASE l_ok.
    WHEN 'INSR'.                      "insert row
      PERFORM fcode_insert_row USING    p_tc_name
                                        p_table_name.
      CLEAR p_ok.
    WHEN 'DELE'.                      "delete row
      PERFORM fcode_delete_row USING    p_tc_name
                                        p_table_name
                                        p_mark_name.
      CLEAR p_ok.
    WHEN 'P--' OR                     "top of list
         'P-'  OR                     "previous page
         'P+'  OR                     "next page
         'P++'.                       "bottom of list
      PERFORM compute_scrolling_in_tc USING p_tc_name
                                            l_ok.
      CLEAR p_ok.
*     WHEN 'L--'.                       "total left
*       PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.
*
*     WHEN 'L-'.                        "column left
*       PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.
*
*     WHEN 'R+'.                        "column right
*       PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.
*
*     WHEN 'R++'.                       "total right
*       PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.
*
    WHEN 'MARK'.                      "mark all filled lines
      PERFORM fcode_tc_mark_lines USING p_tc_name
                                        p_table_name
                                        p_mark_name   .
      CLEAR p_ok.
    WHEN 'DMRK'.                      "demark all filled lines
      PERFORM fcode_tc_demark_lines USING p_tc_name
                                          p_table_name
                                          p_mark_name .
      CLEAR p_ok.
*     WHEN 'SASCEND'   OR
*          'SDESCEND'.                  "sort column
*       PERFORM FCODE_SORT_TC USING P_TC_NAME
*                                   l_ok.
  ENDCASE.
ENDFORM.                              " USER_OK_TC
*&---------------------------------------------------------------------*
*&      Form  FCODE_INSERT_ROW                                         *
*&---------------------------------------------------------------------*
FORM fcode_insert_row
              USING    p_tc_name           TYPE dynfnam
                       p_table_name             .
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
  DATA l_lines_name       LIKE feld-name.
  DATA l_selline          LIKE sy-stepl.
  DATA l_lastline         TYPE i.
  DATA l_line             TYPE i.
  DATA l_table_name       LIKE feld-name.
  FIELD-SYMBOLS <tc>                 TYPE cxtab_control.
  FIELD-SYMBOLS <table>              TYPE STANDARD TABLE.
  FIELD-SYMBOLS <lines>              TYPE i.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
  ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get the table, which belongs to the tc                     *
  CONCATENATE p_table_name '[]' INTO l_table_name. "table body
  ASSIGN (l_table_name) TO <table>.                "not headerline
*&SPWIZARD: get looplines of TableControl                              *
  CONCATENATE 'G_' p_tc_name '_LINES' INTO l_lines_name.
  ASSIGN (l_lines_name) TO <lines>.
*&SPWIZARD: get current line                                           *
  GET CURSOR LINE l_selline.
  IF sy-subrc <> 0.                   " append line to table
    l_selline = <tc>-lines + 1.
*&SPWIZARD: set top line                                               *
    IF l_selline > <lines>.
      <tc>-top_line = l_selline - <lines> + 1 .
    ELSE.
      <tc>-top_line = 1.
    ENDIF.
  ELSE.                               " insert line into table
    l_selline = <tc>-top_line + l_selline - 1.
    l_lastline = <tc>-top_line + <lines> - 1.
  ENDIF.
*&SPWIZARD: set new cursor line                                        *
  l_line = l_selline - <tc>-top_line + 1.
*&SPWIZARD: insert initial line                                        *
  INSERT INITIAL LINE INTO <table> INDEX l_selline.
  <tc>-lines = <tc>-lines + 1.
*&SPWIZARD: set cursor                                                 *
  SET CURSOR LINE l_line.
ENDFORM.                              " FCODE_INSERT_ROW
*&---------------------------------------------------------------------*
*&      Form  FCODE_DELETE_ROW                                         *
*&---------------------------------------------------------------------*
FORM fcode_delete_row
              USING    p_tc_name           TYPE dynfnam
                       p_table_name
                       p_mark_name   .
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
  DATA l_table_name       LIKE feld-name.
  FIELD-SYMBOLS <tc>         TYPE cxtab_control.
  FIELD-SYMBOLS <table>      TYPE STANDARD TABLE.
  FIELD-SYMBOLS <wa>.
  FIELD-SYMBOLS <mark_field>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
  ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get the table, which belongs to the tc                     *
  CONCATENATE p_table_name '[]' INTO l_table_name. "table body
  ASSIGN (l_table_name) TO <table>.                "not headerline
*&SPWIZARD: delete marked lines                                        *
  DESCRIBE TABLE <table> LINES <tc>-lines.
  LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: access to the component 'FLAG' of the table header         *
    ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
    IF <mark_field> = 'X'.
      DELETE <table> INDEX syst-tabix.
      IF sy-subrc = 0.
        <tc>-lines = <tc>-lines - 1.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDFORM.                              " FCODE_DELETE_ROW
*&---------------------------------------------------------------------*
*&      Form  COMPUTE_SCROLLING_IN_TC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TC_NAME  name of tablecontrol
*      -->P_OK       ok code
*----------------------------------------------------------------------*
FORM compute_scrolling_in_tc USING    p_tc_name
                                      p_ok.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
  DATA l_tc_new_top_line     TYPE i.
  DATA l_tc_name             LIKE feld-name.
  DATA l_tc_lines_name       LIKE feld-name.
  DATA l_tc_field_name       LIKE feld-name.
  FIELD-SYMBOLS <tc>         TYPE cxtab_control.
  FIELD-SYMBOLS <lines>      TYPE i.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
  ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get looplines of TableControl                              *
  CONCATENATE 'G_' p_tc_name '_LINES' INTO l_tc_lines_name.
  ASSIGN (l_tc_lines_name) TO <lines>.

*&SPWIZARD: is no line filled?                                         *
  IF <tc>-lines = 0.
*&SPWIZARD: yes, ...                                                   *
    l_tc_new_top_line = 1.
  ELSE.
*&SPWIZARD: no, ...                                                    *
    CALL FUNCTION 'SCROLLING_IN_TABLE'
      EXPORTING
        entry_act             = <tc>-top_line
        entry_from            = 1
        entry_to              = <tc>-lines
        last_page_full        = 'X'
        loops                 = <lines>
        ok_code               = p_ok
        overlapping           = 'X'
      IMPORTING
        entry_new             = l_tc_new_top_line
      EXCEPTIONS
*       NO_ENTRY_OR_PAGE_ACT  = 01
*       NO_ENTRY_TO           = 02
*       NO_OK_CODE_OR_PAGE_GO = 03
        OTHERS                = 0.
  ENDIF.
*&SPWIZARD: get actual tc and column                                   *
  GET CURSOR FIELD l_tc_field_name
             AREA  l_tc_name.
  IF syst-subrc = 0.
    IF l_tc_name = p_tc_name.
*&SPWIZARD: et actual column                                           *
      SET CURSOR FIELD l_tc_field_name LINE 1.
    ENDIF.
  ENDIF.
*&SPWIZARD: set the new top line                                       *
  <tc>-top_line = l_tc_new_top_line.

ENDFORM.                              " COMPUTE_SCROLLING_IN_TC
*&---------------------------------------------------------------------*
*&      Form  FCODE_TC_MARK_LINES
*&---------------------------------------------------------------------*
*       marks all TableControl lines
*----------------------------------------------------------------------*
*      -->P_TC_NAME  name of tablecontrol
*----------------------------------------------------------------------*
FORM fcode_tc_mark_lines USING p_tc_name
                               p_table_name
                               p_mark_name.
*&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------*
  DATA l_table_name       LIKE feld-name.
  FIELD-SYMBOLS <tc>         TYPE cxtab_control.
  FIELD-SYMBOLS <table>      TYPE STANDARD TABLE.
  FIELD-SYMBOLS <wa>.
  FIELD-SYMBOLS <mark_field>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
  ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get the table, which belongs to the tc                     *
  CONCATENATE p_table_name '[]' INTO l_table_name. "table body
  ASSIGN (l_table_name) TO <table>.                "not headerline
*&SPWIZARD: mark all filled lines                                      *
  LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: access to the component 'FLAG' of the table header         *
    ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
    <mark_field> = 'X'.
  ENDLOOP.
ENDFORM.                                          "fcode_tc_mark_lines
*&---------------------------------------------------------------------*
*&      Form  FCODE_TC_DEMARK_LINES
*&---------------------------------------------------------------------*
*       demarks all TableControl lines
*----------------------------------------------------------------------*
*      -->P_TC_NAME  name of tablecontrol
*----------------------------------------------------------------------*
FORM fcode_tc_demark_lines USING p_tc_name
                                 p_table_name
                                 p_mark_name .
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
  DATA l_table_name       LIKE feld-name.
  FIELD-SYMBOLS <tc>         TYPE cxtab_control.
  FIELD-SYMBOLS <table>      TYPE STANDARD TABLE.
  FIELD-SYMBOLS <wa>.
  FIELD-SYMBOLS <mark_field>.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*
  ASSIGN (p_tc_name) TO <tc>.
*&SPWIZARD: get the table, which belongs to the tc                     *
  CONCATENATE p_table_name '[]' INTO l_table_name. "table body
  ASSIGN (l_table_name) TO <table>.                "not headerline
*&SPWIZARD: demark all filled lines                                    *
  LOOP AT <table> ASSIGNING <wa>.
*&SPWIZARD: access to the component 'FLAG' of the table header         *
    ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
    <mark_field> = space.
  ENDLOOP.
ENDFORM.                                          "fcode_tc_mark_lines
*&---------------------------------------------------------------------*
*&      Module  STATUS_0300  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0300 OUTPUT.
  DATA ls_fcat TYPE lvc_s_fcat.
*
  SET PF-STATUS 'TEST' EXCLUDING 'SPOS' .
  SET TITLEBAR 'TEST' .

ENDMODULE.                 " STATUS_0300  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  ALV_OUTPUT  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*Create alv for display (alv 1,contains reason codes)
*  DATA ls_fcat TYPE lvc_s_fcat.
MODULE alv_output OUTPUT.
*--------Disable Save Button----

*  APPEND:
**    'E'    TO iucomm, "To disable back required
*    'SPOS' TO iucomm, " To disable Save as variant
*    'GET'  TO iucomm. " To remove get variant
**    'ECAN' TO iucomm, " To remove cancel
**    'ONLI' TO iucomm, " To remove execute
**    'PRIN' TO iucomm. " To remove print
*  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
*    EXPORTING
*      PF-STATUS  = sy-pfkey
*    TABLES
*      p_exclude = iucomm.
*-----
  IF r_container IS INITIAL.
    CREATE OBJECT r_container
      EXPORTING
*    PARENT                      =
        container_name              = 'CCONTAINER'
        .
    IF sy-subrc <> 0.
    ENDIF.
  ENDIF.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        i_structure_name = 'ZALV_FIELDCAT'
      CHANGING
        ct_fieldcat      = pt_fieldcat.

    LOOP AT pt_fieldcat INTO ls_fcat.
      IF    ls_fcat-fieldname EQ 'QTY'.
*§1.Set status of column qty to editable.
        ls_fcat-edit = 'X'.
        MODIFY pt_fieldcat FROM ls_fcat.
      ENDIF.
    ENDLOOP.

  IF r_alv_grid IS INITIAL.
    CREATE OBJECT r_alv_grid
      EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
        i_parent          = r_container
        .
  ENDIF.
* CALL METHOD r_alv_grid->set_table_for_first_display
*      EXPORTING
**        it_toolbar_excluding = pt_exclude
*        i_structure_name     = 'ZSCRAP_TABLE'
*        is_layout            = ls_layout
*      CHANGING
*        it_fieldcatalog      = pt_fieldcat
*        it_outtab            = s_tab.
**§2.Use SET_READY_FOR_INPUT to allow editing initially.
**   (state "editable and ready for input").
*    CALL METHOD r_alv_grid->set_ready_for_input
*      EXPORTING
*        i_ready_for_input = 1.
*  ENDIF.
  CALL METHOD r_alv_grid->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_modified.
*Check if data has been changed
  CALL METHOD r_alv_grid->check_changed_data.
s_tab_check[] = s_tab.
*clear s_tab.
  DELETE s_tab_check WHERE QTY = '0'.
  Loop at s_tab_check into gs_tab_input.
  Delete s_tab_holder where grund = gs_tab_input-grund.
  append gs_tab_input to s_tab_holder.
  endloop.
  sort s_tab_holder.
*s_tab = s_tab_holder.
*If NOT S_TAB_CHECK IS INITIAL.
If NOT S_TAB_HOLDER IS INITIAL.
   PERFORM update_table.
ENDIF.
If SY-UCOMM = 'SPOS'.
PERFORM update_table.
endif.
  IF NOT s_tab[] IS INITIAL.
    CALL METHOD r_alv_grid->set_table_for_first_display
      EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
        i_structure_name              = 'ZALV_FIELDCAT'
*    IS_VARIANT                    =
*    I_SAVE                        = 'A'
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     = gd_layout
is_layout                     = ls_layout
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =fieldcatalog[]
*    IR_SALV_ADAPTER               =
      CHANGING
        it_outtab                     = s_tab
    IT_FIELDCATALOG               = pt_fieldcat
*    IT_SORT                       =
*    IT_FILTER                     =
*  EXCEPTIONS
*    INVALID_PARAMETER_COMBINATION = 1
*    PROGRAM_ERROR                 = 2
*    TOO_MANY_LINES                = 3
*    others                        = 4
            .
CALL METHOD r_alv_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
*
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
  ENDIF.

ENDMODULE.                    "ALV_OUTPUT OUTPUT

*----------------------------------------------------------------------*
*  MODULE ALV_OUTPUT_QTY OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
*Create qty alv (alv 2).
MODULE alv_output_qty OUTPUT.
*Select which alv toolbar options need to be excluded
  DATA: pt_exclude TYPE ui_functions.
  DATA ls_exclude TYPE ui_func.

*DATA: it_ucomm TYPE TABLE OF sy-ucomm.
*
*APPEND 'SPOS' TO it_ucomm.
*
**call transactionn
*
*  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
*
*    EXPORTING
*
*      p_status  = sy-pfkey
*
*    TABLES
*
*      p_exclude = it_ucomm.

*
ls_exclude = cl_gui_alv_grid=>MC_FC_SAVE_VARIANT.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
  APPEND ls_exclude TO pt_exclude.
*  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
*  APPEND LS_EXCLUDE TO PT_EXCLUDE.
*  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
*  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_sort_asc.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc.
  APPEND ls_exclude TO pt_exclude.
  IF r_container_qty IS INITIAL.
    CREATE OBJECT r_container_qty
      EXPORTING
*    PARENT                      =
        container_name              = 'QTY_CONTAINER'
        .
  ENDIF.
*  s_tab_check[] = s_tab.
*  DELETE s_tab_check WHERE QTY = '0'.
*
*  Loop at s_tab_check into gs_tab_input.
*  Delete s_tab_holder where grund = gs_tab_input-grund.
*  append gs_tab_input to s_tab_holder.
*  endloop.
*  sort s_tab_holder.
*   PERFORM update_table.
*  s_tab[] = s_tab_holder[].
*S_TAB = s_tab_holder.
  IF r_alv_grid_qty IS INITIAL.
    CREATE OBJECT r_alv_grid_qty
      EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
        i_parent          = r_container_qty.
*        *POPULATING THE FIELD CATALOG.
    wa_fcat-fieldname = 'QTY'.
    wa_fcat-ref_table = 'ZSCRAP_TABLE'.
    wa_fcat-ref_field = 'QTY'.
    wa_fcat-col_pos = 2.
    wa_fcat-edit = 'X'.

    IF gs_count_alv = '0'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      gs_count_alv = gs_count_alv + '1'.
    ENDIF.
    .
    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 NOT s_tab_holder[] IS INITIAL.
    CALL METHOD r_alv_grid_qty->set_table_for_first_display
      EXPORTING
      it_toolbar_excluding = pt_exclude
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*        I_STRUCTURE_NAME              = 'ZALV_FIELDCAT'
*    IS_VARIANT                    =
*    I_SAVE                        = 'A'
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     = gd_layout
is_layout                     = ls_layout
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =fieldcatalog[]
*    IR_SALV_ADAPTER               =
      CHANGING
*        IT_OUTTAB                     = s_tab
it_outtab                     = t_itab
*    IT_FIELDCATALOG               = pt_fieldcat
it_fieldcatalog               = t_fcat
            .

  ENDIF.

ENDMODULE.
MODULE user_command_0300 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT' OR 'RETURN' OR 'SAVE' OR 'SPOS'.
*      SET SCREEN '0'.
*CALL TRANSACTION 'Z_SCRAP_CREATE'.
*Perform update_table.
                  .
    WHEN 'DISPLAY'.
      LEAVE TO SCREEN 200.
    WHEN OTHERS.
      PERFORM get_selected_rows.
*      IF count_tab NE '0' AND count_tab_qty NE '0' AND count_tab = count_tab_qty and SY-UCOMM = 'BUT1' OR SY-UCOMM = 'SPOS'.
  
                 .
*        PERFORM update_table.
*        endif.
*      ELSE.
*        MESSAGE 'Error:At least 1 reason and 1 QTY must be selected and No of Reason Texts and Quantities must be the same ' TYPE 'S'.
*      ENDIF.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0300  INPUT

*&---------------------------------------------------------------------*
*&      Form  get_selected_rows
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM get_selected_rows .
  TYPES:
    BEGIN OF stu,
*    CURRENCY TYPE sflight-CURRENCY,
  qty TYPE zscrap_table-qty,
    END OF stu.
  DATA: lt_rows_qty   TYPE lvc_t_row,
        ls_row_qty    TYPE lvc_s_row,
        qty_tab_input TYPE TABLE OF stu,
ls_update TYPE zscrap_table,
        ls_outtab_qty TYPE stu.
  DATA: lt_rows   TYPE lvc_t_row,
        ls_row    TYPE lvc_s_row,
        index_field TYPE lvc_index,
        ls_outtab TYPE tab_qty.
*Get data that user has entered in alv.
  CALL METHOD r_alv_grid->get_selected_rows
    IMPORTING
      et_index_rows = lt_rows
    .
  LOOP AT lt_rows INTO ls_row.
    READ TABLE s_tab_holder INTO ls_outtab INDEX ls_row-index.
    ls_outtab-index = ls_row-index.
    APPEND ls_outtab TO tab_qty.
  ENDLOOP.

  DESCRIBE TABLE lt_rows LINES count_tab.

*Check data has been changed
  CALL METHOD r_alv_grid_qty->check_changed_data.
  LOOP AT t_itab INTO gs_itab.
    IF gs_itab-qty = '0'.
      DELETE t_itab.
    ENDIF.
  ENDLOOP.
  DESCRIBE TABLE t_itab LINES count_tab_qty.
  index_field = '1'.
  LOOP AT tab_qty INTO gs_tab_qty.
    READ TABLE t_itab INTO ls_outtab_qty INDEX index_field.
    gs_scrap_tab-grund = gs_tab_qty-grund.
    gs_scrap_tab-grdtx = gs_tab_qty-grdtx.
    gs_scrap_tab-index = ls_row_qty-index.
    gs_scrap_tab-qty = ls_outtab_qty-qty.
    APPEND gs_scrap_tab TO gt_scrap_tab.
    APPEND ls_outtab_qty TO qty_tab_input.
    index_field = index_field + 1.
  ENDLOOP.

ENDFORM.                    " GET_SELECTED_ROWS

*Update zscrap_table with values entered by the user (order/operation combo + reason codes + quantities)
FORM update_table .
DATA:gt_testm type table of ZSCRAP_TABLE.
*clear s_tab.
*s_tab = s_tab_holder.
Loop at S_TAB_HOLDER into gs_tab_input where QTY NE '0'.
*MODIFY zscrap_table FROM TABLE itab
*Delete from
gs_zscrap-orders = order.
gs_zscrap-operation = oper.
    gs_zscrap-reason = gs_tab_input-grdtx.
    gs_zscrap-dates = sy-datum.
    gs_zscrap-werks = gs_aufk_1.
    gs_zscrap-qty = gs_tab_input-qty.
    gs_zscrap-user_id = sy-uname.
    APPEND gs_zscrap TO gt_zscrap.
*       Select * from zscrap_table into table gt_testm
*  where orders = order and operation = oper and reason = gs_tab_input-grdtx.
endloop.
s_tab = s_tab_holder.
*  LOOP AT gt_scrap_tab INTO gs_scrap_tab.
*
*    gs_zscrap-orders = order.
*    gs_zscrap-operation = oper.
*    gs_zscrap-reason = gs_scrap_tab-grdtx.
*    gs_zscrap-dates = sy-datum.
*    gs_zscrap-werks = gs_aufk_1.
*    gs_zscrap-qty = gs_scrap_tab-qty.
*    gs_zscrap-user_id = sy-uname.
*    APPEND gs_zscrap TO gt_zscrap.
*  ENDLOOP.
If S_TAB_HOLDER IS NOT INITIAL.
  INSERT zscrap_table FROM TABLE gt_zscrap ACCEPTING DUPLICATE KEYS .
*  MESSAGE 'Records Saved ' TYPE 'S'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
         EXPORTING
*     TITLEBAR                    = ' '
*     DIAGNOSE_OBJECT             = ' '
           text_question               ='Records have been saved'
*     TEXT_BUTTON_1               = 'Ja'(001)
*     ICON_BUTTON_1               = ' '
*     TEXT_BUTTON_2               = 'Nein'(002)
*     ICON_BUTTON_2               = ' '
*     DEFAULT_BUTTON              = '1'
*     DISPLAY_CANCEL_BUTTON       = 'X'
*     USERDEFINED_F1_HELP         = ' '
*     START_COLUMN                = 25
*     START_ROW                   = 6
*     POPUP_TYPE                  =
*     IV_QUICKINFO_BUTTON_1       = ' '
*     IV_QUICKINFO_BUTTON_2       = ' '
*   IMPORTING
*     ANSWER                      =
*   TABLES
*     PARAMETER                   =
*   EXCEPTIONS
*     TEXT_NOT_FOUND              = 1
*     OTHERS                      = 2
                 .
  ENDIF.
ENDFORM.                    "update_table
FORM initializa_layout.
DATA: t_layout TYPE lvc_s_layo.

*  t_layout-zebra        = 'X'.
*  t_layout-cwidth_opt   = 'X'.
  t_layout-no_toolbar   = 'X'.
*  T_LAYOUT-EDIT         = 'X'.
*  T_LAYOUT-DETAILINIT    = 'X'.
*  T_LAYOUT-CWIDTH_OPT    = 'X'.
*  T_LAYOUT-TOTALS_BEF    = 'X'.
*  T_LAYOUT-NUMC_TOTAL    = 'X'.

ENDFORM.

6 REPLIES 6
Read only

Former Member
0 Likes
1,620

You should understand that giving us the whole code, when there are z objects all through it is a waste of time.  How about just giving us the lines relating to the line that returns the error?

Neal

Read only

Former Member
0 Likes
1,620

Hi Michael,

You are using -  SET PF-STATUS 'TEST' EXCLUDING 'SPOS'

Go to se41 and remove the Save Button from the PF-STATUS 'TEST'.

Hope this should help.

BR.


Read only

Former Member
0 Likes
1,620

Hi,

check this sample

REPORT  ztest_status.

DATA: it_ucomm TYPE TABLE OF sy-ucomm.

PARAMETERS: carrid TYPE sflight-carrid.

AT SELECTION-SCREEN OUTPUT.

  APPEND :

    'PRIN' TO it_ucomm,  "for print

    'SPOS' TO it_ucomm,

    'ONLI' TO it_ucomm,  "for execute

    'E' TO it_ucomm,    "for back

    'ENDE' TO it_ucomm,  "for exit

    'ECAN' TO it_ucomm.  "for cancel

  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'

    EXPORTING

p_status  = sy-pfkey

    TABLES

p_exclude = it_ucomm.

Thanks

KKP

Read only

Former Member
0 Likes
1,620

Hi Michael,

If you copied the standard GUI then go to the tcode SE41 and provide your zpgmname and open it change mode and then disable the save button .

Let me know if any clarification/help required.

Thanks & Best Regards.

Pavan Neerukonda.

Read only

former_member209120
Active Contributor
0 Likes
1,620

Hi Michael,

Try like this, don't maintain any text in PF-STATUS 'TEST' -> SAVE.

Regards,

Ramesh.T

Read only

Former Member
0 Likes
1,620

Hi Michael,

First of all, where do you want to disable the Save Button?

1. If its in the first Selection- Screen, then you need to use that function module in the INITIALIZATION EVENT or at SELECTION SCREEN_OUTPUT.  Btw Initialization event should be coded first, then at selection-screen output ,  at selection screen , and finally is the start-of-selection event.

INITIALIZATION.

  DATA: t_exclude TYPE STANDARD TABLE OF sy-pfkey.

  APPEND 'SPOS' TO t_exclude.  

*Make sure SPOS is the function code of the save button.

   CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'

    EXPORTING

      p_status        = sy-pfkey

    TABLES

      p_exclude       = t_exclude.

2. If its in the screen that you have created, then as suggested above Go to Menu Painter SE41 and delete the function code associated with save button.

3. If its in the ALV tool bar follow this way.

data : tool_wa_exclude  type ui_func.

         tool_it_exclude type ui_functions.

tool_wa_exclude  = cl_gui_alv_grid=>mc_fc_save_variant.

append tool_wa_exclude  to tool_it_exclude .

  call method grid->set_table_for_first_display

    exporting

      it_toolbar_excluding          = tool_it_exclude

    changing

      it_outtab                            = it_data

      it_fieldcatalog                    = it_fcat

    exceptions

      invalid_parameter_combination = 1

      program_error                           = 2

      too_many_lines                         = 3

      others                                        = 4.

ENDMODULE.

_______________________________________

Now I would also suggest that you try to remove the error.

In the form data_retreival, after the perform alv_display statement, you have given this statement.

   PERFORM alv_display.

  CALL SELECTION-SCREEN 4000 .

Either comment out the call selection-screen 4000 statement, or double click on 4000 and properly define the selection screen.

Let me know if the issue is solved.

Message was edited by: Susmitha Susan Thomas