cancel
Showing results for 
Search instead for 
Did you mean: 

attach SMARTFORM in driver program of printing Invoice

Former Member
0 Kudos

Hi,

I am trying to attach a SMARTFORM with the driver program of an Invoice. There is a SAP Script form is attached with that program already. I am adding the SMARTFORM name and the lay out function module in V/83.

But where will I call the function module in the program? As for the SAP Script the particular elements are printed at the time of write form and then it is clearing the value of the variables. and the values are selecting from the master table itself, no internal table is used. So, where should I call the function module for the SMARTFORM...??

Please help me to solve this.

Thanks,

Sumit.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks a lot. This part has been done. But still I m passing the name of the smartform in the driver program.

is there any way that I don't have to pass the name in the program ??

Former Member
0 Kudos

Hi ,

i think you mean that you want to define the name of your smartform on the normale way with e.g. transaction NACE.

that is no problem. Thestart of your porint program stays about the same. Only the name is standing in another tnapr field.

you have to use tnapr-sform

i've put an example below. maybe you are able to determine what you can use of it.

I don't hope you have only used the smartform conversion from sap-script to smartforms. If you did so you only have the pages and windows-(sizes) but no coding and fields to print it.

At the other hand why is it absolutely necessary to use a smartfroms for that output type.

Even in the latest SAP best practices there is used that same sap-script you are trying to convert to smartforms. For the customer it makes no difference. They want a hardcopy output. How it is made is not important to them.

below the example of an standard invoice:

if you have some questions don't hesitate to ask!

----


  • FORM ENTRY

----


FORM entry USING return_code us_screen.

DATA: lf_retcode TYPE sy-subrc.

CLEAR retcode.

xscreen = us_screen.

PERFORM processing USING us_screen

CHANGING lf_retcode.

IF lf_retcode NE 0.

return_code = 1.

ELSE.

return_code = 0.

ENDIF.

ENDFORM. "ENTRY

----


  • FORM PROCESSING *

----


FORM processing USING proc_screen

CHANGING cf_retcode.

DATA: ls_print_data_to_read TYPE lbbil_print_data_to_read.

DATA: ls_bil_invoice TYPE lbbil_invoice.

DATA: lf_fm_name TYPE rs38l_fnam.

DATA: ls_control_param TYPE ssfctrlop.

DATA: ls_composer_param TYPE ssfcompop.

DATA: ls_recipient TYPE swotobjid.

DATA: ls_sender TYPE swotobjid.

DATA: lf_formname TYPE tdsfname.

DATA: ls_addr_key LIKE addr_key.

DATA: ls_dlv-land LIKE vbrk-land1.

DATA: ls_job_info TYPE ssfcrescl.

  • SmartForm from customizing table TNAPR

lf_formname = tnapr-sform.

IF cf_retcode = 0.

  • select print data

PERFORM get_data

CHANGING ls_addr_key

ls_dlv-land

ls_bil_invoice

cf_retcode.

ENDIF.

IF cf_retcode = 0.

PERFORM set_print_param USING ls_addr_key

ls_dlv-land

CHANGING ls_control_param

ls_composer_param

ls_recipient

ls_sender

cf_retcode.

ENDIF.

IF cf_retcode = 0.

  • determine smartform function module for invoice

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING formname = lf_formname

  • variant = ' '

  • direct_call = ' '

IMPORTING fm_name = lf_fm_name

EXCEPTIONS no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

ENDIF.

IF cf_retcode = 0.

PERFORM check_repeat.

IF ls_composer_param-tdcopies EQ 0.

nast_anzal = 1.

ELSE.

nast_anzal = ls_composer_param-tdcopies.

ENDIF.

ls_composer_param-tdcopies = 1.

DO nast_anzal TIMES.

  • In case of repetition only one time archiving

IF sy-index > 1 AND nast-tdarmod = 3.

nast_tdarmod = nast-tdarmod.

nast-tdarmod = 1.

ls_composer_param-tdarmod = 1.

ENDIF.

IF sy-index NE 1 AND repeat IS INITIAL.

repeat = 'X'.

ENDIF.

  • call smartform invoice

CALL FUNCTION lf_fm_name

EXPORTING

archive_index = toa_dara

archive_parameters = arc_params

control_parameters = ls_control_param

  • mail_appl_obj =

mail_recipient = ls_recipient

mail_sender = ls_sender

output_options = ls_composer_param

user_settings = space

is_bil_invoice = ls_bil_invoice

