Skip to Content
avatar image
Former Member

MULTIPLE DOCUMENTS PRINT IN ONE SMARTFORM VIEW

bELOW IS THE CODE I WROTE ,..In IT_FINAL iget multiple documents but in final view i m getting only single and first document .How can i get multiple document in output smartform.

*&---------------------------------------------------------------------*
*& Report ZFB03_SMRTFRM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZFB03_SMRTFRM.

TABLES : BKPF, BSEG , SKAT , KNA1.

TYPES : BEGIN OF TY_BKPF ,
BELNR TYPE BKPF-BELNR, " ACCOUNTING DOCUMENT
BUKRS TYPE BKPF-BUKRS, " COMAPNY CODE
GJAHR TYPE BKPF-GJAHR, " YEAR
BLART TYPE BKPF-BLART, " DOC TYPE
BLDAT TYPE BKPF-BLDAT, " DOC DATE
MONAT TYPE BKPF-MONAT, " PERIOD
WAERS TYPE BKPF-WAERS, " CURRENCY
BUDAT TYPE BKPF-BUDAT, " POSTING DATE
END OF TY_BKPF.

DATA : IT_BKPF TYPE TABLE OF TY_BKPF," WITH HEADER LINE,
WA_BKPF TYPE TY_BKPF.

TYPES : BEGIN OF TY_BSEG,
BELNR TYPE BSEG-BELNR, " ACCOUNTING DOCUMENT
BUKRS TYPE BSEG-BUKRS,
GJAHR TYPE BSEG-GJAHR,
HKONT TYPE BSEG-HKONT,
KUNNR TYPE BSEG-KUNNR,
BUZEI TYPE BSEG-BUZEI, "LINE ITEM
BSCHL TYPE BSEG-BSCHL, "POSTING KEY
KOART TYPE BSEG-KOART, "ACCOUNT TYPE
REBZZ TYPE BSEG-REBZZ, "LINE ITEM
UMSKZ TYPE BSEG-UMSKZ, "SPECIAL G/L INDICATOR
DMBTR TYPE BSEG-DMBTR, "AMOUNT IN LC
WRBTR TYPE BSEG-WRBTR, "AMOUNT
MWSKZ TYPE BSEG-MWSKZ, "TAX CODE
ZUONR TYPE BSEG-ZUONR, "ASSIGNMENT
SGTXT TYPE BSEG-SGTXT, "TEXT
AUGBL TYPE BSEG-AUGBL, "CLEARING DOCUMENT
NPLNR TYPE BSEG-NPLNR, "NETWORK
KOSTL TYPE BSEG-KOSTL, "COST CENTRE
PRCTR TYPE BSEG-PRCTR, "PROFIT CENTRE
AUFNR TYPE BSEG-AUFNR, "ORDER
PROJK TYPE BSEG-PROJK, "WBS ELEMENT
SAKNR TYPE BSEG-SAKNR,

END OF TY_BSEG.


DATA : IT_BSEG TYPE TABLE OF TY_BSEG ,
WA_BSEG TYPE TY_BSEG.


TYPES : BEGIN OF TY_SKAT,
SAKNR TYPE SKAT-SAKNR,
TXT20 TYPE SKAT-TXT20,
END OF TY_SKAT.

DATA : IT_SKAT TYPE TABLE OF TY_SKAT,
WA_SKAT TYPE TY_SKAT.


TYPES : BEGIN OF TY_KNA1,
KUNNR TYPE KNA1-KUNNR,
NAME1 TYPE KNA1-NAME1,
NAME2 TYPE KNA1-NAME2,


END OF TY_KNA1.

DATA : IT_KNA1 TYPE TABLE OF TY_KNA1,
WA_KNA1 TYPE TY_KNA1.

