Skip to Content

                    Displaying table in Work Flow decision step

                  Using HTML Codes


                                                                     Author – Srivijay K Dinnimath

                                                                             Date – 5th Feb 2015




Overview:


This documentation to know how to use HTML Codes to display table in Workflow decision step.


 
User decision step in SAP-Workflow supports HTML tags, but we can’t display the whole table with multiple entries while creating text for user decision step. As a solution for this, we can include HTML tags along with the DB entries fetched in the BOR Object’s method itself and pass/bind it to work flow’s user decision step.




Pre – requisites:


Before we start to create a table with HTML tags, we must have an idea of Business object repository (BOR) and SAP Business Workflows.



Business Object Repository (BOR):


The Business Object Repository (BOR) is the object-oriented repository in the R/3 System. It contains the SAP business object types and SAP interface types as well as their components, such as methods, attributes and events.

BAPIs are defined as methods of SAP business object types (or SAP interface types) in the BOR. Thus defined, the BAPIs become standard with full stability guarantees as regards their content and interface.

SAP Business Workflow:

SAP Business Workflow can be used to define business processes that are not yet mapped in the R/3 System. These may be simple release or approval procedures, or more complex business processes such as creating a material master and the associated coordination of the departments involved. SAP Business Workflow is particularly suitable for situations in which work processes have to be run through repeatedly, or situations in which the business process requires the involvement of a large number of agents in a specific sequence.

 

Process Logic:


  1. Created test BOR Object ZBUS007 with Key field Purchase Requisition number and method ZTEST_HTML.

/wp-content/uploads/2015/02/1_637868.png


   /wp-content/uploads/2015/02/2_637869.png

    2.  Defining Method parameters:

     /wp-content/uploads/2015/02/3_637870.png

     /wp-content/uploads/2015/02/4_637872.png

3. Method code:

BEGIN_METHOD ZTEST_HTML CHANGING CONTAINER.

DATA: PURCHASEREQUISITION TYPE EBAN-BANFN,
       OUTPUT_TBLE        
LIKE  W3HTML OCCURS 0,
       WA_OUTPUT          
TYPE W3HTML.

TYPES: BEGIN OF TY_EBAN,
      BANFN
TYPE BANFN,
      BNFPO
TYPE BNFPO,
      BSART
TYPE BBSRT,
END OF TY_EBAN.
DATA: LT_EBAN
TYPE TABLE OF TY_EBAN,
       WA_EBAN
TYPE TY_EBAN.
CLEAR: LT_EBAN[].
SWC_GET_ELEMENT CONTAINER
‘PurchaseRequisition’ PURCHASEREQUISITION.
*  SWC_GET_TABLE CONTAINER ‘output_tble’ OUTPUT_TBLE.

SELECT BANFN BNFPO BSART FROM EBAN
INTO TABLE LT_EBAN
WHERE BANFN = PURCHASEREQUISITION.

IF SY-SUBRC = 0.
WA_OUTPUT-LINE =
‘<HTML><BODY><TABLE BORDER=”2″ ><TR><TH>PR Number</TH><TH>Item Number</TH>’.
APPEND WA_OUTPUT TO OUTPUT_TBLE.
CLEAR: WA_OUTPUT.

wa_output-line = ‘<TH>Document Type</TH></TR>’.
APPEND WA_OUTPUT TO OUTPUT_TBLE.
CLEAR: WA_OUTPUT.
IF LT_EBAN[] IS NOT INITIAL.
LOOP AT LT_EBAN INTO WA_EBAN.
CONCATENATE ‘<TR><TD>’ WA_EBAN-BANFN ‘</TD><TD>’ WA_EBAN-BNFPO ‘</TD><TD>’ WA_EBAN-BSART ‘</TD></TR>’ INTO WA_OUTPUT-LINE.
APPEND WA_OUTPUT TO OUTPUT_TBLE.
CLEAR: WA_OUTPUT, WA_EBAN.
ENDLOOP.
ENDIF.
wa_output-line =
‘</TABLE></BODY></HTML>’.
APPEND WA_OUTPUT TO OUTPUT_TBLE.
CLEAR: WA_OUTPUT.
ENDIF.

SWC_SET_ELEMENT CONTAINER ‘PurchaseRequisition’ PURCHASEREQUISITION.
SWC_SET_TABLE CONTAINER
‘output_tble’ OUTPUT_TBLE.
END_METHOD.

4. Generating the Method and BOR Object:

/wp-content/uploads/2015/02/5_637873.png




5. After generating the BOR Object we need to create a Work flow.

Create a work flow with Activity, User decision, Send mail and process control steps.

/wp-content/uploads/2015/02/6_637883.png




6. Create an activity step,

/wp-content/uploads/2015/02/7_637885.png




7. Double click on newly created task (TS99100445 in above case) and call the method ZTEST_HTML of ZBUS007 created,

/wp-content/uploads/2015/02/8_637895.png




8. Bind the variables of method to Work flow,

/wp-content/uploads/2015/02/9_637897.png





9. Create a user decision step with decision texts Approve/Reject and define the user,

/wp-content/uploads/2015/02/10_637898.png




10. Define the Agent assignment,

/wp-content/uploads/2015/02/11_637899.png





11. Bind the variables of Decision step with Work flow variables,

/wp-content/uploads/2015/02/12_637900.png





12. Double click on task TS99100446 to maintain description for the decision task,

/wp-content/uploads/2015/02/13_637904.png





13. Click on the Change text to maintain your custom text,

/wp-content/uploads/2015/02/14_637905.png

Note: Text with HTML tags should be maintained as Comment line (i.e. with /*).




14. Create a send mail step to send a mail on approval,

/wp-content/uploads/2015/02/15_637906.png





15. Create a process control step to stop the Work flow on reject,

/wp-content/uploads/2015/02/16_637907.png




16. Execute the work flow by passing the input parameter i.e. PR number,

/wp-content/uploads/2015/02/17_637908.png





17. Go to transaction code SBWP – business workplace you will find a work item in your inbox with table of HTML tags,

/wp-content/uploads/2015/02/18_637909.png





To report this post you need to login first.

13 Comments

You must be Logged on to comment or reply to a post.

  1. Pranav Patil

    Hi,
    I tried to user the procedure as mentioned, for adding a table in my user decision step. but its not showing anything. output is blank.

    (0) 
    1. Srivijay Dinnimath Post author

      Hi,

      Try to declare structure with one field type char with large size. And append data to it in HTML Table format.

      And most of the times there will be issue with binding. Please check that as well.

      🙂

      (0) 
  2. Pranav Patil

    Hi,
    Got the table output successfully. Thanks for that. But got 1 more issue. Some times the all table rows get displayed in same row and sometimes in new row. I think html code is correct, there might be problem while compiling the html code.

    (0) 
      1. Pranav Patil

        Hi, its the same guy above..some problem with old account, hence new account.

        Yes, the html code generated in the table is fine. I checked it in container for the workitem. When I single click the workitem for the first time in SAP inbox it gives the problem but if I double click then it gives proper output. I think the problem is when sap is compiling the html code bcoz didn’t find any other issue.

        (0) 
    1. saurabh chikate

      Hi pranav,

      try to dump all the code in single line of internal table.

      if you are passing your html code to internal table in multi-line format , it may cause this problem,

      try and let me know what happens.

      regards,

      saurabh

      (0) 
  3. Andres Felipe Silva

    Hi! Great document!

    Does anyone know how to make it work in WEBUI?? It shows the table when using transaction SBWP but I am doing it in SAP CRM portal and I can’t see the table in the browser.

    Regards,

    Andres

    (0) 
    1. Chetan Kalaburgi

      Hi,

      I have the same problem as Andres has mentioned.

      As per the blog i followed the steps…Table is looking Great when i see the approval workitem in SBWP But table just doesn’t appear in SAP CRM WEB UI screen ?

      Any config need to be done to display this HTML table in SAP CRM WEB UI ?

      Reg,

      Chetan S K

      (0) 
  4. yasser aoujil

    Hi,

    I followed all the steps, but the table doesn’t show (see screenshot), when i loop at the content of the container in the decision step it’s correctly filled with html lines (see screenshot picture), so the binding is fine.

    I appreciate any help, I have a similar requirement.

    Thank you.

    Result of decision description:

    Content of container of html table in decision step:

    In case it could help this is how the task description tab looks after filling the script editor with the text to show the table:

    Also the container PEDIDOCOMPRA is not showing the number of the purchase requisition.

     

     

    (0) 
    1. yasser aoujil

      I found the mistake, it’s with the script editor, it didn’t insert the containers as symbols, I just reinserted the containers as symbols and it worked.

      I hope it helps someone.

      (0) 

Leave a Reply