08-19-2011 8:00 AM
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.
08-19-2011 8:36 AM
I dont think any such syntax or FM exists. But there is "CA" for reverse of this, incase you want such code for validation.
08-19-2011 10:41 AM
08-19-2011 10:55 AM
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
08-19-2011 10:59 AM
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
08-19-2011 10:58 AM
Hi Vikrant ,
Yes i am Working on same . after Completing will upload the same .
regards
Deepak.
08-19-2011 11:21 AM
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
08-19-2011 11:31 AM
10-22-2011 6:28 AM
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
10-22-2011 6:32 AM