Go on link..

link us with ...

Friday, December 31, 2010

SALES_DAY

*&---------------------------------------------------------------------*
*& Report ZVVF_FIRO_23_SALES_DAY *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZVVF_FIRO_23_SALES_DAY.


**---------------------------------------------------------------------*
* Tables
**---------------------------------------------------------------------*

tables : vbrk, vbrp, konv, kna1, marc, t001w, tvm1t,bkpf,ZVVF_FT23_PURCON.

**---------------------------------------------------------------------*
* Types Begin with TY_
**---------------------------------------------------------------------*

TYPE-POOLS slis.

data : begin of itab occurs 0,
VBELN LIKE VBRP-VBELN,
MATNR LIKE VBRP-MATNR,
BELNR LIKE BKPF-BELNR,
VKORG LIKE VBRK-VKORG,
VTWEG LIKE VBRK-VTWEG,

SPART LIKE VBRK-SPART,
KNUMV LIKE VBRK-KNUMV,
BUKRS LIKE VBRK-BUKRS,
KUNAG LIKE VBRK-KUNAG,
WAERS LIKE BKPF-WAERS,
BUDAT LIKE BKPF-BUDAT,
BLDAT LIKE BKPF-BLDAT,
BLART LIKE BKPF-BLART,

C_MATNR(20) TYPE C,
WERKS LIKE VBRP-WERKS,
MEINS LIKE VBRP-MEINS,
MWSKZ LIKE VBRP-MWSKZ,
TEXT1 LIKE T007S-TEXT1,
MATKL LIKE VBRP-MATKL,
SHKZG LIKE VBRP-SHKZG,
POSNR LIKE VBRP-POSNR,
FKIMG LIKE VBRP-FKIMG,
BRTWR LIKE VBRP-BRTWR,
HKONT LIKE BSEG-HKONT,
SHKONT LIKE BSEG-HKONT,
C_HKONT(10) TYPE C,
SC_SHKONT(10) TYPE C,

KUNNR LIKE BSEG-KUNNR,
NAME1 LIKE KNA1-NAME1,
KNA1 LIKE KNA1-NAME1,
TXT20 LIKE SKAT-TXT20,
MAKTX LIKE MAKT-MAKTX,
BASIC like konv-kwert,
DIS like konv-kwert,
EXACC LIKE KONV-KWERT,
EXCISE LIKE KONV-KWERT,
ECESS LIKE KONV-KWERT,
LST LIKE KONV-KWERT,
CST LIKE KONV-KWERT,
SLST LIKE KONV-KWERT,
SCST LIKE KONV-KWERT,
TURN LIKE KONV-KWERT,
price_e like konv-kwert,
frei_e like konv-kwert,
ins_e like konv-kwert,
comm_e like konv-kwert,
WAERK LIKE VBRK-WAERK,
PRICE_E_FC LIKE konv-KAWRT,
INS_E_FC LIKE konv-KAWRT,
FREI_E_FC LIKE konv-KAWRT,
KURRF LIKE VBRK-KURRF,
TOTPR LIKE vbrp-netwr,
MENGE LIKE BSEG-MENGE,
NETWR LIKE VBRP-NETWR,
ERDAT LIKE VBRP-ERDAT,

KNUMA LIKE VBRK-KNUMA,
VBTYP LIKE VBRK-VBTYP,
LAND1 LIKE VBRK-LAND1,

KURRF_DAT LIKE VBRK-KURRF_DAT,
KALSM LIKE VBRK-KALSM,

KURSK LIKE VBRP-KURSK,
KURSK_DAT LIKE VBRP-KURSK_DAT,
comm like konv-kwert,
APMCFEE LIKE KONV-KWERT,
VAT like konv-kwert,
VATCST LIKE KONV-KWERT,
VATCSTSUR LIKE KONV-KWERT,
STAX LIKE KONV-KWERT,
ESTAX LIKE KONV-KWERT,
STEXC LIKE KONV-KWERT,
ESTEXC LIKE KONV-KWERT,
w_t(10) type c,
STATUS(10) TYPE C,
fkart like vbrk-fkart,
kursf like bkpf-kursf,
exnum like j_1iexchdr-exnum,
VRKME LIKE VBRP-VRKME,
end of itab.

DATA : W_SEL TYPE I.

DATA : W_COMM LIKE KONV-KWERT,
W_price like konv-kwert,
W_frei like konv-kwert,
W_ins like konv-kwert.

DATA : W_FKIMG LIKE VBRP-FKIMG.


DATA : W_C_HKONT(10) TYPE C,
W_SC_SHKONT(10) TYPE C.


data : net_value like konv-kwert,
sales_tax like konv-kwert,
product_value like konv-kwert,
taxable_amt like konv-kwert,
tot_discount_sum like konv-kwert,
tot_discount_sum1 like konv-kwert,
tot_discount like konv-kwert,
tot_discount_tot like konv-kwert ,
tot_discount_tot_sum like konv-kwert ,
pc_discount type f ,
net_rate like konv-kbetr,
gr_rate type f ,
l_kpein like komv-kpein value 1 ,
net_amt like konv-kwert,
gr_amt like konv-kwert,
gr_amt_tot like konv-kwert,
gr_amt_tot_sum like konv-kwert,
gr_amt_sum like konv-kwert,
gr_amt_sum1 like konv-kwert,
freight like konv-kwert,
octroi like konv-kwert,
final_value like konv-kwert,
product_qty like vbrp-fkimg,
product_mrp like konv-kwert,
tot_qty type p decimals 2 ,
W_COM1 LIKE konv-kwert.

data : taxable_amt1(17) type c,
sales_tax1(17) type c,
cvar(7) type c,
freight1 LIKE KONV-KWERT,
octroi1 LIKE KONV-KWERT,
final_value1 LIKE KONV-KWERT.
data : w_date_t(10) type c,
w_date_f(10) type c.

data : flag(1) type c value 'N'.
data : maktx like makt-maktx.
data : page_cnt(2) type n value 0.


*DATA : IT_bkpf TYPE STANDARD TABLE OF bkpf WITH HEADER LINE.
DATA : BEGIN OF IT_BKPF OCCURS 0,
BUKRS LIKE BKPF-BUKRS,
BELNR LIKE BKPF-BELNR,
WAERS LIKE BKPF-WAERS,
BUDAT LIKE BKPF-BUDAT,
BLDAT LIKE BKPF-BLDAT,
XBLNR LIKE VBRK-VBELN,
GJAHR LIKE BKPF-GJAHR,
BLART LIKE BKPF-BLART,
awkey like vbrk-vbeln,
stgrd like BKPF-stgrd,
kursf like bkpf-kursf,
stblg like bkpf-stblg,
TCODE LIKE BKPF-TCODE,
END OF IT_BKPF.
*DATA : IT_bseg TYPE STANDARD TABLE OF bseg WITH HEADER LINE.
DATA : BEGIN OF IT_BSEG OCCURS 0,
BELNR LIKE BSEG-BELNR,
MATNR LIKE BSEG-MATNR,
VBELN LIKE BSEG-VBELN,
HKONT LIKE BSEG-HKONT,
KUNNR LIKE BSEG-KUNNR,
SGTXT LIKE BSEG-SGTXT,
KOART LIKE BSEG-KOART,
SHKZG LIKE BSEG-SHKZG,
DMBTR LIKE BSEG-DMBTR,
TOTPR LIKE BSEG-DMBTR,
MENGE LIKE BSEG-MENGE,
MWSKZ LIKE BSEG-MWSKZ,
KTOSL LIKE BSEG-KTOSL,
END OF IT_BSEG.

DATA : TOTPR1 LIKE vbrp-netwr.
DATA : W_C1 TYPE I.
DATA : IT_vbrk TYPE STANDARD TABLE OF vbrk WITH HEADER LINE.
DATA : IT_vbrp TYPE STANDARD TABLE OF vbrp WITH HEADER LINE.
DATA : IT_vbrp1 TYPE STANDARD TABLE OF vbrp WITH HEADER LINE.
DATA : IT_cond TYPE STANDARD TABLE OF ZVVF_FT23_PURCON WITH HEADER LINE.

DATA: it_st_list_top_of_page TYPE slis_t_listheader,
it_st_fieldcat TYPE slis_t_fieldcat_alv,
it_st_events TYPE slis_t_event,
st_layout TYPE slis_layout_alv,
s_status TYPE slis_formname VALUE 'STANDARD_ST01',
s_user_command TYPE slis_formname VALUE 'USER_COMMAND-ALV',
s_repid LIKE sy-repid,
s_save(1) TYPE c,
s_variant LIKE disvariant,
code LIKE disvariant-handle.





DATA : LW_LANG LIKE SY-LANGU VALUE 'E'.
**---------------------------------------------------------------------*
* Constants Begin with C_
**---------------------------------------------------------------------*

CONSTANTS: st_formname_top_of_page TYPE slis_formname
VALUE 'TOP_OF_PAGE-ALV'.


**---------------------------------------------------------------------*
* Data Begin with W_
**---------------------------------------------------------------------*

*-------- Declarations for ALV Grid.



**---------------------------------------------------------------------*
*---------------------------------------------------------------------**
* Infotypes ( HR Module Specific)
**---------------------------------------------------------------------*




**---------------------------------------------------------------------*
* Internal tables Begin with IT_
**---------------------------------------------------------------------*


**---------------------------------------------------------------------*
* R A N G E S
**---------------------------------------------------------------------*



**---------------------------------------------------------------------*
* Select Options Begin with SO_
**---------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK MAIN WITH FRAME TITLE TEXT-006.
SELECTION-SCREEN SKIP 2.
PARAMETER : P_BUKRS LIKE VBRK-BUKRS obligatory.
select-options : p_plant for vbrp-werks obligatory,
s_vkorg for vbrk-vkorg , "
s_kdgrp for vbrk-kdgrp, "Customer Group
s_kunag for VBRK-KUNAG,
* s_blart for bkpf-blart obligatory, "Document Type
s_fkart for vbrk-FKART, "Billing Type
s_mvgr1 for vbrp-mvgr1, "Material Group1
s_matnr for vbrp-matnr, "Material
s_gjahr for bkpf-gjahr obligatory,
s_date for bkpf-budat OBLIGATORY. "Date range

SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN END OF BLOCK MAIN.

SELECTION-SCREEN: SKIP 2,
BEGIN OF BLOCK ZVVFSD1 WITH FRAME TITLE text-007,
BEGIN OF LINE,
PUSHBUTTON 20(20) text-003 USER-COMMAND CLK1,
PUSHBUTTON 45(20) text-004 USER-COMMAND CLK2,
PUSHBUTTON 70(20) text-005 USER-COMMAND CLK3,
END OF LINE,
END OF BLOCK ZVVFSD1.

*AT SELECTION-SCREEN OUTPUT.
* SET PF-STATUS 'SDSALESDAY23N'.



AT SELECTION-SCREEN.
CASE sy-ucomm.


WHEN 'CLK1'.
W_SEL = 1.

PERFORM INT_ALV.

PERFORM GET_DATA.
PERFORM comment_build USING it_st_list_top_of_page[]. "dISPLAY hEADING IN ALV
PERFORM fieldcat USING it_st_fieldcat[]. "PUT DATA IN ALV
PERFORM layout_build USING st_layout.
PERFORM reuse_alv_list_display.
WHEN 'CLK2'.
PERFORM INT_ALV.
W_SEL = 2.
PERFORM GET_DATA.
PERFORM comment_build USING it_st_list_top_of_page[]. "dISPLAY hEADING IN ALV
PERFORM fieldcat USING it_st_fieldcat[]. "PUT DATA IN ALV
PERFORM layout_build USING st_layout.
PERFORM reuse_alv_list_display.
WHEN 'CLK3'.
LEAVE PROGRAM.

ENDCASE.

**---------------------------------------------------------------------*
* Parameters Begin with PR_
**---------------------------------------------------------------------*


**---------------------------------------------------------------------*
* Initialisation
**---------------------------------------------------------------------*

INITIALIZATION.
s_repid = sy-repid.
s_save = 'A'.
PERFORM eventtab_build USING it_st_events[].
PERFORM variant_init.



************************************************************************
* S T A R T O F S E L E C T I O N
************************************************************************
START-OF-SELECTION.


* PERFORM GET_DATA.
*
** PERFORM initialize.
*
* PERFORM comment_build USING it_st_list_top_of_page[]. "dISPLAY hEADING IN ALV
*
* PERFORM fieldcat USING it_st_fieldcat[]. "PUT DATA IN ALV
*
* PERFORM layout_build USING st_layout.
*
* PERFORM reuse_alv_list_display.


************************************************************************
* E N D O F S E L E C T I O N
************************************************************************


END-OF-SELECTION.


************************************************************************
* FORM : I N I T I A L I Z E
************************************************************************
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* DATA REQUIRED FROM VERIOUS TABLES
*----------------------------------------------------------------------*
* -->text
*----------------------------------------------------------------------*

FORM GET_DATA.



IF W_SEL = 1.
select * into CORRESPONDING FIELDS OF TABLE
IT_BKPF
"(It_bkpf-BELNR, IT_BKPF-WAERS, IT_BKPF-BUDAT, IT_BKPF-BLDAT, IT_BKPF-BLART, IT_BKPF-XBLNR, it_bkpf-awkey)
from bkpf where bukrs = p_bukrs
and gjahr in s_gjahr
* and blart in s_blart
AND BLART NE 'SA'
and budat in s_date.
DELETE IT_BKPF WHERE BLART = 'AB' AND STBLG GT '9000000000'.
W_SEL = 0.
ELSEIF W_SEL = 2.
select * into CORRESPONDING FIELDS OF TABLE
IT_BKPF
"(It_bkpf-BELNR, IT_BKPF-WAERS, IT_BKPF-BUDAT, IT_BKPF-BLDAT, IT_BKPF-BLART, IT_BKPF-XBLNR, it_bkpf-awkey)
from bkpf where bukrs = p_bukrs
and gjahr in s_gjahr
* and blart in s_blart
AND BLART IN ('SA','AB')
and budat in s_date.

W_SEL = 0.
DELETE IT_BKPF WHERE BLART = 'AB' AND STBLG LT '9000000000'.

ENDIF.


select * FROM BSEG INTO CORRESPONDING FIELDS OF TABLE it_bseg
for all entries in it_bkpf
where bukrs = it_bkpf-bukrs
and belnr = it_bkpf-belnr
and gjahr = it_bkpf-gjahr.


select * into table it_vbrk from vbrk
for all entries in it_bkpf
where vbeln = it_bkpf-awkey "it_bkpf-XBLNR
and kdgrp in s_kdgrp
and FKART in s_fkart
and kunag in s_kunag
and vkorg in s_vkorg.

select * into table it_vbrp from vbrp
for all entries in it_vbrk
where vbeln = it_vbrk-vbeln and
werks in p_plant and
mvgr1 in s_mvgr1 and
matnr in s_matnr.


select * into table it_cond from ZVVF_FT23_PURCON.

DATA : W_XBLNR LIKE VBRK-VBELN.

clear it_bkpf.
clear it_bseg.
clear it_vbrk.
clear it_vbrp.

SORT IT_BKPF BY AWKEY.
SORT IT_BSEG BY BELNR MATNR.
SORT IT_vbrk BY vbeln.
SORT IT_vbrp BY vbeln MATNR.

IT_VBRP1[] = IT_VBRP[].
LOOP AT IT_VBRK.

loop at it_vbrp WHERE VBELN = IT_VBRK-VBELN AND FKIMG GT 0 .
CLEAR TOTPR1.
clear w_fkimg.
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
TOTPR1 = TOTPR1 + ( IT_VBRP1-NETWR + IT_VBRP1-MWSBP ).
w_fkimg = w_fkimg + it_vbrp1-fkimg.
ENDLOOP.

READ TABLE IT_BKPF WITH KEY AWKEY = IT_VBRP-VBELN."TCODE = 'VF01'.
MOVE IT_BKPF-BELNR TO ITAB-BELNR.
MOVE IT_BKPF-WAERS TO ITAB-WAERS.
MOVE IT_BKPF-BUDAT TO ITAB-BUDAT.
MOVE IT_BKPF-BLDAT TO ITAB-BLDAT.
MOVE IT_BKPF-BLART TO ITAB-BLART.
MOVE IT_BKPF-AWKEY TO IT_BSEG-VBELN.
move it_bkpf-kursf to itab-kursf.
MODIFY IT_BSEG TRANSPORTING VBELN WHERE BELNR = ITAB-BELNR.
IF IT_BKPF-STblg NE SPACE.
MOVE 'REVERSAL' TO ITAB-STATUS.
ENDIF.



ITAB-TOTPR = ( TOTPR1 * itab-KURSf ).
* ITAB-TOTPR = ( TOTPR1 * it_vbrp-KURSK ).
itab-fkimg = w_fkimg.
READ TABLE IT_VBRK WITH KEY VBELN = IT_VBRP-VBELN.

MOVE IT_VBRK-KUNAG TO ITAB-KUNAG.
MOVE IT_VBRK-VKORG TO ITAB-VKORG.
MOVE IT_VBRK-VTWEG TO ITAB-VTWEG.
MOVE IT_VBRK-SPART TO ITAB-SPART.
MOVE IT_VBRK-KNUMV TO ITAB-KNUMV.
MOVE IT_VBRK-KUNAG TO ITAB-KUNAG.
MOVE IT_VBRK-KUNAG TO ITAB-KUNAG.
MOVE IT_VBRK-BUKRS TO ITAB-BUKRS.
MOVE IT_VBRK-WAERK TO ITAB-WAERK.
MOVE IT_VBRK-VKORG TO ITAB-VKORG.

MOVE IT_VBRK-KURRF TO ITAB-KURRF.
MOVE IT_VBRK-KNUMA TO ITAB-KNUMA.
MOVE IT_VBRK-VBTYP TO ITAB-VBTYP.
MOVE IT_VBRK-LAND1 TO ITAB-LAND1.
MOVE IT_VBRK-KURRF TO ITAB-KURRF.
MOVE IT_VBRK-KURRF_DAT TO ITAB-KURRF_DAT.
MOVE IT_VBRK-KALSM TO ITAB-KALSM.
move it_VBRK-FKART TO ITAB-FKART.
* IF IT_VBRK-FKART EQ 'G2' OR IT_VBRK-FKART EQ 'ZG2' or ( IT_BKPF-STblg NE SPACE AND
* ( IT_VBRK-FKART EQ 'S1' OR IT_VBRK-FKART EQ 'S3' ) ).
* itab-totpr = itab-totpr * ( -1 ).
* itab-BASIC = ITab-BASIC * ( -1 ).
* itab-DIS = itab-DIS * ( -1 ).
* itab-EXACC = itab-EXACC * ( -1 ).
* itab-EXCISE = itab-EXCISE * ( -1 ).
* itab-ECESS = itab-ECESS * ( -1 ).
* itab-LST = itab-LST * ( -1 ).
* itab-CST = itab-CST * ( -1 ).
* itab-SLST = itab-SLST * ( -1 ).
* itab-SCST = itab-SCST * ( -1 ).
* itab-TURN = itab-TURN * ( -1 ).
* itab-COMM = itab-COMM * ( -1 ).
* itab-APMCFEE = itab-APMCFEE * ( -1 ).
* itab-VAT = itab-VAT * ( -1 ).
* itab-VATCST = itab-VATCST * ( -1 ).
* itab-VATCSTSUR = itab-VATCSTSUR * ( -1 ).
* itab-STAX = itab-STAX * ( -1 ).
* itab-ESTAX = itab-ESTAX * ( -1 ).
* itab-STEXC = itab-STEXC * ( -1 ).
* itab-ESTEXC = itab-ESTEXC * ( -1 ).
* itab-PRICE_E = itab-PRICE_E * ( -1 ).
* itab-PRICE_E_FC = itab-PRICE_E_FC * ( -1 ).
* itab-FREI_E = itab-FREI_E * ( -1 ).
* itab-FREI_E_FC = itab-FREI_E_FC * ( -1 ).
* itab-INS_E = itab-INS_E * ( -1 ).
* itab-INS_E_FC = itab-INS_E_FC * ( -1 ).
* itab-COMM_E = itab-COMM_E * ( -1 ).
*
*
* ENDIF.
*

select single exnum into itab-exnum from j_1iexchdr where rdoc = it_vbrp-vbeln.
* READ TABLE IT_BKPF WITH KEY AWKEY = IT_VBRP-VBELN.
*
* MOVE IT_BKPF-BELNR TO ITAB-BELNR.
* MOVE IT_BKPF-WAERS TO ITAB-WAERS.
* MOVE IT_BKPF-BUDAT TO ITAB-BUDAT.
* MOVE IT_BKPF-BLDAT TO ITAB-BLDAT.
* MOVE IT_BKPF-BLART TO ITAB-BLART.
*
* MOVE IT_BKPF-AWKEY TO IT_BSEG-VBELN.
* MODIFY IT_BSEG TRANSPORTING VBELN WHERE BELNR = ITAB-BELNR.
* IF IT_BKPF-STGRD NE SPACE.
* MOVE 'REVERSAL' TO ITAB-STATUS.
* ENDIF.
MOVE IT_VBRP-MATNR TO ITAB-MATNR.


