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: 

[Rookie] Char vs String

Former Member
0 Kudos

Hey,

this is a beginner question! So please be kind

I created a SAP PI a message interface that includes string fields as data types with a

minlength and a maxlength.

After creating an ABAP Proxy I can use this interface in my ABAP program. Without

the minlength and maxlength attributes, he just created strings in ABAP proxy. With

these attributes he create a char type.

I'm not familiar with chars so how to fill these:

a) hard coded in source code

b) with a dynpro (using parameter command)

I tried to fill these fields like a normal string:

it-SEARCH_FOR-AUTHOR_LAST_NAME = "Smith".

But it doesn't work. So how to handle these chars in ABAP?

thx

chris

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

use single quotes, dont use double quotes in the below statement

it-SEARCH_FOR-AUTHOR_LAST_NAME = 'Smith'.

Reward points if it helps,

Satish

9 REPLIES 9

naimesh_patel
Active Contributor
0 Kudos
it-SEARCH_FOR-AUTHOR_LAST_NAME = 'Smith'.

<b>Smith</b> should be in single quote (') not in double quote (").

Regards,

Naimesh Patel

Former Member
0 Kudos

Hi,

use single quotes, dont use double quotes in the below statement

it-SEARCH_FOR-AUTHOR_LAST_NAME = 'Smith'.

Reward points if it helps,

Satish

0 Kudos

Hey,

thanks for answers. Ok, I figure out, that the problem is a little bit different.

My structure:


DATA it TYPE ZSEARCH_FOR.

     it-SEARCH_FOR-PUBLISHER = 'Cornlesen1'.                   --> a string. occurs 0..1
     it-SEARCH_FOR-AUTHOR_LAST_NAME = "Panzer".        --> a char. occurs 1..unbounded
     it-SEARCH_FOR-ISBNNUMBER = '0123456789'.              --> a char. occurs 0..1

The first and last elements work fine. The second one seems to be a generated table

of type ZDT_SEARCH_FOR_AUTHOR_LAST_TAB. This table got as line type the

predefine char of 35 characters.

How can I use/fill such a table structure in ABAP?

thx

chris

0 Kudos

If you want to fill the double qoutes in the table ... than look at this one

concatnate '"' 'Panzer' '"' into it-SEARCH_FOR-AUTHOR_LAST_NAME.

Hope it will help

Regards,

Naimesh Patel

0 Kudos

Ups, sorry a mistake. I don't want to fill the double quotes. The problem is

to fill this table.

With single or without double quotes following error occurs.

"The type of IT-Search_For-Author_Last_Name cannot be converted to the type of Panzer"

So how to use this table in a structure?

0 Kudos

If th Panzer is somekind of value or charachter or name than you need to use the single quotes to assign it.

IT-Search_For-Author_Last_Name = 'Panzer'.

If it doesn't slove your purpose, let me know what is Panzer ??

Regards,

Naimesh Patel

0 Kudos

It is just the name of the author. You can also write anything else.

Again, the single or double quotes are not the problem. I cannot use

For-Author_Last_Name like the other fields, because it is a table, because

it can occur 0...unbound.

thx

chris

0 Kudos

Ahhh...

what are the field there in the Author_Last_Name ??

You can do it like

Author_Last_Name-field1 = 'Mr.'.

Author_Last_Name-name = 'Test1'.

append author_last_name to it-SEARCH_FOR-AUTHOR_LAST_NAME.

Hope it will help.

Regards,

Naimesh Patel

0 Kudos

Got it. Your answer wasn't 100% correct, but the hint with

the append comand was useful.

Two soloutions are possible:

1) Create a temporary variable with type of the table, append items to it and

set the reference to this.

DATA it_table type ZDT_SEARCH_FOR_AUTHOR_LAST_TAB.

append 'ABC' to it_table.

....

it-SEARCH_FOR-AUTHOR_LAST_NAME = it_table

2) Append datas directly

append 'ABC2' to it-SEARCH_FOR-AUTHOR_LAST_NAME.

Thanks.

Points given.