Thursday, 14 December 2017

Loop Until with Sales Order and Approver example

Flow chart



Steps:-

Step 1 : Create a Business Object.

  • Go to Transaction SWO1.
  • Create Business Object.

  • Add key field.
  • To get Order details create a method.
  • Add the parameters to it.


  •  Select the method and click on Program.
  • Enter the below code.
begin_method jgetorderapp changing container.

data:
  salesdocument type vbak-vbeln,
  applist       type wfsyst-initiator occurs 0,
  applevels     type zsystem_info_cat-counter.
swc_get_element container 'SalesDocument' salesdocument.

data wa_list like line of applist.

applevels 3.

clear wa_list .
wa_list 'USECCUSR48'.
append wa_list to applist.

clear wa_list .
wa_list 'USECCUSR49'.
append wa_list to applist.

clear wa_list .
wa_list 'USECCUSR50'.
append wa_list to applist.

sort applist  ascending.

swc_set_table container 'AppList' applist.
swc_set_element container 'Applevels' applevels.


end_method.

  • Create a method to get next approver. 
  • To add parameters , select the method and click on Parameters.
  • Add the parameters.
  • To enter the code , select the method and click on program.
  • Source code.
data:
  applist type wfsyst-initiator occurs 0,
  nextapp type wfsyst-initiator,
  wa_list like line of applist.
swc_get_table container 'AppList' applist.

clear  wa_list.

read table applist
 into wa_list
 index 1.

if sy-subrc eq 0.

  nextapp wa_list.
  delete applist index 1.

endif.
swc_set_table container 'AppList' applist.
swc_set_element container 'NextApp' nextapp.

  • Create an Event.
  • Save -> Check and Release.

Step 2: Create a task to get sales order details at background.

  • Go to Transaction code PFTC.
  • Select Task Type as Standard Task.
  • Click on Create.
  • Enter the Task name and Description.

  • Select the Object Category as BOR Object Type.
  • Enter the Object Type and Method.
  • Select background processing.
  • Click on Binding and Bind the followings Task to Method.
  • Click on Container.
  • Save and click on Release -> SAVE.


Step 3: Create a task to get Next Approver  details at background.


  • Go to Transaction code PFTC.
  • Select Task type as Standard Task.
  • Enter the Task name and click on Create.
  • Select the Object category as " BOR Object Type".
  • Object type : Enter the Business Object Name.
  • Enter the method name.
  • Click on Background processing.

  • Click on Binding and Bind as per follows.
  • Click on Container tab.
  • Click on Basic Data Tab and select Release status as "Release"
  • Click on SAVE.


-----

1 comment: