cancel
Showing results for 
Search instead for 
Did you mean: 

CRUD : Problem on Update function

0 Kudos

Hi,

   I am designing simple application in that i applied all CRUD function. Create  Read  Delete functions are working nut in Update it is not working

onUpdate: function() {

            var that = this;

            var oDialog = new sap.m.Dialog({

                title: "Update Product",

                content: [

                    /*new sap.m.Label({

                        text: "Product ID"

                    }),

                    new sap.m.Input(),*/

                    new sap.m.Label({

                        text: "Product Name"

                    }),

                    new sap.m.Input(),

                ],

                endButton: new sap.m.Button({

                    text: "Close",

                    press: function() {

                        oDialog.close();

                    }

                }),

                beginButton: new sap.m.Button({

                    text: "Save",

                    press: function() {

                        var udata = {

                   

                            Name: this.getParent().getContent()[3].getValue(),

                        };

                        var myDialog = this.getParent();

                        that.getView().getModel().update("/ProductSet('"+ udata +"')", udata, {

                            success: function() {

                                sap.m.MessageToast.show("Product Update Successfully");

                                myDialog.close();

                            },

                            error: function() {

                                sap.m.MessageToast.show("Error Occur");

                            }

                        });

                    }

                }),

            });

            oDialog.open();

        }



i am getting issue on    Name: this.getParent().getContent()[3].getValue(),



please tell me  how to rectify that error

 

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member203031
Contributor
0 Kudos

Hi Praveen,

Which value you are trying to fetch either from input or from the backend?

I think you can't write like "getContent()[3]" there might be some other path to fetch the value.

Thanks,

Deepak.

0 Kudos

Hi Deepak,

        getContent()[3]  ---- > user enter data in screen { Ex :  Name : Test material }

                   i need to update this information in table


this is complete code


in this code success message is throwing  but  problem is data not updated

former_member203031
Contributor
0 Kudos

I think you are trying to create in the json format those 2 values.

Just place a break- point and try to get the value in the console.

check that once.

u can create json format in some other way.

I don't weather u r process is correct or not.

I will try like this:

var udata = { }  // empty.

udata.ProductID = this.getParent().getContent()[1]  // getting value

r u sure by this u can get the value from the dialog.....

udata.Name= this.getParent().getContent()[3]  // getting value


Now in the Udata u will get those values



Thanks,

Deepak.

karthikarjun
Active Contributor
0 Kudos

Hi Peaveen- I think there the getValue parameter does not exist in the content[3].

You would have to check before the value is existing inside the object or not.

Regards, 

Karthik A

b_punith
Participant
0 Kudos

Hi Praveen,

As per your complete code, you are very correct to access ...getContent()[3]

Code written in the initial post is having your control commented, and ...getContent()[3] will return error instead ...getContent()[1] should work.

Regards,

Punith

0 Kudos

Hi  Punith,

           in debugging i am getting the Values and also  Success message is rerun but  data not updating in data base 

      

b_punith
Participant
0 Kudos

Hi Praveen,

If you are having a success response for your update query, then this issue is something which you need to check in backend.

Ensure that ProductSet Entity update method is implemented in dpc_ext class and update logic is properly implemented.

Refer below CRUDQ operations:

http://scn.sap.com/community/gateway/blog/2014/03/06/let-s-code-crudq-and-function-import-operations...

Regards,

Punith

0 Kudos

Hi Punith,

      Back end code is also successfully executed.Once check the screen shots

Code:

  method PRODUCTSET_UPDATE_ENTITY.

data:ls_key_tab type /iwbep/s_mgw_name_value_pair,

     ls_product_id type bapi_epm_product_id,

     ls_headerdata type bapi_epm_product_header,

     ls_headerdatax type   bapi_epm_product_headerx,

     ls_product like er_entity,

     lt_return type STANDARD TABLE OF bapiret2.

IO_DATA_PROVIDER->READ_ENTRY_DATA(

  importing

    ES_DATA                      =  ls_product

).

  LOOP AT it_key_tab into ls_key_tab.

     IF ls_key_tab-name eq 'ProductID'.

       ls_product_id-product_id = ls_key_tab-value.

     ENDIF.

  ENDLOOP.

  CALL FUNCTION 'BAPI_EPM_PRODUCT_GET_DETAIL'

    EXPORTING

      PRODUCT_ID               = ls_product_id

   IMPORTING

     HEADERDATA               = ls_headerdata

*   TABLES

*     CONVERSION_FACTORS       =

*     RETURN                   =

            .

ls_headerdata-name = ls_product-name.

ls_headerdatax-product_id = ls_headerdata-product_id.

CALL FUNCTION 'BAPI_EPM_PRODUCT_CHANGE'

  EXPORTING

    PRODUCT_ID                = ls_product_id

   HEADERDATA                = ls_headerdata

   HEADERDATAX               = ls_headerdatax

*   PERSIST_TO_DB             = ABAP_TRUE

TABLES

*   CONVERSION_FACTORS        =

*   CONVERSION_FACTORSX       =

   RETURN                    = lt_return

          .

IF lt_return is NOT INITIAL.

mo_context->get_message_container( )->ADD_MESSAGES_FROM_BAPI(

exporting

IT_BAPI_MESSAGES          =  lt_return   " Return parameter table

*     IV_ERROR_CATEGORY        =     " Error Category

IV_DETERMINE_LEADING_MSG  =

      /IWBEP/IF_MESSAGE_CONTAINER=>GCS_LEADING_MSG_SEARCH_OPTION-FIRST ).

RAISE EXCEPTION TYPE /IWBEP/CX_MGW_BUSI_EXCEPTION

  exporting

    TEXTID        = /IWBEP/CX_MGW_BUSI_EXCEPTION=>BUSINESS_ERROR

    MESSAGE_CONTAINER   =  mo_context->GET_MESSAGE_CONTAINER( ).

ENDIF.

  er_entity = ls_product.

  endmethod.

b_punith
Participant
0 Kudos

Hi Praveen,

If you are having sucecss return message from BAPI return paramter, issue BAPI_TRANSACTION_COMMIT.

*----Code---------

CALL FUNCTION 'BAPI_EPM_PRODUCT_CHANGE'

  EXPORTING

    PRODUCT_ID                = ls_product_id

   HEADERDATA                = ls_headerdata

   HEADERDATAX               = ls_headerdatax

*   PERSIST_TO_DB             = ABAP_TRUE

TABLES

*   CONVERSION_FACTORS        =

*   CONVERSION_FACTORSX       =

   RETURN                    = lt_return

          .

IF lt_return is INITIAL.

     // Commit Bapi Changes

ELSE.

mo_context->get_message_container( )->ADD_MESSAGES_FROM_BAPI(

exporting

IT_BAPI_MESSAGES          =  lt_return   " Return parameter table

*     IV_ERROR_CATEGORY        =     " Error Category

IV_DETERMINE_LEADING_MSG  =

      /IWBEP/IF_MESSAGE_CONTAINER=>GCS_LEADING_MSG_SEARCH_OPTION-FIRST ).

RAISE EXCEPTION TYPE /IWBEP/CX_MGW_BUSI_EXCEPTION

  exporting

    TEXTID        = /IWBEP/CX_MGW_BUSI_EXCEPTION=>BUSINESS_ERROR

    MESSAGE_CONTAINER   =  mo_context->GET_MESSAGE_CONTAINER( ).

ENDIF.

Regards,

Punith