MOVE IT_VBRP-WERKS TO ITAB-WERKS.
MOVE IT_VBRP-MEINS TO ITAB-MEINS.


MOVE IT_VBRP-SHKZG TO ITAB-SHKZG.
MOVE IT_VBRP-VBELN TO ITAB-VBELN.
MOVE IT_VBRP-POSNR TO ITAB-POSNR.
MOVE IT_VBRP-VRKME TO ITAB-VRKME.
* MOVE IT_VBRP-FKIMG TO ITAB-FKIMG.

MOVE IT_VBRP-BRTWR TO ITAB-BRTWR.
MOVE IT_VBRP-NETWR TO ITAB-NETWR.
MOVE IT_VBRP-ERDAT TO ITAB-ERDAT.
MOVE IT_VBRP-KURSK TO ITAB-KURSK.
MOVE IT_VBRP-KURSK_DAT TO ITAB-KURSK_DAT.
READ TABLE IT_BSEG WITH KEY VBELN = IT_VBRP-VBELN MATNR = IT_VBRP-MATNR.
MOVE IT_BSEG-MWSKZ TO ITAB-MWSKZ.



SELECT SINGLE TEXT1 INTO ITAB-TEXT1 FROM T007S WHERE MWSKZ = ITAB-MWSKZ and spras = 'EN' and kalsm = 'TAXINJ'.


LOOP AT IT_BSEG WHERE VBELN = IT_VBRP-VBELN.
IF IT_BSEG-KOART = 'D'.
CLEAR W_C_HKONT.
CLEAR W_sc_shkont.
MOVE IT_BSEG-HKONT TO W_C_HKONT.
SHIFT W_C_HKONT LEFT DELETING LEADING '0'.
MOVE W_C_HKONT TO ITAB-C_HKONT.
MOVE IT_BSEG-KUNNR TO ITAB-KUNNR.

* MOVE IT_BSEG-TOTPR TO ITAB-TOTPR.
SELECT SINGLE NAME1 INTO ITAB-NAME1 FROM KNA1 WHERE KUNNR = ITAB-KUNNR.
ENDIF.
MOVE IT_BSEG-HKONT TO W_sc_shkont.
shift itab-kunnr left deleting leading '0'.
SHIFT W_sc_shkont LEFT DELETING LEADING '0'.
IF W_SC_SHKONT(1) = '3'.
SELECT SINGLE TXT20 INTO ITAB-TXT20 FROM SKAT WHERE SAKNR = IT_BSEG-HKONT.
MOVE W_SC_SHKONT TO ITAB-SC_SHKONT.
* MOVE IT_BSEG-SGTXT TO ITAB-SGTXT.
ENDIF.
ENDLOOP.

SELECT SINGLE MAKTX INTO ITAB-MAKTX FROM MAKT WHERE MATNR = IT_VBRP-MATNR.
ITAB-C_MATNR = IT_VBRP-MATNR.
SHIFT ITAB-C_MATNR LEFT DELETING LEADING '0'.
if it_vbrp-VTWEG_AUFT NE '30'.
itab-w_t = 'DOM'.

loop at it_cond where COND_GROUP = '01'.
* READ TABLE TKOMV WITH KEY KSCHL = it_cond-cond_type.
* LOOP AT TKOMV WHERE KSCHL = it_cond-cond_type.
* ITAB-BASIC = ITAB-BASIC + TKOMV-KWERT.
* ENDLOOP.
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'B' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-BASIC = ITAB-BASIC + W_COM1.
ENDIF.
ENDLOOP.
ENDloop.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '04'. "DISCOUNT
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.

SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'A' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-DIS = ITAB-DIS + W_COM1.
ENDIF.
ENDLOOP.
ENDloop.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '02'. "DISCOUNT
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'A' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-EXCISE = ITAB-EXCISE + W_COM1.
ENDIF.
ENDLOOP.

ENDloop.
ITAB-EXACC = ITAB-BASIC - ITAB-DIS.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '03'. "DISCOUNT
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'A' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-ECESS = ITAB-ECESS + W_COM1.
ENDIF.
ENDLOOP.

ENDloop.
loop at it_cond where COND_GROUP = '05'. "
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-LST = ITAB-LST + W_COM1.
ENDIF.

ENDLOOP.
ENDloop.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '08'. "
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-CST = ITAB-CST + W_COM1.
ENDIF.
ENDLOOP.

ENDloop.
clear W_COM1.
loop at it_cond where COND_GROUP = '07'. "DISCOUNT
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.

SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-SLST = ITAB-SLST + W_COM1.
ENDIF.

ENDLOOP.
ENDloop.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '09'. "DISCOUNT
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-SCST = ITAB-SCST + W_COM1.
ENDIF.
ENDLOOP.
ENDloop.

CLEAR W_COM1.
loop at it_cond where COND_GROUP = '06'. "DISCOUNT
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-TURN = ITAB-TURN + W_COM1.
ENDIF.
endloop.
ENDLOOP.

