cancel
Showing results for 
Search instead for 
Did you mean: 

Update structure does not contain any elements error

Former Member
0 Kudos

Dear Friends in am a newbie in WDA. My Function Module has the following decalarations.

TABLES

*" U_P9006 STRUCTURE P9006

*" IT_P9006 STRUCTURE P9006

IT_P9006 is used to fill all the values in the Table, if the user wants to create a new entry in the table then he will click on the new button and U_9006 will be used to hold the new value and save in the database.

when i binded U_9006-EmployeeNumber to a Input box to accept values and tested the application dumps giving the error

"Adapter error in INPUT_FIELD "TC_1_EMPLOYEE_CODE" of view "ZHOLIDAY.MAINVIEW": Context binding of property STATE cannot be resolved: Node COMPONENTCONTROLLER.1.ZESS_EDU.1.CHANGING_1.1.U_P9006 does not contain any elements "

i have 3 basic questions please help me.

1. Currently the cardinality of the Node U_9006 is 0..n and Selection 0..1 , i reffered few sdn threads where it says change the cardinality to 0..n and issue will resolve , my issue is cardinality is already 0...n and even if i try to change it at the context tab it is not changing.

2. if map the INPUT BOX a String attribute ctx_employee rather than mapping it to the U_P9006-EmployeeNumber the page does not dumps , but how do i assign this ctx_employee value to the u_9006-employeenumber in the coding?

3. any sample of SAVE code so that on those lines i write SAVE coding and try to update the record.

Regards,

Jack

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Point 2. : Update:

I used the Webdynpro COde wizard to READ the employee code and put the value in a temp variable lv_pernr

  • get single attribute for `CTX_PERNR`

lo_el_contextNEW->get_attribute(

EXPORTING

name = `CTX_PERNR`

IMPORTING

value = lv_ctx_pernr ).

  • Now again using the Webdynpro code wizard i SET the employee code

lv_employee_code = lv_ctx_pernr. " ************SETTING THE CTX_PERNR HERE*****

  • set single attribute

lo_el_u_p9006->set_attribute(

name = `EMPLOYEE_CODE`

value = lv_employee_code ).

Here i have make sure that the lv_employee_code and the lv_ctx_pernr are of the same type PERNR_D

still i am getting the

error " Access via 'NULL' object reference not possible."

Dear Shrini, Jhansi

i am not able to change the cardinality when i double clcik on the U_9006 and check the cardinality below it does not allow me to change...very strange

Edited by: Jack on Feb 10, 2012 4:52 PM

Former Member
0 Kudos

This Node U_9006 was at the Controller i binded to a Node U_9006 at the view.

AT the view layout i am in the CONTEXT TAB , there i am trying to change the cardinality.

is this the correct place to chnage it?

former_member199125
Active Contributor
0 Kudos

before reading attribtue, first read element,

lo_el_contextnew = lo_nd_contextnew->get_element( ).

lo_el_contextNEW->get_attribute(

EXPORTING

name = `CTX_PERNR`

IMPORTING

value = lv_ctx_pernr ).

//ly

lo_el_u_p9006 = lo_nd_p9006->get_element( ).

lo_el_u_p9006->set_attribute(

name = `EMPLOYEE_CODE`

value = lv_employee_code ).

and i think you are trying to change the cardinality from view controller..go to component controller, then change the cardinality of node there.

Regards

Srinivas

Former Member
0 Kudos

Srini that's correct i am able to change the cardinality at the Controller level.

now since i am using a empty input box (in ctx_pernr) filling the value in it then trying to copy this value ctx_pernr to

u_p9006-EmployeeNumber, please help me to move ahead in this direction only..

i am also reading the element, the code is like this.....

  • get element via lead selection

lo_el_contextNEW = wd_context->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_contextNEW IS INITIAL.

ENDIF.

  • get single attribute for `CTX_PERNR`

lo_el_contextNEW->get_attribute(

EXPORTING

name = `CTX_PERNR`

IMPORTING

value = lv_ctx_pernr ).

but it dumps

former_member199125
Active Contributor
0 Kudos

If my guess correct,

you have not selected the "initialize the lead selection' property of node.

Please select the check box of Initialize the lead selection property of node then check.

Regards

srinivas

Former Member
0 Kudos

Hi Thanks for the help so far ... i have mapped the Import Structure to the input box and it is not dumping beauce i set it to cardinality 1..1 as per your advice.

Now i want to save this input parameter to the database table, please let me know how to do it.

i have used the read wizard and Read the Employee Code and Employee Name ,

do i need to Bind it just like webdynpro java , and do i need to appeand it before EXECUTE ? please help with a small sample code to perform this.

former_member199125
Active Contributor
0 Kudos

I dont know abt ur database table structure...

For ex, if your ztable has two fields say name and empid...

declare work area say: data wa_Data type ztable.

now read the name and empid attributes using codewizard,,,

now these values will be in LV_NAME and LV_empid..

wa_data-name = lv_name .

wa_data-empid = lv_empid.

modify ztable from wa_Data. ( it will create a record in ur database table )

Regards

Srinivas

Former Member
0 Kudos

Hi i understood the concept but not able to use it here ....This piece of code is to be written under the method ONACTIONSAVE which is callled on the click of the SAVE button and this is on the MainView.

I am using a function module which is doing the SAVING stuff i need to just pass this value correctly to the U9006 import structure so that in the FM it passess correctly and SAVE's.

I have READ both of them and have values in LV_NAME and LV_empid .......and also READ the MODE which is MOD

with this 3 values my FM creates a record in the DB.

........my problem is now how do i pass this to FM..(rahter than directly updating the infotype form here, which i dont want to do )..........do i need to use the Append code wizard here ....or how to proceed...my FM is ready i just need to pass it till there...

former_member199125
Active Contributor
0 Kudos

Please tell me which function module you are using? which infotype you are updating or inserting new record?

open your function module in SE37, observe the structure of importing and exporting parameters...

the same structures should define in ur onaction save,

then, pass your values to above defined structures... then pass the structures to function modules parameters.

then it will create record.

Regards

srinivas

Edited by: sanasrinivas on Feb 13, 2012 11:25 AM

Former Member
0 Kudos

I am using a cutom infotype 9006 which is used to update the employee extra details like Alias name , interest and hobbies ectc etc.

i have a programming expereice in WDJava thought it must be similar here as well, on the action SAVE i have READ the 3 items i.e MODE=MOD, employee number, name ...in se37 i am able to save it.

what we do in WDJava is we create a Object of the Table and fill it, then Append it, Bind It and then EXECUTE......

same i am trying here using the below code............ONActionSAve...

DATA lo_nd_u_p9006NEW TYPE REF TO if_wd_context_node.

DATA ls_u_p9006NEW TYPE wd_this->element_u_p9006.

DATA lt_u_p9006 TYPE wd_this->elements_u_p9006.

  • navigate from <CONTEXT> to <U_P9006> via lead selection

lo_nd_u_p9006NEW = wd_context->path_get_node( path = `ZES_EMP.CHANGING_1.U_P9006` ).

ls_u_p9006NEW-employee_code = lv_employee_code.

ls_u_p9006NEW-relation = lv_relation.

lo_nd_u_p9006NEW->bind_table( new_items = lt_u_p9006 set_initial_elements = abap_false ).

*********************Execute Code

DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .

lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).

lo_componentcontroller->execute_zes_emp(

).

Nothing is happening here

former_member199125
Active Contributor
0 Kudos

Jack,

Bind_table , bind_element methods are used to insert records into NODE, not into database table.

As you said you want to insert records into custom infotype, you need to use function modules to create .

For infotype tables we use below function module to insert records

HR_INFOTYPE_OPERATION

DATA return1 TYPE bapireturn1.

DATA: wa_9006 TYPE p9006.

NOW PASS ALL THE VALUES OF WA_9006.

WA_9006-PERNR = LV_EMPID.

wa_9006-begda = " provide start date'

wa_9006-endda = ' provide end date

wa_9006-aedtm = sy-datum.

wa_9006-uname = sy-uname. ///LY PASS ALL THE VALUES OF P9006 TABLE( CHECK SE11 FOR FIELDS )

THEN CALL BELOW FUNCTION MODULE.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'
               EXPORTING
                        infty                  = '9006'
                         number                 = wa_9006-pernr
*                         subtype                = wa_9006-subty
*               OBJECTID               =
*               LOCKINDICATOR          =
                        validityend            = wa_9006-endda
                        validitybegin          = wa_9006-begda
*               RECORDNUMBER           =
                        record                 = wa_9006
                        operation              = 'INS'
*                TCLAS                  = 'A'
*                DIALOG_MODE            = '0'
*                NOCOMMIT               =
*                 VIEW_IDENTIFIER        =
*                 SECONDARY_RECORD       =
              IMPORTING
                      return                 = return1
*              KEY                    =
                       .

Hope this will be useful

Regards

Srinivas

Edited by: sanasrinivas on Feb 13, 2012 12:28 PM

Former Member
0 Kudos

Hi i am able to SAVE the record i just READ the Employee-code and the Name from the U_9006 structure and Executed the RFC call....i.e instantiated the RFC and it is updating the new record.

Last question: if i need to delete a record line i will slect the record from the table and then slect the delete button,

now when i click on the Table how will i slect that particular record (or employee code) at the runtime to further use it to delete the record?

i mean what should i write code to capture the employee code to further send it to RFC for Delelte?

Former Member
0 Kudos

Hi Jack,

You can use GET_LEAD_SELECTION_INDEX method of interface IF_WD_CONTEXT_NODE to get

the index of the selected line. Now using this index loop at your table and find the employee code

and you can delete it.

Former Member
0 Kudos

Thanks for your inputs harshit, please can you ellborate more on it?

please give a sample code on how to get the index pernr and then loop it to get employee? i am not able to get it .

Answers (3)

Answers (3)

former_member199125
Active Contributor
0 Kudos

Make the cardinality of U_9006 node to 1:1,

hope you are not binded this node to any table.

Regards

Srinivas

Former Member
0 Kudos

Hi,

Change the cardinality of node from 0..n to 1..n. It will work.

It is giving the dump as it does not contain any elements to hold the inpiut.

Chaging the cardinality of node U_9006 to 1..n will resolve the issue.

Regards,

Jhansi

Former Member
0 Kudos

Hi,

Change the cardinality of node from 0..n to 1..n. It will work.

It is giving the dump as it does not contain any elements to hold the inpiut.

Chaging the cardinality of node U_9006 to 1..n will resolve the issue.

Regards,

Jhansi