Print duplicate service ticket form in CRM

By Mansoor Ahmed

Today, I am going to share something very rare and useful. If you guys are aware of ABAP then you will definitely get this small tutorial. This is all about the printing of duplicate Service Ticket Smartform.

Now let’s start; if you are aware of the transaction code CRMD_ORDER then you would probably know that this is used to create / view service tickets and print them accordingly. You may do so via WebUI as well.

So, whenever service ticket is created and saved; it automatically sends the print out of the Smartform and it is then handed over to the consumer and MNC (Maintenance and Construction) guys (in my case I am working in a Utility company).

Now if you want to print this Smartform for the second time then it won’t let you do so. To cater this we got a very strange requirement that whenever we enter any service ticket number a program should print the relevant information.

There were two ways to do so one was BDC (I don’t recommend), second; to find a way around to get output via BAPI or some function module. So below are the steps how I managed to do that.

Steps:

1.    Create a Z program with name: ZMA_DUPLICATE_SERVICE_TICKET.

2.    Now I will use one parameter which is a service ticket number.

3.    Then, we will use a function module which will take GUID of the service ticket and name of the smartform as input and it will then return all the tables related to that. To get the GUID of the ticket we will use the following query on the table CRMD_ORDERADM_H.

SELECT SINGLE GUID INTO GUID FROM CRMD_ORDERADM_H WHERE OBJECT_ID OBJ_ID-LOW.  

  CALL FUNCTION 'CRM_OUTPUT_SINGLE_READ'
    
EXPORTING
      IV_SMART_FORM             
'ZSRV_TICKET'
      IV_GUID                   
GUID
    
IMPORTING
      ES_OUTPUT_ORDERADM_H      
ES_OUTPUT_ORDERADM_H
      ES_OUTPUT_ACTIVITY_H      
ES_OUTPUT_ACTIVITY_H
      ES_OUTPUT_LEAD_H          
ES_OUTPUT_LEAD_H
      ES_OUTPUT_OPPORT_H        
ES_OUTPUT_OPPORT_H
      ES_OUTPUT_ORGMAN_H        
ES_OUTPUT_ORGMAN_H
      ES_OUTPUT_PRICINGDATA_H   
ES_OUTPUT_PRICINGDATA_H
      ES_OUTPUT_SALES_H         
ES_OUTPUT_SALES_H
      ES_OUTPUT_SHIPPING_H      
ES_OUTPUT_SHIPPING_H
      ET_OUTPUT_PARTNER_H       
ET_OUTPUT_PARTNER_H
      ET_OUTPUT_PAYPLAN_D_H     
ET_OUTPUT_PAYPLAN_D_H
      ES_OUTPUT_CUSTOMER_H      
ES_OUTPUT_CUSTOMER_H
      ES_OUTPUT_CUMULAT_H       
ES_OUTPUT_CUMULAT_H
      ET_OUTPUT_BILLING_H       
ET_OUTPUT_BILLING_H
      ET_OUTPUT_CANCEL_H        
ET_OUTPUT_CANCEL_H
      ET_OUTPUT_APPOINTMENT_H   
ET_OUTPUT_APPOINTMENT_H
      ET_OUTPUT_BILLPLAN_D_H    
ET_OUTPUT_BILLPLAN_D_H
      ET_OUTPUT_BILLPLAN_H      
ET_OUTPUT_BILLPLAN_H
      ET_OUTPUT_STATUS_D_H      
ET_OUTPUT_STATUS_D_H
      ET_OUTPUT_SRV_SUBJECT_H   
ET_OUTPUT_SRV_SUBJECT_H
      ET_OUTPUT_SRV_SUBJECT_I   
ET_OUTPUT_SRV_SUBJECT_I
      ET_OUTPUT_SRV_REFOBJ_H    
ET_OUTPUT_SRV_REFOBJ_H
      ET_OUTPUT_SRV_REFOBJ_I    
ET_OUTPUT_SRV_REFOBJ_I
      ET_OUTPUT_SRV_REASON_H    
