Sunday, 27 April 2014

Important links for SAP Business Workflow

Documents:
Tutorials:
References:
http://help.sap.com/saphelp_40b/helpdata/en/04/926f8546f311d189470000e829fbbd/frameset.htm
http://scn.sap.com/community/bpm/business-workflow/content?filterID=contentstatus[published]~objecttype~objecttype[thread]


http://www.saptechies.com/troubleshooting-tips-tricks-workflow-issues/
http://workflowleaks.com



Saturday, 19 April 2014

Convert Smartform into PDF

Here I’m trying to explain how to convert a smartform into a PDF and download.
All the below steps contains only sample codes and are self explanatory, so I’m not going into details of every step.

Prerequisites: You need to know how to call the smartform FM from ur driver program and all. Although you can find the same from the step 1.

If u r running out of time then u can go through the step 3 only.

Step 1.

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    
EXPORTING
      formname           
'Z_SMARTFORM_NAME'   
    IMPORTING
      fm_name            
v_fm_name
    
EXCEPTIONS
      no_form            
1
      no_function_module 
2
      
OTHERS             3.

Step 2.

  CALL FUNCTION lc_fm_name
    
EXPORTING
      control_parameters 
s_control_par
    .
    .
    IMPORTING
      job_output_info    
s_job_output
    
TABLES
    .
    .
    EXCEPTIONS
      formatting_error   
1
      internal_error     
2
      send_error         
3
      user_canceled      
4
      
OTHERS             5.

Step 3.

Use the s_job_output-otfdata[] from the previous step into the OTF table parameter in the FM 'CONVERT_OTF_2_PDF'.

    CALL FUNCTION 'CONVERT_OTF_2_PDF'
      
IMPORTING
        bin_filesize           
bin_filesize
      
TABLES
        otf                    
s_job_output-otfdata[]
        doctab_archive         
doctab_archive
        
lines                  t_file_pdf
      
EXCEPTIONS
        err_conv_not_possible  
1
        err_otf_mc_noendmarker 
2
        
OTHERS                 3.

Step 4.

      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        
EXPORTING
          window_title            
'Open file'
          default_extension       
'*.pdf'
        
CHANGING
          file_table              
file_table[]
          rc                      
rc
          user_action             
user_action
        
EXCEPTIONS
          file_open_dialog_failed 
1
          cntl_error              
2
          error_no_gui            
3
          
OTHERS                  4.


Step 5.

      IF user_action 9EXITENDIF.
      
IF rc 1.
        
READ TABLE file_table INDEX 1.
      
ENDIF.

     MOVE file_table-filename TO filename.

      CALL METHOD cl_gui_frontend_services=>gui_download
        
EXPORTING
          bin_filesize            
bin_filesize
          filename                
filename
          filetype                
'BIN'
        
CHANGING
          data_tab                
t_file_pdf
        
EXCEPTIONS
          file_write_error        
1
          no_batch                
2
          gui_refuse_filetransfer 
3
          invalid_type            
4
          no_authority            
5
          unknown_error           
6
          header_not_allowed      
7
          separator_not_allowed   
8
          filesize_not_allowed    
9
          header_too_long         
10
          dp_error_create         
11
          dp_error_send           
12
          dp_error_write          
13
          unknown_dp_error        
14
          access_denied           
15
          dp_out_of_memory        
16
          disk_full               
17
          dp_timeout              
18
          file_not_found          
19
          dataprovider_exception  
20
          control_flush_error     
21
          
OTHERS                  22.

Friday, 18 April 2014

Copy Control Routine in SAP

We can make the required business data (customers, plant, materials, pricing ..) available from a certain source (sales order, delivery, billing) to a sales order or delivery or billing, like copy and paste without human intervention.

Here the benefit is like:
  • No human intervention to put all the data to create a sales order or delivery or billing.
  • Less hit of database table which would improve the program performance.
  • We can put certain rules based on certain condition to automatically fill up the required data while creating order or delivery or billing.


There are several types to control copy control of sales documents:
VTAA – control for copying from sales order to sales order
VTLA – control for copying from sales order to delivery
VTFL – control for copying from delivery to billing doc
VTAF – control for copying from billing doc to sales order
VTFA – control for copying from sales order to billing doc
VTFF – control for copying from billing doc to billing doc


We can also achieve the same using SPRO. Like below.









How to use copy control for our custom business logic :

We can use copy control by two ways like below:

  1. We can copy the standard routine and add our own custom logic. Then need to configure the routine. Generally functional ppl will do the configuration after our coding part will be complete.
  2. We can write our own custom logic inside the standard copy control routine (if there we can find the perfect place like implicit or explicit enhancements).






Let’s go through one requirement that I have done few days back.
A copy control routine was already there for copying the data from billing document to sales order while creating sales order with using ‘Create with Reference’ option.

Need to mention that we are going to create return order based on the previous billing document.

But the problem was certain data was not copying from billing to sales order because the fields are custom (Z fields).

Here we have the solution.

Functional guy told me to copy the standard routine 153 (include - FV45C153) and create a custom routine.

When I go inside the include I found there we have certain implicit and explicit enhancements.

At last I have written the custom filed population logic inside a enhancement-point with using the billing data.





Please Note:
You can also do the same by copying the 153 routine and configure the custom routine.