***TYPES : BEGIN OF TY_FINAL,
*** BELNR TYPE BKPF-BELNR,
*** BUKRS TYPE BKPF-BUKRS,
*** GJAHR TYPE BKPF-GJAHR,
*** BLDAT TYPE BKPF-BLDAT,
**** BELNR2 TYPE BSEG-BELNR,
*** BUZEI TYPE BSEG-BUZEI, "LINE ITEM
*** BSCHL TYPE BSEG-BSCHL, "POSTING KEY
*** KOART TYPE BSEG-KOART, "ACCOUNT TYPE
*** REBZZ TYPE BSEG-REBZZ, "LINE ITEM
*** UMSKZ TYPE BSEG-UMSKZ, "SPECIAL G/L INDICATOR
*** DMBTR TYPE BSEG-DMBTR, "AMOUNT IN LC
*** WRBTR TYPE BSEG-WRBTR, "AMOUNT
*** MWSKZ TYPE BSEG-MWSKZ, "TAX CODE
*** ZUONR TYPE BSEG-ZUONR, "ASSIGNMENT
*** SGTXT TYPE BSEG-SGTXT, "TEXT
*** AUGBL TYPE BSEG-AUGBL, "CLEARING DOCUMENT
*** NPLNR TYPE BSEG-NPLNR, "NETWORK
*** KOSTL TYPE BSEG-KOSTL, "COST CENTRE
*** PRCTR TYPE BSEG-PRCTR, "PROFIT CENTRE
*** AUFNR TYPE BSEG-AUFNR, "ORDER
*** PROJK TYPE BSEG-PROJK, "WBS ELEMENT
***
***
*** END OF TY_FINAL.
***
***DATA : IT_FINAL TYPE TABLE OF TY_FINAL,
*** WA_FINAL TYPE TY_FINAL.

DATA : IT_ITEM TYPE TABLE OF ZFB03_STRUCT,
WA_ITEM TYPE ZFB03_STRUCT.

DATA : IT_FINAL TYPE TABLE OF ZFB03_STRUCT,
WA_FINAL TYPE ZFB03_STRUCT.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TXT01.

SELECT-OPTIONS : T_DOCNO FOR BKPF-BELNR.
PARAMETERS : T_BUKRS LIKE BKPF-BUKRS.
PARAMETERS : T_YEAR LIKE BKPF-GJAHR.

SELECTION-SCREEN END OF BLOCK B1.

START-OF-SELECTION.

SELECT BELNR BUKRS GJAHR BLART BLDAT MONAT WAERS BUDAT FROM BKPF INTO TABLE IT_BKPF
WHERE BELNR IN T_DOCNO AND BUKRS = T_BUKRS AND GJAHR = T_YEAR.

* READ TABLE IT_BKPF INTO WA_BKPF WITH KEY BELNR = T_DOCNO.

*IF IT_BKPF IS NOT INITIAL.
IF IT_BKPF IS NOT INITIAL.
SELECT BELNR BUKRS GJAHR HKONT KUNNR BUZEI BSCHL KOART REBZZ UMSKZ DMBTR WRBTR MWSKZ ZUONR SGTXT AUGBL NPLNR KOSTL PRCTR AUFNR PROJK SAKNR
FROM BSEG
INTO TABLE IT_BSEG FOR ALL ENTRIES IN IT_BKPF WHERE BELNR = IT_BKPF-BELNR AND BUKRS = IT_BKPF-BUKRS AND GJAHR = IT_BKPF-GJAHR.
" AND KOART = 'S'.

** IF IT_BSEG IS NOT INITIAL .
** SELECT SAKNR TXT20 FROM SKAT INTO TABLE IT_SKAT FOR ALL ENTRIES IN IT_BSEG WHERE SAKNR = IT_BSEG-HKONT.


* ENDIF.

ENDIF.

*** IF IT_BKPF IS NOT INITIAL.
*** SELECT BELNR BUKRS GJAHR HKONT KUNNR BUZEI BSCHL KOART REBZZ UMSKZ DMBTR WRBTR MWSKZ ZUONR SGTXT AUGBL NPLNR KOSTL PRCTR AUFNR PROJK FROM BSEG
*** INTO TABLE IT_BSEG FOR ALL ENTRIES IN IT_BKPF WHERE BELNR = IT_BKPF-BELNR AND BUKRS = IT_BKPF-BUKRS AND GJAHR = IT_BKPF-GJAHR
*** AND KOART = 'D'.
***
*** IF IT_BSEG IS NOT INITIAL.
*** SELECT KUNNR NAME1 NAME2 FROM KNA1 INTO TABLE IT_KNA1 FOR ALL ENTRIES IN IT_BSEG WHERE KUNNR = IT_BSEG-KUNNR .
***
***
*** ENDIF.
***
*** ENDIF.

