Go on link..

link us with ...

Thursday, December 30, 2010

REPORT ON DETAILS OF DOMESTIC PURCHASE

*&---------------------------------------------------------------------*
*& Report ZVVF_MR010_DOMPUR *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZVVF_MR010_DOMPUR .

*---------------------------------------------------------------------**
* MODULE MM.
**---------------------------------------------------------------------*
* Objective : REPORT ON DETAILS OF DOMESTIC PURCHASE

** Program : Updates Tables ( ) Downloads data ( ) **
* Outputs List ( ) **

* Technical Spec No

* Date Created
*** Author
* Developer
*** Location ***
* LDB .....
**---------------------------------------------------------------------*
* External Dependencies
**---------------------------------------------------------------------*
*
**---------------------------------------------------------------------*
* Amendment History
**---------------------------------------------------------------------*
* Who Change ID Reason
*** ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*---------------------------------------------------------------------**


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

TABLES: EKKO, "PURCHASING DOC. HEADER
EKPO, "PURCHASING DOC. ITEM
MAKT, "MATERIAL DISCRIPTION
LFA1, "VENDOR MASTER
RSEG, "DOC. ITEM - INCOMING INVOICE
KONV, "CONDITION (TRANSECTION DATA - CLUSTER TABLE)
EKPA. "Partner Roles in Purchasing

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

TYPE-POOLS slis.

TYPES: BEGIN OF TY_HEAD ,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
BUKRS LIKE EKKO-BUKRS,
AEDAT LIKE EKKO-AEDAT,
LIFNR LIKE EKKO-LIFNR,
EKORG LIKE EKKO-EKORG,
EKGRP LIKE EKKO-EKGRP,
KNUMV LIKE EKKO-KNUMV,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
WERKS LIKE EKPO-WERKS,
MATKL LIKE EKPO-MATKL,
LIFN2 LIKE EKPA-LIFN2, "FOR PARVW = 'BR'
PARVW LIKE EKPA-PARVW,
BNAME1 LIKE LFA1-NAME1,
NAME1 LIKE LFA1-Name1,
MAKTX LIKE MAKT-MAKTX,
BELNR LIKE RSEG-BELNR,
BUZEI LIKE RSEG-BUZEI,
MWSKZ LIKE RSEG-MWSKZ,
MENGE LIKE RSEG-MENGE,
WRBTR LIKE RSEG-WRBTR,
BSC_PR LIKE RSEG-WRBTR,
KSCHL LIKE RSEG-KSCHL,
KTOSL LIKE BSEG-KTOSL,
EXCISE LIKE BSEG-WRBTR,
ECESS LIKE BSEG-WRBTR,
LST LIKE BSEG-WRBTR,
VAT_RM LIKE BSEG-WRBTR,
VAT_CG LIKE BSEG-WRBTR,
SRV_TAX LIKE BSEG-WRBTR,
ECESS_SRV_TAX LIKE BSEG-WRBTR,
FREIGHT LIKE RSEG-WRBTR,
COMM_CRG LIKE RSEG-WRBTR,
HAND_CRG LIKE RSEG-WRBTR,
INSPC_CRG LIKE RSEG-WRBTR,
INSTL_CRG LIKE RSEG-WRBTR,
APMC_CRG LIKE RSEG-WRBTR,
INSUR LIKE RSEG-WRBTR,
OCTROI LIKE RSEG-WRBTR,
ZSUP LIKE RSEG-WRBTR,
ZPC1 LIKE RSEG-WRBTR,
ZFC1 LIKE RSEG-WRBTR,
ZEXP LIKE RSEG-WRBTR,
ZMIS LIKE RSEG-WRBTR,
LAND(10) TYPE C,
LANDPU(10) TYPE C,

END OF TY_HEAD.

**---------------------------------------------------------------------*
* Constants Begin with C_
**---------------------------------------------------------------------*

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



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

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

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: G_VARIANT LIKE DISVARIANT.
*-------- Declarations for Internal tables

DATA : IT_HEAD TYPE STANDARD TABLE OF TY_HEAD WITH HEADER LINE.

DATA : BEGIN OF IT_BSEG OCCURS 0.
INCLUDE STRUCTURE BSEG.
DATA: END OF IT_BSEG.

