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: 

Class/FM instead of PFAC t code ??

former_member392866
Active Participant
0 Kudos

Hello Team,

Do we have any classes or Function modules in SAP ABAP to create Standard roles ?

Note : - I need to create Role (with Container values) by using SE38 report program .

Regards,

Balaji

1 ACCEPTED SOLUTION

former_member392866
Active Participant
0 Kudos

Hi Team,

Below logic for your reference..

  1. Responsibility creation

    CALL FUNCTION 'RH_INSERT_INFTY'
    EXPORTING
    *         FCODE               = 'INSE'
    vtask              
    = 'S'
    *         ORDER_FLG           = 'X'
    *         COMMIT_FLG          = 'X'
    *         AUTHY               = 'X'
    *         PPPAR_IMP           =
    *         OLD_TABNR           = ' '
    repid              
    = sy-repid
    *         form                = ' '
    *         KEEP_LUPD           =
    *         WORKF_ACTV          = 'X'
    TABLES
    innnn              
    = t_p1000
    *         ILFCODE             =
    EXCEPTIONS
    no_authorization   
    = 1
    error_during_insert
    = 2
    repid_form_initial 
    = 3
    corr_exit          
    = 4
    begda_greater_endda
    = 5
    OTHERS              = 6.
    IF sy-subrc EQ 0.

    CALL FUNCTION 'RH_UPDATE_DATABASE'
    EXPORTING
    vtask    
    = 'S'
    EXCEPTIONS
    corr_exit
    = 1
    OTHERS    = 2.


  1. Assign responsibility to Rule

CALL FUNCTION 'RH_INSERT_INFTY'
EXPORTING
*       FCODE               = 'INSE'
vtask              
= 'S'
*       ORDER_FLG           = 'X'
*       COMMIT_FLG          = 'X'
*       AUTHY               = 'X'
*       PPPAR_IMP           =
*       OLD_TABNR           = ' '
*       repid               = sy-repid
*       form                = ' '
*       KEEP_LUPD           =
*       WORKF_ACTV          = 'X'
TABLES
innnn              
= t_p1240
*       ILFCODE             =
EXCEPTIONS
no_authorization   
= 1
error_during_insert
= 2
repid_form_initial 
= 3
corr_exit          
= 4
begda_greater_endda
= 5
OTHERS              = 6.

CALL FUNCTION 'RH_UPDATE_DATABASE'
EXPORTING
vtask    
= 'S'
EXCEPTIONS
corr_exit
= 1
OTHERS    = 2.

  1. Insert/Update Container values for a responsibility

CALL FUNCTION 'RH_UPDATE_INFTY'

       EXPORTING

         vtask               = 'S'

*       ORDER_FLG           = 'X'

*       COMMIT_FLG          = 'X'

*       authy               = 'X'

*       PPPAR_IMP           =

*       OLD_TABNR_NEW_LANGU = ' '

         repid               = sy-repid

         form                = 'INSERT_TAB'

*       KEEP_LUPD           =

*       WORKF_ACTV          = 'X'

       TABLES

         innnn               = t_p1218

*       ILFCODE             =

       EXCEPTIONS

         error_during_update = 1

         no_authorization    = 2

         repid_form_initial  = 3

         corr_exit           = 4

         OTHERS              = 5.

*for 1st time - need to insert container values

     CALL FUNCTION 'RH_INSERT_INFTY'

       EXPORTING

*       FCODE               = 'INSE'

         vtask               = 'S'

*       ORDER_FLG           = 'X'

*       COMMIT_FLG          = 'X'

*       AUTHY               = 'X'

*       PPPAR_IMP           =

*       OLD_TABNR           = ' '

         repid               = sy-repid

         form                = 'INSERT_TAB'

*       KEEP_LUPD           =

*       WORKF_ACTV          = 'X'

       TABLES

         innnn               = t_p1218

