GoodleAds

EXAMPLE ON SMARTFORMS

EXAMPLE ON SAMRTFORMS:

'SMARTFORMS' is the transaction code to design the smartform layout.

 Based on the given company code display the company code, comp name & city by using smart forms. 

Execute SMARTFORMS trnsaction.
Provide the smartform name.
Click on create.
Provide the short description.
click on save.


Double click on form interface in the left panel.
In the import tab provide details as below. Click on save.



Double click on global definitions in the left panel.
Click on types tab and declare the types.


Now click on global data tab and provide the work area as below.


Now click on initialization tab and implement the logic and also provide the input parameters 
and output parameters.


Expand the page in the left panel. Select the main window. Right click  create  text. 
Double click on text. Click on editor under general attributes tab. Provide symbols. 



Click on back. 
Save, check and activate the form.
In the menu bar click on environment. Select function module. 
It will give you the function module. Based on this we develop the print program.
Click on ok.

PRINT PROGRAM:

*&---------------------------------------------------------------------*
*& Report  ZP_SFORM_DEMO1
*&
*&---------------------------------------------------------------------*
REPORT ZP_SFORM_DEMO1.
Parameter p_bukrs type t001-bukrs.
CALL FUNCTION '/1BCDWB/SF00000289'
  
EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
    i_bukrs                    
P_BUKRS* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
* EXCEPTIONS
*   FORMATTING_ERROR           = 1
*   INTERNAL_ERROR             = 2
*   SEND_ERROR                 = 3
*   USER_CANCELED              = 4
*   OTHERS                     = 5
          
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

In the real time, we never call the function module directly like this, why because whenever we 
move this object to quality and production server the function module generated is different from 
development server. To avoid this we always use the 'SSF_FUNCTION_MODULE_NAME' 
function module. Now the print program is 

*&---------------------------------------------------------------------*
*& Report  ZP_SFORM_DEMO1
*&
*&---------------------------------------------------------------------*
REPORT ZP_SFORM_DEMO1.
Parameter p_bukrs type t001-bukrs.
DATA FM TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  
EXPORTING
    formname                
'ZF_SFORM_DEMO1'
  
IMPORTING
    FM_NAME                  
FM .
CALL FUNCTION FM
  
EXPORTING
    i_bukrs                    
P_BUKRS.

Save, check and activate the print program.
Execute the print program.
Provide the input.
Provide output device as 'LP01'.
Click on print preview.

OUTPUT:



Note: Here, I am wrote the logic in smartform. But, most of the cases we need to write the logic in print program why because re-usability concept of the smartform. So, that we can reuse the same smartform for other requirements with minor changes.




No comments:

Post a Comment