DATA : BEGIN OF IT_RSEG OCCURS 0.
INCLUDE STRUCTURE RSEG.
DATA: END OF IT_RSEG.

DATA : BEGIN OF IT_BKPF OCCURS 0.
INCLUDE STRUCTURE BKPF.
DATA: END OF IT_BKPF.


DATA : BEGIN OF IT_NAME1 OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF IT_NAME1.

DATA : BEGIN OF IT_EKPO OCCURS 0.
INCLUDE STRUCTURE EKPO.
DATA: END OF IT_EKPO.

DATA : BEGIN OF IT_LFA1 OCCURS 0.
INCLUDE STRUCTURE LFA1.
DATA: END OF IT_LFA1.


DATA : BEGIN OF IT_EKPA OCCURS 0.
INCLUDE STRUCTURE EKPA.
DATA: END OF IT_EKPA.


DATA: BEGIN OF IT_COUNT OCCURS 0,
RNUM LIKE BSEG-ZUONR,
END OF IT_COUNT.

DATA: BEGIN OF IT_TOTAL OCCURS 0,
WRBTR LIKE RSEG-WRBTR,
END OF IT_TOTAL.

DATA : WS_AWKEY LIKE BKPF-AWKEY.

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

ranges: r_loekz for ekPo-loekz. " Deletion Indicator


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

SELECTION-SCREEN BEGIN OF BLOCK MAIN WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP 2.
SELECT-OPTIONS : SO_LIFNR FOR EKKO-LIFNR.
SELECT-OPTIONS : SO_EKORG FOR EKKO-EKORG .
SELECT-OPTIONS : SO_WERKS FOR EKPO-WERKS .
SELECT-OPTIONS : SO_EBELN FOR EKKO-EBELN.
SELECT-OPTIONS : SO_AEDAT FOR EKKO-AEDAT .
SELECT-OPTIONS : SO_EKGRP FOR EKKO-EKGRP.
SELECT-OPTIONS : SO_BSART FOR EKKO-BSART DEFAULT 'NB'.
SELECT-OPTIONS : SO_MATKL FOR EKPO-MATKL.
SELECT-OPTIONS : SO_MATNR FOR EKPO-MATNR.
SELECTION-SCREEN SKIP 2.

selection-screen: skip,
begin of line,
comment (15) text-002.

parameters: p_all radiobutton group del.

selection-screen comment 25(9) for field p_all.

parameters: p_del radiobutton group del.

selection-screen comment 45(12) for field p_del.

parameters: p_undel radiobutton group del default 'X'.

selection-screen comment 65(14) for field p_undel.

selection-screen end of line.

SELECTION-SCREEN SKIP 2.

SELECTION-SCREEN END OF BLOCK MAIN.

**---------------------------------------------------------------------*
* AT SELECTION SCREEN
**---------------------------------------------------------------------*

AT SELECTION-SCREEN.

IF ( SO_BSART-LOW = 'ZI' ) OR ( SO_BSART-HIGH = 'ZI' ).

MESSAGE 'Document Type Not Allowed.' TYPE 'E'.

ENDIF.



**---------------------------------------------------------------------*
* 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 initialize.

PERFORM GET_DATA.

PERFORM comment_build USING it_st_list_top_of_page[].

PERFORM fieldcat USING it_st_fieldcat[].

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 initialize.


clear: r_loekz.
refresh: r_loekz.
*----ALL TYPE
if p_all = 'X'.
r_loekz-sign = 'I'.
r_loekz-option = 'EQ'.
r_loekz-low = ' '.
r_loekz-high = 'L'.
append r_loekz.

endif.
*--- Deleted PO's only
if p_del = 'X'.
r_loekz-sign = 'I'.
r_loekz-option = 'EQ'.
r_loekz-low = 'L'.
r_loekz-high = 'L'.
append r_loekz.
endif.
*--- UnDeleted PO's only
if p_undel = 'X'.
r_loekz-sign = 'E'.
r_loekz-option = 'EQ'.
r_loekz-low = ' '.
r_loekz-high = ' '.

append r_loekz.
endif.
endform. "initialize


