on 06-24-2010 8:09 AM
Hi Devolopers,
I have a Smartform with 1 page which print the FI Voucher for only one document. Now the End User wants to Print Multiple Vouchers (document Number 0001-0005) with each Document should print in Separate Page. I have changed the PARAMETERS option to SELECT-OPTIONS in my Driver Program. Now ALL the Documents are Printing in One Smartform.
How can break the pages? so that each Document will print in separate pages.
My Driver 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
Hi Bibhu,
Try the following code
DATA : gs_con_settings TYPE SSFCTRLOP.
gs_con_settings-NO_OPEN = 'X'.
gs_con_settings-NO_CLOSE = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
CONTROL_PARAMETERS = gs_con_settings .
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_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = SF_NAME " For zztest_sform1
IMPORTING
FM_NAME = SFM_NAME .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_BKPF.
PERFORM fetch_BSEG USING IT_BKPF-BELNR IT_BKPF-BUKRS IT_BKPF-GJAHR.
CALL FUNCTION SFM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = gs_con_settings
TABLES
it_bseg = it_bseg.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
CLEAR it_bkpf.
REFRESH it_bseg.
ENDLOOP. "it_bkpf
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
JOB_OUTPUT_INFO =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Try the above code
Let me know if you any concerns.........
Regards ,
Lokesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
No need of of changing anything in the smartform.
In Looping of your data it will automatically trigger the page break .
Suppose for one docuemtn number u have more than 1 page it will take care automatically no need of putting any pagebreak in the form .
Let me know if u have any concerns... i will help u
Regards ,
Lokesh
Hi,
Thanks Now the page break problem is solved but No data is coming. I cant understand the code below. How can I put the Perform statement under the loop and where should I write the FORM?
LOOP AT IT_BKPF.
PERFORM fetch_BSEG USING IT_BKPF-BELNR IT_BKPF-BUKRS IT_BKPF-GJAHR.
CALL FUNCTION SFM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = gs_con_settings
TABLES
it_bseg = it_bseg.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
CLEAR it_bkpf.
REFRESH it_bseg.
ENDLOOP. "it_bkpf
Hi ,
As Per Your coding before calling the form your fetching the BSEG data .
In the
LOOP at it_bkpf .
You have to pass the data of it_bseg- belnr = it_bkpf -belnr in each iteration to the form
ENDLOOP.
Otherwise do like this
1. soltuion
As per your coding each time your passing the entire data of BSEG(it_bseg ) to form in that case follow below
Put the condition in the form at the time of printing it_bseg-belnr EQ it_bkpf-belnr.
2.solution
you to pass the it_bkpf (Work area data ) to the form
in the form you have to fetch the BSEG data for that particular BELNR and print
Let me know if any concerns....
Regards ,
Lokesh.
Hi ,
LOOP AT IT_BKPF.
PERFORM fetch_BSEG USING IT_BKPF-BELNR IT_BKPF-BUKRS IT_BKPF-GJAHR.
CALL FUNCTION SFM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = gs_con_settings
TABLES
it_bseg = it_bseg.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
CLEAR it_bkpf.
REFRESH it_bseg.
ENDLOOP. "it_bkpf
FORM fetch_BSEG USING p_belnr p_bukrs p_gjahr
SELECT * FROM BSEG
INTO table it_bseg
WHERE belnr EQ p_belnr
AND bukrs EQ p_bukrs
AND gjahr EQ p_gjahr.
ENDFORM . " End of fetch_bseg
Let me know if any concerns..........
Regards ,
Lokesh.
Hi Lokesh,
I cant write PERFORM and FORM again because in my Code I am calling all the function Modules within a FORM...........ENDFORM. and subroutines cant be nested. Please tell me what to do now. My code below:
FORM CALL_SMARTFORM .
gs_con_settings-NO_OPEN = 'X'.
gs_con_settings-NO_CLOSE = 'X'.
CALL FUNCTION 'SSF_OPEN'
EXPORTING
CONTROL_PARAMETERS = gs_con_settings .
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_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.
LOOP AT IT_BKPF.
CALL FUNCTION WRK_FRMNAME
EXPORTING
HEADER_DATA = IT_BKPF
CONTROL_PARAMETERS = gs_con_settings
TABLES
ITEM_DATA = IT_BSEG
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELLED = 4
OTHERS = 5.
CLEAR it_bkpf.
refresh it_bseg.
ENDLOOP. "it_bkpf
CALL FUNCTION 'SSF_CLOSE'
IMPORTING
JOB_OUTPUT_INFO =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM. " call_smartform
Hi ,
As per your post it_bseg data is not properly fetchin or Not passing to your form .
In the form(layout ) what data your ging to printing .
See the below code Assume that it_bkpf having 10 rec - your O/P willl be 10 pages
here it_bseg will 10 or more that 10 records (Assume it as it_bseg will 100 record .means each page will be 10 records)
LOOP AT it_bkpf INTO wa_bkpf.
CALL FUNCTION SFM_NAME
EXPORTING
CONTROL_PARAMETERS = gs_con_settings
wa_bkpf = wa_bkpf
TABLES
it_bseg = it_bseg.
CLEAR : wa_bkpf.
ENDLOOP.
In the form your are going to print it_bseg data by using table node
in TABLE node data = it_bseg into wa_bseg
in condition tab belnr EQ wa_bkpf-belnr (Put this condition )
Hope u will resolve your issue ... chekc my businesscard.
Let me know if any concerns....
Regards .
Hi..
To print each Accounting Document in separate pages, you can follow the following steps:
1. In TABLE node, DATA tab, enter the field name (BELNR probably) based on which new page should be triggered and check on 'Event on Sort Begin'.
2. An event will be created between the header and Main Area in the Smartform Table.
3. In the node Event, Create-> Flow Logic ->Command.
4. In the command node, check on goto new page and give the same page as New Page.
This will print each Accnt. Doc on separate page. If the first prints without any entry, then you can put some condition such that blank is not printed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Karthik,
Thank you for the Reply. I did the steps as said by you. Now the problem is if I am printing Document Number 001-004 then in my output 8 pages are coming. 1st page is Blanc, 2nd page onwards Data are coming but Not in proper manner. i.e. not every page is having Data. Some of the pages are Blanc. Only the last page is coming properly. What will I do Now?
Regards,
Bibhu
Hi Bibhu..
The printing of first page blank can be avoided by a putting condition " sy-tabix NE 1 " (such that new page is not triggered for the first entry) in the command node.
Rest the steps followed in the samrtform, result in the same manner as using AT NEW event in a report. You need to make sure that the field based on which new page needs to be triggered, should be the first column of the internal table which is being looped upon.
Here your table IT_BSEG is of type ZFI_BSEG, so I cant say whether the AT NEW event will trigger properly or not.
Else you can transfer the data into a new internal table with BELNR or (the field based on which new page is to be triggered) as first column and other fields following it. In this case it will definitely work as expected.
Regards,
Karthik
Hi Bibhu..
I will just try to make things clear. You need not write the event AT NEW. Whatsoever you have done in the smartform as I had mentioned step wise covers this event.
This event results in triggering of new page in your smartform. But it will work properly only if the Document number is the first coloumn in your internal table.
You can add some code as below:
TYPES: BEGIN OF TY_BSEG,
BELNR TYPE ***,
(now put in the rest of the fields as they are in IT_BSEG)
END OF TY_BSEG
DATA : IT_BSEG_NEW TYPE STANDARD TABLE OF TY_BSEG....etc
Now while looping at your IT_BSEG table, use MOVE-CORRESPONDING to this new internal table, pass it to the smartform, which will help print data in required format.
suppose an internal table has following format:
Field1 Field2 Field3
Using, AT NEW Field2 will trigger event At New whenever Field1 or Field2 changes and thus new page gets triggered in your smartform. In this case you may get data in improper format. As in your case, new page for new document.
So please check whether document number is the first column or not
But if you use AT NEW Field1, the event and hence new page triggers only when Field1 changes, that is the field- document number.
I hope this will solve your problem.
Regards,
Karthik.
Hi..
I meant to say that the Document Number probably BELNR based on which you want to print data in different page, should be the first coloumn of your internal table i.e. the first field in the internal table.
Like,
Begin of ty_****,
First_Field type XXXX, (this field should be the that particular field, based on which new page is to be triggered)
Sec_Field type XXXX, (all other fields as per your requirements)
..... and so on...
end of ty_****.
Also I forgot to mention that the internal table should be sort by this field, and additionally any other field as per your requirement.
Regards.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.