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

Assign Multiple values to a Variable.

Former Member
0 Likes
8,591

Hi

I want to use a set of 5 different values of a particular variable in my FM. Is there any way in ABAP to assign multiple values on a single variable? Suppose, it is not a field of any table - just a normal variable!!!

Something like...

var_name = { val1, val2, val3, val4, val5 }.

Plz help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,921

Hi,

You cannot assign multiple values to the same variable in ABAP. You can use Ranges for this.



Data: var_name like rsranges,
var like line of var.

var-SIGN = 'I'.
var-OPTION = 'CP'.

var-low = 'val1'.
append var to var_nam.

var-low = 'val2'.
append var to var_nam.

var-low = 'val3'.
append var to var_nam.

var-low = 'val4'.
append var to var_nam.

var-low = 'val5'.
append var to var_nam.

Regards,

Vik

12 REPLIES 12
Read only

Former Member
0 Likes
3,921

A variable can store a single value at a time so if you want to assgign multiple values to a variable then one soultion can be use of CONCATENATE command.

I am not sure whether it will fulfil your requirements or not.

Example

CONCATENATE var1 var2 va3 var4 var4 into var SEPARATED BY space.

Read only

Former Member
0 Likes
3,922

Hi,

You cannot assign multiple values to the same variable in ABAP. You can use Ranges for this.



Data: var_name like rsranges,
var like line of var.

var-SIGN = 'I'.
var-OPTION = 'CP'.

var-low = 'val1'.
append var to var_nam.

var-low = 'val2'.
append var to var_nam.

var-low = 'val3'.
append var to var_nam.

var-low = 'val4'.
append var to var_nam.

var-low = 'val5'.
append var to var_nam.

Regards,

Vik

Read only

0 Likes
3,921

Can we use CONTAINS PATTERN operator while selecting records from a STD Table?

Like....

select firld1 field2.... fieldn

from <STD TABLE>

into table <INTERNAL TABLE>

where fieldx CP '#P#P'.

plz suggest

Read only

0 Likes
3,921

Hi,

No. The CP operator cannot be used directly in the select statement. Instead you can use like operation to search with wild card patterns.

Eg,


select firld1 field2.... fieldn
from <STD TABLE>
into table <INTERNAL TABLE>
where fieldx like  '%P%P%'.

Regards,

Vik

Read only

0 Likes
3,921

Hi vikred

Thx for ur reply. Its really helpful.

One more doubt - do you know if there is any table that stores the Production Order related Order Types?

Thx

Rich

Read only

0 Likes
3,921

Well am afraid you are not supposed to ask multiple questions within the same thread. It would be better if you close this thread and post a new one with all your queries.

Regards,

Vik

Read only

0 Likes
3,921

Hi, Richard

Please First Search for your Query and if not able to find any Solution than Post and always open new Thread for your New Question

Have a look at [Forum Rules|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]

Faisal

Read only

0 Likes
3,921

>

> Hi,

>

> No. The CP operator cannot be used directly in the select statement. Instead you can use like operation to search with wild card patterns.

>

> Eg,

>

>


> select firld1 field2.... fieldn
> from <STD TABLE>
> into table <INTERNAL TABLE>
> where fieldx like  '%P%P%'.
> 

>

> Regards,

> Vik

Dear Vikred

Please Don't Reply this way it is against the Forum Rules, Please

@Nitesh Pandey: Please you too

I think asking him to open New Thread for his New Query is Enough

Please Don't Mind

Faisal

Read only

0 Likes
3,921

Hi Faisal,

Well what was wrong with my reply? You mean ur asking not to reply for a different question? I felt we can consider replying for just one additional question instead of spamming the forum with new threads.

Read only

0 Likes
3,921

Hi Faisal/Vikred

Sorry for the confusion - In fact, my latter query is very much connected to former. and Vikred's reply solved my issue also.

For better understanding the query only, I changed the title for tht alone in my reply.

Thx a lot Vikred.

Regards

Rich

Read only

faisalatsap
Active Contributor
0 Likes
3,921

Hi, Richard

You can Simple Fill an Internal Table and Pass to your FM

Please Reply for any more help.

Regards,

Faisal

Read only

Former Member
0 Likes
3,921

Hi,

It's advisable to use CP in if statement.

Just have a look at this.

Loop at <Your-internal-table.
IF <field> CP 'A@#$'.
** Write your code here.
ENDIF.
endloop.

Thanks