/scripts/ahub.form.attachments.js
-1

Error while saving new data in DB in OOPs ALV

Nov 03, 2016 at 05:00 AM

62

avatar image

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Raymond Giuseppi
Nov 03, 2016 at 07:07 AM
1

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Raymond,

I replaced it. The error is not coming anymore but then again the data is not getting saved. In debugger the sy-subrc is coming as 4 and the 'i_modified' is not getting filled.

Thanks,

Sauptik

0

Add a


CALL METHOD cl_gui_cfw=>flush.

After the get_selected_rows call.

Regards,
Raymond

0
Kali Charan Nov 03, 2016 at 05:27 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Sauptik Saha Nov 03, 2016 at 05:53 AM
0
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
Share
10 |10000 characters needed characters left characters exceeded
Krishna K Nov 03, 2016 at 06:39 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Yes, it has all the columns.

Thanks,

Sauptik

0
Sauptik Saha Nov 03, 2016 at 09:56 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Skip to Content