Driver Program to execute Print Form
Driver Program to execute Print Form
107,602
TO EXECUTE
Nitin Bhatia
There are two ways we can execute our adobe forms which we have developed using
interface:
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.
NAME: Z_XXXX_IF_CAFM_XXXXX_LTR
PARAMETERS:
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
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:
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.
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:
Then go to Management tab and specify the style name from where we will assign the
paragraph format as shown:
Go back to text tab and enter “Dear” and then press the editor button
Inside the editor window press insert command button:
Then give the node names for first and last name inside the ampersand symbol as shown
and hit enter:
Once done go back and save the text. This will look like as shown:
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:
TABLES: stxbitmaps.
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:
TABLES: stxbitmaps.
CLEAR ls_wa_stx.
*******************************************
*******************************************
SELECT * FROM stxbitmaps
INTO ls_wa_stx
WHERE tdname EQ z_logo_name.
*******************************************
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.
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).
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).
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.
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.
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:
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:
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.