cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Expression creation in Process controlled workflow

Former Member
0 Kudos

Hi All,

I am working on SRM 7.0 and utilizing process controlled workflow to model my approval workflow scenario. Below are the steps that i have done but still i have not got the desired result. May be i am missing something which the forum members can let me know.

step 1: i have copied the standard function module /SAPSRM/WF_BRF_0EXP001 and made chnages in the code based on the logic to populate the ev_value.

basically in the coding it is done this way.

      • initialize

EV_TYPE = 'B'.

EV_LENGTH = 1.

CLEAR EV_CURRENCY.

EV_OUTPUT_LENGTH = 1.

EV_DECIMALS = 0.

EV_VALUE = ABAP_FALSE. " no processing

EV_DATA_MISSING = 'X'.

  • get event object

LO_WF_BRF_EVENT ?= IO_EVENT.

  • get Context Container from BRF event

LO_CONTEXT_PROVIDER = LO_WF_BRF_EVENT->GET_CONTEXT_PROVIDER( ).

CALL METHOD LO_CONTEXT_PROVIDER->GET_DOCUMENT

IMPORTING

EV_DOCUMENT_GUID = LV_DOCUMENT_GUID

EV_DOCUMENT_TYPE = LV_DOCUMENT_TYPE.

CASE LV_DOCUMENT_TYPE.

WHEN 'BUS2121'.

  • Get shopping cart instance

LO_WF_PDO_SC ?= /SAPSRM/CL_WF_PDO_IMPL_FACTORY=>GET_INSTANCE(

IV_DOCUMENT_GUID = LV_DOCUMENT_GUID

IV_DOCUMENT_TYPE = LV_DOCUMENT_TYPE

IV_PDO_EVENT_HANDLING = ABAP_FALSE

).

      • custom logic with the GUID of the shopping cart then populate value accordingly

EV_VALUE = ABAP_TRUE.

CLEAR EV_DATA_MISSING.

step 2: create an event ZEV_001 linked to expresion ZEX_001.

step 3: expression ZEX_001 is of type 0FB001. and the xpression is as below.

ZEX_002 = OB_WF_TRUE.

step 4: ZEX_002 is of type 0CF001 and output result type is B. the attached function module is the one created above by copying /SAPSRM/WF_BRF_0EXP001

no parameters provided .

step 5: the process step level config completed.

now when i am creating shopping cart go for approval preview its gives an exception occured error . i cant see any dump in the system. however if in the custom fucnction module code if i do not clear the EV_DATA_MISSING. then i d o not get the error but my steps is not executed. Inslg1 log i see the process level executed but return as space.

as per other post in the forum we have to clear EV_DATA_MISSING but that casuing exception eror for me. in the dlg1 log howere the steps expressin i can see executed with return =X.

hope i am made myself clear . feel free to ask for any more info.

i have below question.

1) do we need to copy /SAPSRM/WF_BRF_0EXP001 or /SAPSRM/WF_BRF_0EXP000 for creating a custom FM expression.

2)what does the check box "Calculation of Parameter in Function Module/Badi/method" does

3) how can i do debugging for such FM expression , probably saving the cart and then debugging the expression.

Thanks in advance for any help provided.

Cheers

Iftekhar Alam

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Everything looks good. Just change your code as shown below and try..

Instead of

      • custom logic with the GUID of the shopping cart then populate value accordingly

EV_VALUE = ABAP_TRUE.

CLEAR EV_DATA_MISSING.

      • custom logic with the GUID of the shopping cart then populate value accordingly

CLEAR EV_DATA_MISSING.

EV_VALUE = ABAP_TRUE.

Saravanan

Former Member
0 Kudos

Hi Sarvanan,

NO it has not helped me by chnaging the code as per your suggestion. I think in the expression ZEX_002 where i have used the cutsom function module i have to pass some parameters. what that parameters could be. my output EV_VALUE of the function is a boole and that is set by cheking if nay of the line items of the shopping cart have a custom field filled with a certain value.

please let me know what could be the parameters of the cutsom function module which is copy of standard FM /SAPSRM/WF_BRF_0EXP000.

Cheers

Iftekhar Alam

Former Member
0 Kudos

Hi,

Are you using any parameter in the FM expression? if you so make sure you have followed the naming standard for parameters. The name standard would be like below.. Try and let me know...

Class - XX_C1

Method - XX_C2

Attributes - XX_C3 and XX_C4.

Regards,

Saravanan

The difference between FM's /SAPSRM/WF_BRF_0EXP000 and /SAPSRM/WF_BRF_0EXP001 is if you use the parameter in the FM Expression then copy the FM /SAPSRM/WF_BRF_0EXP000 else copy the /SAPSRM/WF_BRF_0EXP001 which you don't need to create parameters..

Edited by: Saravanan Dharmaraj on Jun 23, 2010 10:01 AM

Former Member
0 Kudos

Hi Saravanan,

I am not using any parameter for the cutsom function module that i have created which is copy of /SAPSRM/WF_BRF_0EXP001 .This is also what you suggested. so i understand if we use the FM /SAPSRM/WF_BRF_0EXP000 we will have to use the parameter and then we might then have to create cutom method in the class. Am i correct ?

Strange is if i comment the EV_DATA_MISSING i dont get the exception error , but the expression is always with result as space.

Thanks for all your thought.

any more things to look for ?

Cheers

Iftekhar Alam

Former Member
0 Kudos

Hi ,