CLEAR W_COM1.
loop at it_cond where COND_GROUP = '10'. "Commision
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'A' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-comm = ITAB-comm + W_COM1.
ENDIF.
endloop.
ENDLOOP.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '11'. " APMC FEE
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-APMCFEE = ITAB-APMCFEE + W_COM1.
ENDIF.
endloop.
ENDLOOP.

CLEAR W_COM1.
loop at it_cond where COND_GROUP = '12'. " VAT
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-VAT = ITAB-VAT + W_COM1.
ENDIF.
endloop.
ENDLOOP.

CLEAR W_COM1.
loop at it_cond where COND_GROUP = '13'. " VAT CST
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-VATCST = ITAB-VATCST + W_COM1.
ENDIF.
endloop.
ENDLOOP.

CLEAR W_COM1.
loop at it_cond where COND_GROUP = '14'. " VAT CST SUR
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-VATCSTSUR = ITAB-VATCSTSUR + W_COM1.
ENDIF.
endloop.
ENDLOOP.

CLEAR W_COM1.
loop at it_cond where COND_GROUP = '15'. " SERVICE TAX
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-STAX = ITAB-STAX + W_COM1.
ENDIF.
endloop.
ENDLOOP.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '16'. " ECESS SER TAX
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-ESTAX = ITAB-ESTAX + W_COM1.
ENDIF.
endloop.
ENDLOOP.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '17'. " STATE EXC
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-STEXC = ITAB-STEXC + W_COM1.
ENDIF.
endloop.
ENDLOOP.
CLEAR W_COM1.
loop at it_cond where COND_GROUP = '18'. " ECESS STATE EXC
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
SELECT SINGLE kwert INTO W_COM1 FROM KONV WHERE KNUMV = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR
AND KSTAT EQ SPACE AND KOAID = 'D' AND KSCHL = IT_COND-COND_TYPE AND KWERT GT 0.
IF SY-SUBRC = 0.
ITAB-ESTEXC = ITAB-ESTEXC + W_COM1.
ENDIF.
endloop.
ENDLOOP.

ENDIF.


if it_vbrp-VTWEG_AUFT = '30'." it_vbrp-VTWEG_AUFT = '40'. "deemed exports are exports within India .
itab-w_t = 'EXP'.
LOOP AT IT_VBRP1 WHERE VBELN = IT_VBRP-VBELN AND MATNR = IT_VBRP-MATNR AND FKIMG GT 0.
select single kwert into W_PRICE from konv where kschl = 'ZFOB' and knumv = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR AND KWERT GT 0.
itab-price_e = itab-price_e + W_PRICE.
* ENDSELECT.
select single kwert into W_FREI from konv where kschl = 'ZEFR' and knumv = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR AND KWERT GT 0.
itab-frei_e = itab-frei_e + W_FREI.
* ENDSELECT.
select single kwert into W_INS from konv where kschl = 'ZINS' and knumv = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR AND KWERT GT 0.
itab-ins_e = itab-ins_e + W_INS.
* ENDSELECT.
select single kwert into W_COMM from konv where kschl IN ('ZACM','ZACV') and knumv = ITAB-KNUMV AND KPOSN = IT_VBRP1-POSNR AND KWERT GT 0.
itab-comm_e = itab-comm_e + W_COMM.

* endselect.
ENDLOOP.
clear w_comm.
clear w_ins.
clear w_frei.
clear w_price.


ITAB-PRICE_E_FC = itab-price_e * ITAB-KURRF.
ITAB-INS_E_FC = itab-INS_E * ITAB-KURRF.
ITAB-FREI_E_FC = itab-FREI_E * ITAB-KURRF.
endif.
SHIFT ITAB-BELNR LEFT DELETING LEADING '0'.
SHIFT ITAB-VBELN LEFT DELETING LEADING '0'.

IF IT_VBRK-FKART EQ 'G2' OR IT_VBRK-FKART EQ 'ZG2' or ( IT_BKPF-STblg NE SPACE AND
( IT_VBRK-FKART EQ 'S1' OR IT_VBRK-FKART EQ 'S3' ) ).
itab-totpr = itab-totpr * ( -1 ).
itab-BASIC = ITab-BASIC * ( -1 ).
itab-DIS = itab-DIS * ( -1 ).
itab-EXACC = itab-EXACC * ( -1 ).
itab-EXCISE = itab-EXCISE * ( -1 ).
itab-ECESS = itab-ECESS * ( -1 ).
itab-LST = itab-LST * ( -1 ).
itab-CST = itab-CST * ( -1 ).
itab-SLST = itab-SLST * ( -1 ).
itab-SCST = itab-SCST * ( -1 ).
itab-TURN = itab-TURN * ( -1 ).
itab-COMM = itab-COMM * ( -1 ).
itab-APMCFEE = itab-APMCFEE * ( -1 ).
itab-VAT = itab-VAT * ( -1 ).
itab-VATCST = itab-VATCST * ( -1 ).
itab-VATCSTSUR = itab-VATCSTSUR * ( -1 ).
itab-STAX = itab-STAX * ( -1 ).
itab-ESTAX = itab-ESTAX * ( -1 ).
itab-STEXC = itab-STEXC * ( -1 ).
itab-ESTEXC = itab-ESTEXC * ( -1 ).
itab-PRICE_E = itab-PRICE_E * ( -1 ).
itab-PRICE_E_FC = itab-PRICE_E_FC * ( -1 ).
itab-FREI_E = itab-FREI_E * ( -1 ).
itab-FREI_E_FC = itab-FREI_E_FC * ( -1 ).
itab-INS_E = itab-INS_E * ( -1 ).
itab-INS_E_FC = itab-INS_E_FC * ( -1 ).
itab-COMM_E = itab-COMM_E * ( -1 ).


