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: 

To get All Possible Combination of word

deepak_dhamat
Active Contributor
0 Kudos

Hi All ,

After Long Search on SDN , i am Posting this Thread ...

Can anyone tell me Any Function Module or Hint to get Possible Different Combination of Word .

Say Example i will pass one word 'deepak' .

i should get result

deepak

deepka

deekap

deekpa

and so on till 36 combination

.

It is not nessecary that i will pass only six charater word it can be any word of any length .

i know IT might look as i am doing this for testing .. But it will help me to create one Function Module which will return all possible combination .

regards

Deepak.

9 REPLIES 9

Former Member
0 Kudos

I dont think any such syntax or FM exists. But there is "CA" for reverse of this, incase you want such code for validation.

0 Kudos

Hi ,

I want all Possible Combination of a Word .

regards

Deepak.

0 Kudos

If you search in google for the term 'Perumtations of a string' you will get loads of algorithms using which you can build your own logic in ABAP.

Vikranth

0 Kudos

Hi,

I cant imagine why such a standard function would exist.

I would suggest building it yourself. That shouldn't be too hard, should it?

Try using dynamic DOs and SHIFT...CIRCULAR for instance.

Roy

deepak_dhamat
Active Contributor
0 Kudos

Hi Vikrant ,

Yes i am Working on same . after Completing will upload the same .

regards

Deepak.

0 Kudos

and so on till 36 combination

Shouldn't this be: fak(6)/2 = 360 combinations ?

Besides that, I don't think that this is an ABAP question. I can't imagine there could be a function module.

Ask a friend who is good at mathematics, or try Google, keyword : permutation

(I agree with Vikranth here, apart from a typo.)

regards

0 Kudos

Google was kind enough to correct my typo

0 Kudos

Hi ,

All Possible combination of word

PARAMETERS : g_text1 type string .



types: y_s_text type rstxtsh,
y_ts_text type standard table of y_s_text with default key,
y_ts_permu type standard table of string with default key.

data: g_d_text type y_s_text,
*      g_d_text1 type y_s_text ,
g_t_text_table type y_ts_text,
g_d_permu type string,
g_t_permu_table type standard table of string with default key,
ln type  i value 0.

g_d_text = g_text1 .
len =  strlen( g_d_text ) .
do len times  .
g_d_text = g_text1+ln(1) .

 ln = ln + 1 .

append g_d_text to g_t_text_table.

ENDDO .

perform permu using g_t_text_table changing g_t_permu_table.

loop at g_t_permu_table into g_d_permu.
write: / g_d_permu.
endloop.
*&---------------------------------------------------------------------
*& Form permu
*&---------------------------------------------------------------------
** text
*----------------------------------------------------------------------
** -->P_G_T_TEXT_TABLE text
** <--P_G_T_PERMU_TABLE text
*----------------------------------------------------------------------
FORM permu USING u_T_TEXT_TABLE type y_ts_text
CHANGING c_T_PERMU_TABLE type y_ts_permu.
data: l_t_text_copy type y_ts_text,
l_d_text type y_s_text,
l_t_permu_copy type y_ts_permu,
l_d_permu type string,
l_d_tabix like sy-tabix.

refresh c_t_permu_table.
describe table u_t_text_table lines l_d_tabix.
if l_d_tabix <= 1.
loop at u_t_text_table into l_d_text.
l_d_permu = l_d_text.
append l_d_permu to c_t_permu_table.
endloop.
else.
do l_d_tabix times.
l_t_text_copy = u_t_text_table.
read table u_t_text_table into l_d_text index sy-index.
delete l_t_text_copy index sy-index.
perform permu using l_t_text_copy
changing l_t_permu_copy.
loop at l_t_permu_copy into l_d_permu.
concatenate l_d_text l_d_permu into l_d_permu.
append l_d_permu to c_t_permu_table.
endloop.
enddo.
endif.

ENDFORM. " permu

Closing Thread as Answered

regards

Deepak.

Edited by: Deepak Dhamat on Oct 22, 2011 7:29 AM

Edited by: Deepak Dhamat on Oct 22, 2011 7:32 AM

deepak_dhamat
Active Contributor
0 Kudos

answered