avatar image
-1
Former Member

Error while saving new data in DB in OOPs ALV

Hi All,

I am new to OOPS ALV and I am trying to save a data by using editable OOPS ALV. But every time I hit "SAVE" button an error is getting displayed. I have created a structure and an internal table for this. I am attaching a screen-shot. Please provide me the solution.

sap-oops-alv.jpg (46.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Nov 03, 2016 at 07:07 AM

    Replace

    wa_fcat-ref_table = 'IT_ZTMM_WFDOA'

    with

    wa_fcat-ref_table = 'ZTMM_WFDOA'

    Systeme expects a database table/structure ddic name not an local type. (reference at Generating the Field Catalog Manually)

    Regards,
    Raymond

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2016 at 05:27 AM

    It is better if you mentione any code , if it is a small program.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 03, 2016 at 05:53 AM
    REPORT zoops_alv.
    TABLES: ztmm_wfdoa,icon.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    
    DATA: "event_receiver1 TYPE REF TO lcl_event_receiver,
     i_selected_rows TYPE lvc_t_row, "Selected Rows
     w_selected_rows TYPE lvc_s_row.
    DATA: i_modified TYPE STANDARD TABLE OF ztmm_wfdoa, "For getting modified rows
     w_modified TYPE ztmm_wfdoa.
    
    TYPES: BEGIN OF ty_ztmm_wfdoa,
     apprtype TYPE ztmm_wfdoa-apprtype,
     uname TYPE ztmm_wfdoa-uname,
     firstname TYPE ztmm_wfdoa-firstname,
     lastname TYPE ztmm_wfdoa-lastname,
     doavalue TYPE ztmm_wfdoa-doavalue,
     zzwbs_doavalue TYPE ztmm_wfdoa-zzwbs_doavalue,
     END OF ty_ztmm_wfdoa.
    DATA: it_ztmm_wfdoa TYPE STANDARD TABLE OF ty_ztmm_wfdoa,
     wa_ztmm_wfdoa TYPE ty_ztmm_wfdoa,
     alv_container TYPE REF TO cl_gui_custom_container,
     alv_grid TYPE REF TO cl_gui_alv_grid,
     ok_code TYPE sy-ucomm,
     it_fcat TYPE lvc_t_fcat,
     wa_fcat TYPE lvc_s_fcat,
     wa_layout TYPE lvc_s_layo,
     g_container TYPE scrfname VALUE 'CONTAINER'.
    DATA: or_doc TYPE REF TO cl_gui_docking_container,
     event_receiver TYPE REF TO lcl_event_receiver.",
    
    DATA : obj_lcl TYPE REF TO lcl_event_receiver.
    
    DATA it_ztmm_wfdoa_old TYPE STANDARD TABLE OF ty_ztmm_wfdoa.
    SELECTION-SCREEN BEGIN OF BLOCK b1.
    SELECT-OPTIONS: s_appr FOR ztmm_wfdoa-apprtype NO-EXTENSION NO INTERVALS.
    SELECT-OPTIONS: s_uname FOR ztmm_wfdoa-uname NO-EXTENSION NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK b1.
    
    CLASS lcl_event_receiver DEFINITION.
    ENDCLASS.
    START-OF-SELECTION.
     CALL SCREEN 100.
    
    CLASS lcl_event_receiver IMPLEMENTATION.
    
    ENDCLASS.
    *&---------------------------------------------------------------------*
    
    *& Module STATUS_0100 OUTPUT
    
    *&---------------------------------------------------------------------*
    
    * text
    
    *----------------------------------------------------------------------*
    
    MODULE status_0100 OUTPUT.
    
     SET PF-STATUS 'PF_STATUS'.
    * SET TITLEBAR 'PF_STATUS'.
     PERFORM select_ztmm_wfdoa.
     CREATE OBJECT alv_container
     EXPORTING
     container_name = g_container.
    
     CREATE OBJECT alv_grid
     EXPORTING
     i_parent = alv_container.
    
     PERFORM get_fcat.
     PERFORM layout.
     PERFORM fcat.
     
    ENDMODULE.
    MODULE user_command_0100 INPUT.
    
    DATA: lv_valid TYPE xfeld,
    
    lv_refresh TYPE xfeld.
     WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
    
     LEAVE PROGRAM.
     CALL METHOD alv_grid->refresh_table_display
     EXCEPTIONS
     finished = 1
     OTHERS = 2.
     IF sy-subrc <> 0.
     ENDIF.
    
     WHEN 'SAVE'.
         PERFORM save_database.
     call method alv_grid->check_changed_data
     IMPORTING
     e_valid = lv_valid
     CHANGING
     c_refresh = lv_refresh.
     CALL METHOD alv_grid->refresh_table_display
     EXCEPTIONS
     finished = 1
     OTHERS = 2.
     ENDCASE.
    ENDMODULE.
    END-OF-SELECTION.
    FORM get_fcat.
    
     REFRESH: it_fcat.
     CLEAR:wa_fcat.
     wa_fcat-reptext = 'Approval Type'.
     wa_fcat-fieldname = 'APPRTYPE'.
     wa_fcat-ref_table = 'IT_ZTMM_WFDOA'.
     wa_fcat-edit = 'X'.
     APPEND wa_fcat TO it_fcat.
    
     wa_fcat-reptext = 'User Name'.
     wa_fcat-fieldname = 'UNAME'.
     wa_fcat-ref_table = 'IT_ZTMM_WFDOA'.
     wa_fcat-edit = 'X'.
     APPEND wa_fcat TO it_fcat.
    
     wa_fcat-reptext = 'First name'.
     wa_fcat-fieldname = 'FIRSTNAME'.
     wa_fcat-ref_table = 'IT_ZTMM_WFDOA'.
     wa_fcat-edit = 'X'.
     APPEND wa_fcat TO it_fcat.
    
     wa_fcat-reptext = 'Last name'.
     wa_fcat-fieldname = 'LASTNAME'.
     wa_fcat-ref_table = 'IT_ZTMM_WFDOA'.
     wa_fcat-edit = 'X'.
     APPEND wa_fcat TO it_fcat.
    
     wa_fcat-reptext = 'Total value at time of release'.
     wa_fcat-fieldname = 'DOAVALUE'.
     wa_fcat-ref_table = 'IT_ZTMM_WFDOA'.
     wa_fcat-edit = 'X'.
     APPEND wa_fcat TO it_fcat.
    
     wa_fcat-reptext = 'WBS based DOA Value'.
     wa_fcat-fieldname = 'ZZWBS_DOAVALUE'.
     wa_fcat-ref_table = 'IT_ZTMM_WFDOA'.
     wa_fcat-edit = 'X'.
     APPEND wa_fcat TO it_fcat.
    ENDFORM.
    FORM fcat.
     CALL METHOD alv_grid->set_table_for_first_display
     EXPORTING
     is_layout = wa_layout
     i_save = 'A'
    * i_default = 'X'
     CHANGING
     it_outtab = it_ztmm_wfdoa[]
     it_fieldcatalog = it_fcat[]
     EXCEPTIONS
     invalid_parameter_combination = 1
     program_error = 2
     too_many_lines = 3
     OTHERS = 4.
    ENDFORM.
    FORM select_ztmm_wfdoa.
     SELECT apprtype
     uname
     firstname
     lastname
     doavalue
     zzwbs_doavalue
     FROM ztmm_wfdoa
     INTO TABLE it_ztmm_wfdoa
     WHERE apprtype IN s_appr AND
     uname IN s_uname.
     IF sy-subrc = 0.
     SORT it_ztmm_wfdoa AS TEXT BY lastname.
     ENDIF.
    ENDFORM.
    
    FORM layout.
     wa_layout-cwidth_opt = 'X'.
     wa_layout-zebra = 'X'.
     wa_layout-grid_title = 'Work Flow Authorization Report' .
    ENDFORM.
    FORM save_database .
    *--- Getting the selected rows index
     CALL METHOD alv_grid->get_selected_rows
     IMPORTING
     et_index_rows = i_selected_rows.
    *--- Through the index capturing the values of selected rows
     LOOP AT i_selected_rows INTO w_selected_rows.
     READ TABLE it_ztmm_wfdoa INTO wa_ztmm_wfdoa INDEX w_selected_rows-index.
     IF sy-subrc EQ 0.
    * MOVE-CORRESPONDING wa_ztmm_wfdoa TO w_modified.
     w_modified-mandt = sy-mandt.
     w_modified-apprtype = wa_ztmm_wfdoa-apprtype .
     w_modified-uname = wa_ztmm_wfdoa-uname .
     w_modified-firstname = wa_ztmm_wfdoa-firstname.
     w_modified-lastname = wa_ztmm_wfdoa-lastname .
     w_modified-doavalue = wa_ztmm_wfdoa-doavalue.
     w_modified-zzwbs_doavalue = wa_ztmm_wfdoa-zzwbs_doavalue.
    
     APPEND w_modified TO i_modified.
     ENDIF.
     ENDLOOP.
    
     MODIFY ztmm_wfdoa FROM TABLE i_modified.
    
    * MESSAGE 'Value Saved' type 'S'.
    
    ENDFORM.
    ENDFORM. " SAVE_DATABASE
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 03, 2016 at 06:39 AM

    Hi Sauptik,

    Could you please check the table "ztmm_wfdoa" , is it having all the columns what you mention in the select query?

    Thanks in advance,

    Krishna

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 03, 2016 at 09:56 AM

    Hi Everyone,

    The issue has been solved. I just removed the 'refresh_table_display' method and interchanged the 'perform save_database' with 'check_changed_data' method.

    Thanks everyone for your help.

    Sauptik

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content