Just put the below code in the FM and try..

DATA: lo_wf_brf_event TYPE REF TO /sapsrm/cl_wf_brf_event,

lo_wf_pdo TYPE REF TO /sapsrm/if_wf_pdo,

lo_ctxt_provider TYPE REF TO /sapsrm/cl_wf_context_provider.

DATA: lv_document_guid TYPE /sapsrm/wf_document_guid,

lv_msg TYPE string,

lv_document_type TYPE /sapsrm/wf_document_type.

DATA: lx_exception TYPE REF TO /sapsrm/cx_wf_abort.

*=======================================================================

  • Preset return parameters

*=======================================================================

ev_type = /sapsrm/if_wf_rule_c=>type_bool.

ev_length = 1.

CLEAR ev_currency.

ev_output_length = 1.

ev_decimals = 0.

  • get event object

IF NOT io_event IS BOUND.

  • BRF event Object not bound. No further execution possible.

MESSAGE e089(/sapsrm/brf) INTO lv_msg.

TRY.

CALL METHOD /sapsrm/cl_wf_brf_ccms=>send_message( ).

CATCH /sapsrm/cx_wf_abort INTO lx_exception.

ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.

EXIT.

ENDTRY.

ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.

EXIT.

ENDIF.

*=======================================================================

  • Get purchasing document

*=======================================================================

  • get event object

lo_wf_brf_event ?= io_event.

  • get context container from BRF event

lo_ctxt_provider = lo_wf_brf_event->get_context_provider( ).

  • get Content Container from BRF event

IF NOT lo_ctxt_provider IS BOUND.

  • BRF Context Container Object not bound. No further execution possible.

MESSAGE e090(/sapsrm/brf) INTO lv_msg.

TRY.

CALL METHOD /sapsrm/cl_wf_brf_ccms=>send_message( ).

CATCH /sapsrm/cx_wf_abort INTO lx_exception.

ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.

EXIT.

ENDTRY.

ev_data_missing = /sapsrm/if_wf_rule_c=>brf_data_missing.

EXIT.

ENDIF.

  • get document

CALL METHOD lo_ctxt_provider->get_document

IMPORTING

ev_document_guid = lv_document_guid

ev_document_type = lv_document_type.

  • get instance

lo_wf_pdo ?= /sapsrm/cl_wf_pdo_impl_factory=>get_instance(

iv_document_guid = lv_document_guid

iv_document_type = lv_document_type

).

Case lv_document_type.

When u2018BUS2121u2019.

Pass the lv_document_guid to get SC details.

IF THE CONDITION TRUE..

CLEAR: ev_data_missing.

ev_value = c_x.

ELSE.

ev_data_missing = c_x.

ev_value = c_blnk.

ENDIF.

WHEN OTHERS.

ev_data_missing = c_x.

ev_value = c_blnk.

ENDCASE.

Make sure the check expression will have check as shown below

ZEX_002= 0C_WF_B_FALSE

FYI-

You don't need to have expression ZEX_001 to check the result of ZEX_002, because both expressios resut is type 'B". you can directly attached the ZEX_002 to main Event ZEV_001

Regards,

Saravanan

Edited by: Saravanan Dharmaraj on Jun 23, 2010 12:25 PM

Former Member
0 Kudos

Hi Saravanan,

i did the exact code but still the same problem. i agree with your that i dont need to nest expression ZEX_002 to ZEX_001 as both are of type bool . Actually earlier my expression ZEX_002 was of typr char and i was passing 'X' or blank accordingly and in ZEX_001 i was checking if ZEX_002 = 'X'.

once i got the error i tried chnage the ev_value to type boole and was using ABAP_TRUE or ABAP_FALSE to pass the value.

i have a doubt .

in your code you defined ev_type as boole but you are uinsg the value 'X' or space .. does that work ?

i have sent you my code dump and config screen shot . please excuse me for that as that might help you to understand and pin point my error.

Thanks for your help.

cheers

Iftekhar Alam

Former Member
0 Kudos

Hi Alam,

I replied your Email with some suggestions .. have a look.. hope that will fix your issue.. if not.. please reply back.. i'll bulid the same way in my system and let you know my suggestion...

Best Regards,

Saravanan

Former Member
0 Kudos

Hi Saravanan,

Wow man your suggestion did worked ... great !!!!!

for the benefir of all the member the issue was with process level numbering. My process level was configured as 1 , 100,200,400. I deleted the process level and rebuild again with 100 200 300 400 and it worked...

what i dint understand when SAP says the workflow is more configurable , so if i have configured process level as 100, 200 , 300 etc and then there is chnage in business required and i have to insert a process level in between then what should i do ? say if i have to insert a step between 100 and 200 then can't i make the process level as any number between 100 - 200 ??

Also refer to oss not 1388575 though it did not help much and we were already with support pack 5.

Former Member
0 Kudos

Hi,

Glad that my suggestion helped and fix your issue.

Regarding your queries..

what i dint understand when SAP says the workflow is more configurable , so if i have configured process level as 100, 200 , 300 etc and then there is change in business required and i have to insert a process level in between then what should i do ? say if i have to insert a step between 100 and 200 then can't i make the process level as any number between 100 - 200 ??

You can still add process level in between 100 and 200 from 101 to 199.. Make sure the process level number suppose to be three digits..

Also refer to oss not 1388575 though it did not help much and we were already with support pack 5.

I though youu2019re in SP3.

Saravanan

Answers (0)