ET_OUTPUT_SRV_REASON_H
      ET_OUTPUT_SRV_RESULT_H    
ET_OUTPUT_SRV_RESULT_H
      ET_OUTPUT_STATUS_H        
ET_OUTPUT_STATUS_H
      ES_OUTPUT_ACS_H           
ES_OUTPUT_ACS_H
      ET_OUTPUT_ORDERADM_I      
ET_OUTPUT_ORDERADM_I
      ET_OUTPUT_ORGMAN_I        
ET_OUTPUT_ORGMAN_I
      ET_OUTPUT_PRICINGDATA_I   
ET_OUTPUT_PRICINGDATA_I
      ET_OUTPUT_PRICING_I       
ET_OUTPUT_PRICING_I
      ET_OUTPUT_PRODUCT_I       
ET_OUTPUT_PRODUCT_I
      ET_OUTPUT_SALES_I         
ET_OUTPUT_SALES_I
      ET_OUTPUT_SHIPPING_I      
ET_OUTPUT_SHIPPING_I
      ET_OUTPUT_SCHEDLIN_I      
ET_OUTPUT_SCHEDLIN_I
      ET_OUTPUT_PARTNER_I       
ET_OUTPUT_PARTNER_I
      ET_ITEM_CSTICS_I          
ET_ITEM_CSTICS_I
      ET_OUTPUT_CUSTOMER_I      
ET_OUTPUT_CUSTOMER_I
      ET_OUTPUT_BILLING_I       
ET_OUTPUT_BILLING_I
      ET_OUTPUT_CANCEL_I        
ET_OUTPUT_CANCEL_I
      ET_OUTPUT_FINPROD_I       
ET_OUTPUT_FINPROD_I
      ET_OUTPUT_ORDPRP_I        
ET_OUTPUT_ORDPRP_I
      ET_OUTPUT_ORDPRP_I_D      
ET_OUTPUT_ORDPRP_I_D
      ET_OUTPUT_ORDPRP_OBJL_I_D 
ET_OUTPUT_ORDPRP_OBJL_I_D
      ET_OUTPUT_APPOINTMENT_I   
ET_OUTPUT_APPOINTMENT_I
      ET_OUTPUT_BILLPLAN_D_I    
ET_OUTPUT_BILLPLAN_D_I
      ET_OUTPUT_BILLPLAN_I      
ET_OUTPUT_BILLPLAN_I
      ET_OUTPUT_ORDERADM_I_QT   
ET_OUTPUT_ORDERADM_I_QT
      ET_OUTPUT_ORDERADM_I_IN   
ET_OUTPUT_ORDERADM_I_IN
      ET_OUTPUT_SCHEDLIN_I_CF   
ET_OUTPUT_SCHEDLIN_I_CF
      ET_OUTPUT_STATUS_I        
ET_OUTPUT_STATUS_I
      ET_OUTPUT_SERVICE_I       
ET_OUTPUT_SERVICE_I
      ET_OUTPUT_WRK_SET_E_S_BBP 
ET_OUTPUT_WRK_SET_E_S_BBP
      EV_LANGUAGE               
EV_LANGUAGE
      ET_OUTPUT_SERVICE_I_ASSI  
ET_OUTPUT_SERVICE_I_ASSI
      ES_OUTPUT_BUAG_H          
ES_OUTPUT_BUAG_H
      ET_OUTPUT_BUAG_I          
ET_OUTPUT_BUAG_I
      ET_OUTPUT_PRICE_AGMTS_H   
ET_OUTPUT_PRICE_AGMTS_H
      ET_OUTPUT_PRICE_AGMTS_I   
ET_OUTPUT_PRICE_AGMTS_I.

4.    Then we will call this smartform which is to be printed

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    
EXPORTING
      FORMNAME 
'ZSRV_TICKET'
    
IMPORTING
      FM_NAME  
FUNC_MOD_NAME.

  CALL FUNCTION FUNC_MOD_NAME
    
EXPORTING
      CONTROL_PARAMETERS  