*&--------------------------------------------------------------------*
*& Form GET_DATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM GET_DATA.


SELECT A~EBELN A~BUKRS A~BSART A~AEDAT A~LIFNR A~EKORG A~EKGRP A~KNUMV
B~EBELN B~EBELP B~BUKRS B~MATNR B~WERKS B~MATKL
C~LIFNR C~NAME1
D~MATNR D~MAKTX
*
INTO CORRESPONDING FIELDS OF TABLE IT_HEAD

FROM EKKO AS A INNER JOIN EKPO AS B
ON A~EBELN = B~EBELN
LEFT OUTER JOIN LFA1 AS C
ON A~LIFNR = C~LIFNR
LEFT OUTER JOIN MAKT AS D
ON B~MATNR = D~MATNR AND D~SPRAS = 'E'
LEFT OUTER JOIN RSEG AS E
ON A~EBELN = E~EBELN AND A~BUKRS = E~BUKRS
AND A~LIFNR = E~LIFNR
WHERE A~EBELN IN SO_EBELN
AND A~BSART IN SO_BSART
AND A~AEDAT IN SO_AEDAT
AND A~LIFNR IN SO_LIFNR
AND A~EKORG IN SO_EKORG
AND A~EKGRP IN SO_EKGRP
AND B~MATNR IN SO_MATNR
AND B~WERKS IN SO_WERKS
AND B~MATKL IN SO_MATKL
AND B~LOEKZ between R_LOEKZ-LOW and R_LOEKZ-high.


DELETE ADJACENT DUPLICATES FROM IT_HEAD COMPARING EBELN EBELP.


SELECT *
FROM RSEG
INTO CORRESPONDING FIELDS OF TABLE IT_RSEG
FOR ALL ENTRIES IN IT_HEAD
WHERE EBELN = IT_HEAD-EBELN
AND SHKZG = 'S'.
*AND BUKRS = IT_HEAD-BUKRS
*AND LIFNR = IT_HEAD-LIFNR.

* DELETE ADJACENT DUPLICATES FROM IT_RSEG COMPARING EBELN EBELP.

LOOP AT IT_RSEG.

CONCATENATE IT_RSEG-BELNR IT_RSEG-GJAHR INTO WS_AWKEY.

SELECT BUKRS BELNR GJAHR AWKEY FROM BKPF
INTO CORRESPONDING FIELDS OF IT_BKPF
FOR ALL ENTRIES IN IT_RSEG
WHERE BUKRS = IT_RSEG-BUKRS
AND AWKEY = WS_AWKEY.

APPEND IT_BKPF.


ENDSELECT.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM IT_BKPF COMPARING BELNR GJAHR.

SELECT * FROM BSEG
INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
FOR ALL ENTRIES IN IT_BKPF
WHERE BELNR = IT_BKPF-BELNR
AND GJAHR = IT_BKPF-GJAHR.


*SELECT * FROM BKPF INTO INTO TABLE IT_BKPF
*FOR ALL ENTRIES IN IT_BKPF
*WHERE


* LOOP AT IT_RSEG.
*
* concatenate IT_RSEG-EBELN IT_RSEG-EBELP into IT_COUNT-RNUM.
* APPEND IT_COUNT.
* CLEAR IT_COUNT-RNUM.
*
* ENDLOOP.
*
*
*SELECT ZUONR BELNR EBELN EBELP BUKRS WERKS MATNR WRBTR KTOSL
*FROM BSEG
*INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
*FOR ALL ENTRIES IN IT_COUNT
*WHERE ZUONR = IT_COUNT-RNUM
*AND SHKZG = 'S'.
*


*EBELN = IT_RSEG-EBELN
*AND EBELP = IT_RSEG-EBELP.
*AND BUKRS = IT_HEAD-BUKRS
*AND WERKS = IT_HEAD-WERKS
*AND MATNR = IT_HEAD-MATNR.
*

SELECT EBELN LIFN2 FROM EKPA
INTO CORRESPONDING FIELDS OF TABLE IT_EKPA
FOR ALL ENTRIES IN IT_HEAD
WHERE EBELN = IT_HEAD-EBELN
AND PARVW = 'BR'.