*       ILFCODE             =

       EXCEPTIONS

         no_authorization    = 1

         error_during_insert = 2

         repid_form_initial  = 3

         corr_exit           = 4

         begda_greater_endda = 5

         OTHERS              = 6.


FORM insert_tab TABLES pt_tab                               "#EC *

                 USING VALUE(p_wplog)

                       VALUE(p_tabix).

   FIELD-SYMBOLS: <l_p1222>      TYPE p1218,

                  <l_wa_hrt1222> TYPE hrt1218,

                  <l_pt1222>     TYPE pt1218.

   ASSIGN p_wplog TO <l_p1222> CASTING.

   ASSIGN pt_tab  TO <l_pt1222> CASTING.

   CLEAR: <l_pt1222>, pt_tab[].

   DATA : ls_container_det LIKE LINE OF lt_container_det.

   DATA : ls_pt1218 LIKE LINE OF t_pt1218.

   LOOP AT lt_container_det INTO ls_container_det.

     READ TABLE t_pt1218 INTO ls_pt1218 WITH KEY tabnr = <l_p1222>-tabnr

                                                 tabseqnr = ls_container_det-tabseqnr

                                                 element = ls_container_det-element .

     IF sy-subrc EQ 0.

*for existing element.

       IF ls_pt1218-expr_low NE ls_container_det-low OR ls_pt1218-expr_high NE ls_container_det-high.

         ls_pt1218-expr_low = ls_container_det-low.

         ls_pt1218-expr_high = ls_container_det-high.

       ENDIF.

     ELSE.

*for new element

       ls_pt1218-element = ls_container_det-element.

       ls_pt1218-expr_low = ls_container_det-low.

       ls_pt1218-expr_high = ls_container_det-high.

     ENDIF.

     MOVE-CORRESPONDING ls_pt1218 TO <l_pt1222>.

     APPEND pt_tab TO pt_tab[].

     CLEAR :ls_container_det,ls_pt1218.

   ENDLOOP.


  1. Agent assignment

CALL FUNCTION 'RH_READ_INFTY_1001'
EXPORTING
plvar           
= '01'
otype           
= 'RY'
objid           
= zcl_hpe_eco_roles_resp_list=>gv_resp_id
istat           
= '1'
*         subty            = 'A007'
TABLES
i1001           
= t_1001
EXCEPTIONS
nothing_found   
= 1
wrong_condition 
= 2
wrong_parameters
= 3
OTHERS           = 4.


CALL FUNCTION 'RH_INSERT_INFTY'
EXPORTING
vtask              
= 'S'
TABLES
innnn              
= t_1001
EXCEPTIONS
no_authorization   
= 1
error_during_insert
= 2
repid_form_initial 
= 3
corr_exit          
= 4
begda_greater_endda
= 5
OTHERS              = 6.

IF sy-subrc EQ 0.
CALL FUNCTION 'RH_UPDATE_DATABASE'
EXPORTING
vtask    
= 'S'
EXCEPTIONS
corr_exit
= 1
OTHERS    = 2.

Regards,

Balaji P

9 REPLIES 9

Former Member
0 Kudos

Hi ,

First of all  what kind of Roles you want to create , there are few FM/BAPI can create any kind of role  :-

PRGN_RFC_CREATE_ACTIVITY_GROUP for Master role .

/VIRSA/RE_BAPI_CREATE_ROLE for Master , Derive and composite roles .

You might have to check these FM's if it is suitable for your requirement or not .

Regards,

Manish

0 Kudos

Hi Manish,

Thanks for your turn around .

I cant see any container values or Responsibilities parameters in above FMs which you have provided .

Regards,

Balaji

0 Kudos

This message was moderated.

0 Kudos

There is a standard functionality in workflow with PFAC, can't it be used?

FM: RH_GET_ACTORS should provide the interface.

The following table parameters have to exist in the custom function module.

“ACTOR_TAB STRUCTURE SWHACTOR”

“AC_CONTAINER STRUCTURE SWCONT”


Regards,

Akber

former_member186746
Active Contributor
0 Kudos

Hi,

You're using different terminology which might unnecessary complicate things.

PFAC is to create rules or responsibilities. Not roles that is transaction PFCG.

I couldn't find a function module/class to create rules programmatically.

How many Rules need to be created anyway that you're trying to do this with ABAP insted of with PFAC

Kind regards, Rob Dielemans

0 Kudos

Hi Rob,

for me also confusing.. as you said  PFAC is to create Rules only in ECC6. But if i see in ECC4.7 system the t code PFAC was used for standard roles .

let me correct if i wrong any thing . Thank you .

Regards,

Balaji

0 Kudos

Now I'm confused..... because you're correct

http://help.sap.com/saphelp_47x200/helpdata/en/9b/572614f6ca11d1952e0000e82dec10/frameset.htm

I think in 4.7 you're limited with the number of  bapis and classes to do stuff programmatically.

So you can check the code of the transaction, as has already been mentioned, to find out where creation takes place.

Or you can do a recording with SHDB to automate the process.

Or you can check CATT (transaction SCAT) I don't think eCatt exists in 4.7

Good luck!

Kind regards, Rob Dielemans

Former Member
0 Kudos

Open the code program behind the T.Code you will see the stuffs.

former_member392866
Active Participant
0 Kudos

Hi Team,

Below logic for your reference..

  1. Responsibility creation

    CALL FUNCTION 'RH_INSERT_INFTY'
    EXPORTING
    *         FCODE               = 'INSE'
    vtask              
    = 'S'
    *         ORDER_FLG           = 'X'
    *         COMMIT_FLG          = 'X'
    *         AUTHY               = 'X'
    *         PPPAR_IMP           =
    *         OLD_TABNR           = ' '
    repid              
    = sy-repid
    *         form                = ' '
    *         KEEP_LUPD           =
    *         WORKF_ACTV          = 'X'
    TABLES
    innnn              
    = t_p1000
    *         ILFCODE             =
    EXCEPTIONS
    no_authorization   
    = 1
    error_during_insert
    = 2
    repid_form_initial 
    = 3
    corr_exit          
    = 4
    begda_greater_endda
    = 5
    OTHERS              = 6.
    IF sy-subrc EQ 0.

    CALL FUNCTION 'RH_UPDATE_DATABASE'
    EXPORTING
    vtask    
    = 'S'
    EXCEPTIONS
    corr_exit
    = 1
    OTHERS    = 2.


  1. Assign responsibility to Rule

CALL FUNCTION 'RH_INSERT_INFTY'
EXPORTING
*       FCODE               = 'INSE'
vtask              
= 'S'
*       ORDER_FLG           = 'X'
*       COMMIT_FLG          = 'X'
*       AUTHY               = 'X'
*       PPPAR_IMP           =
*       OLD_TABNR           = ' '
*       repid               = sy-repid
*       form                = ' '
*       KEEP_LUPD           =
*       WORKF_ACTV          = 'X'
TABLES
innnn              
= t_p1240
*       ILFCODE             =
EXCEPTIONS
no_authorization   
= 1
error_during_insert
= 2
repid_form_initial 
= 3
corr_exit          
= 4
begda_greater_endda
= 5
OTHERS              = 6.

CALL FUNCTION 'RH_UPDATE_DATABASE'
EXPORTING
vtask    
= 'S'
EXCEPTIONS
corr_exit
= 1
OTHERS    = 2.

  1. Insert/Update Container values for a responsibility

CALL FUNCTION 'RH_UPDATE_INFTY'

       EXPORTING

         vtask               = 'S'

*       ORDER_FLG           = 'X'

*       COMMIT_FLG          = 'X'

*       authy               = 'X'

*       PPPAR_IMP           =

*       OLD_TABNR_NEW_LANGU = ' '

         repid               = sy-repid

         form                = 'INSERT_TAB'

*       KEEP_LUPD           =