WA_CPARAM
      OUTPUT_OPTIONS      
WA_OUTPUT
      USER_SETTINGS       
'X'
      ORDERADM_H          
ES_OUTPUT_ORDERADM_H
      ACTIVITY_H          
ES_OUTPUT_ACTIVITY_H
      OPPORT_H            
ES_OUTPUT_OPPORT_H
      ORGMAN_H            
ES_OUTPUT_ORGMAN_H
      PARTNER_H           
ET_OUTPUT_PARTNER_H
      PRICINGDATA_H       
ES_OUTPUT_PRICINGDATA_H
      SALES_H             
ES_OUTPUT_SALES_H
      SHIPPING_H          
ES_OUTPUT_SHIPPING_H
      PAYPLAN_D_H         
ET_OUTPUT_PAYPLAN_D_H
      CUMULAT_H           
ES_OUTPUT_CUMULAT_H
      CUSTOMER_H          
ES_OUTPUT_CUSTOMER_H
      ACS_H               
ES_OUTPUT_ACS_H
      BILLING_H           
ET_OUTPUT_BILLING_H
      CANCEL_H            
ET_OUTPUT_CANCEL_H
      APPOINTMENT_H       
ET_OUTPUT_APPOINTMENT_H
      BILLPLAN_D_H        
ET_OUTPUT_BILLPLAN_D_H
      BILLPLAN_H          
ET_OUTPUT_BILLPLAN_H
      STATUS_D_H          
ET_OUTPUT_STATUS_D_H
      STATUS_H            
ET_OUTPUT_STATUS_H
      SRV_SUBJECT_H       
ET_OUTPUT_SRV_SUBJECT_H
      SRV_REASON_H        
ET_OUTPUT_SRV_REASON_H
      SRV_RESULT_H        
ET_OUTPUT_SRV_RESULT_H
      ORDERADM_I          
ET_OUTPUT_ORDERADM_I
      ORDERADM_I_QT       
ET_OUTPUT_ORDERADM_I_QT
      ORDERADM_I_IN       
ET_OUTPUT_ORDERADM_I_IN
      ORGMAN_I            
ET_OUTPUT_ORGMAN_I
      PRICINGDATA_I       
ET_OUTPUT_PRICINGDATA_I
      PRICING_I           
ET_OUTPUT_PRICING_I
      PRODUCT_I           
ET_OUTPUT_PRODUCT_I
      SALES_I             
ET_OUTPUT_SALES_I
      SCHEDLIN_I          
ET_OUTPUT_SCHEDLIN_I
      SCHEDLIN_I_CF       
ET_OUTPUT_SCHEDLIN_I_CF
      SHIPPING_I          
ET_OUTPUT_SHIPPING_I
      PARTNER_I           
ET_OUTPUT_PARTNER_I
      ITEM_CSTICS_I       
ET_ITEM_CSTICS_I
      CUSTOMER_I          
ET_OUTPUT_CUSTOMER_I
      BILLING_I           
ET_OUTPUT_BILLING_I
      CANCEL_I            
ET_OUTPUT_CANCEL_I
      FINPROD_I           
ET_OUTPUT_FINPROD_I
      ORDPRP_I            
ET_OUTPUT_ORDPRP_I
      APPOINTMENT_I       
ET_OUTPUT_APPOINTMENT_I
      BILLPLAN_D_I        
ET_OUTPUT_BILLPLAN_D_I
      BILLPLAN_I          
ET_OUTPUT_BILLPLAN_I
      STATUS_I            
ET_OUTPUT_STATUS_I
      WORKING_SET_E_S_BBP 
ET_OUTPUT_WRK_SET_E_S_BBP
      
LANGUAGE            EV_LANGUAGE
    
EXCEPTIONS
      FORMATTING_ERROR    
1
      INTERNAL_ERROR      
2
      SEND_ERROR          
3
      USER_CANCELED       
4
      
OTHERS              5.
  
IF SY-SUBRC <> 0.
    
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  
ENDIF.

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image