‎2013 Oct 10 6:57 AM
hi experts,
i have developed a smartform for voucher printing. by using parameters: p_belnr type bkpf-belnr. now the end user need to develop a multiple voucher printing means by using select-options: s_belnr for bkpf-belnr. experts i dont have any idea below is my code and attached smartform i have done a little modification for mutiple voucher printing but it is not trigering. so experts can any one correct me please....
report z_purchase_voucher_test .
tables: bkpf,bseg.
data: fm_name type rs38l_fnam.
types: begin of ty_bkpf,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
xblnr type xblnr1,
usnam type usnam,
bldat type bldat,
end of ty_bkpf.
types:begin of ty_bseg,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
shkzg type shkzg,
prctr type prctr,
dmbtr type dmbtr,
sgtxt type sgtxt,
hkont type hkont,
koart type koart,
kunnr type kunnr,
lifnr type lifnr,
txt50 type txt50_skat,
debit type dmbtr,
credit type dmbtr,
end of ty_bseg.
types:begin of ty_final,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
shkzg type shkzg,
prctr type prctr,
dmbtr type dmbtr,
sgtxt type sgtxt,
hkont type hkont,
koart type koart,
kunnr type kunnr,
lifnr type lifnr,
txt50 type txt50_skat,
debit type dmbtr,
credit type dmbtr,
flag ,
end of ty_final.
data: wa_bkpf type ty_bkpf,
it_bkpf type table of ty_bkpf,
it_bseg type table of ty_bseg,
wa_bseg type ty_bseg,
it_bseg1 type table of ty_bseg,
wa_bseg1 type ty_bseg,
it_final type table of ty_final,
wa_final type ty_final.
data : gs_con_settings type ssfctrlop.
field-symbols:<fs_bseg> type ty_bseg,
<fs_final> type ty_final.
selection-screen begin of block b1 with frame title text-001.
select-options: s_belnr for bkpf-belnr obligatory.
parameters : p_bukrs type bkpf-bukrs obligatory.
parameters : p_gjahr type bkpf-gjahr obligatory.
selection-screen end of block b1.
at selection-screen.
start-of-selection.
perform get_data.
perform print.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_data .
select bukrs belnr gjahr xblnr usnam bldat
from bkpf
into table it_bkpf
where belnr in s_belnr
and bukrs eq p_bukrs
and gjahr eq p_gjahr.
if it_bkpf is not initial.
select bukrs
belnr
gjahr
shkzg
prctr
dmbtr
sgtxt
hkont
koart
kunnr
lifnr
from bseg
into table it_bseg
for all entries in it_bkpf
where bukrs = it_bkpf-bukrs
and belnr = it_bkpf-belnr
and gjahr = it_bkpf-gjahr.
endif.
sort it_bseg by bukrs belnr gjahr.
loop at it_bseg assigning <fs_bseg>.
if <fs_bseg>-koart = 'K'.
select single name1 from lfa1 into <fs_bseg>-txt50
where lifnr = <fs_bseg>-lifnr.
elseif <fs_bseg>-koart = 'D'.
select single name1 from kna1 into <fs_bseg>-txt50
where kunnr = <fs_bseg>-kunnr.
elseif <fs_bseg>-hkont is not initial.
select single txt50 from skat into <fs_bseg>-txt50
where spras = 'EN'
and saknr = <fs_bseg>-hkont.
endif.
if <fs_bseg>-shkzg = 'S'.
<fs_bseg>-debit = <fs_bseg>-dmbtr.
elseif <fs_bseg>-shkzg = 'H'.
<fs_bseg>-credit = <fs_bseg>-dmbtr .
endif.
endloop.
append lines of it_bseg[] to it_final[].
sort it_final by bukrs belnr gjahr.
loop at it_final assigning <fs_final>.
at end of belnr.
<fs_final>-flag = 'X'.
endat.
endloop.
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form PRINT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form print .
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.
* Implement suitable error handling here
endif.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'Z_PURCHASE_VOUCHER_TEST'
* 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.
if fm_name is not initial.
*loop at it_bkpf into wa_bkpf.
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'
p_bukrs = p_bukrs
p_belnr = s_belnr
p_gjahr = p_gjahr
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
tables
gt_bseg = it_bseg
gt_bseg1 = it_bseg1
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.
endif.
endform. " PRINT
‎2013 Oct 10 7:07 AM
Don't change anything in the Smartforms if not required.
Some values to adapt fields of the control structure.
More information at Printing Several Forms in One Print Request.
And look more carefully at what you wrote, "p_belnr = s_belnr" is obviously wrong, use fields of the work area filled in the LOOP (else why did you loop ) : wa_bkpf-bukrs, belnr and gjahr...
Regards,
Raymond
‎2013 Oct 10 7:07 AM
Don't change anything in the Smartforms if not required.
Some values to adapt fields of the control structure.
More information at Printing Several Forms in One Print Request.
And look more carefully at what you wrote, "p_belnr = s_belnr" is obviously wrong, use fields of the work area filled in the LOOP (else why did you loop ) : wa_bkpf-bukrs, belnr and gjahr...
Regards,
Raymond
‎2013 Oct 10 12:38 PM
hi Rayomd sir,
issue has been fixed thank q..
regards,
uday bhaskar.