*       WORKF_ACTV          = 'X'

       TABLES

         innnn               = t_p1218

*       ILFCODE             =

       EXCEPTIONS

         error_during_update = 1

         no_authorization    = 2

         repid_form_initial  = 3

         corr_exit           = 4

         OTHERS              = 5.

*for 1st time - need to insert container values

     CALL FUNCTION 'RH_INSERT_INFTY'

       EXPORTING

*       FCODE               = 'INSE'

         vtask               = 'S'

*       ORDER_FLG           = 'X'

*       COMMIT_FLG          = 'X'

*       AUTHY               = 'X'

*       PPPAR_IMP           =

*       OLD_TABNR           = ' '

         repid               = sy-repid

         form                = 'INSERT_TAB'

*       KEEP_LUPD           =

*       WORKF_ACTV          = 'X'

       TABLES

         innnn               = t_p1218

*       ILFCODE             =

       EXCEPTIONS

         no_authorization    = 1

         error_during_insert = 2

         repid_form_initial  = 3

         corr_exit           = 4

         begda_greater_endda = 5

         OTHERS              = 6.


FORM insert_tab TABLES pt_tab                               "#EC *

                 USING VALUE(p_wplog)

                       VALUE(p_tabix).

   FIELD-SYMBOLS: <l_p1222>      TYPE p1218,

                  <l_wa_hrt1222> TYPE hrt1218,

                  <l_pt1222>     TYPE pt1218.

   ASSIGN p_wplog TO <l_p1222> CASTING.

   ASSIGN pt_tab  TO <l_pt1222> CASTING.

   CLEAR: <l_pt1222>, pt_tab[].

   DATA : ls_container_det LIKE LINE OF lt_container_det.

   DATA : ls_pt1218 LIKE LINE OF t_pt1218.

   LOOP AT lt_container_det INTO ls_container_det.

     READ TABLE t_pt1218 INTO ls_pt1218 WITH KEY tabnr = <l_p1222>-tabnr

                                                 tabseqnr = ls_container_det-tabseqnr

                                                 element = ls_container_det-element .

     IF sy-subrc EQ 0.

*for existing element.

       IF ls_pt1218-expr_low NE ls_container_det-low OR ls_pt1218-expr_high NE ls_container_det-high.

         ls_pt1218-expr_low = ls_container_det-low.

         ls_pt1218-expr_high = ls_container_det-high.

       ENDIF.

     ELSE.

*for new element

       ls_pt1218-element = ls_container_det-element.

       ls_pt1218-expr_low = ls_container_det-low.

       ls_pt1218-expr_high = ls_container_det-high.

     ENDIF.

     MOVE-CORRESPONDING ls_pt1218 TO <l_pt1222>.

     APPEND pt_tab TO pt_tab[].

     CLEAR :ls_container_det,ls_pt1218.

   ENDLOOP.


  1. Agent assignment

CALL FUNCTION 'RH_READ_INFTY_1001'
EXPORTING
plvar           
= '01'
otype           
= 'RY'
objid           
= zcl_hpe_eco_roles_resp_list=>gv_resp_id
istat           
= '1'
*         subty            = 'A007'
TABLES
i1001           
= t_1001
EXCEPTIONS
nothing_found   
= 1
wrong_condition 
= 2
wrong_parameters
= 3
OTHERS           = 4.


CALL FUNCTION 'RH_INSERT_INFTY'
EXPORTING
vtask              
= 'S'
TABLES
innnn              
= t_1001
EXCEPTIONS
no_authorization   
= 1
error_during_insert
= 2
repid_form_initial 
= 3
corr_exit          
= 4
begda_greater_endda
= 5
OTHERS              = 6.

IF sy-subrc EQ 0.
CALL FUNCTION 'RH_UPDATE_DATABASE'
EXPORTING
vtask    
= 'S'
EXCEPTIONS
corr_exit
= 1
OTHERS    = 2.

Regards,

Balaji P