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

String parameter problem

Former Member
0 Likes
901

Hello,

I get a strange error when calling a method with

a parameter of type String. With debug the varaible use

as parameter has the correct value, using explicit value

the method its work.

Here some code for a better understanding:

This way is not working

<i>

Call Method g_tree->add_node

Exporting node_key = l_tm_child

<b>relative_node_key = l_tm_parent</b>

relationship = cl_simple_tree_model=>relat_last_child

isfolder = ' '

text = l_child_text.</i>

where l_tm_parametr is of type String and has value 'BMECAT'

But with expicit value will work :

Exporting node_key = l_tm_child

<b>relative_node_key = 'BMECAT'</b>

relationship = cl_simple_tree_model=>relat_last_child

isfolder = ' '

text = l_child_text.</i>

Anyone knows what's the problem?

I've met this problem once more when comparing String?

Many Thanks!

kojo

Message was edited by: Bogdan Cojocaru

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
738

Hi Bogdan,

The parameter for the method is of type TV_NODEKEY which is a Character field of 12 positions. You can't use type string for this.

Kind regards,

John.

7 REPLIES 7
Read only

FredericGirod
Active Contributor
0 Likes
738

Hello,

don't understand your problem ... but I declare relative_node_key as type lvc_nkey.

maybe that will help you

Regards

Frédéric

Read only

Former Member
0 Likes
739

Hi Bogdan,

The parameter for the method is of type TV_NODEKEY which is a Character field of 12 positions. You can't use type string for this.

Kind regards,

John.

Read only

0 Likes
738

Hello John,

The type for parameter relative_node_key is TM_NODEKEY which data type is STRING ( in method cl_simple_tree_model->add_node).But thank you anyway

One thing that I notice at debug is the hex value differs

for 'BMECAT1' is <b>424D4543415431</b>

and for varible l_tm_parent is <b>424D454341543120</b>.

Another thing to say is that before calling method I make

a concatenation between 'BMECAT' and 1 into l_tm_parent.

( actually the value is BMECAT1 ).

Thank you!

Bogdan

ps. sorry for my english

<b></b>

Read only

0 Likes
738

In hexa 20 is not a space ?

Read only

0 Likes
738

Check this one

&----


*& Form CREATE_ALVTREE_HIERARCHY

&----


  • text

----


  • Builds ALV tree display, (inserts nodes, subnodes etc)

----


form create_alvtree_hierarchy.

data: ls_sflight type sflight,

lt_sflight type sflight occurs 0.

data: ld_ebeln_key type lvc_nkey,

ld_ebelp_key type lvc_nkey.

  • clear: wa_usrtab.

  • wa_usrtab-disname = 'Contacts'.

  • perform add_user_node using wa_usrtab

  • ''

  • changing ld_ebeln_key.

If p_friend EQ ' '.

loop at it_messfriends into wa_messfriends

where friend ne sy-uname.

perform add_user_line using wa_messfriends

ld_ebeln_key

changing ld_ebelp_key.

endloop.

ELSE.

loop at it_usrtab into wa_usrtab

where bname ne sy-uname.

perform add_user_line using wa_usrtab

ld_ebeln_key

changing ld_ebelp_key.

endloop.

endif.

  • calculate totals

call method gd_userlist->update_calculations.

  • this method must be called to send the data to the frontend

call method gd_userlist->frontend_update.

endform. " CREATE_ALVTREE_HIERARCHY

<b>* Add node

call method gd_userlist->add_node

EXPORTING

i_relat_node_key = <b>p_relate_key</b>

i_relationship = cl_gui_column_tree=>relat_last_child

i_node_text = ld_node_text

is_outtab_line = ps_usrtab

it_item_layout = lt_item_layout

IMPORTING

e_new_node_key = p_node_key.</b>

http://www.sapdevelopment.co.uk/saptalk/saptalkincf01.htm

Thanks & Regards,

Judith.

U can reward points for the answers that are helpful and that solved ur problem and Please close the thread.

Message was edited by: Judith Jessie Selvi

Read only

0 Likes
738

Hi,

I figure the cause of the error

using concatenate on 'BMECAT' and an integer, an extra character is added at the end of the string

But If the integer is converteted to N (numeric chars)

the concatenate works fine.

Thank you!

Bogdan

Read only

0 Likes
738

Bogdan,

please set your message as solved by yourself.

Frédéric