SELECT LIFNR NAME1 FROM LFA1
INTO CORRESPONDING FIELDS OF TABLE IT_LFA1
FOR ALL ENTRIES IN IT_EKPA
WHERE LIFNR = IT_EKPA-LIFN2.


LOOP AT IT_HEAD.

LOOP AT IT_EKPA WHERE EBELN = IT_HEAD-EBELN.
MOVE IT_EKPA-LIFN2 TO IT_HEAD-LIFN2.

MODIFY IT_HEAD TRANSPORTING LIFN2 BNAME1.
CLEAR IT_EKPA-LIFN2.

ENDLOOP.


LOOP AT IT_LFA1 WHERE LIFNR = IT_HEAD-LIFN2.
MOVE IT_LFA1-NAME1 TO IT_HEAD-BNAME1.

MODIFY IT_HEAD TRANSPORTING BNAME1.
CLEAR IT_LFA1-NAME1.

ENDLOOP.



LOOP AT IT_RSEG WHERE EBELN = IT_HEAD-EBELN AND EBELP = IT_HEAD-EBELP.

MOVE IT_RSEG-MENGE TO IT_HEAD-MENGE.
MOVE IT_RSEG-MWSKZ TO IT_HEAD-MWSKZ.
MODIFY IT_HEAD TRANSPORTING MENGE MWSKZ.
CLEAR IT_RSEG-MENGE.
CLEAR IT_RSEG-MWSKZ.



* IF IT_RSEG-BUSTW = 'RE01'.
*
* IT_HEAD-BSC_PR = IT_RSEG-WRBTR.
*
*
* MODIFY IT_HEAD TRANSPORTING BSC_PR.
* CLEAR IT_RSEG-WRBTR.
* ENDIF.

IF ( IT_RSEG-KSCHL = 'ZFA1' ) OR
( IT_RSEG-KSCHL = 'ZFB1' ) OR
( IT_RSEG-KSCHL = 'ZFC1' ).

IT_HEAD-FREIGHT = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING FREIGHT.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZCOM' ).

IT_HEAD-COMM_CRG = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING COMM_CRG.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZHAN' ).

IT_HEAD-HAND_CRG = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING HAND_CRG.
CLEAR IT_RSEG-WRBTR.

ENDIF.

IF ( IT_RSEG-KSCHL = 'ZICH' ).

IT_HEAD-INSPC_CRG = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING INSPC_CRG.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZIST' ).

IT_HEAD-INSTL_CRG = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING INSTL_CRG.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZAPM' ).

IT_HEAD-APMC_CRG = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING APMC_CRG.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZINS' ).

IT_HEAD-INSUR = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.
MODIFY IT_HEAD TRANSPORTING INSUR.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZSUP' ).

IT_HEAD-ZSUP = IT_RSEG-WRBTR.

MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING ZSUP.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZMIS' ).

IT_HEAD-ZMIS = IT_RSEG-WRBTR.

MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING ZMIS.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZPC1' ) OR ( IT_RSEG-KSCHL = 'ZPC2' ).

IT_HEAD-ZPC1 = IT_RSEG-WRBTR.

MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING ZPC1.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZFC1' ) OR ( IT_RSEG-KSCHL = 'ZFC2' ).

IT_HEAD-ZFC1 = IT_RSEG-WRBTR.

MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING ZFC1.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZEXP' ).

IT_HEAD-ZEXP = IT_RSEG-WRBTR.

MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING ZEXP.
CLEAR IT_RSEG-WRBTR.


ENDIF.

IF ( IT_RSEG-KSCHL = 'ZOCT' ).

IT_HEAD-OCTROI = IT_RSEG-WRBTR.
MOVE IT_RSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING OCTROI.
CLEAR IT_RSEG-WRBTR.


ENDIF.

LOOP AT IT_BSEG.

DATA: ONE LIKE BSEG-EBELN.
DATA: TWO LIKE BSEG-EBELP.

ONE = IT_BSEG-ZUONR+0(10).
TWO = IT_BSEG-ZUONR+10(5).

*SPLIT IT_BSEG-ZUONR AT DELIMITER INTO ONE TWO.

IF ONE = IT_RSEG-EBELN AND TWO = IT_RSEG-EBELP.

