Skip to Content
avatar image
Former Member

attach SMARTFORM in driver program of printing Invoice

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Feb 23, 2009 at 11:26 AM

    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 ??

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Feb 21, 2009 at 09:19 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 21, 2009 at 09:22 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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...

  • avatar image
    Former Member
    Feb 23, 2009 at 05:08 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 23, 2009 at 06:50 AM

    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

    Add comment
    10|10000 characters needed characters exceeded