is_nast = nast

is_repeat = repeat

importing job_output_info = ls_job_info

  • document_output_info =

  • job_output_options =

EXCEPTIONS formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

  • get SmartForm protocoll and store it in the NAST protocoll

PERFORM add_smfrm_prot.

ENDIF.

ENDDO.

  • get SmartForm spoolid and store it in the NAST protocoll

DATA ls_spoolid LIKE LINE OF ls_job_info-spoolids.

LOOP AT ls_job_info-spoolids INTO ls_spoolid.

IF ls_spoolid NE space.

export spoolid = ls_spoolid to memory id 'KYK_SPOOLID'.

PERFORM protocol_update_spool USING '342' ls_spoolid

space space space.

ENDIF.

ENDLOOP.

ls_composer_param-tdcopies = nast_anzal.

IF NOT nast_tdarmod IS INITIAL.

nast-tdarmod = nast_tdarmod.

CLEAR nast_tdarmod.

ENDIF.

ENDIF.

  • get SmartForm protocoll and store it in the NAST protocoll

  • PERFORM ADD_SMFRM_PROT.

Former Member
0 Kudos

Hi,

I know that. But actually I am doing internship in a comapny. And they gave me this project to convert invoice printing from SAP Script to SMARTFORMS. I have done the things but now it is giving error of type conflict. I have checked the types of importing variables with the variables of the program.

But the thing is that in the SAP Script, there are program lines. when i am doing in smartforms, I am giving the same program lines like script. is it right? or I am doing the whole thing worng??

like this is written in the SAP Script----

/: IF &VBRP-WERKS& EQ 'PCAB'.

  • XXXXXXXXXX 85441190 85445930 85446020

/: ELSEIF &VBRP-WERKS& EQ 'UOFC'.

  • XXXXXXXXXX 90011000

/: ELSEIF &VBRP-WERKS& EQ 'USHT'.

  • XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 39204900

  • 39204900 39153090 39042290

/: ENDIF

So I wrote the same in smartform also. is it ok?? or I have to do something else to give those if-else statement.

Please help me.

Thank you for your reply.

Sumit

Former Member
0 Kudos

Hi,

In the NACE transaction U will have the Standard Program Name for the Smartform, COPY the Driver Program to ZPROGRAM by Selecting all Includes and Give the Z Include Names and Select all the Includes and Say Copy. So that all the code that is available in the Standard Program also get copied.

Go to the Data Declare Include and give the Declarions for

----


  • DATA DECLARATIONS *

----


DATA: LF_FORMNAME TYPE TDSFNAME, " To get the Form name

LF_FM_NAME TYPE RS38L_FNAM. " To get the Fun.Module Name

and Declare the Internal Tables and Work areas you have used to build the Smartform

In the Second Include in the Subroutine GET_DATA before the call function LB_BIL_INV_OUTP_READ_PRTDATA

Declare all the Performs for the Select Query U have Written

For Example

*--- Perform to get the Billing Document header data

PERFORM GET_VBRK_DATA.

*--- Perform to get the Customer Billing Document: Item Data

PERFORM GET_VBRP_DATA.

*--- Perform to get the Sales Document: Business Data

PERFORM GET_VBKD_DATA.

*--- Perform to get the Plant details

PERFORM GET_T001W_DATA.

*--- Perform to get the Customer details

PERFORM GET_KNA1_DATA.

*--- Perform to get the Address details

PERFORM GET_ADRC_DATA.

*--- Perform to get the Email Address details

PERFORM GET_ADR6_DATA.

In the third Include --- No Changes

In the Main Program write the Routines

&----


*& Form GET_VBRK_DATA

&----


  • text

----


FORM GET_VBRK_DATA .

*--- Select construct to get the Billing Document header details

SELECT * "vbeln fkart knumv fkdat kurrf netwr kunrg

FROM VBRK

INTO TABLE IT_VBRK

WHERE VBELN = NAST-OBJKY. -


If U have any Parameters declared

IF SY-SUBRC <> 0.

  • --- On Failure display message

MESSAGE S000(ZMSG) WITH 'No Data found with selection criteria'(004).

ENDIF.

ENDFORM. " GET_VBRK_DATA

&----


*& Form GET_VBRP_DATA

&----


  • text

----


FORM GET_VBRP_DATA .

IF NOT IT_VBRK[] IS INITIAL.

*--- Select construct to get the Billing Document Item Details

SELECT *

FROM VBRP

