Skip to Content
0
Former Member
Jun 21, 2010 at 06:43 AM

Voucher Printing for multiple Documents in SMARTFORMS

148 Views

Hi Developers,

I want to change my driver program which calls a smartform. I need to print multiple forms according to the input given.

I want to print multiple Smartforms for a range of Documents.

Example:

Document Number: 2000000002 to 2000000005

I want to print Separate Smartforms for each Document Number.

I dont have any idea about printing multiple smartforms.Pls Help me.

My Program code Below.

TABLES : BKPF,

BSEG,

ZFI_BSEG.

TYPES : BEGIN OF TY_BKPF,

BUKRS TYPE BKPF-BUKRS,

BELNR TYPE BKPF-BELNR,

GJAHR TYPE BKPF-GJAHR,

BUDAT TYPE BKPF-BUDAT,

XBLNR TYPE BKPF-XBLNR,

BKTXT TYPE BKPF-BKTXT,

BLART TYPE BKPF-BLART,

END OF TY_BKPF.

DATA : IT_BKPF TYPE TABLE OF TY_BKPF WITH HEADER LINE,

IT_BSEG TYPE TABLE OF ZFI_BSEG.

DATA : WA_BKPF LIKE LINE OF IT_BKPF,

WA_BSEG LIKE LINE OF IT_BSEG.

DATA : WRK_KTOPL TYPE T001-KTOPL,

WRK_FRMNAME TYPE RS38L_FNAM.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : PA_BELNR FOR BKPF-BELNR.

PARAMETERS :

PA_BUKRS TYPE BKPF-BUKRS,

PA_GJAHR TYPE BKPF-GJAHR.

SELECTION-SCREEN END OF BLOCK B1.

PERFORM DATA_SELECTION.

FORM DATA_SELECTION .

SELECT BUKRS

BELNR

GJAHR

BUDAT

XBLNR

BKTXT

BLART

FROM BKPF

INTO CORRESPONDING FIELDS OF TABLE IT_BKPF

WHERE BUKRS = PA_BUKRS

AND BELNR IN PA_BELNR

AND GJAHR = PA_GJAHR.

LOOP AT IT_BKPF.

IF IT_BKPF IS NOT INITIAL.

SELECT BUKRS

BELNR

GJAHR

BUZEI

BSCHL

SHKZG

DMBTR

HKONT

SGTXT

LIFNR

KUNNR

AUGBL

AUGGJ

FROM BSEG

INTO CORRESPONDING FIELDS OF TABLE IT_BSEG

WHERE BELNR = IT_BKPF-BELNR

AND BUKRS = IT_BKPF-BUKRS

AND GJAHR = IT_BKPF-GJAHR.

ENDIF.

SELECT SINGLE KTOPL

FROM T001

INTO WRK_KTOPL

WHERE BUKRS = PA_BUKRS.

LOOP AT IT_BSEG INTO WA_BSEG.

SELECT SINGLE SAKNR

TXT50

FROM SKAT

INTO (WA_BSEG-SAKNR,WA_BSEG-TXT50)

WHERE SAKNR = WA_BSEG-HKONT

AND KTOPL = WRK_KTOPL.

MODIFY IT_BSEG FROM WA_BSEG INDEX SY-TABIX TRANSPORTING SAKNR

TXT50.

ENDLOOP.

SORT IT_BSEG BY SHKZG DESCENDING.

PERFORM CALL_SMARTFORM.

CLEAR : WRK_KTOPL , WA_BSEG.

FREE : IT_BSEG .

ENDLOOP.

ENDFORM. " data_selection

FORM CALL_SMARTFORM .

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZFI_VOUCHER'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = WRK_FRMNAME

EXCEPTIONS

NO_FORM = 1

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

IF WRK_FRMNAME IS NOT INITIAL.

CALL FUNCTION WRK_FRMNAME

  • EXPORTING

  • HEADER_DATA = IT_BKPF

TABLES

ITEM_DATA = IT_BSEG

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELLED = 4

OTHERS = 5.

ENDIF.

ENDFORM. " call_smartform