IF IT_BSEG-KTOSL = 'WRX'.

IT_HEAD-BSC_PR = IT_BSEG-WRBTR.


MODIFY IT_HEAD TRANSPORTING BSC_PR WHERE EBELN = ONE.
CLEAR IT_BSEG-WRBTR.
CLEAR IT_HEAD-BSC_PR.
ENDIF.


IF ( IT_BSEG-KTOSL = 'JI1' ).

MOVE IT_BSEG-WRBTR TO IT_HEAD-EXCISE.
* IT_HEAD-EXCISE = IT_BSEG-WRBTR.
MOVE IT_BSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

IF ONE = IT_RSEG-EBELN.
MODIFY IT_HEAD TRANSPORTING EXCISE.
CLEAR IT_BSEG-WRBTR.
CLEAR IT_HEAD-EXCISE.
ENDIF.

ENDIF.

IF ( IT_BSEG-KTOSL = 'VS8' ).

MOVE IT_BSEG-WRBTR TO IT_HEAD-ECESS.

* IT_HEAD-ECESS = IT_BSEG-WRBTR.
MOVE IT_BSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING ECESS.
CLEAR IT_BSEG-WRBTR.

ENDIF.

IF ( IT_BSEG-KTOSL = 'VS5' ).

MOVE IT_BSEG-WRBTR TO IT_HEAD-LST.

* IT_HEAD-LST = IT_BSEG-WRBTR.
MOVE IT_BSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING LST.
CLEAR IT_BSEG-WRBTR.
ENDIF.

IF ( IT_BSEG-KTOSL = 'JP5' ).

MOVE IT_BSEG-WRBTR TO IT_HEAD-VAT_RM.

* IT_HEAD-VAT_RM = IT_BSEG-WRBTR.
MOVE IT_BSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING VAT_RM.
CLEAR IT_BSEG-WRBTR.
ENDIF.

IF ( IT_BSEG-KTOSL = 'JP7' ).

MOVE IT_BSEG-WRBTR TO IT_HEAD-VAT_CG.

* IT_HEAD-VAT_CG = IT_BSEG-WRBTR.
MOVE IT_BSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING VAT_CG.
CLEAR IT_BSEG-WRBTR.
ENDIF.

IF ( IT_BSEG-KTOSL = 'ZS1' ).

MOVE IT_BSEG-WRBTR TO IT_HEAD-SRV_TAX.

* IT_HEAD-SRV_TAX = IT_BSEG-WRBTR.
MOVE IT_BSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING SRV_TAX.
CLEAR IT_BSEG-WRBTR.
ENDIF.

IF ( IT_BSEG-KTOSL = 'ZS2' ).

MOVE IT_BSEG-WRBTR TO IT_HEAD-ECESS_SRV_TAX.

* IT_HEAD-ECESS_SRV_TAX = IT_BSEG-WRBTR.
MOVE IT_BSEG-WRBTR TO IT_TOTAL-WRBTR.
APPEND IT_TOTAL.

MODIFY IT_HEAD TRANSPORTING ECESS_SRV_TAX.

CLEAR IT_BSEG-WRBTR.
ENDIF.
ENDIF.

ENDLOOP. "END OF IT_BSEG


ENDLOOP.




ENDLOOP.

DELETE ADJACENT DUPLICATES FROM IT_HEAD COMPARING EBELN EBELP.

ENDFORM.



*&---------------------------------------------------------------------*
*& 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,
mix_ekorg(40) type c,
mixekorg(40) type c,
mix_werks(40) type c,
mixwerks(40) type c,
mix_ebeln(40) type c,
mixebeln(40) type c,
mix_aedat(40) type c,
mixaedat(40) type c,
mix_ekgrp(40) type c,
mixekgrp(40) type c,
mixbsart(40) type c,
mix_bsart(40) type c,
mixmatkl(40) type c,
mix_matkl(40) type c,
mixmatnr(40) type c,
mix_matnr(40) type c,
temp(40) type c.
data : w_date_t(10) type c,
w_date_f(10) type c,
w_tdate(100) type c.

REFRESH p_it_st_list_top_of_page.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = 'Details of Domestic Purchases'.
APPEND ls_line TO p_it_st_list_top_of_page.

*----- Display Vendor
concatenate so_lifnr-low ' - ' so_lifnr-high into mix_date
SEPARATED BY SPACE.

concatenate 'Vendor :' ' ' mix_date into mix SEPARATED BY SPACE.

ls_line-typ = 'S'.
ls_line-info = mix.
APPEND ls_line TO p_it_st_list_top_of_page.

*----- Display Pur. Org.
concatenate so_ekorg-low ' - ' so_ekorg-high into mix_ekorg
SEPARATED BY SPACE.

concatenate 'Pur. Org. :' ' ' mix_ekorg into mixekorg SEPARATED BY
SPACE
.

ls_line-typ = 'S'.
ls_line-info = mixekorg.
APPEND ls_line TO p_it_st_list_top_of_page.


*----- Display Plant
concatenate so_werks-low ' - ' so_werks-high into mix_werks
SEPARATED BY SPACE.

concatenate 'Plant :' ' ' mix_werks into mixwerks SEPARATED BY SPACE
.

ls_line-typ = 'S'.
ls_line-info = mixwerks.
APPEND ls_line TO p_it_st_list_top_of_page.



*----- Display Document No.
concatenate so_ebeln-low ' - ' so_ebeln-high into mix_ebeln
SEPARATED BY SPACE.

concatenate 'PO No. :' ' ' mix_ebeln into mixebeln SEPARATED BY
SPACE
.

ls_line-typ = 'S'.
ls_line-info = mixebeln.
APPEND ls_line TO p_it_st_list_top_of_page.


if so_aedat-low ne SPACE and so_aedat-low gt 0.
concatenate SO_AEDAT-LOW+6(2) '-' SO_AEDAT-LOW+4(2) '-'
SO_AEDAT-LOW(4) into w_date_f.
concatenate SO_AEDAT-high+6(2) '-' SO_AEDAT-high+4(2) '-'
SO_AEDAT-high(4) into w_date_t.

concatenate 'PO Date :' ' ' w_date_f '-' w_date_t into
w_tdate
SEPARATED BY SPACE.
ls_line-typ = 'S'.
ls_line-info = w_tdate.
APPEND ls_line TO p_it_st_list_top_of_page.
endif.

clear mix_date.
clear mix.


*----- Display Purchasing Group
concatenate so_ekgrp-low ' - ' so_ekgrp-high into mix_ekgrp
SEPARATED BY SPACE.

concatenate 'Purchasing Group :' ' ' mix_ekgrp into mixekgrp
SEPARATED BY SPACE.

ls_line-typ = 'S'.
ls_line-info = mixekgrp.
APPEND ls_line TO p_it_st_list_top_of_page.



*----- Display Document Type
concatenate so_bsart-low ' - ' so_bsart-high into mix_bsart
SEPARATED BY SPACE.

concatenate 'Document Type :' ' ' mix_bsart into mixbsart
SEPARATED BY SPACE.

ls_line-typ = 'S'.
ls_line-info = mixbsart.
APPEND ls_line TO p_it_st_list_top_of_page.


*----- Display Material Group
concatenate so_matkl-low ' - ' so_matkl-high into mix_matkl
SEPARATED BY SPACE.

concatenate 'Material Group :' ' ' mix_matkl into mixmatkl
SEPARATED BY SPACE.

ls_line-typ = 'S'.
ls_line-info = mixmatkl.
APPEND ls_line TO p_it_st_list_top_of_page.


*----- Display Material
concatenate so_matnr-low ' - ' so_matnr-high into mix_matnr
SEPARATED BY SPACE.

concatenate 'Material :' ' ' mix_matkl into mixmatnr
SEPARATED BY SPACE.