ENDIF.



APPEND ITAB.
CLEAR ITAB.
endloop.
ENDLOOP.

sort itab by vbeln matnr.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING VBELN MATNR.



*Processing extracted data for reporting
clear itab.
clear : tot_discount , pc_discount , gr_amt , net_amt .
clear : tot_discount_sum , gr_amt_sum .

*-----------------------------------------------------------------------
endform. "GET_DATA
*&---------------------------------------------------------------------*
*& Form COMMENT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM comment_build USING p_it_st_list_top_of_page TYPE slis_t_listheader. DATA: ls_line TYPE slis_listheader, mix_date(130) type c, mix(130) type c, head_label(130) type c value 'Sales Day Book'. REFRESH p_it_st_list_top_of_page. CLEAR ls_line. ls_line-typ = 'H'. ls_line-info = head_label. APPEND ls_line TO p_it_st_list_top_of_page. *----- Display Vendor concatenate 'Plant :' ' ' p_plant+3(4) into mix SEPARATED BY SPACE. ls_line-typ = 'S'. ls_line-info = mix. APPEND ls_line TO p_it_st_list_top_of_page. clear mix. concatenate 'Customer Group :' ' ' s_kdgrp-low ' ' s_kdgrp-high into mix SEPARATED BY SPACE. ls_line-typ = 'S'. ls_line-info = mix. APPEND ls_line TO p_it_st_list_top_of_page. * clear mix. * concatenate 'Document Type :' ' ' s_blart-low ' ' s_blart-high into mix SEPARATED BY SPACE. * ls_line-typ = 'S'. * ls_line-info = mix. * APPEND ls_line TO p_it_st_list_top_of_page. clear mix. concatenate 'Billing Type :' ' ' s_fkart-low ' ' s_fkart-high into mix SEPARATED BY SPACE. ls_line-typ = 'S'. ls_line-info = mix. APPEND ls_line TO p_it_st_list_top_of_page. clear mix. concatenate 'Material Group :' ' ' s_mvgr1-low ' ' s_mvgr1-high into mix SEPARATED BY SPACE. ls_line-typ = 'S'. ls_line-info = mix. APPEND ls_line TO p_it_st_list_top_of_page. clear mix. concatenate 'Material No :' ' ' s_matnr-low ' ' s_matnr-high into mix SEPARATED BY SPACE. ls_line-typ = 'S'. ls_line-info = mix. APPEND ls_line TO p_it_st_list_top_of_page. clear mix. if s_date-low ne SPACE and s_date-low gt 0. concatenate S_date-LOW+6(2) '-' S_date-LOW+4(2) '-' S_DATe-LOW(4) into w_date_f. concatenate S_DATe-high+6(2) '-' S_DATe-high+4(2) '-' S_DATe-high(4) into w_date_t. concatenate 'Doc Date :' ' ' w_date_f '-' w_date_t into mix SEPARATED BY SPACE. ls_line-typ = 'S'. ls_line-info = mix. APPEND ls_line TO p_it_st_list_top_of_page. endif. * concatenate 'Date :' ' ' s_date-low ' ' s_date-high into mix SEPARATED BY SPACE. * ls_line-typ = 'S'. * ls_line-info = mix. * APPEND ls_line TO p_it_st_list_top_of_page. * ENDFORM. " COMMENT_BUILD *&--------------------------------------------------------------------* *& Form TOP_OF_PAGE-ALV *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* FORM top_of_page-alv. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = it_st_list_top_of_page. ENDFORM. "TOP_OF_PAGE-ALV *&---------------------------------------------------------------------* *& Form FIELDCAT *&---------------------------------------------------------------------* * -->P_IT_ST_FIELDCAT[] text
*----------------------------------------------------------------------*
FORM fieldcat USING p_it_st_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.



*SALES DOCUMENTS
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'FKART'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-seltext_m = 'Billing Type' .
* ls_fieldcat-rollname = 'BELNR'.

APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VKORG'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-seltext_m = 'SALES ORG' .
* ls_fieldcat-rollname = 'BELNR'.

APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VBELN'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'Comm Inv' .
* ls_fieldcat-rollname = 'BELNR'.
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EXNUM'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'EXC Inv' .
* ls_fieldcat-rollname = 'BELNR'.
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.



CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BELNR'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'Acct Doc' .
* ls_fieldcat-rollname = 'BELNR'.
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'W_T'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'Sales Type' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'STATUS'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'Status' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BUDAT'.
ls_fieldcat-rollname = 'BUDAT'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 10.
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

*GL A/C FOR SALES
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
* ls_fieldcat-rollname = 'WERKS'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 4.
* ls_fieldcat-key = 'X'.
ls_fieldcat-seltext_m = 'PLANT' .

APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BLART'.
* ls_fieldcat-rollname = 'FKART'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-seltext_m = 'Acct Doc Type' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


*
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MWSKZ'.
* ls_fieldcat-rollname = 'MWSKZ'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-seltext_m = 'Tax Code' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'TEXT1'.
* ls_fieldcat-rollname = 'MWSKZ'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_m = 'Tax Desc' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.



CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'KUNNR'.
* ls_fieldcat-rollname = 'MAKTX'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Party Code' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'NAME1'.
* ls_fieldcat-rollname = 'MAKTX'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_m = 'Party Desc' .
* ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'C_HKONT'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'Party Sub-Ledger' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SC_SHKONT'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'Sales G/L' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'TXT20'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Sales Text' .

APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'C_MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'Material Code' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MAKTX'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 30.
ls_fieldcat-seltext_m = 'Material Desc' .

APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'FKIMG'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Quantity' .

APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VRKME'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'UNIT' .

APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'TOTPR'.
* ls_fieldcat-rollname = 'MATNR'.
** ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_m = 'BILL AMT' .
APPEND ls_fieldcat TO p_it_st_fieldcat.



CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BASIC'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Loc-Basic Price' .
APPEND ls_fieldcat TO p_it_st_fieldcat.
*
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'DIS'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Discount' .
APPEND ls_fieldcat TO p_it_st_fieldcat.
*
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EXACC'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_m = 'Ass Value' .
APPEND ls_fieldcat TO p_it_st_fieldcat.
*
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EXCISE'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Excise Duty' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ECESS'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'ECESS' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LST'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Loc Sales Tax' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'CST'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Cent Sales Tax' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SLST'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'LST Surcharge' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SCST'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'CST Surcharge' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'TURN'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'TurnoverTax' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'COMM'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Loc Comm.' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'APMCFEE'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'APMC Fee' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VAT'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'VAT' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VATCST'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'VAT CST' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VATCSTSUR'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'VAT CST Sur' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'STAX'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Service Tax'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ESTAX'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Ecess-Service Tax' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'STEXC'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'State Excise' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ESTEXC'.
* ls_fieldcat-rollname = 'MATNR'.
* ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 18.
ls_fieldcat-seltext_m = 'Ecess-State Excise' .
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'WAERK'.
ls_fieldcat-outputlen = 6.
ls_fieldcat-seltext_m = 'Exp-Currency' .
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'PRICE_E'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Exp-Basic Price(FOR)' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'PRICE_E_FC'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Exp-Basic Price(INR)' .
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'FREI_E'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Exp-Freight(FOR)' .
APPEND ls_fieldcat TO p_it_st_fieldcat.



CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'FREI_E_FC'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Exp-Freight(INR)' .
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'INS_E'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Exp-Insurance(FOR)' .
APPEND ls_fieldcat TO p_it_st_fieldcat.



CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'INS_E_FC'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Exp-Insurance(INR)' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'COMM_E'.
ls_fieldcat-outputlen = 16.
ls_fieldcat-seltext_m = 'Exp-Comm.' .
APPEND ls_fieldcat TO p_it_st_fieldcat.



ENDFORM. " FIELDCAT


*&---------------------------------------------------------------------*
*& Form LAYOUT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ST_LAYOUT text
*----------------------------------------------------------------------*
FORM layout_build USING p_st_layout TYPE slis_layout_alv.

p_st_layout-box_fieldname = 'SELK'. " Checkbox
p_st_layout-get_selinfos = 'X'.
p_st_layout-f2code = 'PICK' . " Doppelklickfunktion
p_st_layout-confirmation_prompt = 'X'. "Sicherheitsabfrage
p_st_layout-key_hotspot = 'X'. "Schlüssel als Hotspot
p_st_layout-info_fieldname = 'COL'. "Zeilenfarbe


ENDFORM. " LAYOUT_BUILD




*&---------------------------------------------------------------------*
*& Form REUSE_ALV_LIST_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM reuse_alv_list_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = S_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'ALV_BACKGROUND'
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = it_st_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS = IT_slis_t_specialcol_alv[]
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A'
* IS_VARIANT =
IT_EVENTS = IT_ST_EVENTS[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDFORM. " REUSE_ALV_LIST_DISPLAY



*&---------------------------------------------------------------------*
*& Form EVENTTAB_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_ST_EVENTS[] text
*----------------------------------------------------------------------*
FORM eventtab_build USING p_st_events TYPE slis_t_event .

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = p_st_events.

READ TABLE p_st_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE st_formname_top_of_page TO ls_event-form.
APPEND ls_event TO p_st_events.
ENDIF.



* READ TABLE p_st_events WITH KEY name = slis_ev_pf_status_set
* INTO ls_event.
*
* IF sy-subrc = 0.
* MOVE s_status TO ls_event-form.
* APPEND ls_event TO p_st_events.
* ENDIF.

ENDFORM. " EVENTTAB_BUILD



*&---------------------------------------------------------------------*
*& Form VARIANT_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM variant_init . CLEAR s_variant. s_variant-report = s_repid. s_variant-handle = code. ENDFORM. " VARIANT_INIT *&--------------------------------------------------------------------* *& Form INT_ALV *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* FORM INT_ALV. REFRESH it_st_list_top_of_page. CLEAR it_st_list_top_of_page. REFRESH it_st_fieldcat. CLEAR it_st_fieldcat. REFRESH IT_BKPF. CLEAR IT_BKPF. REFRESH IT_BSEG. CLEAR IT_BSEG. REFRESH IT_VBRK. CLEAR IT_VBRK. REFRESH IT_VBRP. CLEAR IT_VBRP. REFRESH IT_VBRP1. CLEAR IT_VBRP1. REFRESH ITAB. CLEAR ITAB. ENDFORM. "INT_ALV

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)