INTO TABLE IT_VBRP

FOR ALL ENTRIES IN IT_VBRK

WHERE VBELN = IT_VBRK-VBELN.

IF SY-SUBRC <> 0.

  • --- On Failure display message

MESSAGE S000(ZMSG) WITH 'No Data found with selection criteria'(004).

ENDIF.

ENDIF.

ENDFORM. " GET_VBRP_DATA

&----


*& Form GET_VBKD_DATA

&----


  • text

----


FORM GET_VBKD_DATA .

IF NOT IT_VBRP[] IS INITIAL.

*--- Select construct to get the Sales Document: Business Data

SELECT *

FROM VBKD

INTO TABLE IT_VBKD

FOR ALL ENTRIES IN IT_VBRP

WHERE VBELN = IT_VBRP-AUBEL.

IF SY-SUBRC <> 0.

  • --- On Failure display message

MESSAGE S000(ZMSG) WITH 'No Data found with selection criteria'(004).

ENDIF.

ENDIF.

ENDFORM. " GET_VBKD_DATA

etc.....

In the Subroutine Form Entry

Go to the Perform FORMPROCESSING

and include the following Code

IF CF_RETCODE = 0.

  • determine smartform function module for invoice

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING FORMNAME = LF_FORMNAME

  • variant = ' '

  • direct_call = ' '

IMPORTING FM_NAME = LF_FM_NAME

EXCEPTIONS NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • error handling

CF_RETCODE = SY-SUBRC.

PERFORM PROTOCOL_UPDATE.

ENDIF.

ENDIF.

  • set preview parameters

MOVE 'X' TO LS_CONTROL_PARAM-NO_DIALOG.

MOVE 'X' TO LS_CONTROL_PARAM-PREVIEW.

MOVE 'PRINTER' TO LS_CONTROL_PARAM-DEVICE.

  • call smartform invoice

CALL FUNCTION LF_FM_NAME -


> the FM number generated and rename with LF_FM_NAME

  • EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

  • CONTROL_PARAMETERS =

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

  • OUTPUT_OPTIONS =

  • USER_SETTINGS = 'X'

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

IT_T001W = IT_T001W

IT_J_1IREGSET = IT_J_1IREGSET

IT_KNA1 = IT_KNA1

IT_ADRC = IT_ADRC

IT_ADR6 = IT_ADR6

IT_VBRK = IT_VBRK

EXCEPTIONS FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

Save , Activate all the Incudes and Assign in NACE the Smartform with Driver Program

Regards,

Vijaya Lakshmi.T

Former Member
0 Kudos

Well I am working on "J_1IEXCP" driver program. and there is already an SAP Script attached with it. I just want to convert that SAP Script to SMARTFORM and apply it to that driver program.

and the problem is I haven't found "LB_BIL_INV_OUTP_READ_PRTDATA" anywhere in that program.

I have applied the 'SSF_FUNCTION_MODULE_NAME' FM as u said using the lf_fm_name and lf_formname. but when I am trying to get the print preview in VF31, The error is given that "FM_name" parameter is unknown.

Former Member
0 Kudos

Hi,

When u activate the Smartform It generates a function Module, U copy that one and in the driver Program u call the FM

EX Say In the Pattern give the Number of the FM generated of the Smartform

/1BCDWB/SF00000005.

And replace this FM with LF_FM_NAME.

Regards,

Vijaya Lakshmi.T

Former Member
0 Kudos

I did that too. But still It is giving the same thing.

and do I need to inactive all the write_form and open_form statements which have been declared for SAP Script in that program???

when I am using the 'SSF_FUNCTION_MODULE_NAME' in driver program, It is not working for the SAP Script also. and It is giving error like "there is no form like that".

and where should I call the 'SSF_FUNCTION_MODULE_NAME' ?? I have called it into "FORM item_print" which is in "FORM processing" .

Former Member
0 Kudos

Hi,

U need to comment the code in all the function Modules like CALL FUNCTION ' Write_form'..

etc,only the fM not the subroutines....

And follow the Previous procedure...

U call the FM 'SSF_Function_module_name' in the Subroutine Form Entry

Regards,

Vijaya Lakshmi.T

Edited by: Vijaya Lakshmi on Feb 23, 2009 10:32 AM

Former Member
0 Kudos

I did that. I have commented all the write_form, open_form, close_form. But still it is giving error that "Function Parameter 'FM_NAME' is unknown" .