**SELECT BELNR BUKRS GJAHR BLDAT FROM BKPF INTO TABLE IT_BKPF
** WHERE BELNR IN T_DOCNO AND BUKRS = T_BUKRS AND GJAHR = T_YEAR.

*SELECT BELNR BUKRS GJAHR HKONT KUNNR

BREAK-POINT.

* LOOP AT IT_FINAL INTO WA_FINAL WHERE BELNR = T_DOCNO." WA_BKPF-BELNR." AND BUKRS .
* clear : wa_bkpf , wa_bseg , wa_skat, wa_kna1.
LOOP AT IT_BKPF INTO WA_BKPF ."WHERE BELNR = T_DOCNO.
***** clear : wa_final.
***** refresh it_final.
* refresh : wa_bkpf, wa_bseg.
* READ TABLE IT_BKPF INTO WA_BKPF WITH KEY BELNR = .
* READ TABLE IT_BKPF INTO WA_BKPF WITH KEY BELNR = T_DOCNO.
* IF SY-SUBRC = 0.

*** WA_FINAL-BELNR = WA_BKPF-BELNR.
*** WA_FINAL-BUKRS = WA_BKPF-BUKRS.
*** WA_FINAL-GJAHR = WA_BKPF-GJAHR.
*** WA_FINAL-BLDAT = WA_BKPF-BLDAT.

* ENDIF.
* LOOP AT IT_BSEG INTO WA_BSEG .
READ TABLE IT_BSEG INTO WA_BSEG WITH KEY BELNR = WA_BKPF-BELNR BUKRS = WA_BKPF-BUKRS."T_DOCNO.


IF SY-SUBRC = 0.
WA_FINAL-BELNR = WA_BKPF-BELNR.
* WA_FINAL-BELNR = WA_BSEG-BELNR.
WA_FINAL-BUKRS = WA_BKPF-BUKRS.
WA_FINAL-GJAHR = WA_BKPF-GJAHR.
WA_FINAL-BLART = WA_BKPF-BLART.
WA_FINAL-BLDAT = WA_BKPF-BLDAT.
WA_FINAL-MONAT = WA_BKPF-MONAT.
WA_FINAL-WAERS = WA_BKPF-WAERS.
WA_FINAL-BUDAT = WA_BKPF-BUDAT.
* WA_FINAL-BELNR = WA_BSEG-BELNR.
WA_FINAL-BUZEI = WA_BSEG-BUZEI.
WA_FINAL-BSCHL = WA_BSEG-BSCHL.
** WA_FINAL-HKONT = WA_BSEG-HKONT.
WA_FINAL-KUNNR = WA_BSEG-KUNNR.
* WA_FINAL-KOART = WA_BSEG-KOART.
* WA_FINAL-REBZZ = WA_BSEG-REBZZ.
WA_FINAL-UMSKZ = WA_BSEG-UMSKZ.
WA_FINAL-DMBTR = WA_BSEG-DMBTR.
WA_FINAL-WRBTR = WA_BSEG-WRBTR.
WA_FINAL-MWSKZ = WA_BSEG-MWSKZ.
WA_FINAL-ZUONR = WA_BSEG-ZUONR.
WA_FINAL-SGTXT = WA_BSEG-SGTXT.
WA_FINAL-AUGBL = WA_BSEG-AUGBL.
WA_FINAL-NPLNR = WA_BSEG-NPLNR.
WA_FINAL-KOSTL = WA_BSEG-KOSTL.
* WA_FINAL-PRCTR = WA_BSEG-PRCTR.
* WA_FINAL-AUFNR = WA_BSEG-AUFNR.
* WA_FINAL-PROJK = WA_BSEG-PROJK.

ENDIF .
** MODIFY IT_BSEG FROM WA_BSEG INDEX SY-TABIX TRANSPORTING SAKNR.
** ENDLOOP.


