06-27-2007 5:55 AM
Hi all,
I have made a smart form for employees and a driver program with logical database pnp. If I give say 10 employees in the selection screen and print the forms, I have to press print button 10 times. Is there any way we can avoid this? We want that print button should be pressed only once and smartforms of all 10 employees should get printed. Please suggest.
Thanks
Ribhu
06-27-2007 5:59 AM
Hi,
You can pass the employees to the smartforms altogether as a table.In the below link, I am explaining how to pass select option to smartform.
Try this code.It will avoid pressing the dialog box.
Variable Declaration
DATA : v_form_name TYPE rs38l_fnam,
itab TYPE STANDARD TABLE OF pa0001,
w_ctrlop TYPE ssfctrlop,
w_compop TYPE ssfcompop,
w_return TYPE ssfcrescl.
SELECT * FROM pa0001 INTO TABLE itab UP TO 5 ROWS.
SORT itab BY pernr.
DELETE ADJACENT DUPLICATES FROM itab COMPARING pernr.
DATA: control TYPE ssfctrlop,
control_parameters TYPE ssfctrlop,
output_options type SSFCOMPOP.
control-preview = 'X'.
control-no_open = 'X'.
control-no_close = 'X'.
control-no_dialog = 'X'.
control-device = 'PRINTER'.
output_options-tddest = 'LOCL'.
OUTPUT_OPTIONS-TDNOPRINT = 'X'.
OUTPUT_OPTIONS-BCS_LANGU = SY-LANGU.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
USER_SETTINGS = ' '
OUTPUT_OPTIONS = output_options
CONTROL_PARAMETERS = control
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.
output_options-tddest = 'LOCL'.
OUTPUT_OPTIONS-TDNOPRINT = 'X'.
OUTPUT_OPTIONS-BCS_LANGU = SY-LANGU.
CALL FUNCTION '/1BCDWB/SF00000066'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = control
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = output_options
USER_SETTINGS = ' '
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = w_return
JOB_OUTPUT_OPTIONS =
TABLES
itab = itab
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.
CALL FUNCTION 'SSF_CLOSE'.
06-27-2007 5:59 AM
Hi,
You can pass the employees to the smartforms altogether as a table.In the below link, I am explaining how to pass select option to smartform.
Try this code.It will avoid pressing the dialog box.
Variable Declaration
DATA : v_form_name TYPE rs38l_fnam,
itab TYPE STANDARD TABLE OF pa0001,
w_ctrlop TYPE ssfctrlop,
w_compop TYPE ssfcompop,
w_return TYPE ssfcrescl.
SELECT * FROM pa0001 INTO TABLE itab UP TO 5 ROWS.
SORT itab BY pernr.
DELETE ADJACENT DUPLICATES FROM itab COMPARING pernr.
DATA: control TYPE ssfctrlop,
control_parameters TYPE ssfctrlop,
output_options type SSFCOMPOP.
control-preview = 'X'.
control-no_open = 'X'.
control-no_close = 'X'.
control-no_dialog = 'X'.
control-device = 'PRINTER'.
output_options-tddest = 'LOCL'.
OUTPUT_OPTIONS-TDNOPRINT = 'X'.
OUTPUT_OPTIONS-BCS_LANGU = SY-LANGU.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
USER_SETTINGS = ' '
OUTPUT_OPTIONS = output_options
CONTROL_PARAMETERS = control
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.
output_options-tddest = 'LOCL'.
OUTPUT_OPTIONS-TDNOPRINT = 'X'.
OUTPUT_OPTIONS-BCS_LANGU = SY-LANGU.
CALL FUNCTION '/1BCDWB/SF00000066'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = control
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = output_options
USER_SETTINGS = ' '
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = w_return
JOB_OUTPUT_OPTIONS =
TABLES
itab = itab
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.
CALL FUNCTION 'SSF_CLOSE'.
06-27-2007 6:07 AM
Jayanthi,
I want to pass the employees to my form from selection screen at runtime. I hope my driver program'll make it clear
REPORT ZHRPAS0004.
***********************************************************************
Database Tables
***********************************************************************
Tables:
pa0000, "Table for Actions
pa0001, " Table for Organisational Assignments
pa0002, " Table for Personal Data
pa0041, " Table for Date Specifications
pernr, " Logical Pernr
T528T, " Position Texts
T527X, " Organizational Units
T510, " Pay Scale Groups
T500p, " Personnel Areas
T526, " Administrators
T522t. " Forms of Address
infotypes :
0000, " Action
0001, " Organisational Assignments
0002, " Personal Data
0041. " Date Specifications
************************************************************************
Declaration of Variables
***********************************************************************
data : E_PAREA TYPE PERSA,
E_PCODE LIKE T500P-NAME1,
E_EMPNAME TYPE EMNAM,
E_EMPNO TYPE PERSNO,
E_TERDATE TYPE DATS,
E_POSIT TYPE T528T-PLSTX,
E_DATE TYPE SY-DATUM,
e_ADDFORM TYPE T522T-ATEXT,
E_ORGUNIT TYPE T527X-ORGTX.
DATA : WS_UCOMM LIKE SY-UCOMM.
data : DAR like pa0041-dar01,
dat like pa0041-dat01.
data : v_year(4) type c,
v_mon(2) type c,
v_date like sy-datum,
v_date1 like sy-datum.
data : v_formname type tdsfname value 'ZSF_ODR_TER_01',
v_fmname type rs38l_fnam.
data: i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
***********************************************************************
Declaration of Constants
***********************************************************************
constants : c_x type c value 'X', " Sign
c_pernr(8) type n value '00000000', " Pernr
c_val1(2) type c value '31', " Date Type
c_val2(2) type c value '12', " Date Type
c_val like p0041-dar01 value '01', " Date Type
c_1 like pernr-persg value '1', " Emp Group
c_type like hrp1001-otype value 'S', " Object Type
c_date1 like sy-datum value '18000101', " Date
c_date2 like sy-datum value '99991231', " Date
r_all value 'X'.
***********************************************************************
Selection Screen
***********************************************************************
Selection-screen begin of block b2 with frame title text-001.
selection-screen begin of line.
parameter pdf radiobutton group smf.
selection-screen comment 5(20) text-002.
parameter prn radiobutton group smf.
selection-screen comment 40(20) text-003.
selection-screen end of line.
Selection-screen end of block b2.
***********************************************************************
At selection-screen
***********************************************************************
At selection-screen.
perform validate_screen.
***********************************************************************
Start-of-Selection
***********************************************************************
start-of-selection.
perform get_period.
Get PERNR from LDB
get pernr.
rp_provide_from_last p0001 space pnpbegda pnpendda .
rp_provide_from_last p0000 space pnpbegda pnpendda .
rp_provide_from_last p0041 space pnpbegda pnpendda.
Get the form of address
select single atext from t522t into t522t-atext where anred = p0002-anred and sprsl = sy-langu.
if sy-subrc = 0.
E_ADDFORM = t522t-atext.
endif.
Get the Personnel Area Long Description/Text
select single name1 into t500p-name1 from t500p where persa = p0001-werks.
Get the relevant date from 0041 (date repetitive structure)
do 12 times varying dar from p0041-DAR01 next p0041-DAR02
varying dat from p0041-dat01 next p0041-dat02.
if dar = 'TD'.
E_TERDATE = dat.
ENDIF.
enddo.
Get the Org Unit Text of the employee.
select single ORGTX from T527X into T527X-ORGTX where ORGEH = p0001-orgeh and SPRSL = sy-langu.
if sy-subrc = 0.
E_ORGUNIT = T527X-ORGTX.
endif.
Get the position text of the employee.
select single PLSTX from T528T into T528T-PLSTX where PLANS = p0001-plans and SPRSL = sy-langu and OTYPE = c_type .
if sy-subrc = 0.
E_POSIT = T528T-PLSTX.
endif.
Assigning the values
E_PAREA = p0001-werks.
E_PCODE = t500p-name1.
E_EMPNAME = p0001-ENAME.
E_EMPNO = p0000-pernr.
E_DATE = SY-DATUM.
&----
Get the values from respective infotypes to print the file *
----
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = v_formname
importing
fm_name = v_fmname
exceptions
no_form = 1
no_function_module = 2
others = 3.
call function v_fmname
exporting
i_PAREA = E_PAREA
i_PCODE = E_pcode
i_EMPNAME = E_empname
i_EMPNO = E_empno
i_TERDATE = E_terdate
i_POSIT = E_posit
i_DATE = E_date
i_ADDFORM = E_ADDFORM
i_ORGUNIT = E_orgunit.
&----
*& Form validate_screen
&----
Validation on the screen
----
FORM validate_screen .
clear sy-index.
loop at pnppernr.
endloop.
if sy-index GT 1.
message 'Enter only one personal number' type 'E'.
endif.
if pnppernr-low is initial.
message 'enter a personal number' type 'E'.
endif.
ENDFORM. " validate_screen
&----
*& Form get_period
&----
Validation on Period
----
FORM get_period .
clear: v_year,v_mon, v_date, v_date1.
v_year = sy-datum+0(4).
v_mon = sy-datum+4(2).
if pnptimr1 = c_x. " Current Date
pnpbegda = sy-datum.
pnpendda = sy-datum.
elseif pnptimr2 = c_x. " Current Month
concatenate v_year v_mon c_val into v_date.
concatenate v_year v_mon c_val1 into v_date1.
pnpbegda = v_date.
pnpendda = v_date1.
elseif pnptimr3 = c_x. " Current Year
concatenate v_year c_val c_val into v_date.
concatenate v_year c_val2 c_val1 into v_date1.
pnpbegda = v_date.
pnpendda = v_date1.
elseif pnptimr4 = c_x. " Upto Today
pnpbegda = c_date1.
pnpendda = sy-datum.
elseif pnptimr5 = c_x. " From Today
pnpbegda = sy-datum.
pnpendda = c_date2.
else.
if ( pnpbegda is initial and pnpendda is initial ).
pnpbegda = c_date1.
pnpendda = c_date2.
elseif pnpbegda is initial and not pnpendda is initial.
pnpbegda = c_date1.
pnpendda = pnpendda.
elseif not ( pnpbegda is initial and pnpendda is initial ).
pnpbegda = pnpbegda.
pnpendda = pnpendda.
endif.
endif.
ENDFORM. " get_period
06-27-2007 6:14 AM
Hi,
I think you are passing all the data separately as aprameters to form.You can declare one structure in SE11 and declare internal table of that structure and populate the values as a table to smartform.You can do it by using table parameter.
In smartform,declare as below in Form Interface->Table
itab like structure_name
08-30-2007 3:37 PM
Ribhu,
If you haven't already solved your problem:
you want to Open_Form at the beginning of your program.
Then
...Start_form
write_form
end_form
for each document/employee
and then close_form at the very end.