Application Development 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 cant get right answer

Former Member
0 Kudos

Hi experts:

my code:

data: gs_iihttpnvp TYPE IHTTPNVP,

gt_tihttpnvp TYPE TIHTTPNVP,

sname type string.

sname = 'sname1'.

read table gt_tihttpnvp into gs_iihttpnvp with key name = 'sname1'.

read table gt_tihttpnvp into gs_iihttpnvp with key name = sname.

The first read can get the right value and the second can't. I don't know why,someone knows please help me, thanks.

Allen

3 REPLIES 3

gopi_narendra
Active Contributor
0 Kudos

Welcome to SDN Allen

IHTTPNVP should be having a field called NAME which is of type of SNAME as declared.

In your 1st READ since you are checking with some value it returns SY-SUBRC = 0.

In your 2nd READ you are trying yo match it with some variable of type STRING.

This might be the reason. So declare the SNAME of type IHTTPNVP-NAME

Hope this solves.

Happy Coding

Regards

Gopi

Former Member
0 Kudos

Hi,

If you see field type for TIHTTPNVP-NAME, it is a string whose length varies. It has unlimited length.

When you compare the same with string, it matches exact characters so it is working. But when you compare with the variables, characters to compare are not matching so it is not working.

If it had been of TYPE CHAR length 10 and also SNAME would have been type char and length 10 then second read also would have worked.

Hope this helps.

ashish

former_member223537
Active Contributor
0 Kudos

data: gs_iihttpnvp TYPE IHTTPNVP,
gt_tihttpnvp TYPE standard table of TIHTTPNVP,
sname type string.

clear gs_iithttpnvp.
gs_iihttpnvp-sname = 'sname1'.
append gs_iihttpnvp to gt_tihttpnvp.

clear gs_iihttpnvp.
read table gt_tihttpnvp into gs_iihttpnvp with key sname = 'sname1'.
write 😕 gs_iihttpnvp-sname.