ls_line-typ = 'S'.
ls_line-info = mixmatnr.
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.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BSART'.
ls_fieldcat-datatype = 'CHAR'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-seltext_m = text-002 .
* ls_fieldcat-rollname = 'BSART'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EBELN'.
* ls_fieldcat-rollname = 'EBELN'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 10.
ls_fieldcat-seltext_m = 'PO Number'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'AEDAT'.
* ls_fieldcat-rollname = 'AEDAT'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 8.
ls_fieldcat-seltext_m = 'PO Date'.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EKGRP'.
* ls_fieldcat-rollname = 'EKGRP'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 3.
ls_fieldcat-seltext_m = 'PGrp'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EBELP'.
ls_fieldcat-rollname = 'EBELP'.
ls_fieldcat-ddictxt = 'L'.
* ls_fieldcat-outputlen = 3.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-rollname = 'LIFNR'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 10.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'NAME1'.
* ls_fieldcat-rollname = 'NAME1'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-seltext_m = 'Vendor Name'.
ls_fieldcat-outputlen = 35.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LIFN2'.
* ls_fieldcat-rollname = 'LIFN2'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-seltext_m = 'Broker'.
ls_fieldcat-outputlen = 10.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BNAME1'.
ls_fieldcat-rollname = 'BNAME1'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-seltext_m = 'Broker''s Name' .
ls_fieldcat-outputlen = 35.
APPEND ls_fieldcat TO p_it_st_fieldcat.


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


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MAKTX'.
ls_fieldcat-rollname = 'MAKTX'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 40.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MENGE'.
* ls_fieldcat-rollname = 'KWERT'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 13.
ls_fieldcat-seltext_l = 'Quantity' .
APPEND ls_fieldcat TO p_it_st_fieldcat.



CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'BSC_PR'.
* ls_fieldcat-rollname = 'IKBETR'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_m = 'Basic Price'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MWSKZ'.
* ls_fieldcat-rollname = 'FKBETR'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-seltext_m = 'Taxcode' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'EXCISE'.
* ls_fieldcat-rollname = 'AKBETR'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Excise Duty' .
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ECESS'.
ls_fieldcat-rollname = 'ECESS'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_L = 'Ecess on Excise' .
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LST'.
ls_fieldcat-rollname = 'LST'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_L = 'LST Setoff'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VAT_RM'.
ls_fieldcat-rollname = 'VAT_RM'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_L = 'VAT RM Setoff'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'VAT_CG'.
ls_fieldcat-rollname = 'VAT_CG'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_m = 'VAT CG Setoff'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SRV_TAX'.
ls_fieldcat-rollname = 'SRV_TAX'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_m = 'Service Tax'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ECESS_SRV_TAX'.
ls_fieldcat-rollname = 'ECESS_SRV_TAX'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Ecess on Service Tax'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'FREIGHT'.
ls_fieldcat-rollname = 'FREIGHT'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Freight'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'COMM_CRG'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Commission Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'HAND_CRG'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Handling Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'INSPC_CRG'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Inspection Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'INSTL_CRG'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Installation Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'APMC_CRG'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'APMC Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'INSUR'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Insurance'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZSUP'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Supervision Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZMIS'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Misscellaneous Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZPC1'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Packing Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZFC1'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Forwarding Charges'.
APPEND ls_fieldcat TO p_it_st_fieldcat.

CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'ZEXP'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Export Fees'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'OCTROI'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Octroi'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LAND'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Landed Value'.
APPEND ls_fieldcat TO p_it_st_fieldcat.


CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LANDPU'.
ls_fieldcat-ddictxt = 'L'.
ls_fieldcat-outputlen = 20.
ls_fieldcat-seltext_l = 'Landed Value Per Unit'.
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
p_st_layout-zebra = 'X'.
p_st_layout-colwidth_optimize = 'X'.
p_st_layout-no_totalline = 'X'.



ENDFORM. " LAYOUT_BUILD




*&---------------------------------------------------------------------*
*& Form REUSE_ALV_LIST_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM reuse_alv_list_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_background_id = 'ALV_BACKGROUND'
i_callback_program = s_repid
* I_CALLBACK_PF_STATUS_SET = S_STATUS
* I_CALLBACK_USER_COMMAND = S_USER_COMMAND
I_CALLBACK_TOP_OF_PAGE = st_formname_top_of_page
* I_STRUCTURE_NAME = ''
* IS_LAYOUT = ST_LAYOUT
it_fieldcat = it_st_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS = ST_SP_GROUP
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = G_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
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_HEAD
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_user_command
* INTO ls_event.
* IF sy-subrc = 0.
* MOVE s_user_command 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

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)