IF IT_BKPF IS NOT INITIAL.
SELECT BELNR BUKRS GJAHR HKONT KUNNR BUZEI BSCHL KOART REBZZ UMSKZ DMBTR WRBTR MWSKZ ZUONR SGTXT AUGBL NPLNR KOSTL PRCTR AUFNR PROJK
SAKNR FROM BSEG
INTO TABLE IT_BSEG FOR ALL ENTRIES IN IT_BKPF WHERE BELNR = IT_BKPF-BELNR AND BUKRS = IT_BKPF-BUKRS AND GJAHR = IT_BKPF-GJAHR
AND KOART = 'S'.

READ TABLE IT_BSEG INTO WA_BSEG WITH KEY BELNR = WA_BKPF-BELNR BUKRS = WA_BKPF-BUKRS.
IF SY-SUBRC = 0.
WA_FINAL-HKONT = WA_BSEG-HKONT.

ENDIF.

IF IT_BSEG IS NOT INITIAL .
SELECT SAKNR TXT20 FROM SKAT INTO TABLE IT_SKAT FOR ALL ENTRIES IN IT_BSEG WHERE SAKNR = IT_BSEG-HKONT.


READ TABLE IT_SKAT INTO WA_SKAT WITH KEY SAKNR = WA_BSEG-HKONT.
IF SY-SUBRC = 0 .
WA_FINAL-TXT20 = WA_SKAT-TXT20.
WA_FINAL-SAKNR = WA_SKAT-SAKNR.

ENDIF.

ENDIF.

ENDIF.

IF IT_BKPF IS NOT INITIAL.
SELECT BELNR BUKRS GJAHR HKONT KUNNR BUZEI BSCHL KOART REBZZ UMSKZ DMBTR WRBTR MWSKZ ZUONR SGTXT AUGBL NPLNR KOSTL PRCTR AUFNR PROJK SAKNR
FROM BSEG
INTO TABLE IT_BSEG FOR ALL ENTRIES IN IT_BKPF WHERE BELNR = IT_BKPF-BELNR AND BUKRS = IT_BKPF-BUKRS AND GJAHR = IT_BKPF-GJAHR
AND KOART = 'D'.

IF IT_BSEG IS NOT INITIAL.
SELECT KUNNR NAME1 NAME2 FROM KNA1 INTO TABLE IT_KNA1 FOR ALL ENTRIES IN IT_BSEG WHERE KUNNR = IT_BSEG-KUNNR .

READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_BSEG-KUNNR.
IF SY-SUBRC = 0.
WA_FINAL-KUNNR = WA_KNA1-KUNNR.
WA_FINAL-NAME1 = WA_KNA1-NAME1.
WA_FINAL-NAME2 = WA_KNA1-NAME2.

ENDIF.

ENDIF.

ENDIF.

READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_BSEG-KUNNR.
IF SY-SUBRC = 0.

WA_FINAL-NAME1 = WA_KNA1-NAME1.
WA_FINAL-NAME2 = WA_KNA1-NAME2.


ENDIF.

* IF
BREAK-POINT.
APPEND WA_FINAL TO IT_FINAL.
CLEAR : WA_BKPF , WA_BSEG , WA_SKAT, WA_KNA1 .
ENDLOOP.
* MODIFY IT_FINAL FROM WA_FINAL.
* ENDLOOP.
*ENDLOOP.


DATA : FM_NAME TYPE RS38L_FNAM.



CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZFB03_SMRTFRM'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

*ENDIF.

**CALL FUNCTION 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 =
*** EXCEPTIONS
*** FORMATTING_ERROR = 1
*** INTERNAL_ERROR = 2
*** SEND_ERROR = 3
*** USER_CANCELED = 4
*** OTHERS = 5
** .
**IF sy-subrc <> 0.
* Implement suitable error handling here

*ENDIF.

CALL FUNCTION 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_final = IT_FINAL
* EXCEPTIONS
* FORMATTING_ERROR = 1
* INTERNAL_ERROR = 2
* SEND_ERROR = 3
* USER_CANCELED = 4
* OTHERS = 5
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

*CALL FUNCTION F
** 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_final = IT_FINAL
** wa_final = WA_FINAL
** EXCEPTIONS
** FORMATTING_ERROR = 1
** INTERNAL_ERROR = 2
** SEND_ERROR = 3
** USER_CANCELED = 4
** OTHERS = 5
* .
*IF sy-subrc <> 0.
** Implement suitable error handling here
*ENDIF.
*ENDLOOP.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers