Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

address structure's component dynamically

Former Member
0 Likes
1,189

Dear All,

I am getting the message "The data object ls_udat3 does not have a component called <fs_genfield>"
when I am trying to address structure's component dynamically. I kindly ask you for your support,
What have I done wrong at the point in the program. 

Best regards

Alex


data:  ls_udata type zbbpusr01_2,
         lt_attr_data  type bbpt_attr,
         ls_attr_data  type bbps_attr,
         ls_vlist      type bbps_attr_values,
         lt_vlist      type bbpt_attr_values,
         ls_udat3      type zbbpusr01_3,
         ls_udat3_2    type zbbpusr01_3,
         lv_fieldname  type string,
         lt_udat3      type table of zbbpusr01_3,
         et_fcat       type lvc_t_fcat,
         lv_user type baluser.

  LOOP AT p_gt_udate INTO ls_udata.
    lv_user = ls_udata-userid.

    CALL FUNCTION 'BBP_READ_ATTRIBUTES'
      EXPORTING
        iv_user                 = lv_user
        IV_SCENARIO             = 'BBP'
        it_attr_list            = gt_attr_list2
      IMPORTING
        ET_ATTR                 = lt_attr_data
      EXCEPTIONS
        object_id_not_found     = 1
        no_attributes_requested = 2
        attributes_read_error   = 3
        OTHERS                  = 4.


    FIELD-SYMBOLS:
    <fs_zbbpusr03>  type zbbpusr01_3,
    <fs_zbbpusr>    type zbbpusr01_3,
    <fs_field>      type bbps_attr-attr_id,
    <fs_attr_data>  type bbps_attr,
    <fs_vlist>      type bbps_attr_values,
    <fs_genfield>   type any.

    loop at lt_attr_data ASSIGNING <fs_attr_data>.
      assign <fs_attr_data>-attr_id to <fs_genfield>.
      loop at <fs_attr_data>-vlist  ASSIGNING <fs_vlist>.
        MOVE <fs_vlist>-value to ls_udat3-<fs_genfield>.
      ENDLOOP.
    ENDLOOP.
  ENDLOOP.
ENDFORM.                    " READ_ATTR

9 REPLIES 9
Read only

former_member585060
Active Contributor
0 Likes
1,124

Hi,

It seems you are trying to populate LS_UDAT3-VALUE with the <fs_vlist>-value. May be you can try some thing with ASSIGN COMPONENT statement.

ex:-

ASSIGN COMPONENT 'VALUE' OF STRUCTURE <fs_vlist> TO <fs_genfield>.

ls_udat3-value = <fs_genfield>.

Thanks & Regards

Bala Krishna

Read only

0 Likes
1,124

Hi,

thats wrong.

I am not trying  to populate LS_UDAT3-VALUE with the <fs_vlist>-value.

I am      trying  to populate  ONLY LS_UDAT3-<fs_genfield> with the <fs_vlist>-value.

I can't do anything with your suggestion.

Furthermore.. LS_UDAT3 does not have a component called value.

Read only

0 Likes
1,124

How come you are mapping LS_UDAT3 field with <fs_genfield>, it will throw an error that LS_UDAT3 does not have a component called <fs_genfield>.

What is the field name in LS_UDAT3 to which you are mapping <fs_vlist>-value?

Read only

0 Likes
1,124

imagine that <fs> is the same as ls. Meaning - once assigned, working with a field-symbol and a standard variable is (almost) the same.

So what your have written have the same meaning as would have LS_UDAT3-ls_variable, if "ls_variable" was a standard variable.

If you want to assign any value to a specific column of ls_udat3 structure, use this syntax:

assign component 'component_name' of structure ls_udat3 to <lv_field>.

<lv_field> = value.

Read only

Former Member
0 Likes
1,124

If you want to assign any value to a specific column of ls_udat3 structure, use this syntax:

assign component 'component_name' of structure ls_udat3 to <lv_field>.

<lv_field> = value.

     in my case the 'component_name' must be determined dynamically. This is the challenge

     in my issue

This was the reason why got the error message: The data object ls_udat3 does not have a component called <fs_genfield>"

Look at:

MOVE <fs_vlist>-value to ls_udat3-<fs_genfield>.

ls_udat3  -> Structure

<fs_genfield>  -> Field/Component

Read only

0 Likes
1,124

Hi Alexander,

If I understood the requirement correctly , <fs_genfield> will have component name (of ls_udat3)at run time , then you can use Jozef 's suggestion . It will solve the problem

FIELD SYMBOL <fs_value> type any.

ASSIGN COMPONENT <fs_genfield> OF STRUCTURE LS_UDAT3 to <fs_value>.

<fs_value> = <fs_vlist>-value.

Thanks & Regards,

Arun

Read only

0 Likes
1,124

Hi Arun,

thank you very much. Problem is solved.

This is how I have implemented it.

assign component <fs_attr_data>-attr_id of structure ls_udat3 to <fs_field>.

<fs_field> = <fs_vlist>-value.

Reagrds

Alex

Read only

Former Member
0 Likes
1,124

I can't see any link or button about how I can reward.

Read only

0 Likes
1,124

if you are logged in, the button should be seen in every post.