Hi ,
I have created customer invoice..
for smartform i need to create z table to pass internal table data in smartform.
Is it compulsory to create z table..
i have declared internal table in smartform as given below:
itab_final like ZMM_CUSTOMER_INV.
becoz without creating z table data is not displayed in smartt form.
is thier any other way to display data in smartform without z table.
*&---------------------------------------------------------------------*
*& Report ZMM_CUSTOMER_INVOICE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMM_CUSTOMER_INVOICE.
tables: vbrk, vbrp, eikp, konv,mara, likp, vbak, ZMM_CUSTOMER_INV.
TYPES: BEGIN OF TY_final ,
tragr type ZMM_CUSTOMER_INV-tragr,
IEVER type ZMM_CUSTOMER_INV-IEVER,
ladel type ZMM_CUSTOMER_INV-ladel,
vbeln type ZMM_CUSTOMER_INV-vbeln,
fkdat type ZMM_CUSTOMER_INV-fkdat,
aubel type ZMM_CUSTOMER_INV-aubel,
audat type ZMM_CUSTOMER_INV-audat,
anzpk type ZMM_CUSTOMER_INV-anzpk,
aland type ZMM_CUSTOMER_INV-aland,
zterm type ZMM_CUSTOMER_INV-zterm,
vstel type ZMM_CUSTOMER_INV-vstel,
arktx type ZMM_CUSTOMER_INV-arktx,
fkimg type ZMM_CUSTOMER_INV-fkimg,
* kbetr type ZMM_CUSTOMER_INV-kbetr,
* kwert type ZMM_CUSTOMER_INV-kwert,
matnr type ZMM_CUSTOMER_INV-matnr,
TRMTYP type ZMM_CUSTOMER_INV-TRMTYP,
exnum type ZMM_CUSTOMER_INV-exnum,
VRKME TYPE ZMM_CUSTOMER_INV-VRKME,
kbetr type ZMM_CUSTOMER_INV-kbetr,
kwert type ZMM_CUSTOMER_INV-kwert,
KOEI1 type ZMM_CUSTOMER_INV-kbetr,
waerk type ZMM_CUSTOMER_INV-kwert,
amount type ZMM_CUSTOMER_INV-amount,
bed type ZMM_CUSTOMER_INV-bed,
ecs type ZMM_CUSTOMER_INV-ecs,
hecs type ZMM_CUSTOMER_INV-hecs,
END OF TY_final.
DATA: ITAB_FINAL TYPE TABLE OF ZMM_CUSTOMER_INV WITH HEADER LINE,
* BEGIN OF itab2 OCCURS 0,
* tragr type mara-tragr,
* IEVER type eikp-IEVER,
* ladel type eikp-ladel,
* vbeln type vbrk-vbeln,
* fkdat type vbrk-fkdat,
* aubel type vbrp-aubel,
* audat type vbak-audat,
* anzpk type likp-anzpk,
* aland type eikp-aland,
* zterm type vbrk-zterm,
* vstel type vbrp-vstel,
* arktx type vbrp-arktx,
* fkimg type vbrp-fkimg,
* kbetr type konv-kbetr,
* kwert type konv-kwert,
* matnr type mara-matnr,
* TRMTYP type likp-TRMTYP,
* exnum type likp-exnum,
* END OF itab2,
BEGIN OF itab_vbrk OCCURS 0,
knumv type vbrk-knumv,
vbeln type vbrk-vbeln,
fkdat type vbrk-fkdat,
zterm type vbrk-zterm,
exnum type vbrk-exnum,
end of itab_vbrk,
BEGIN OF itab_vbrp OCCURS 0,
vbeln type vbrp-vbeln,
matnr type vbrp-matnr,
aubel type vbrp-aubel,
vstel type vbrp-vstel,
arktx type vbrp-arktx,
fkimg type vbrp-fkimg,
end of itab_vbrp,
BEGIN OF itab_mara OCCURS 0,
matnr type mara-matnr,
tragr type mara-tragr ,
end of itab_mara,
BEGIN OF itab_likp OCCURS 0,
anzpk type likp-anzpk,
EXNUM type likp-EXNUM,
TRMTYP type likp-TRMTYP,
end of itab_likp,
begin of itab_eikp OCCURS 0,
iever type eikp-iever,
ladel type eikp-ladel,
aland type eikp-aland,
exnum type eikp-exnum,
END OF itab_eikp,
BEGIN OF ITAB_VBAK OCCURS 0,
VBELN TYPE VBAK-VBELN,
AUDAT TYPE VBAK-AUDAT,
END OF ITAB_VBAK ,
BEGIN OF ITAB_VBAP OCCURS 0,
matnr type vbap-matnr,
VBELN TYPE VBAP-VBELN,
END OF ITAB_VBAP,
BEGIN OF itab_konv OCCURS 0,
knumv type konv-knumv,
kbetr type konv-kbetr,
kschl type konv-kschl,
kwert type konv-kwert,
END OF itab_konv.
data: f_name type rs38l_fnam.
START-OF-SELECTION.
* select m~tragr e~iever e~ladel rk~vbeln rk~fkdat rp~aubel
* L~anzpk e~aland rk~zterm rp~vstel rp~arktx
* rp~fkimg into CORRESPONDING FIELDS OF TABLE ITAB
* from vbrk as rk INNER JOIN vbrp as rp
* on rk~vbeln = rp~vbeln INNER JOIN eikp as e
* on rk~EXNUM = e~EXNUM INNER JOIN mara as m
* on rp~matnr = m~matnr inner join likp as l
* on rk~exnum = l~EXNUM .
SELECT vbeln knumv fkdat zterm exnum from vbrk into CORRESPONDING FIELDS
OF TABLE itab_vbrk.
* if itab_vbrk is not INITIAL.
select aubel vstel arktx matnr vbeln FKIMG from vbrp into CORRESPONDING
FIELDS OF TABLE itab_vbrp
FOR ALL ENTRIES IN itab_vbrk where vbeln = itab_vbrk-vbeln.
* if itab_vbrp is not INITIAL.
SELECT tragr matnr from mara into CORRESPONDING FIELDS OF TABLE
itab_mara
FOR ALL ENTRIES IN itab_vbrp WHERE matnr = itab_vbrp-matnr.
* if itab_mara is NOT INITIAL.
SELECT anzpk TRMTYP EXNUM from likp INTO CORRESPONDING FIELDS OF TABLE
itab_likp
FOR ALL ENTRIES IN itab_vbrk WHERE exnum = itab_vbrk-exnum.
*if itab_likp is not INITIAL.
SELECT iever ladel aland EXNUM from eikp INTO CORRESPONDING FIELDS OF
TABLE itab_eikp
FOR ALL ENTRIES IN itab_eikp WHERE EXNUM = itab_eikp-EXNUM.
SELECT VBELN MATNR FROM VBAP INTO CORRESPONDING FIELDS OF TABLE
ITAB_VBAP
FOR ALL ENTRIES IN ITAB_MARA WHERE MATNR = ITAB_MARA-MATNR.
SELECT VBELN AUDAT FROM VBAK INTO CORRESPONDING FIELDS OF TABLE
ITAB_VBAK
FOR ALL ENTRIES IN ITAB_VBAP WHERE VBELN = ITAB_VBAP-VBELN.
SELECT knumv kwert kbetr kschl from konv INTO CORRESPONDING FIELDS OF
TABLE itab_konv
FOR ALL ENTRIES IN itab_vbrk
WHERE knumv = itab_vbrk-knumv.
LOOP at itab_vbrp.
ITAB_FINAL-aubel = itab_vbrp-aubel.
ITAB_FINAL-vstel = itab_vbrp-vstel.
ITAB_FINAL-arktx = itab_vbrp-arktx.
ITAB_FINAL-fkimg = itab_vbrp-fkimg.
ITAB_FINAL-vbeln = itab_vbrp-vbeln.
ITAB_FINAL-matnr = itab_vbrp-matnr.
ZMM_CUSTOMER_INV-AUBEL = ITAB_FINAL-AUBEL.
ZMM_CUSTOMER_INV-VSTEL = ITAB_FINAL-VSTEL.
ZMM_CUSTOMER_INV-ARKTX = ITAB_FINAL-ARKTX.
ZMM_CUSTOMER_INV-FKIMG = ITAB_FINAL-FKIMG.
ZMM_CUSTOMER_INV-VBELN = ITAB_FINAL-VBELN.
READ TABLE itab_vbrk WITH KEY vbeln = ITAB_FINAL-vbeln BINARY SEARCH.
ITAB_FINAL-vbeln = itab_vbrk-vbeln.
ITAB_FINAL-fkdat = itab_vbrk-fkdat.
ITAB_FINAL-zterm = itab_vbrk-zterm.
ZMM_CUSTOMER_INV-VBELN = ITAB_FINAL-VBELN.
ZMM_CUSTOMER_INV-FKDAT = ITAB_FINAL-FKDAT.
ZMM_CUSTOMER_INV-ZTERM = ITAB_FINAL-ZTERM.
READ TABLE itab_mara with key matnr = ITAB_FINAL-matnr BINARY SEARCH.
ITAB_FINAL-tragr = itab_mara-tragr.
ZMM_CUSTOMER_INV-TRAGR = ITAB_FINAL-TRAGR.
READ TABLE itab_likp with KEY TRMTYP = ITAB_FINAL-matnr BINARY SEARCH
.
ITAB_FINAL-anzpk = itab_likp-anzpk.
ITAB_FINAL-exnum = itab_likp-exnum.
ZMM_CUSTOMER_INV-ANZPK = ITAB_FINAL-ANZPK.
ZMM_CUSTOMER_INV-EXNUM = ITAB_FINAL-EXNUM.
READ TABLE itab_eikp with key exnum = ITAB_FINAL-exnum BINARY SEARCH.
ITAB_FINAL-iever = itab_eikp-iever.
ITAB_FINAL-ladel = itab_eikp-ladel.
ITAB_FINAL-aland = itab_eikp-aland.
ZMM_CUSTOMER_INV-IEVER = ITAB_FINAL-IEVER.
ZMM_CUSTOMER_INV-LADEL = ITAB_FINAL-LADEL.
ZMM_CUSTOMER_INV-ALAND = ITAB_FINAL-ALAND.
READ TABLE itab_vbap with key matnr = itab_final-matnr BINARY SEARCH.
READ TABLE itab_vbak with key vbeln = itab_vbap-vbeln BINARY SEARCH.
itab_final-audat = itab_vbak-audat.
READ TABLE itab_konv with key knumv = itab_vbrk-knumv BINARY SEARCH.
itab_final-kbetr = itab_konv-kbetr.
itab_final-kwert = itab_konv-kwert.
itab_final-Amount = itab_final-fkimg * itab_final-kbetr.
ZMM_CUSTOMER_INV-kbetr = itab_final-kbetr.
ZMM_CUSTOMER_INV-kwert = itab_final-kwert.
ZMM_CUSTOMER_INV-amount = itab_final-amount.
modify ZMM_CUSTOMER_INV.
ENDLOOP.
SELECT * FROM ZMM_CUSTOMER_INV into CORRESPONDING FIELDS OF TABLE
ITAB_FINAL.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZMM_SD_SF'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = f_name.
* 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.
Call FUNCTION f_name
TABLES
ITAB_FINAL = ITAB_FINAL.