I have called the 'SSF_FUNCTION_MODULE_NAME' in "FORM entry" now. But still the same error is coming.

Edited by: Sumit Dutta on Feb 23, 2009 3:23 PM

Former Member
0 Kudos

Hi,

Have u declared this in the data declaration Part.

-


DATA DECLARATIONS *

-


DATA: LF_FORMNAME TYPE TDSFNAME, " To get the Form name

LF_FM_NAME TYPE RS38L_FNAM. " To get the Fun.Module Name

and Have u assign the smartform with the Driver Program in the NACE transaction for the given Output Type...

Can u give the Standard Program of your Smartform

Regards,

Vijaya Lakshmi.T

Former Member
0 Kudos

yes I did the data declaration part. I have assigned the smartform in V/83. Thats what I know. Actually I am new in this things.

this is SAP Script "J_1I_EXC_INV_02" from where I have converted the SMARTFORM.

and the standard program is "J_1IEXCP" .

Former Member
0 Kudos

Hey thanks for all your help. I have solved the problem.

Thank you very much.

Former Member
0 Kudos

Hi,

I have called the 'SSF_FUNCTION_MODULE_NAME' in ITEM_PRINT. and its ok.

but when I am giving the FM_NAME, It is giving problem with the V/83. As my driver program and smartform is define there. it is giving error like--- 'type conflict when calling function module' and 'function parameter "fm_name" is unknown' . I have tried evey way to change the name, but its not working.

please help me...

Edited by: Sumit Dutta on Feb 23, 2009 10:40 AM

Former Member
0 Kudos

using NACE tcode select the Application V3 and select the output type here you have PROGRAM ,FORM Entry and SMARTFORM. here copy the program with Zporgram in that you have form entry ...

Program Name : Z-- print program

FORM Entry same form entry

SMARTFORM your smart form name

form entry using return_code us_screen.

data: lf_retcode type sy-subrc.

clear retcode.

xscreen = us_screen.

perform processing using us_screen --> here create the form routine and call the S'SSF_FUNCTION_MODULE_NAME' module

changing lf_retcode.

if lf_retcode ne 0.

return_code = 1.

else.

return_code = 0.

Former Member
0 Kudos

This is written in that form processing..... now where will I write the 'SSF_FUNCTION_MODULE_NAME' .???

FORM PROCESSING USING PROC_SCREEN.

PERFORM GET_DATA.

PERFORM LR_NO.

CHECK RETCODE = 0 OR VBRP-LGORT = 'DIV1'.

PERFORM FORM_OPEN USING PROC_SCREEN VBDKR-LAND1.

CHECK RETCODE = 0 OR VBRP-LGORT = 'DIV1'.

PERFORM ITEM_PRINT.

CLEAR : TJ_1IEXCDTL-MAT_DESC1,TJ_1IEXCDTL-MAT_DESC2.

CHECK RETCODE = 0 OR VBRP-LGORT = 'DIV1'.

  • PERFORM SPACE_PRINT.

  • ENDDO.

IF VBRP-KONDM EQ '13' AND J_1IEXCHDR-KUNAG = '0001000451' .

PERFORM TEXT_AFTER_ITEM_PRINT.

ENDIF.

  • CHECK RETCODE = 0.

  • PERFORM END_PRINT.

  • CHECK RETCODE = 0.

PERFORM FORM_CLOSE.

CLEAR FREESW.

CHECK RETCODE = 0 OR VBRP-LGORT = 'DIV1'.

ENDFORM. "PROCESSING

Former Member
0 Kudos

what is the code in perform item_print.

i thick code in this perform will be replaced

Former Member
0 Kudos

the code is very long. and all the 'write_form' statements are there. So should I put the 'SSF_FUNCTION_MODULE_NAME' after all the 'write_form' ??

Edited by: Sumit Dutta on Feb 21, 2009 5:00 PM

Former Member
0 Kudos

the call to the fm open_form and write_from will be replace by the smartform fm.

Former Member
0 Kudos

Hi,

I have called the 'SSF_FUNCTION_MODULE_NAME' in ITEM_PRINT. and its ok.

but when I am giving the FM_NAME, It is giving problem with the V/83. As my driver program and smartform is define there. it is giving error like--- 'type conflict when calling function module' and 'function parameter "fm_name" is unknown' . I have tried evey way to change the name, but its not working.

please help me...

Former Member
0 Kudos

Hi Sumit,

Refer this wiki whether this resolves your issue

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/printing+invoices

Regards,

Sravanthi