cancel
Showing results for 
Search instead for 
Did you mean: 

my database insertion doesn`t quite work

Former Member
0 Kudos

I have a ALV table in a WwbDynpro component.

I have a ON_DATA_CHECK event handler for my INTERFACECONTROLLER.

I`m trying to insert a new row in the table. Even if it gets to the succes message when I check the database table is does have a new row but it`s empty!

Does somebody know why?

Regards,

Ilinca

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Could you post the source code you have written in this event handler. It is difficult to comment on what is wrong without actually seeing what is coded there.

Former Member
0 Kudos

method ON_DATA_CHECK .

DATA: node_angajati TYPE REF TO if_wd_context_node,

elem_node_angajati TYPE REF TO if_wd_context_element,

lt_angajati TYPE wd_this->elements_angajati,

cod_angajati TYPE wd_this->element_angajati-cod_angajat,

.......declaration for each attribute in node angajati

data_nasteree TYPE wd_this->element_angajati-data_nastere.

node_angajati = wd_context->get_child_node( name = wd_this->wdctx_angajati ).

node_angajati->get_static_attributes_table( IMPORTING table = lt_angajati ).

DATA: itab TYPE STANDARD TABLE OF zangajati,

itab_angajati LIKE LINE OF itab.

itab_angajati-cod_angajat = cod_angajati.

itab_angajati-nume = numee.

.......

itab_angajati-email = emaill.

itab_angajati-data_nastere = data_nasteree.

INSERT itab_angajati INTO TABLE itab.

INSERT zangajati FROM TABLE itab ACCEPTING DUPLICATE KEYS.

COMMIT WORK.

......

message_text = 'Data was successfully saved.'.

Former Member
0 Kudos

I have a "SAVE" button that calls data_check and the code from above is from the on_data_check event handler.

Do I have to refer somehow to the Insert button from the alv table?

former_member463524
Contributor
0 Kudos

Hi,

Please check the new record has the primary key as same as existing record in the table.

If this is the case then the record will not be inserted to the table and it does not show any error since you have specified ACCEPTING DUPLICATE KEYS.

Check the sy-subrc after the insert statement.

Regards,

Meera

Former Member
0 Kudos

It is not working.

Every time I change a thing I get the " Access via 'NULL' object reference not possible." error.

Former Member
0 Kudos

HI,

Please check whether your ITAb is filled with your new values in Debug mode.Here instead of INSERTING to ITAB you can also use APPEND. If ITAB has new values then your DB table will get updated.

Regards,

Santosh

Former Member
0 Kudos

I never had to test in debug mode.

I know that you can switch debugging on with /h....but I don`t really understand where to go from there. Some of the documentation on the internet are confusing for me.

Now I`m getting " Access via 'NULL' object reference not possible." with this call stack:

Method: ON_DATA_CHECK of program /1BCWDY/04RQA8JMA4W8RQKR21UM==CP

Method: ON_DATA_CHECK of program /1BCWDY/04RQA8JMA4W8RQKR21UM==CP

Method: IF_WDR_VIEW_DELEGATE~WD_INVOKE_EVENT_HANDLER of program /1BCWDY/04RQA8JMA4W8RQKR21UM==CP

Method: INVOKE_EVENTHANDLER of program CL_WDR_DELEGATING_VIEW========CP

Method: FIRE_EVENT of program CL_WDR_COMPONENT==============CP

Method: IFWDR_INTERNAL_API~RAISE_EVENT of program SAPLWDR_RG_PROXY_FACTORY

Method: IF_COMPONENTCONTROLLER~FIRE_ON_DATA_CHECK_EVT of program /1BCWDY/05925V4FUOXTQY7GYD5U==CP

Method: IF_SALV_WD_COMPONENT~FIRE_EVENT of program CL_SALV_WD_C_TABLE============CP

Method: IF_SALV_WD_COMP_TABLE_EVENTS~ON_DATA_CHECK of program CL_SALV_WD_C_TABLE_V_TABLE====CP

Method: IF_SALV_WD_COMP_TABLE_IF~DATA_CHECK of program CL_SALV_WD_C_TABLE============CP

Former Member
0 Kudos

Hi,

Are u really a technical consultant? I mean Debugging is a very basic thing a ABAPer should know.

Anyways to switch in debugging mode goto se80-> give your web dynpro compnent/intf.

Goto the view ,then to methods where you have coded put the cursor on the line which you want to debug goto Utilities ->External Breakpoint->set/delete external breakpoint. In web Dynpro abap /H debugging wont work. Or else paste the entire code wich you are getting error.

Regards,

Santosh

Former Member
0 Kudos

Of course I`m not an sap consultant. I`m a newbie trying to learn abap.

I already tried what you said with the breakpoint....The problem is what should I do in ABAP Debugger to figure out what went wrong in my code? There are many tabs in Abap Debugger that I don`t understand. Which is the right one in my case?

Former Member
0 Kudos

Hi,

Use modify Statement, and Enque and deque table. check below sample code.

LlOOP AT IT_VTTK INTO WA_VTTK.

WA_VTTK-UATEN = WA_VTTK-UATEN.

WA_VTTK-TDLNR = WA_VTTK-TDLNR.

MODIFY IT_VTTK from WA_VTTK.

ENDLOOP.

  • lock the table

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

MODE_RSTABLE = 'E'

TABNAME = 'VTTK'

  • VARKEY = ship_no

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

MODIFY VTTK from table IT_VTTK.

if sy-subrc is initial.

COMMIT WORK .

else.

ROLLBACK work.

endif.

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

MODE_RSTABLE = 'E'

TABNAME = 'VTTK' .

Cheers,

Kris.

Former Member
0 Kudos

HI,

Take help from your senior consultant as this is not a training place to give you all details.Or else there are many sites where you can find how to debug a code. Debug the code with the help of your senior and find wat value you get in Internal table ITAB.

And i asked you to send the whole code so that it can be more clear where you went wrong.The above code which you have send is incomplete. If that is the only code in method ON_DATA_CHECK then the output you are getting is correct.

Regards,

Santosh