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: 

Function Module for Permutation Combination of 1234

Former Member
0 Kudos
135

Dear ALL,

I have a string suppose for example 1234 and i have to make permutation combination for the given string.

1 ) By taking all four word

2 ) By taking any three of them,

3 ) By taking any two of them,

is there any function module to provide permutation combination of the given string or please provide any logic related to calculate permutation & combination .

Thanks in advance,

With Regards

Shantanu

3 REPLIES 3

Former Member
0 Kudos
52

i could not find such fm.

logic is---

suppose u have 4 digit string.

u can find out the length of string using <b>strln( str)</b>

now if u want to number of possible combination be.

<b>total no = 4c4 + 4c3 + 4c2 + 4c1 = 2(pow,n) - 1.

where n = lenth of string.</b>

Clemenss
Active Contributor
0 Kudos
52

Hi shantanu,

no function AFAIK.

The logic should be recursive as follows:

(set are all members like example 1234, N is size of resulting set like all four, three, two; sets are the resulting variations - only all of them is called permutation)

get_variations importing set N exporting sets;

check N > 0.

for <all members of set> do:

remove member from set;

put member to result set;

get_variations exporting set N importing partsets;

put member to all partsets;

put partsets to resulting sets

This is the recursive logic. You can use internal tables for the sets. The internal table may have fields that are internal table as well.

Hope you get it! - it is recursive

Regards,

Clemens

BTW: Post once.

Former Member
0 Kudos
52

Hello,

Please check this function module

RSEC_GENERATE_PASSWORD

Best Regards,

Krishnakumar