Skip to Content

CREATING DRIVER PROGRAM

TO EXECUTE

THE ADOBE FORMS

Created by:

Nitin Bhatia

iGATE Global Solutions Ltd

There are two ways we can execute our adobe forms which we have developed using interface:

  1. Executing the Adobe Forms directly.
  2. Making a driver program and executing it. We can configure the Adobe forms and their respective driver programs in NACE transaction, which would be helpful for business as they might want to have a triggering point.

We all know executing the Adobe Forms as it is by passing the parameters. Let’s create a program to define and pass everything through it.

Create an interface with the following name and parameters:

NAME: Z_XXXX_IF_CAFM_XXXXX_LTR

PARAMETERS:

1.JPG

IM_N_L                       : parameter for last name

IM_N_F                       : parameter for first name

IM_RET_ADRNR          : parameter for address number for return address

IM_PERSNO                 : parameter for personal number

IM_ADRNR                   : parameter for the recipient address

IM_VAR_STRING        : parameter to store the MIME type with value image/bmp for logo

IM_VAR_XSTRING      : parameter for the image returned from STXBITMAPS table in SAP

IM_FNAME                  : parameter to pass the form name

IM_LANGU                  : parameter for the language

Save and activate the interface.

Now let’s start by creating the form and defining text modules in it. Create a form with the following name, texts & addresses:

NAME: Z_XXXX_AF_CAFM_XXXXX_LTR

NODES:

2.JPG

Logo                             : Graphic

SAL_SUB                     : Text

MORT_INFO                : Text

CONTEXT                    : Text

CONTEXT2                  : Text

BUS_REP                      : Text

TRADEMARK                : Text

REC_ADDRESS : Address

LEG_ENT                     : Text

RET_ADDRESS : Address

In the layout section, put all the respective fields as desired by the business layout and style guide provided and bind the fields.

Nodes IM_N_L and IM_N_F will be used in the text module (Z_XXXX_TM_XXXXX_SALSUB) assigned to SAL_SUB text node above to fill data dynamically.

Assumption: All the text modules have been already created and assigned to the text nodes, address nodes defined above.

Now let’s go and create text modules for the texts above if not created already.

  

For this go to transaction smartforms and select Text Module, provide the name and hit create as shown:

3.JPG

Then go to Management tab and specify the style name from where we will assign the paragraph format as shown:

4.JPG

Go back to text tab and enter “Dear” and then press the editor button

5.JPG

Inside the editor window press insert command button:

6.JPG

Then give the node names for first and last name inside the ampersand symbol as shown and hit enter:

7.JPG

Once done go back and save the text. This will look like as shown:

8.JPG

We are done with creating the text module.

Now let’s start creating a driver program for the same. For this go to transaction SE38 and give the driver program name “Z_XXXX_DP_CAFM_XXXXX_LTR” for my case.

Make sure you follow the coding standards and define variable or fields as per the naming conventions only. I have created two includes:

  1. TOP containing all the field definitions
  2. F01 containing all the sub-routines.

9.JPG

TOP:

TABLES: stxbitmaps.

PARAMETERS: p_langu TYPE sy-langu default sy-langu obligatory,
            p_bp   
TYPE but020-partner.

CONSTANTS: c_en(25) TYPE c VALUE ‘Z_XXXXX_LOGODES_H_K_PE’,
           c_fn(30)
TYPE c VALUE ‘Z_XXXX_AF_CAFM_XXXXX_LTR’.

DATA: lv_bin             TYPE xstring,         (to get logo)
      lv_fm_name        
TYPE rs38l_fnam,     (to get the generated FM)
      lv_fp_docparams   
TYPE sfpdocparams,    (document parameters)
      lv_fp_outputparams
TYPE sfpoutputparams, (output parameters)
      lv_adrnr          
TYPE ad_addrnum,      (to get rec addr num)
      lv_ret_adrnr      
TYPE ad_addrnum,      (to get ret addr num)
      lv_n_l            
TYPE bu_namep_l,      (to get last name)
      lv_n_f            
TYPE bu_namep_f,      (to get first name)
      lv_persno         
TYPE ad_persnum.      (to get the person num)

DATA: it_but000 TYPE standard table of but000,
      wa_but000
like line of it_but000.

Get Logo:

  • To call the logo from the stxbitmaps table I have written a function module which we call in our driver program passing the name (c_en) of the desired logo:

            CALL FUNCTION ‘Z_XXXX_RCT_FM_LOGO’
             
EXPORTING
               z_logo_name = c_en
             
IMPORTING
                lv_binary   = lv_bin.

CODE FOR THE FUNCTION MODULE IS:

TABLES: stxbitmaps.

  TYPES: it_stx TYPE STANDARD TABLE OF stxbitmaps.
  DATA:  ls_wa_stx
TYPE LINE OF it_stx.

  CLEAR ls_wa_stx.
*******************************************

Fetching data from the standard table 

*******************************************
 
SELECT * FROM stxbitmaps
          
INTO ls_wa_stx
          
WHERE tdname EQ z_logo_name.

                       ‘z_logo_name  defined in Import param as char25)
  ENDSELECT.
*******************************************

Calling method to get the logo        

*******************************************
 
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
   
EXPORTING
      p_object       = ls_wa_stx-tdobject
      p_name         = ls_wa_stx-tdname
      p_id           = ls_wa_stx-tdid
      p_btype        = ls_wa_stx-tdbtype
    RECEIVING
      p_bmp          = lv_binary (defined in export paramet as Xtsring)
   
EXCEPTIONS
      not_found      =
1
      internal_error =
2
     
OTHERS         = 3.
 
IF sy-subrc <> 0.

*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Get Address

I wrote a small code shown below to get the name, person number and address number from the but000 and but020 tables.

  • The code below will get the address number from the table but020. This address is of business partner created as organization which we will pass on to the address node RET_ADDRESS (return address, which will be RBC an organization).

    

            SELECT SINGLE addrnumber FROM but020
                                    
INTO lv_ret_adrnr
                                    
WHERE partner = ‘1000002706’.

Note: ‘1000002706’ is the business partner we have created as organization in BP transaction.

  • This code below will fetch the personal details of the business partner created as person from the but000 table which we will pass on to the address node created in form REC_ADDRESS (recipient address, which will be a person).


           
SELECT SINGLE * FROM but000
                           
INTO wa_but000
                           
WHERE partner = p_bp.

            IF sy-subrc IS INITIAL.
              lv_persno = wa_but000-persnumber.
              lv_n_l    = wa_but000-name_last.
              lv_n_f    = wa_but000-name_first.
           
ENDIF.

            SELECT SINGLE addrnumber FROM but020
                                   
INTO lv_adrnr
                                    
WHERE partner = p_bp.

Note: p_bp is a parameter on selection screen taking business partner as i/p.

Open Job / Call Generated FM / Close Job

This is how we open the form which we have made for processing through driver program. You call the function module FP_JOB_OPEN. You use this function module to specify settings for the form output. You specify whether you want the form to be printed, archived, or sent back to the application program as a PDF.

CALL FUNCTION ‘FP_JOB_OPEN’
       
CHANGING
          ie_outputparams = lv_fp_outputparams
       
EXCEPTIONS
          cancel          =
1
          usage_error     =
2
          system_error    =
3
          internal_error  =
4
       
OTHERS          = 5.
     
IF sy-subrc <> 0.
       
* Implement suitable error handling here      ENDIF.

Then we will call a function module FP_FUNCTION_MODULE_NAME which will generate the function module name for the form we have created using SFP and we will collect this name in a variable “lv_fm_name“. We are passing

CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
       
EXPORTING
          i_name              = c_fn
       
IMPORTING
          e_funcname          = lv_fm_name.
     

The code below will pass the document parameters for language depending upon the selection screen input. Similarly we can define many document parameters apart from language.

IF NOT p_langu IS INITIAL.
        lv_fp_docparams-langu   = p_langu.
     
ELSE.        lv_fp_docparams-langu   = sy-langu.
     
ENDIF.

 

Then we call the function module lv_fm_name (this is the name of the generated function module we got from above code) as shown:

CALL FUNCTION lv_fm_name
       
EXPORTING
          /1bcdwb/docparams = lv_fp_docparams
          im_n_l            = lv_n_l
          im_n_f            = lv_n_f
          im_ret_adrnr      = lv_ret_adrnr
          im_persno         = lv_persno
          im_adrnr          = lv_adrnr
         
* im_var_string     = ‘image/bmp’
          im_var_xstring    = lv_bin.
     
IF sy-subrc <> 0.
       
* Implement suitable error handling here
     
ENDIF.

This function module will bring all the import parameters defined in the interface of our adobe form “Z_XXXX_DP_CAFM_XXXXX_LTR” into the exporting section of the function module.

Then finally will close the processing of the form by calling the below function module:

CALL FUNCTION ‘FP_JOB_CLOSE’
 
* IMPORTING
 
*   E_RESULT             =
  
EXCEPTIONS
     usage_error          =
1
     system_error         =
2
     internal_error       =
3
    
OTHERS               = 4
            .IF sy-subrc <> 0.
 
* Implement suitable error handling hereENDIF.

All the above steps are necessary to make sure form is open and closed for processing.

Now the last step is to save, activate and execute the driver program.

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply