Report Using Simple FM 'Reuse ALV Grid' and conversion also
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
**********************************************************************
**********************************************************************
REPORT zrsd_exp_register_src.
**********************************************************************
* TYPE POOLS *
**********************************************************************
TYPE-POOLS : slis.
**********************************************************************
**********************************************************************
* TABLES *
**********************************************************************
TABLES : ekko, vttk, vbak, lips, eket , rbkp , mara , lfa1,vbap. " declare tables
**********************************************************************
**********************************************************************\
" Declare types and date ...
TYPES: BEGIN OF ty_ekkn,
ebeln TYPE ekkn-ebeln,
ebelp TYPE ekkn-ebelp,
vbeln TYPE ekkn-vbeln,
vbelp TYPE ekkn-vbelp,
END OF ty_ekkn.
TYPES: BEGIN OF ty_vbkd,
vbeln TYPE vbkd-vbeln,
posnr TYPE vbkd-posnr,
bstkd TYPE vbkd-bstkd,
END OF ty_vbkd.
types: slis_tabname(30) type c,
slis_fieldname(30) type c,
slis_sel_tab_field(60) type c,
slis_formname(30) type c,
slis_entry(60) type c,
slis_edit_mask(60) type c,
slis_coldesc(4) type c.
" Data ******************************************
DATA : it_vbpa TYPE TABLE OF ty_vbpa,
wa_vbpa TYPE ty_vbpa,
***********************************************************************
* Select Options Begin with S_ *
* Parameters Begin with P_ *
***********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS p_plant TYPE lips-werks OBLIGATORY.
****** start code by danish on 02/07/09 *****
SELECT-OPTIONS : so_ebeln FOR ekko-ebeln,
so_matnr FOR mara-matnr.
***** end code by danish on 02/07/09 ******
*=====> Start Code added by Hansraj on 21.11.08
SELECT-OPTIONS : s_vkgrp FOR vbak-vkgrp , "For Sales Group
s_kunnr FOR vbak-kunnr . "For Customer
*<===== End Code added by Hansraj on 21.11.08
*PARAMETERS p_ord TYPE ekpo-ebeln.
SELECT-OPTIONS s_date FOR rbkp-budat.
*PARAMETERS p_mtart TYPE mara-mtart OBLIGATORY. " line commented by prashant 16.9.2009
SELECT-OPTIONS : p_mtart FOR mara-mtart OBLIGATORY. " line added by prashant 16.9.2009
* Country Key :: danish - 16/11/09
SELECT-OPTIONS : so_land1 FOR lfa1-land1,
* Purchase Group
so_ekgrp FOR ekko-ekgrp.
*PARAMETERS : srepa RADIOBUTTON GROUP rgrp. "commented by danish on 08/07/09 " code added by prashant 24.11.2008
* srepp RADIOBUTTON GROUP rgrp. " commented by danish on 08/07/2009
* season added by danish - 04/06/2010
SELECT-OPTIONS : so_mvgr5 FOR vbap-mvgr5.
* end code danish - 04/06/2010
SELECTION-SCREEN END OF BLOCK b1 .
***********************************************************************
START-OF-SELECTION.
***********************************************************************
***********************************************************************
PERFORM data_retrival. " For DATA Retrival
PERFORM field_cat. " For Creation of feild catalog.
PERFORM build_layout.
PERFORM make_finaltab. " To make final Internal Table for Display
PERFORM display_report." To Display the final table in report.
*&---------------------------------------------------------------------*
*& Form FEILD_CAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM field_cat.
CLEAR: it_fcat[],
col_pos.
wa_sort-fieldname = 'EKNAM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'EKGRP'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'KNAME1'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'MATNR'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'SONUM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'SOITM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'PONUM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'POITM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
***************************************************************************************
*~~ FIELDNAME COL HEADING
***************************************************************************************
PERFORM fld_cat USING 'EKGRP' 'Purchase Grp.' .
PERFORM fld_cat USING 'EKNAM' 'Purchase Grp. Name'.
PERFORM fld_cat USING 'KNAME1' 'Customer Name' .
PERFORM fld_cat USING 'MATNR' 'Style Number' .
PERFORM fld_cat USING 'MAKTX' 'Style Description' .
PERFORM fld_cat USING 'SONUM' 'SO Number' .
ENDFORM. " FIELD_CAT
*&---------------------------------------------------------------------*
*& Form fld_cat
*&---------------------------------------------------------------------*
* DESCRIPTION:
* SubRoutine to create a line in the Field Catalog
*----------------------------------------------------------------------*
* -->FIELDNAME text
* -->COLTEXT text
* -->EDIT text
* -->KEY text
* -->NO_OUT text
*----------------------------------------------------------------------*
FORM fld_cat USING fieldname TYPE slis_fieldname
coltext TYPE dd03p-scrtext_l.
CLEAR: wa_fcat.
col_pos = col_pos + 1.
wa_fcat-fieldname = fieldname. "Field Name of the Internal Table
wa_fcat-seltext_m = coltext. "Column Heading
wa_fcat-col_pos = col_pos. "Column Positioning
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-lowercase = 'X'.
wa_fcat-no_zero = 'X'.
IF fieldname EQ 'POITM' OR fieldname EQ 'SOITM'.
wa_fcat-outputlen = 8.
ELSE.
wa_fcat-outputlen = 15.
ENDIF.
IF fieldname EQ 'MENGE_D' OR fieldname EQ 'FKIMG' OR fieldname EQ 'SOQTY' OR fieldname EQ 'MENGE' OR fieldname EQ 'NETPR'
OR fieldname EQ 'NETWR' OR fieldname EQ 'WRBTR' OR fieldname EQ 'NETPR_P' OR fieldname EQ 'MENGE1' OR fieldname EQ 'KWERT'
OR fieldname EQ 'USDVAL' OR fieldname EQ 'LFIMG_S' OR fieldname EQ 'KBETR'.
wa_fcat-no_zero = 'X'.
ENDIF.
IF fieldname EQ 'SOQTY' OR fieldname EQ 'FKIMG' OR fieldname EQ 'MENGE_D' OR fieldname EQ 'MENGE' OR fieldname EQ 'MENGE1'.
wa_fcat-decimals_out = 0.
ENDIF.
IF fieldname EQ 'USDVAL'.
wa_fcat-decimals_out = 2.
ENDIF.
APPEND wa_fcat TO it_fcat.
ENDFORM. "fld_cat
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
gd_layout-zebra = 'X'.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
*=====>Start Code added By hansraj on 21.11.08
gd_slis_print_alv-no_coverpage = 'X'.
gd_slis_print_alv-no_print_listinfos = 'X'.
*<=====End Code added By hansraj on 21.11.08
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIVAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM data_retrival .
***** for plant
AUTHORITY-CHECK OBJECT 'ZREPORTS'
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD p_plant.
IF sy-subrc <> 0.
MESSAGE s001(00) WITH 'No Authorisation for selected Plant' DISPLAY LIKE 'E'.
LEAVE TO CURRENT TRANSACTION.
ENDIF.
***** for purchase group
SELECT vkgrp
FROM tvbvk
INTO TABLE it_tvbvk
WHERE
vkbur = p_plant AND
vkgrp IN s_vkgrp.
LOOP AT it_tvbvk INTO wa_tvbvk .
AUTHORITY-CHECK OBJECT 'ZREPORTS'
ID 'ACTVT' FIELD '03'
ID 'VKGRP' FIELD wa_tvbvk-vkgrp.
IF sy-subrc <> 0.
MESSAGE s001(00) WITH 'No Authorisation for selected Sales Group -' wa_tvbvk-vkgrp DISPLAY LIKE 'E'.
LEAVE TO CURRENT TRANSACTION.
ENDIF.
ENDLOOP.
* break hopflabap1.
SELECT belnr xblnr bldat budat waers stblg gjahr lifnr cpudt
FROM rbkp
INTO TABLE it_rbkp
WHERE bukrs = p_plant
AND budat IN s_date
AND stblg = ''.
SELECT belnr xblnr bldat budat waers stblg gjahr lifnr cpudt
FROM rbkp
INTO TABLE it_rbkp
WHERE bukrs = p_plant
AND budat IN s_date
AND stblg = ''.
IF sy-subrc EQ 0.
SORT it_rbkp[] BY belnr gjahr.
SELECT lifnr name1 land1
FROM lfa1
INTO TABLE it_lfa1_d.
SELECT ebeln ebelp belnr gjahr wrbtr menge lifnr j_3asize kschl
FROM rseg
INTO TABLE it_rseg
FOR ALL ENTRIES IN it_rbkp
WHERE belnr = it_rbkp-belnr
AND gjahr = it_rbkp-gjahr
AND ebeln IN so_ebeln
AND werks = p_plant.
ENDIF.
SELECT bukrs belnr gjahr awkey blart budat
FROM bkpf
INTO TABLE it_bkpf
WHERE bukrs = p_plant
AND blart IN ('RE','RV').
it_bkpfi[] = it_bkpf[].
it_bkpfm[] = it_bkpf[].
DELETE it_bkpfi[] WHERE blart EQ 'RE'.
DELETE it_bkpfm[] WHERE blart EQ 'RV'.
break hopflabap1.
LOOP AT it_rseg INTO wa_rseg.
CLEAR : sawkey.
CONCATENATE wa_rseg-belnr wa_rseg-gjahr INTO sawkey.
CLEAR wa_bkpfm.
READ TABLE it_bkpfm INTO wa_bkpfm WITH KEY awkey = sawkey.
IF sy-subrc NE 0.
DELETE it_rseg[].
ENDIF.
ENDLOOP.
it_rsegm[] = it_rseg[].
SORT it_rsegm BY ebeln ebelp belnr gjahr.
DELETE ADJACENT DUPLICATES FROM it_rsegm COMPARING ebeln ebelp belnr gjahr.
it_rsegd[] = it_rsegm[].
IF it_rseg[] IS NOT INITIAL.
SORT it_rseg[] BY ebeln ebelp.
SELECT ebeln ebelp aedat netpr matnr menge mtart loekz
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_rseg
WHERE ebeln = it_rseg-ebeln
AND ebelp = it_rseg-ebelp
AND mtart IN p_mtart .
ENDIF.
IF it_ekpo[] IS NOT INITIAL.
SELECT matnr mtart
FROM mara
INTO TABLE it_mara
FOR ALL ENTRIES IN it_ekpo
WHERE matnr = it_ekpo-matnr.
SELECT ebeln ekgrp lifnr knumv waers lifre
FROM ekko
INTO TABLE it_ekko
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln
AND ekgrp IN so_ekgrp . " added by danish - 16/11/09
IF sy-subrc IS INITIAL.
SELECT ekgrp eknam
FROM t024
INTO TABLE it_t024
FOR ALL ENTRIES IN it_ekko
WHERE ekgrp = it_ekko-ekgrp.
SELECT lifnr name1 land1
FROM lfa1
INTO TABLE it_lfa1.
* FOR ALL ENTRIES IN it_ekko " commented by danish - 05/06/2010
* WHERE lifnr = it_ekko-lifnr
* AND land1 IN so_land1 .
ENDIF.
IF it_ekpo IS NOT INITIAL.
SELECT lcno ebeln ebelp
FROM zmmlc
INTO TABLE it_zmmlc
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln.
ENDIF.
SORT it_ekpo[] BY ebeln ebelp.
* SELECT lcno ebeln ebelp
* FROM zmmlcdtl
* INTO TABLE it_zmmlc
* FOR ALL ENTRIES IN it_ekpo
* WHERE bukrs = p_plant
* AND ebeln = it_ekpo-ebeln
* AND ebelp = it_ekpo-ebelp.
SELECT matnr maktx
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_ekpo
WHERE matnr = it_ekpo-matnr.
SELECT ebeln ebelp vbeln vbelp
FROM ekkn
INTO TABLE it_ekkn
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln
AND ebelp = it_ekpo-ebelp
AND sakto = '0050000000'.
ENDIF.
IF it_ekkn[] IS NOT INITIAL.
SORT it_ekkn[] BY vbeln vbelp.
it_ekknd[] = it_ekkn[]. " added by danish - 15/06/2010
SELECT vbeln posnr bstkd
FROM vbkd
INTO TABLE it_vbkd
FOR ALL ENTRIES IN it_ekkn
WHERE vbeln = it_ekkn-vbeln
AND posnr = it_ekkn-vbelp.
SELECT vbeln posnr kwmeng netpr ps_psp_pnr mvgr5 matnr prctr" mvgr5 added by danish - 04/06/2010
FROM vbap
INTO TABLE it_vbap
FOR ALL ENTRIES IN it_ekkn
WHERE vbeln = it_ekkn-vbeln
AND posnr = it_ekkn-vbelp.
IF it_vbap IS NOT INITIAL.
SELECT prctr ltext
FROM cepct
INTO CORRESPONDING FIELDS OF TABLE it_cepct
FOR ALL ENTRIES IN it_vbap
WHERE prctr EQ it_vbap-prctr
AND spras EQ sy-langu.
ENDIF.
IF it_vbap[] IS NOT INITIAL.
SELECT mvgr5 bezei
FROM tvm5t
INTO TABLE it_tvm5t
FOR ALL ENTRIES IN it_vbap
WHERE mvgr5 = it_vbap-mvgr5
AND spras = sy-langu.
* end code by danish - 04/06/2010
SORT it_vbap[] BY vbeln.
SELECT vbeln kunnr vkgrp auart spart vgbel knumv
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak
FOR ALL ENTRIES IN it_vbap
WHERE vbeln = it_vbap-vbeln
AND vkgrp IN s_vkgrp
AND kunnr IN s_kunnr.
IF it_ekkn IS NOT INITIAL.
SELECT lips~vbeln posnr vgbel vgpos kcmeng likp~lfdat vsart " posnr vgbel vgpos
FROM lips INNER JOIN likp
ON lips~vbeln = likp~vbeln
INTO CORRESPONDING FIELDS OF TABLE it_lips
FOR ALL ENTRIES IN it_ekkn
WHERE vgbel = it_ekkn-ebeln
AND kcmeng NE 0 . "AND vgpos = it_ekkn-ebelp
ENDIF.
*
IF it_lips IS NOT INITIAL.
SELECT vttp~tknum tpnum vbeln vsart
FROM vttp INNER JOIN vttk
ON vttp~tknum = vttk~tknum
INTO CORRESPONDING FIELDS OF TABLE it_vttp
FOR ALL ENTRIES IN it_lips
WHERE vbeln = it_lips-vbeln.
ENDIF.
IF it_lips IS NOT INITIAL.
SELECT spras vsart bezei
FROM t173t
INTO CORRESPONDING FIELDS OF TABLE it_t173t
FOR ALL ENTRIES IN it_lips
WHERE vsart = it_lips-vsart
AND spras EQ sy-langu.
ENDIF.
SELECT vbeln knumv
FROM vbak
INTO TABLE it_vbak1
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vgbel.
* fetching the payer - danish- 12/07/2010
SELECT vbeln posnr parvw kunnr pernr "pernr added by anuj Dt 22.07.2010
FROM vbpa
INTO TABLE it_vbpa
FOR ALL ENTRIES IN it_vbap
WHERE vbeln = it_vbap-vbeln
AND parvw IN ('RG', 'VE','ZM').
it_vbpa1[] = it_vbpa[].
DELETE it_vbpa1 WHERE parvw = 'VE' OR parvw = 'RG'.
IF it_vbpa1 IS NOT INITIAL .
SELECT pernr vorna nachn
FROM pa0002
INTO TABLE it_merchant
FOR ALL ENTRIES IN it_vbpa1
WHERE pernr = it_vbpa1-pernr.
ENDIF.
it_vbpa2[] = it_vbpa[].
DELETE it_vbpa2 WHERE parvw = 'ZM' OR parvw = 'RG'.
IF it_vbpa2[] IS NOT INITIAL .
SELECT pernr vorna nachn
FROM pa0002
INTO TABLE it_sales_emp
FOR ALL ENTRIES IN it_vbpa2
WHERE pernr = it_vbpa2-pernr.
ENDIF.
DELETE it_vbpa WHERE parvw = 'VE' OR parvw = 'ZM'.
"end code by anuj Dt 22.07.2010
IF it_vbpa IS NOT INITIAL.
SELECT kunnr name1
FROM kna1
INTO TABLE it_payer
FOR ALL ENTRIES IN it_vbpa
WHERE kunnr = it_vbpa-kunnr.
ENDIF.
ENDIF.
ENDIF.
"code added by anuj Dt 22.07.2010
IF it_vbak1[] IS NOT INITIAL.
SELECT vbeln posnr matnr kwmeng netwr waerk objnr
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE it_vbap1
FOR ALL ENTRIES IN it_vbak1
WHERE vbeln = it_vbak1-vbeln.
ENDIF.
"end code by anuj Dt 22.07.2010
IF it_vbak[] IS NOT INITIAL.
* fetching sales group name
SELECT vkgrp bezei
FROM tvgrt
INTO TABLE it_tvgrt
FOR ALL ENTRIES IN it_vbak
WHERE vkgrp EQ it_vbak-vkgrp
AND spras EQ sy-langu.
* fetching the text for Division :: danish 10/11/09
SELECT spart vtext
FROM tspat
INTO TABLE it_tspat
FOR ALL ENTRIES IN it_vbak
WHERE spart = it_vbak-spart AND spras = sy-langu .
* end code
SELECT kunnr name1
FROM kna1
INTO TABLE it_kna1
FOR ALL ENTRIES IN it_vbak
WHERE kunnr = it_vbak-kunnr.
SELECT vbeln knumv
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak_cs
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vgbel.
IF it_vbak_cs[] IS NOT INITIAL.
SELECT vbeln posnr matnr
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE it_vbap_cs
FOR ALL ENTRIES IN it_vbak_cs
WHERE vbeln = it_vbak_cs-vbeln.
ENDIF.
SELECT knumv kbetr kschl kposn
FROM konv
INTO CORRESPONDING FIELDS OF TABLE it_konv_cs
FOR ALL ENTRIES IN it_vbak_cs
WHERE knumv = it_vbak_cs-knumv.
it_konv_all[] = it_konv_cs[].
DELETE it_konv_cs WHERE kschl NE 'ZCOM'.
ENDIF.
IF it_bkpfi[] IS NOT INITIAL .
SORT it_bkpfi[] BY belnr gjahr.
SELECT bukrs belnr gjahr buzei prctr hkont
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bkpfi"it_bkpf " it_bkpf commented by danish - 09/06/2010
WHERE bukrs = p_plant AND belnr = it_bkpfi-belnr AND gjahr = it_bkpfi-gjahr .
ENDIF .
"Product Type
SELECT mvke~matnr mvke~vkorg mvke~vtweg mvke~mvgr1 tvm1t~bezei
FROM mvke INNER JOIN tvm1t
ON mvke~mvgr1 EQ tvm1t~mvgr1
AND tvm1t~spras EQ 'E'
INTO TABLE it_mvke FOR ALL ENTRIES IN it_ekpo
WHERE matnr EQ it_ekpo-matnr.
"Sourcing office code
SORT it_ekko[] BY knumv.
SELECT knumv kposn kbetr lifnr kschl
FROM konv
INTO CORRESPONDING FIELDS OF TABLE it_konv
FOR ALL ENTRIES IN it_ekko
WHERE knumv EQ it_ekko-knumv.
it_konv_po[] = it_konv[] .
DELETE it_konv[] WHERE kschl NE 'ZGRW'.
* SELECT vbeln posnr lcno lcval
* FROM zsdlcdtl
* INTO TABLE it_zsdlc
* FOR ALL ENTRIES IN it_vbap
* WHERE vbeln = it_vbap-vbeln
* AND posnr = it_vbap-posnr.
****** start code by danish for exchange rate on 29/06/09 ******
SELECT *
FROM tcurr
INTO TABLE it_tcurr
WHERE kurst EQ 'M'.
LOOP AT it_tcurr INTO wa_tcurr.
lv_tabix = sy-tabix.
CALL FUNCTION 'CONVERSION_EXIT_INVDT_OUTPUT'
EXPORTING
input = wa_tcurr-gdatu
IMPORTING
output = lv_gdatu. " dd/mm/yyyy
IF sy-subrc EQ 0.
CONCATENATE lv_gdatu+6(4) lv_gdatu+3(2) lv_gdatu+0(2) INTO lv_gdatu.
wa_tcurr-gdatu = lv_gdatu.
MODIFY it_tcurr FROM wa_tcurr INDEX lv_tabix TRANSPORTING gdatu.
ENDIF.
ENDLOOP.
DELETE it_tcurr WHERE gdatu GT sy-datum.
SORT it_tcurr DESCENDING BY fcurr tcurr gdatu.
****** end code by danish for exchange rate on 29/06/09 ******
*&---------------------------------------------------------------------*
*& Form MAKE_FINALTAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM make_finaltab .
********************** Inserting data into teporary table for output**************
* break hopflabap1.
SORT it_rseg BY belnr ebeln ebelp.
LOOP AT it_rseg INTO wa_rseg.
wa_mtot-belnr = wa_rseg-belnr.
wa_mtot-gjahr = wa_rseg-gjahr.
wa_mtot-ebeln = wa_rseg-ebeln.
wa_mtot-ebelp = wa_rseg-ebelp.
wa_mtot-menge = wa_rseg-menge.
wa_mtot-wrbtr = wa_rseg-wrbtr.
COLLECT wa_mtot INTO it_mtot.
ENDLOOP.
* SORT it_qvbrp BY vbeln aubel aupos.
* SORT it_vbrpd BY vbeln aubel aupos.
* SORT it_hvbrp BY vbeln aubel aupos.
SORT it_konv_inv BY knumv kposn kschl.
break hopflabap1.
* LOOP AT it_qvbrp INTO wa_qvbrp.
* LOOP AT it_vbrpd INTO wa_vbrpd.
*
* wa_qtot-vbeln = wa_vbrpd-vbeln.
* wa_qtot-aubel = wa_vbrpd-aubel.
* wa_qtot-aupos = wa_vbrpd-aupos.
* wa_qtot-fkimg = wa_vbrpd-fkim."fkimg.
* wa_qtot-netwr = wa_vbrpd-netw."netwr.
*
** CLEAR wa_hvbrp.
** READ TABLE it_hvbrp INTO wa_hvbrp WITH KEY vbeln = wa_qvbrp-vbeln
** aubel = wa_qvbrp-aubel
** aupos = wa_qvbrp-aupos BINARY SEARCH.
**
** CLEAR : wa_konv_inv .
** READ TABLE it_konv_inv INTO wa_konv_inv WITH KEY knumv = wa_hvbrp-knumv
** kposn = wa_hvbrp-posnr
** kschl = 'ZLEP' BINARY SEARCH.
** wa_qtot-kwert = wa_konv_inv-kwert.
*
* COLLECT wa_qtot INTO it_qtot.
*
* ENDLOOP.
SORT it_rseg BY ebeln ebelp.
SORT it_makt BY matnr.
SORT it_mara BY matnr.
SORT it_ekkn BY ebeln ebelp.
SORT it_vbkd BY vbeln posnr.
SORT it_vbap BY vbeln posnr.
SORT it_vbak BY vbeln.
SORT it_vbak_cs BY vbeln.
SORT it_konv_cs BY knumv kposn kschl.
SORT it_ekko BY ebeln.
SORT it_lfa1 BY lifnr.
SORT it_mtot BY belnr ebeln ebelp.
* SORT it_qtot BY vbeln aubel aupos.
SORT it_bkpf BY awkey.
SORT it_bseg BY belnr bukrs gjahr hkont.
SORT it_rsegm BY ebeln ebelp.
SORT it_ekko BY ebeln.
SORT it_zmmlc BY ebeln ebelp.
SORT it_konv BY knumv kposn.
* SORT it_zsdlc BY vbeln posnr.
SORT it_bkpfm BY awkey.
SORT it_bkpfi BY awkey.
SORT it_konv_all BY knumv kposn kschl. " Added by Ravi_12.02.2011
LOOP AT it_ekpo INTO wa_ekpo.
* vsrc = 'Y' .
*==========================================================================*
* code by danish for fetching the PO whose MIRO is not reversed:: 05/10/09 *
IF wa_ekpo-loekz IS NOT INITIAL.
CLEAR wa_rsegt.
READ TABLE it_rsegm INTO wa_rsegt WITH KEY ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
ENDIF.
*==========================================================================*
***** start code by danish on 02/07/09 ******
IF so_ebeln IS NOT INITIAL AND wa_ekpo-ebeln NOT IN so_ebeln.
CONTINUE.
ENDIF.
IF so_matnr IS NOT INITIAL AND wa_ekpo-matnr NOT IN so_matnr.
CONTINUE.
ENDIF.
* if PO is not garment PO then continue by gaurav on 27/7/2010
CLEAR wa_ekkn.
READ TABLE it_ekkn INTO wa_ekkn WITH KEY ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
* if PO is not garment PO then continue by gaurav on 27/7/2010 till here
CLEAR wa_makt.
READ TABLE it_makt INTO wa_makt WITH KEY matnr = wa_ekpo-matnr BINARY SEARCH.
wa_temp-ponum = wa_ekpo-ebeln.
wa_temp-poitm = wa_ekpo-ebelp.
wa_temp-matnr = wa_ekpo-matnr.
wa_temp-maktx = wa_makt-maktx.
wa_temp-menge_d = wa_ekpo-menge.
"for purchase order unit price.
wa_temp-netpr_p = wa_ekpo-netpr.
wa_temp-netpr_pc = wa_temp-netpr_p.
READ TABLE it_mara INTO wa_mara WITH KEY matnr = wa_ekpo-matnr BINARY SEARCH.
IF wa_mara-mtart NOT IN p_mtart. " added by danish on 09/07/09
CLEAR wa_temp.
CONTINUE.
ENDIF.
wa_temp-mtart = wa_mara-mtart.
CLEAR wa_ekkn.
READ TABLE it_ekkn INTO wa_ekkn WITH KEY ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc = 0 .
wa_temp-sonum = wa_ekkn-vbeln.
wa_temp-soitm = wa_ekkn-vbelp.
ENDIF.
CLEAR wa_vbkd.
READ TABLE it_vbkd INTO wa_vbkd WITH KEY vbeln = wa_ekkn-vbeln posnr = wa_ekkn-vbelp BINARY SEARCH.
IF sy-subrc = 0 .
wa_temp-bstkd = wa_vbkd-bstkd.
ENDIF.
CLEAR wa_vbap.
READ TABLE it_vbap INTO wa_vbap WITH KEY vbeln = wa_ekkn-vbeln posnr = wa_ekkn-vbelp BINARY SEARCH.
wa_temp-soqty = wa_vbap-kwmeng.
wa_temp-wbs = wa_vbap-wbs.
wa_temp-netpr1 = wa_vbap-netpr.
wa_temp-prctr = wa_vbap-prctr .
CLEAR wa_cepct.
READ TABLE it_cepct INTO wa_cepct WITH KEY prctr = wa_vbap-prctr.
wa_temp-ltext = wa_cepct-ltext.
CLEAR wa_vbpa.
READ TABLE it_vbpa INTO wa_vbpa WITH KEY vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr.
IF sy-subrc NE 0.
CLEAR wa_vbpa.
READ TABLE it_vbpa INTO wa_vbpa WITH KEY vbeln = wa_vbap-vbeln.
ENDIF.
"Fetching Merchant
CLEAR wa_vbpa1.
READ TABLE it_vbpa1 INTO wa_vbpa1 WITH KEY vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr.
IF sy-subrc NE 0.
CLEAR wa_vbpa1.
READ TABLE it_vbpa1 INTO wa_vbpa1 WITH KEY vbeln = wa_vbap-vbeln.
ENDIF.
CLEAR wa_merchant.
READ TABLE it_merchant INTO wa_merchant WITH KEY pernr = wa_vbpa1-pernr.
CONCATENATE wa_merchant-vorna wa_merchant-nachn INTO wa_temp-merchant SEPARATED BY space.
"Fetching sales employee
CLEAR wa_vbpa1.
READ TABLE it_vbpa2 INTO wa_vbpa2 WITH KEY vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr.
IF sy-subrc NE 0.
CLEAR wa_vbpa2.
READ TABLE it_vbpa2 INTO wa_vbpa2 WITH KEY vbeln = wa_vbap-vbeln.
ENDIF.
CLEAR wa_sales_emp.
READ TABLE it_sales_emp INTO wa_sales_emp WITH KEY pernr = wa_vbpa2-pernr.
CONCATENATE wa_sales_emp-vorna wa_sales_emp-nachn INTO wa_temp-sales_emp SEPARATED BY space.
CLEAR: wa_vbak_new,wa_vbak1.
READ TABLE it_vbak INTO wa_vbak_new WITH KEY vbeln = wa_temp-sonum.
*
CLEAR wa_vbak1.
READ TABLE it_vbak1 INTO wa_vbak1 WITH KEY vbeln = wa_vbak_new-vgbel.
CLEAR wa_vbap1.
READ TABLE it_vbap1 INTO wa_vbap1 WITH KEY vbeln = wa_vbak_new-vgbel
matnr = wa_vbap-matnr.
CALL FUNCTION 'ZFM_CALC_COSTING_MARGIN'
EXPORTING
knumv = wa_vbak1-knumv
vbeln = wa_vbak1-vbeln
posnr = wa_vbap1-posnr
IMPORTING
margin = wa_temp-margin
* MARGIN_VAL =
* VTOT = v_tot
* VVAL = v_val
* VTOTC = v_totc
* VVALC = v_valc
.
" for season
IF so_mvgr5 IS NOT INITIAL AND wa_vbap-mvgr5 NOT IN so_mvgr5.
CLEAR wa_temp.
CONTINUE.
ENDIF.
CLEAR wa_tvm5t.
READ TABLE it_tvm5t INTO wa_tvm5t WITH KEY mvgr5 = wa_vbap-mvgr5.
wa_temp-season = wa_tvm5t-bezei.
wa_temp-soqtyc = wa_temp-soqty.
CLEAR: wa_vbak ,wa_kna1.
READ TABLE it_vbak INTO wa_vbak WITH KEY vbeln = wa_ekkn-vbeln BINARY SEARCH.
IF sy-subrc = 0 .
* fetching sales group name
CLEAR wa_tvgrt.
READ TABLE it_tvgrt INTO wa_tvgrt WITH KEY vkgrp = wa_vbak-vkgrp.
wa_temp-grpnm = wa_tvgrt-grpnm.
* fetching the Division Text :: danish :: 10/11/09
wa_temp-spart = wa_vbak-spart.
CLEAR : wa_tspat .
READ TABLE it_tspat INTO wa_tspat WITH KEY spart = wa_vbak-spart .
IF sy-subrc = 0 .
wa_temp-divsn = wa_tspat-vtext .
ENDIF.
* end code
wa_temp-vkgrp = wa_vbak-vkgrp.
READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_vbak-kunnr.
wa_temp-kname1 = wa_kna1-name1.
ENDIF." code added by vishnu dt :3/6/2010.
CLEAR wa_vbak_cs.
READ TABLE it_vbak_cs INTO wa_vbak_cs WITH KEY vbeln = wa_vbak-vgbel BINARY SEARCH.
CLEAR wa_vbap_cs.
READ TABLE it_vbap_cs INTO wa_vbap_cs WITH KEY vbeln = wa_vbak_cs-vbeln matnr = wa_vbap-matnr.
CLEAR wa_konv_cs .
READ TABLE it_konv_cs INTO wa_konv_cs WITH KEY knumv = wa_vbak_cs-knumv kposn = wa_vbap_cs-posnr kschl = 'ZCOM' BINARY SEARCH.
wa_temp-kbetr = ( ( wa_konv_cs-kbetr ) / 10 ).
******************************************************************************** Start Code is added by ravi _12.02.2011
CLEAR wa_konv_all.
READ TABLE it_konv_all INTO wa_konv_all WITH KEY knumv = wa_vbak_cs-knumv kposn = wa_vbap_cs-posnr kschl = 'ZFOB' BINARY SEARCH.
wa_temp-zfob = wa_konv_all-kbetr .
CLEAR wa_konv_all.
READ TABLE it_konv_all INTO wa_konv_all WITH KEY knumv = wa_vbak_cs-knumv kposn = wa_vbap_cs-posnr kschl = 'ZDS' BINARY SEARCH.
wa_temp-zds = ( -1 * ( wa_konv_all-kbetr ) / 10 ) .
wa_temp-ntfob = ( wa_temp-zfob - ( wa_temp-zfob * ( wa_temp-zds ) / 100 ) ).
******************************************************************************* End
*=====>Start Code added By hansraj on 21.11.08
IF wa_vbak-vkgrp NOT IN s_vkgrp.
CLEAR: wa_temp,wa_ekpo.
CONTINUE.
ENDIF.
IF wa_vbak-kunnr NOT IN s_kunnr.
CLEAR: wa_temp,wa_ekpo.
CONTINUE.
ENDIF.
*<=====End Code added By hansraj on 21.11.08
CLEAR wa_ekko.
READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln = wa_ekpo-ebeln BINARY SEARCH.
IF so_ekgrp IS NOT INITIAL AND wa_ekko-ekgrp NOT IN so_ekgrp.
CLEAR wa_temp.
CONTINUE.
ENDIF.
wa_temp-waers = wa_ekko-waers.
wa_temp-ekgrp = wa_ekko-ekgrp.
wa_temp-vendcd = wa_ekko-lifnr.
****************************************************************************** Start Code is added by ravi _12.02.2011
CLEAR wa_konv_po.
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl ='J3AX' .
wa_temp-j3ax = wa_konv_po-kbetr .
CLEAR wa_konv_po.
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl = 'ZRA0'.
wa_temp-zra0 = ( -1 * ( wa_konv_po-kbetr ) / 10 ).
CLEAR wa_konv_po .
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl = 'ZCLD'.
wa_temp-zclm = ( ( wa_konv_po-kbetr ) / 10 ).
CLEAR wa_konv_po .
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl = 'ZPD'.
wa_temp-zpd = wa_konv_po-kbetr.
****************************************************************************** End
* fetching the Purchase grp name
CLEAR wa_t024.
READ TABLE it_t024 INTO wa_t024 WITH KEY ekgrp = wa_ekko-ekgrp.
wa_temp-eknam = wa_t024-eknam.
* end code
CLEAR wa_lfa1.
READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_ekko-lifnr BINARY SEARCH.
* code by danish :: 16/11/09
IF so_land1 IS NOT INITIAL AND wa_lfa1-land1 NOT IN so_land1 .
CLEAR wa_temp.
CONTINUE.
ENDIF.
* end code
wa_temp-lname1 = wa_lfa1-name1.
wa_temp-land1 = wa_lfa1-land1. " added by danish - 16/11/09
CLEAR wa_mvke.
READ TABLE it_mvke INTO wa_mvke WITH KEY matnr = wa_ekpo-matnr.
IF sy-subrc EQ 0.
wa_temp-bezei_pt = wa_mvke-bezei.
ENDIF.
"Source office code
CLEAR wa_konv.
READ TABLE it_konv INTO wa_konv WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc EQ 0.
wa_temp-lifnr = wa_konv-lifnr.
ENDIF.
APPEND wa_temp TO it_temp.
vmflg = 'N'.
CLEAR : vmqty.
LOOP AT it_rsegm INTO wa_rsegm WHERE ebeln = wa_ekpo-ebeln AND ebelp = wa_ekpo-ebelp.
DELETE it_rsegd WHERE ebeln = wa_ekpo-ebeln AND ebelp = wa_ekpo-ebelp. " deleting records to check for remaining miro
CLEAR wa_rbkp.
READ TABLE it_rbkp INTO wa_rbkp WITH KEY belnr = wa_rsegm-belnr stblg = ''.
IF sy-subrc EQ 0.
CLEAR wa_lfa1.
READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_rbkp-lifnr BINARY SEARCH. " added by danish - 09/06/2010
wa_temp-lname2 = wa_lfa1-name1.
* wa_temp-menge = wa_rsegm-menge.
wa_temp-belnr = wa_rbkp-belnr.
wa_temp-bldat = wa_rbkp-bldat.
wa_temp-budat = wa_rbkp-budat.
wa_temp-mwaers = wa_rbkp-waers.
wa_temp-xblnr = wa_rbkp-xblnr.
wa_temp-cpudt = wa_rbkp-cpudt. " added by danish - 06/01/09
CONCATENATE wa_rbkp-budat+0(4) '/' wa_rbkp-budat+4(2) INTO wa_temp-vmonth SEPARATED BY space. " added by danish on 01/12/09
ELSE.
* if its revesal has been made
CONTINUE.
ENDIF.
CLEAR : wa_temp-menge , wa_temp-wrbtr,wa_temp-uwrbtr.
* code by danish :: 11/11/09
* converting MIRO value to USD
*************************************************************************** Start Commet by ravi _14.02.2011
* IF wa_temp-mwaers NE 'USD'.
* CLEAR vexrt.
* LOOP AT it_tcurr INTO wa_tcurr WHERE fcurr = wa_temp-mwaers AND tcurr = 'USD'.
*
* IF wa_tcurr-gdatu GT wa_rbkp-bldat .
* CONTINUE.
* ELSEIF wa_tcurr-gdatu LE wa_rbkp-bldat.
* vexrt = wa_tcurr-ukurs. " Exchange Rate
* EXIT.
* ENDIF.
*
* ENDLOOP.
**break hopflabap1.
* IF vexrt LT 0 .
*
* vexrt = ( -1 ) * vexrt .
* wa_temp-uwrbtr = ( wa_temp-wrbtr / vexrt ).
*
* ELSEIF vexrt GT 0 .
* wa_temp-uwrbtr = ( wa_temp-wrbtr * vexrt ).
*
* ENDIF.
* ELSE.
* wa_temp-uwrbtr = wa_temp-wrbtr.
* ENDIF.
* end code :: 11/11/09
************************************************************************** end
************************************************************************* Start Code is commented by ravi _14.02.2011
CLEAR : vawkey." ,wa_mbkpf
CONCATENATE wa_rsegm-belnr wa_rsegm-gjahr INTO vawkey.
CLEAR wa_bkpf.
READ TABLE it_bkpfm INTO wa_bkpf WITH KEY awkey = vawkey.
wa_temp-belnr_m = wa_bkpf-belnr.
************************************************************************* End
*--------------------------------------------------------------------*
* code by danish - 05/06/2010
CLEAR wa_mtot.
READ TABLE it_mtot INTO wa_mtot WITH KEY belnr = wa_rsegm-belnr ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
wa_temp-menge = wa_mtot-menge.
IF wa_bkpf-budat IS NOT INITIAL. " if miro accounting is posted then only show the miro value
wa_temp-wrbtr = wa_mtot-wrbtr.
ENDIF.
IF wa_temp-menge IS NOT INITIAL.
wa_temp-ntbtr = wa_temp-wrbtr / wa_temp-menge .
ENDIF.
* end code by danish - 05/06/2010
*--------------------------------------------------------------------*
vmflg = 'Y'.
******************************************************************************************* add by ravi_09.03.2011
LOOP AT it_lips INTO wa_lips WHERE vgbel = wa_ekpo-ebeln AND vgpos = wa_ekpo-ebelp.
wa_temp-delnm = wa_lips-vbeln .
wa_temp-deldt = wa_lips-lfdat.
wa_temp-delqy = wa_lips-kcmeng.
CLEAR wa_vttp.
READ TABLE it_vttp INTO wa_vttp WITH KEY vbeln = wa_lips-vbeln.
wa_temp-shnum = wa_vttp-tknum .
CLEAR wa_t173t.
READ TABLE it_t173t INTO wa_t173t WITH KEY vsart = wa_lips-vsart .
wa_temp-vsart = wa_t173t-bezei.
*
* CLEAR wa_temp-mwaers .
* CLEAR wa_temp-divsn.
* CLEAR wa_temp-spart.
* CLEAR wa_temp-merchant.
* CLEAR wa_temp-sales_emp.
APPEND wa_temp TO it_temp.
ENDLOOP.
************************************************************************************** End
APPEND wa_temp TO it_temp.
CLEAR wa_temp-lfimg_s.
CLEAR wa_temp-menge_d.
CLEAR : wa_temp-soqty , wa_temp-soqtyc .
CLEAR : wa_temp-belnr,wa_temp-bldat,wa_temp-budat,wa_temp-waers,wa_temp-menge,wa_temp-wrbtr,wa_temp-belnr_m,wa_temp-lname1,wa_temp-vmonth .
CLEAR : wa_temp-menge_d,wa_temp-xblnr,wa_temp-cpudt.
CLEAR : wa_temp-soqty , wa_temp-soqtyc ,wa_temp-uwrbtr.
CLEAR : wa_temp-j3ax ,wa_temp-zra0 ,wa_temp-zclm , wa_temp-zpd , wa_temp-netpr_pc,wa_temp-zfob,wa_temp-zds,wa_temp-ntfob .
CLEAR : wa_temp-mwaers,wa_temp-lname2,wa_temp-ntbtr,wa_temp-vendcd.
CLEAR : wa_temp-lifnr. "Sourcing off
CLEAR : wa_temp-kbetr . " so offce comm %
CLEAR : wa_temp-bezei_pt. "'Product Type'
CLEAR : wa_temp-land1. " 'Country Code'
CLEAR : wa_temp-prctr. "'Profit Centre'
CLEAR : wa_temp-ltext. "'Profit Centre Text'
CLEAR : wa_temp-spart. " 'Division'
CLEAR : wa_temp-divsn . " 'Division Desc.'
CLEAR : wa_temp-sales_emp.
CLEAR : wa_temp-merchant." 'Merchant Name'
CLEAR : wa_temp-vkgrp. "'Sales Group'
CLEAR : wa_temp-grpnm. "'Sales Grp. Name'
CLEAR : wa_temp-maktx. "'Style description'
CLEAR : wa_temp-bstkd. "'Buyer Po Number'
CLEAR : wa_temp-season. " Season
ENDLOOP.
******************************************************************************************** Start Code is added by ravi _12.02.2011
" read for inbound delivery,date and qty.
LOOP AT it_lips INTO wa_lips WHERE vgbel = wa_ekpo-ebeln AND vgpos = wa_ekpo-ebelp.
wa_temp-delnm = wa_lips-vbeln .
wa_temp-deldt = wa_lips-lfdat.
wa_temp-delqy = wa_lips-kcmeng.
CLEAR wa_vttp.
READ TABLE it_vttp INTO wa_vttp WITH KEY vbeln = wa_lips-vbeln.
wa_temp-shnum = wa_vttp-tknum .
CLEAR wa_t173t.
READ TABLE it_t173t INTO wa_t173t WITH KEY vsart = wa_lips-vsart .
wa_temp-vsart = wa_t173t-bezei.
*
* CLEAR wa_temp-mwaers .
* CLEAR wa_temp-divsn.
* CLEAR wa_temp-spart.
* CLEAR wa_temp-merchant.
* CLEAR wa_temp-sales_emp.
APPEND wa_temp TO it_temp.
ENDLOOP.
" read for inbound shipment no and type .
********************************************************************************************* End
IF vmflg EQ 'Y'.
DELETE it_temp WHERE ponum = wa_ekpo-ebeln AND poitm = wa_ekpo-ebelp AND belnr = '' AND delnm = ''. .
ENDIF.
CLEAR : wa_temp-belnr,wa_temp-bldat,wa_temp-budat,wa_temp-vmonth,wa_temp-waers,wa_temp-menge,wa_temp-wrbtr,wa_temp-belnr_m,wa_temp-lname1 .
CLEAR : wa_temp-menge_d,wa_temp-xblnr,wa_temp-cpudt.
CLEAR : wa_temp-soqty , wa_temp-soqtyc,wa_temp-uwrbtr .
DELETE it_ekknd[] WHERE ebeln = wa_ekpo-ebeln AND ebelp = wa_ekpo-ebelp.
CLEAR wa_temp.
ENDLOOP.
CLEAR : wa_temp , wa_vbkd, wa_vbap, wa_ekkn, wa_makt,
wa_vbak , wa_kna1, wa_ekko.
it_final[] = it_temp[].
BREAK hopflabap1.
delete it_final[] WHERE soqty is INITIAL AND menge_d is INITIAL. " added by narendra_12.01.2012
delete ADJACENT DUPLICATES FROM it_final COMPARING ALL FIELDS. " added by narendra_13.01.2012
*****************************************************************************************
ENDFORM. " MAKE_FINALTAB
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form DISPLAY_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_report .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_pf_status_set = 'SET_STATUS'
i_callback_top_of_page = 'TOP-OF-PAGES'
is_layout = gd_layout
is_print = gd_slis_print_alv
it_fieldcat = it_fcat[]
it_sort = it_sort[]
TABLES
t_outtab = it_final[].
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM top-of-pages.
ENDFORM. " DISPLAY_REPORT
*&---------------------------------------------------------------------*
*& Form TOP-OF-PAGES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM top-of-pages .
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c.
SELECT werks name1 " code added by prashant 25.11.2008
FROM t001w
INTO TABLE it_t001w.
READ TABLE it_t001w " code added by prashant 25.11.2008
INTO wa_t001w
WITH KEY werks = p_plant .
vplant = wa_t001w-name1. " code added by prashant 25.11.2008
"----> Title
wa_header-info = 'SOURCING REGISTER ' . "'EXPORT REGISTER FOB ' changed to 'EXPORT REGISTER' by Hansraj on 21.11.08
wa_header-typ = 'H'.
APPEND wa_header TO t_header.
CLEAR wa_header.
CONCATENATE 'FOR PLANT ' '' vplant INTO wa_header-info SEPARATED BY space. " code added by prashant 25.11.2008
wa_header-typ = 'H '.
APPEND wa_header TO t_header.
CLEAR wa_header.
IF s_date IS NOT INITIAL.
CONCATENATE ' FOR PERIOD: ' s_date-low+6(2) '/' s_date-low+4(2) '/' s_date-low+0(4) 'TO' s_date-high+6(2) '/' s_date-high+4(2) '/' s_date-high+0(4) INTO wa_header-info SEPARATED BY space.
wa_header-typ = 'H'.
APPEND wa_header TO t_header.
CLEAR wa_header.
ENDIF.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM. " TOP-OF-PAGES
*--------------------------------------------------------------------*
**********************************************************************
**********************************************************************
REPORT zrsd_exp_register_src.
**********************************************************************
* TYPE POOLS *
**********************************************************************
TYPE-POOLS : slis.
**********************************************************************
**********************************************************************
* TABLES *
**********************************************************************
TABLES : ekko, vttk, vbak, lips, eket , rbkp , mara , lfa1,vbap. " declare tables
**********************************************************************
**********************************************************************\
" Declare types and date ...
TYPES: BEGIN OF ty_ekkn,
ebeln TYPE ekkn-ebeln,
ebelp TYPE ekkn-ebelp,
vbeln TYPE ekkn-vbeln,
vbelp TYPE ekkn-vbelp,
END OF ty_ekkn.
TYPES: BEGIN OF ty_vbkd,
vbeln TYPE vbkd-vbeln,
posnr TYPE vbkd-posnr,
bstkd TYPE vbkd-bstkd,
END OF ty_vbkd.
types: slis_tabname(30) type c,
slis_fieldname(30) type c,
slis_sel_tab_field(60) type c,
slis_formname(30) type c,
slis_entry(60) type c,
slis_edit_mask(60) type c,
slis_coldesc(4) type c.
" Data ******************************************
DATA : it_vbpa TYPE TABLE OF ty_vbpa,
wa_vbpa TYPE ty_vbpa,
***********************************************************************
* Select Options Begin with S_ *
* Parameters Begin with P_ *
***********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS p_plant TYPE lips-werks OBLIGATORY.
****** start code by danish on 02/07/09 *****
SELECT-OPTIONS : so_ebeln FOR ekko-ebeln,
so_matnr FOR mara-matnr.
***** end code by danish on 02/07/09 ******
*=====> Start Code added by Hansraj on 21.11.08
SELECT-OPTIONS : s_vkgrp FOR vbak-vkgrp , "For Sales Group
s_kunnr FOR vbak-kunnr . "For Customer
*<===== End Code added by Hansraj on 21.11.08
*PARAMETERS p_ord TYPE ekpo-ebeln.
SELECT-OPTIONS s_date FOR rbkp-budat.
*PARAMETERS p_mtart TYPE mara-mtart OBLIGATORY. " line commented by prashant 16.9.2009
SELECT-OPTIONS : p_mtart FOR mara-mtart OBLIGATORY. " line added by prashant 16.9.2009
* Country Key :: danish - 16/11/09
SELECT-OPTIONS : so_land1 FOR lfa1-land1,
* Purchase Group
so_ekgrp FOR ekko-ekgrp.
*PARAMETERS : srepa RADIOBUTTON GROUP rgrp. "commented by danish on 08/07/09 " code added by prashant 24.11.2008
* srepp RADIOBUTTON GROUP rgrp. " commented by danish on 08/07/2009
* season added by danish - 04/06/2010
SELECT-OPTIONS : so_mvgr5 FOR vbap-mvgr5.
* end code danish - 04/06/2010
SELECTION-SCREEN END OF BLOCK b1 .
***********************************************************************
START-OF-SELECTION.
***********************************************************************
***********************************************************************
PERFORM data_retrival. " For DATA Retrival
PERFORM field_cat. " For Creation of feild catalog.
PERFORM build_layout.
PERFORM make_finaltab. " To make final Internal Table for Display
PERFORM display_report." To Display the final table in report.
*&---------------------------------------------------------------------*
*& Form FEILD_CAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM field_cat.
CLEAR: it_fcat[],
col_pos.
wa_sort-fieldname = 'EKNAM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'EKGRP'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'KNAME1'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'MATNR'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'SONUM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'SOITM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'PONUM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
wa_sort-fieldname = 'POITM'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
***************************************************************************************
*~~ FIELDNAME COL HEADING
***************************************************************************************
PERFORM fld_cat USING 'EKGRP' 'Purchase Grp.' .
PERFORM fld_cat USING 'EKNAM' 'Purchase Grp. Name'.
PERFORM fld_cat USING 'KNAME1' 'Customer Name' .
PERFORM fld_cat USING 'MATNR' 'Style Number' .
PERFORM fld_cat USING 'MAKTX' 'Style Description' .
PERFORM fld_cat USING 'SONUM' 'SO Number' .
ENDFORM. " FIELD_CAT
*&---------------------------------------------------------------------*
*& Form fld_cat
*&---------------------------------------------------------------------*
* DESCRIPTION:
* SubRoutine to create a line in the Field Catalog
*----------------------------------------------------------------------*
* -->FIELDNAME text
* -->COLTEXT text
* -->EDIT text
* -->KEY text
* -->NO_OUT text
*----------------------------------------------------------------------*
FORM fld_cat USING fieldname TYPE slis_fieldname
coltext TYPE dd03p-scrtext_l.
CLEAR: wa_fcat.
col_pos = col_pos + 1.
wa_fcat-fieldname = fieldname. "Field Name of the Internal Table
wa_fcat-seltext_m = coltext. "Column Heading
wa_fcat-col_pos = col_pos. "Column Positioning
wa_fcat-tabname = 'IT_FINAL'.
wa_fcat-lowercase = 'X'.
wa_fcat-no_zero = 'X'.
IF fieldname EQ 'POITM' OR fieldname EQ 'SOITM'.
wa_fcat-outputlen = 8.
ELSE.
wa_fcat-outputlen = 15.
ENDIF.
IF fieldname EQ 'MENGE_D' OR fieldname EQ 'FKIMG' OR fieldname EQ 'SOQTY' OR fieldname EQ 'MENGE' OR fieldname EQ 'NETPR'
OR fieldname EQ 'NETWR' OR fieldname EQ 'WRBTR' OR fieldname EQ 'NETPR_P' OR fieldname EQ 'MENGE1' OR fieldname EQ 'KWERT'
OR fieldname EQ 'USDVAL' OR fieldname EQ 'LFIMG_S' OR fieldname EQ 'KBETR'.
wa_fcat-no_zero = 'X'.
ENDIF.
IF fieldname EQ 'SOQTY' OR fieldname EQ 'FKIMG' OR fieldname EQ 'MENGE_D' OR fieldname EQ 'MENGE' OR fieldname EQ 'MENGE1'.
wa_fcat-decimals_out = 0.
ENDIF.
IF fieldname EQ 'USDVAL'.
wa_fcat-decimals_out = 2.
ENDIF.
APPEND wa_fcat TO it_fcat.
ENDFORM. "fld_cat
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
gd_layout-zebra = 'X'.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
*=====>Start Code added By hansraj on 21.11.08
gd_slis_print_alv-no_coverpage = 'X'.
gd_slis_print_alv-no_print_listinfos = 'X'.
*<=====End Code added By hansraj on 21.11.08
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIVAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM data_retrival .
***** for plant
AUTHORITY-CHECK OBJECT 'ZREPORTS'
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD p_plant.
IF sy-subrc <> 0.
MESSAGE s001(00) WITH 'No Authorisation for selected Plant' DISPLAY LIKE 'E'.
LEAVE TO CURRENT TRANSACTION.
ENDIF.
***** for purchase group
SELECT vkgrp
FROM tvbvk
INTO TABLE it_tvbvk
WHERE
vkbur = p_plant AND
vkgrp IN s_vkgrp.
LOOP AT it_tvbvk INTO wa_tvbvk .
AUTHORITY-CHECK OBJECT 'ZREPORTS'
ID 'ACTVT' FIELD '03'
ID 'VKGRP' FIELD wa_tvbvk-vkgrp.
IF sy-subrc <> 0.
MESSAGE s001(00) WITH 'No Authorisation for selected Sales Group -' wa_tvbvk-vkgrp DISPLAY LIKE 'E'.
LEAVE TO CURRENT TRANSACTION.
ENDIF.
ENDLOOP.
* break hopflabap1.
SELECT belnr xblnr bldat budat waers stblg gjahr lifnr cpudt
FROM rbkp
INTO TABLE it_rbkp
WHERE bukrs = p_plant
AND budat IN s_date
AND stblg = ''.
SELECT belnr xblnr bldat budat waers stblg gjahr lifnr cpudt
FROM rbkp
INTO TABLE it_rbkp
WHERE bukrs = p_plant
AND budat IN s_date
AND stblg = ''.
IF sy-subrc EQ 0.
SORT it_rbkp[] BY belnr gjahr.
SELECT lifnr name1 land1
FROM lfa1
INTO TABLE it_lfa1_d.
SELECT ebeln ebelp belnr gjahr wrbtr menge lifnr j_3asize kschl
FROM rseg
INTO TABLE it_rseg
FOR ALL ENTRIES IN it_rbkp
WHERE belnr = it_rbkp-belnr
AND gjahr = it_rbkp-gjahr
AND ebeln IN so_ebeln
AND werks = p_plant.
ENDIF.
SELECT bukrs belnr gjahr awkey blart budat
FROM bkpf
INTO TABLE it_bkpf
WHERE bukrs = p_plant
AND blart IN ('RE','RV').
it_bkpfi[] = it_bkpf[].
it_bkpfm[] = it_bkpf[].
DELETE it_bkpfi[] WHERE blart EQ 'RE'.
DELETE it_bkpfm[] WHERE blart EQ 'RV'.
break hopflabap1.
LOOP AT it_rseg INTO wa_rseg.
CLEAR : sawkey.
CONCATENATE wa_rseg-belnr wa_rseg-gjahr INTO sawkey.
CLEAR wa_bkpfm.
READ TABLE it_bkpfm INTO wa_bkpfm WITH KEY awkey = sawkey.
IF sy-subrc NE 0.
DELETE it_rseg[].
ENDIF.
ENDLOOP.
it_rsegm[] = it_rseg[].
SORT it_rsegm BY ebeln ebelp belnr gjahr.
DELETE ADJACENT DUPLICATES FROM it_rsegm COMPARING ebeln ebelp belnr gjahr.
it_rsegd[] = it_rsegm[].
IF it_rseg[] IS NOT INITIAL.
SORT it_rseg[] BY ebeln ebelp.
SELECT ebeln ebelp aedat netpr matnr menge mtart loekz
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_rseg
WHERE ebeln = it_rseg-ebeln
AND ebelp = it_rseg-ebelp
AND mtart IN p_mtart .
ENDIF.
IF it_ekpo[] IS NOT INITIAL.
SELECT matnr mtart
FROM mara
INTO TABLE it_mara
FOR ALL ENTRIES IN it_ekpo
WHERE matnr = it_ekpo-matnr.
SELECT ebeln ekgrp lifnr knumv waers lifre
FROM ekko
INTO TABLE it_ekko
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln
AND ekgrp IN so_ekgrp . " added by danish - 16/11/09
IF sy-subrc IS INITIAL.
SELECT ekgrp eknam
FROM t024
INTO TABLE it_t024
FOR ALL ENTRIES IN it_ekko
WHERE ekgrp = it_ekko-ekgrp.
SELECT lifnr name1 land1
FROM lfa1
INTO TABLE it_lfa1.
* FOR ALL ENTRIES IN it_ekko " commented by danish - 05/06/2010
* WHERE lifnr = it_ekko-lifnr
* AND land1 IN so_land1 .
ENDIF.
IF it_ekpo IS NOT INITIAL.
SELECT lcno ebeln ebelp
FROM zmmlc
INTO TABLE it_zmmlc
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln.
ENDIF.
SORT it_ekpo[] BY ebeln ebelp.
* SELECT lcno ebeln ebelp
* FROM zmmlcdtl
* INTO TABLE it_zmmlc
* FOR ALL ENTRIES IN it_ekpo
* WHERE bukrs = p_plant
* AND ebeln = it_ekpo-ebeln
* AND ebelp = it_ekpo-ebelp.
SELECT matnr maktx
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_ekpo
WHERE matnr = it_ekpo-matnr.
SELECT ebeln ebelp vbeln vbelp
FROM ekkn
INTO TABLE it_ekkn
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln
AND ebelp = it_ekpo-ebelp
AND sakto = '0050000000'.
ENDIF.
IF it_ekkn[] IS NOT INITIAL.
SORT it_ekkn[] BY vbeln vbelp.
it_ekknd[] = it_ekkn[]. " added by danish - 15/06/2010
SELECT vbeln posnr bstkd
FROM vbkd
INTO TABLE it_vbkd
FOR ALL ENTRIES IN it_ekkn
WHERE vbeln = it_ekkn-vbeln
AND posnr = it_ekkn-vbelp.
SELECT vbeln posnr kwmeng netpr ps_psp_pnr mvgr5 matnr prctr" mvgr5 added by danish - 04/06/2010
FROM vbap
INTO TABLE it_vbap
FOR ALL ENTRIES IN it_ekkn
WHERE vbeln = it_ekkn-vbeln
AND posnr = it_ekkn-vbelp.
IF it_vbap IS NOT INITIAL.
SELECT prctr ltext
FROM cepct
INTO CORRESPONDING FIELDS OF TABLE it_cepct
FOR ALL ENTRIES IN it_vbap
WHERE prctr EQ it_vbap-prctr
AND spras EQ sy-langu.
ENDIF.
IF it_vbap[] IS NOT INITIAL.
SELECT mvgr5 bezei
FROM tvm5t
INTO TABLE it_tvm5t
FOR ALL ENTRIES IN it_vbap
WHERE mvgr5 = it_vbap-mvgr5
AND spras = sy-langu.
* end code by danish - 04/06/2010
SORT it_vbap[] BY vbeln.
SELECT vbeln kunnr vkgrp auart spart vgbel knumv
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak
FOR ALL ENTRIES IN it_vbap
WHERE vbeln = it_vbap-vbeln
AND vkgrp IN s_vkgrp
AND kunnr IN s_kunnr.
IF it_ekkn IS NOT INITIAL.
SELECT lips~vbeln posnr vgbel vgpos kcmeng likp~lfdat vsart " posnr vgbel vgpos
FROM lips INNER JOIN likp
ON lips~vbeln = likp~vbeln
INTO CORRESPONDING FIELDS OF TABLE it_lips
FOR ALL ENTRIES IN it_ekkn
WHERE vgbel = it_ekkn-ebeln
AND kcmeng NE 0 . "AND vgpos = it_ekkn-ebelp
ENDIF.
*
IF it_lips IS NOT INITIAL.
SELECT vttp~tknum tpnum vbeln vsart
FROM vttp INNER JOIN vttk
ON vttp~tknum = vttk~tknum
INTO CORRESPONDING FIELDS OF TABLE it_vttp
FOR ALL ENTRIES IN it_lips
WHERE vbeln = it_lips-vbeln.
ENDIF.
IF it_lips IS NOT INITIAL.
SELECT spras vsart bezei
FROM t173t
INTO CORRESPONDING FIELDS OF TABLE it_t173t
FOR ALL ENTRIES IN it_lips
WHERE vsart = it_lips-vsart
AND spras EQ sy-langu.
ENDIF.
SELECT vbeln knumv
FROM vbak
INTO TABLE it_vbak1
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vgbel.
* fetching the payer - danish- 12/07/2010
SELECT vbeln posnr parvw kunnr pernr "pernr added by anuj Dt 22.07.2010
FROM vbpa
INTO TABLE it_vbpa
FOR ALL ENTRIES IN it_vbap
WHERE vbeln = it_vbap-vbeln
AND parvw IN ('RG', 'VE','ZM').
it_vbpa1[] = it_vbpa[].
DELETE it_vbpa1 WHERE parvw = 'VE' OR parvw = 'RG'.
IF it_vbpa1 IS NOT INITIAL .
SELECT pernr vorna nachn
FROM pa0002
INTO TABLE it_merchant
FOR ALL ENTRIES IN it_vbpa1
WHERE pernr = it_vbpa1-pernr.
ENDIF.
it_vbpa2[] = it_vbpa[].
DELETE it_vbpa2 WHERE parvw = 'ZM' OR parvw = 'RG'.
IF it_vbpa2[] IS NOT INITIAL .
SELECT pernr vorna nachn
FROM pa0002
INTO TABLE it_sales_emp
FOR ALL ENTRIES IN it_vbpa2
WHERE pernr = it_vbpa2-pernr.
ENDIF.
DELETE it_vbpa WHERE parvw = 'VE' OR parvw = 'ZM'.
"end code by anuj Dt 22.07.2010
IF it_vbpa IS NOT INITIAL.
SELECT kunnr name1
FROM kna1
INTO TABLE it_payer
FOR ALL ENTRIES IN it_vbpa
WHERE kunnr = it_vbpa-kunnr.
ENDIF.
ENDIF.
ENDIF.
"code added by anuj Dt 22.07.2010
IF it_vbak1[] IS NOT INITIAL.
SELECT vbeln posnr matnr kwmeng netwr waerk objnr
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE it_vbap1
FOR ALL ENTRIES IN it_vbak1
WHERE vbeln = it_vbak1-vbeln.
ENDIF.
"end code by anuj Dt 22.07.2010
IF it_vbak[] IS NOT INITIAL.
* fetching sales group name
SELECT vkgrp bezei
FROM tvgrt
INTO TABLE it_tvgrt
FOR ALL ENTRIES IN it_vbak
WHERE vkgrp EQ it_vbak-vkgrp
AND spras EQ sy-langu.
* fetching the text for Division :: danish 10/11/09
SELECT spart vtext
FROM tspat
INTO TABLE it_tspat
FOR ALL ENTRIES IN it_vbak
WHERE spart = it_vbak-spart AND spras = sy-langu .
* end code
SELECT kunnr name1
FROM kna1
INTO TABLE it_kna1
FOR ALL ENTRIES IN it_vbak
WHERE kunnr = it_vbak-kunnr.
SELECT vbeln knumv
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE it_vbak_cs
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vgbel.
IF it_vbak_cs[] IS NOT INITIAL.
SELECT vbeln posnr matnr
FROM vbap
INTO CORRESPONDING FIELDS OF TABLE it_vbap_cs
FOR ALL ENTRIES IN it_vbak_cs
WHERE vbeln = it_vbak_cs-vbeln.
ENDIF.
SELECT knumv kbetr kschl kposn
FROM konv
INTO CORRESPONDING FIELDS OF TABLE it_konv_cs
FOR ALL ENTRIES IN it_vbak_cs
WHERE knumv = it_vbak_cs-knumv.
it_konv_all[] = it_konv_cs[].
DELETE it_konv_cs WHERE kschl NE 'ZCOM'.
ENDIF.
IF it_bkpfi[] IS NOT INITIAL .
SORT it_bkpfi[] BY belnr gjahr.
SELECT bukrs belnr gjahr buzei prctr hkont
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bkpfi"it_bkpf " it_bkpf commented by danish - 09/06/2010
WHERE bukrs = p_plant AND belnr = it_bkpfi-belnr AND gjahr = it_bkpfi-gjahr .
ENDIF .
"Product Type
SELECT mvke~matnr mvke~vkorg mvke~vtweg mvke~mvgr1 tvm1t~bezei
FROM mvke INNER JOIN tvm1t
ON mvke~mvgr1 EQ tvm1t~mvgr1
AND tvm1t~spras EQ 'E'
INTO TABLE it_mvke FOR ALL ENTRIES IN it_ekpo
WHERE matnr EQ it_ekpo-matnr.
"Sourcing office code
SORT it_ekko[] BY knumv.
SELECT knumv kposn kbetr lifnr kschl
FROM konv
INTO CORRESPONDING FIELDS OF TABLE it_konv
FOR ALL ENTRIES IN it_ekko
WHERE knumv EQ it_ekko-knumv.
it_konv_po[] = it_konv[] .
DELETE it_konv[] WHERE kschl NE 'ZGRW'.
* SELECT vbeln posnr lcno lcval
* FROM zsdlcdtl
* INTO TABLE it_zsdlc
* FOR ALL ENTRIES IN it_vbap
* WHERE vbeln = it_vbap-vbeln
* AND posnr = it_vbap-posnr.
****** start code by danish for exchange rate on 29/06/09 ******
SELECT *
FROM tcurr
INTO TABLE it_tcurr
WHERE kurst EQ 'M'.
LOOP AT it_tcurr INTO wa_tcurr.
lv_tabix = sy-tabix.
CALL FUNCTION 'CONVERSION_EXIT_INVDT_OUTPUT'
EXPORTING
input = wa_tcurr-gdatu
IMPORTING
output = lv_gdatu. " dd/mm/yyyy
IF sy-subrc EQ 0.
CONCATENATE lv_gdatu+6(4) lv_gdatu+3(2) lv_gdatu+0(2) INTO lv_gdatu.
wa_tcurr-gdatu = lv_gdatu.
MODIFY it_tcurr FROM wa_tcurr INDEX lv_tabix TRANSPORTING gdatu.
ENDIF.
ENDLOOP.
DELETE it_tcurr WHERE gdatu GT sy-datum.
SORT it_tcurr DESCENDING BY fcurr tcurr gdatu.
****** end code by danish for exchange rate on 29/06/09 ******
*&---------------------------------------------------------------------*
*& Form MAKE_FINALTAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM make_finaltab .
********************** Inserting data into teporary table for output**************
* break hopflabap1.
SORT it_rseg BY belnr ebeln ebelp.
LOOP AT it_rseg INTO wa_rseg.
wa_mtot-belnr = wa_rseg-belnr.
wa_mtot-gjahr = wa_rseg-gjahr.
wa_mtot-ebeln = wa_rseg-ebeln.
wa_mtot-ebelp = wa_rseg-ebelp.
wa_mtot-menge = wa_rseg-menge.
wa_mtot-wrbtr = wa_rseg-wrbtr.
COLLECT wa_mtot INTO it_mtot.
ENDLOOP.
* SORT it_qvbrp BY vbeln aubel aupos.
* SORT it_vbrpd BY vbeln aubel aupos.
* SORT it_hvbrp BY vbeln aubel aupos.
SORT it_konv_inv BY knumv kposn kschl.
break hopflabap1.
* LOOP AT it_qvbrp INTO wa_qvbrp.
* LOOP AT it_vbrpd INTO wa_vbrpd.
*
* wa_qtot-vbeln = wa_vbrpd-vbeln.
* wa_qtot-aubel = wa_vbrpd-aubel.
* wa_qtot-aupos = wa_vbrpd-aupos.
* wa_qtot-fkimg = wa_vbrpd-fkim."fkimg.
* wa_qtot-netwr = wa_vbrpd-netw."netwr.
*
** CLEAR wa_hvbrp.
** READ TABLE it_hvbrp INTO wa_hvbrp WITH KEY vbeln = wa_qvbrp-vbeln
** aubel = wa_qvbrp-aubel
** aupos = wa_qvbrp-aupos BINARY SEARCH.
**
** CLEAR : wa_konv_inv .
** READ TABLE it_konv_inv INTO wa_konv_inv WITH KEY knumv = wa_hvbrp-knumv
** kposn = wa_hvbrp-posnr
** kschl = 'ZLEP' BINARY SEARCH.
** wa_qtot-kwert = wa_konv_inv-kwert.
*
* COLLECT wa_qtot INTO it_qtot.
*
* ENDLOOP.
SORT it_rseg BY ebeln ebelp.
SORT it_makt BY matnr.
SORT it_mara BY matnr.
SORT it_ekkn BY ebeln ebelp.
SORT it_vbkd BY vbeln posnr.
SORT it_vbap BY vbeln posnr.
SORT it_vbak BY vbeln.
SORT it_vbak_cs BY vbeln.
SORT it_konv_cs BY knumv kposn kschl.
SORT it_ekko BY ebeln.
SORT it_lfa1 BY lifnr.
SORT it_mtot BY belnr ebeln ebelp.
* SORT it_qtot BY vbeln aubel aupos.
SORT it_bkpf BY awkey.
SORT it_bseg BY belnr bukrs gjahr hkont.
SORT it_rsegm BY ebeln ebelp.
SORT it_ekko BY ebeln.
SORT it_zmmlc BY ebeln ebelp.
SORT it_konv BY knumv kposn.
* SORT it_zsdlc BY vbeln posnr.
SORT it_bkpfm BY awkey.
SORT it_bkpfi BY awkey.
SORT it_konv_all BY knumv kposn kschl. " Added by Ravi_12.02.2011
LOOP AT it_ekpo INTO wa_ekpo.
* vsrc = 'Y' .
*==========================================================================*
* code by danish for fetching the PO whose MIRO is not reversed:: 05/10/09 *
IF wa_ekpo-loekz IS NOT INITIAL.
CLEAR wa_rsegt.
READ TABLE it_rsegm INTO wa_rsegt WITH KEY ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
ENDIF.
*==========================================================================*
***** start code by danish on 02/07/09 ******
IF so_ebeln IS NOT INITIAL AND wa_ekpo-ebeln NOT IN so_ebeln.
CONTINUE.
ENDIF.
IF so_matnr IS NOT INITIAL AND wa_ekpo-matnr NOT IN so_matnr.
CONTINUE.
ENDIF.
* if PO is not garment PO then continue by gaurav on 27/7/2010
CLEAR wa_ekkn.
READ TABLE it_ekkn INTO wa_ekkn WITH KEY ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
* if PO is not garment PO then continue by gaurav on 27/7/2010 till here
CLEAR wa_makt.
READ TABLE it_makt INTO wa_makt WITH KEY matnr = wa_ekpo-matnr BINARY SEARCH.
wa_temp-ponum = wa_ekpo-ebeln.
wa_temp-poitm = wa_ekpo-ebelp.
wa_temp-matnr = wa_ekpo-matnr.
wa_temp-maktx = wa_makt-maktx.
wa_temp-menge_d = wa_ekpo-menge.
"for purchase order unit price.
wa_temp-netpr_p = wa_ekpo-netpr.
wa_temp-netpr_pc = wa_temp-netpr_p.
READ TABLE it_mara INTO wa_mara WITH KEY matnr = wa_ekpo-matnr BINARY SEARCH.
IF wa_mara-mtart NOT IN p_mtart. " added by danish on 09/07/09
CLEAR wa_temp.
CONTINUE.
ENDIF.
wa_temp-mtart = wa_mara-mtart.
CLEAR wa_ekkn.
READ TABLE it_ekkn INTO wa_ekkn WITH KEY ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc = 0 .
wa_temp-sonum = wa_ekkn-vbeln.
wa_temp-soitm = wa_ekkn-vbelp.
ENDIF.
CLEAR wa_vbkd.
READ TABLE it_vbkd INTO wa_vbkd WITH KEY vbeln = wa_ekkn-vbeln posnr = wa_ekkn-vbelp BINARY SEARCH.
IF sy-subrc = 0 .
wa_temp-bstkd = wa_vbkd-bstkd.
ENDIF.
CLEAR wa_vbap.
READ TABLE it_vbap INTO wa_vbap WITH KEY vbeln = wa_ekkn-vbeln posnr = wa_ekkn-vbelp BINARY SEARCH.
wa_temp-soqty = wa_vbap-kwmeng.
wa_temp-wbs = wa_vbap-wbs.
wa_temp-netpr1 = wa_vbap-netpr.
wa_temp-prctr = wa_vbap-prctr .
CLEAR wa_cepct.
READ TABLE it_cepct INTO wa_cepct WITH KEY prctr = wa_vbap-prctr.
wa_temp-ltext = wa_cepct-ltext.
CLEAR wa_vbpa.
READ TABLE it_vbpa INTO wa_vbpa WITH KEY vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr.
IF sy-subrc NE 0.
CLEAR wa_vbpa.
READ TABLE it_vbpa INTO wa_vbpa WITH KEY vbeln = wa_vbap-vbeln.
ENDIF.
"Fetching Merchant
CLEAR wa_vbpa1.
READ TABLE it_vbpa1 INTO wa_vbpa1 WITH KEY vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr.
IF sy-subrc NE 0.
CLEAR wa_vbpa1.
READ TABLE it_vbpa1 INTO wa_vbpa1 WITH KEY vbeln = wa_vbap-vbeln.
ENDIF.
CLEAR wa_merchant.
READ TABLE it_merchant INTO wa_merchant WITH KEY pernr = wa_vbpa1-pernr.
CONCATENATE wa_merchant-vorna wa_merchant-nachn INTO wa_temp-merchant SEPARATED BY space.
"Fetching sales employee
CLEAR wa_vbpa1.
READ TABLE it_vbpa2 INTO wa_vbpa2 WITH KEY vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr.
IF sy-subrc NE 0.
CLEAR wa_vbpa2.
READ TABLE it_vbpa2 INTO wa_vbpa2 WITH KEY vbeln = wa_vbap-vbeln.
ENDIF.
CLEAR wa_sales_emp.
READ TABLE it_sales_emp INTO wa_sales_emp WITH KEY pernr = wa_vbpa2-pernr.
CONCATENATE wa_sales_emp-vorna wa_sales_emp-nachn INTO wa_temp-sales_emp SEPARATED BY space.
CLEAR: wa_vbak_new,wa_vbak1.
READ TABLE it_vbak INTO wa_vbak_new WITH KEY vbeln = wa_temp-sonum.
*
CLEAR wa_vbak1.
READ TABLE it_vbak1 INTO wa_vbak1 WITH KEY vbeln = wa_vbak_new-vgbel.
CLEAR wa_vbap1.
READ TABLE it_vbap1 INTO wa_vbap1 WITH KEY vbeln = wa_vbak_new-vgbel
matnr = wa_vbap-matnr.
CALL FUNCTION 'ZFM_CALC_COSTING_MARGIN'
EXPORTING
knumv = wa_vbak1-knumv
vbeln = wa_vbak1-vbeln
posnr = wa_vbap1-posnr
IMPORTING
margin = wa_temp-margin
* MARGIN_VAL =
* VTOT = v_tot
* VVAL = v_val
* VTOTC = v_totc
* VVALC = v_valc
.
" for season
IF so_mvgr5 IS NOT INITIAL AND wa_vbap-mvgr5 NOT IN so_mvgr5.
CLEAR wa_temp.
CONTINUE.
ENDIF.
CLEAR wa_tvm5t.
READ TABLE it_tvm5t INTO wa_tvm5t WITH KEY mvgr5 = wa_vbap-mvgr5.
wa_temp-season = wa_tvm5t-bezei.
wa_temp-soqtyc = wa_temp-soqty.
CLEAR: wa_vbak ,wa_kna1.
READ TABLE it_vbak INTO wa_vbak WITH KEY vbeln = wa_ekkn-vbeln BINARY SEARCH.
IF sy-subrc = 0 .
* fetching sales group name
CLEAR wa_tvgrt.
READ TABLE it_tvgrt INTO wa_tvgrt WITH KEY vkgrp = wa_vbak-vkgrp.
wa_temp-grpnm = wa_tvgrt-grpnm.
* fetching the Division Text :: danish :: 10/11/09
wa_temp-spart = wa_vbak-spart.
CLEAR : wa_tspat .
READ TABLE it_tspat INTO wa_tspat WITH KEY spart = wa_vbak-spart .
IF sy-subrc = 0 .
wa_temp-divsn = wa_tspat-vtext .
ENDIF.
* end code
wa_temp-vkgrp = wa_vbak-vkgrp.
READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_vbak-kunnr.
wa_temp-kname1 = wa_kna1-name1.
ENDIF." code added by vishnu dt :3/6/2010.
CLEAR wa_vbak_cs.
READ TABLE it_vbak_cs INTO wa_vbak_cs WITH KEY vbeln = wa_vbak-vgbel BINARY SEARCH.
CLEAR wa_vbap_cs.
READ TABLE it_vbap_cs INTO wa_vbap_cs WITH KEY vbeln = wa_vbak_cs-vbeln matnr = wa_vbap-matnr.
CLEAR wa_konv_cs .
READ TABLE it_konv_cs INTO wa_konv_cs WITH KEY knumv = wa_vbak_cs-knumv kposn = wa_vbap_cs-posnr kschl = 'ZCOM' BINARY SEARCH.
wa_temp-kbetr = ( ( wa_konv_cs-kbetr ) / 10 ).
******************************************************************************** Start Code is added by ravi _12.02.2011
CLEAR wa_konv_all.
READ TABLE it_konv_all INTO wa_konv_all WITH KEY knumv = wa_vbak_cs-knumv kposn = wa_vbap_cs-posnr kschl = 'ZFOB' BINARY SEARCH.
wa_temp-zfob = wa_konv_all-kbetr .
CLEAR wa_konv_all.
READ TABLE it_konv_all INTO wa_konv_all WITH KEY knumv = wa_vbak_cs-knumv kposn = wa_vbap_cs-posnr kschl = 'ZDS' BINARY SEARCH.
wa_temp-zds = ( -1 * ( wa_konv_all-kbetr ) / 10 ) .
wa_temp-ntfob = ( wa_temp-zfob - ( wa_temp-zfob * ( wa_temp-zds ) / 100 ) ).
******************************************************************************* End
*=====>Start Code added By hansraj on 21.11.08
IF wa_vbak-vkgrp NOT IN s_vkgrp.
CLEAR: wa_temp,wa_ekpo.
CONTINUE.
ENDIF.
IF wa_vbak-kunnr NOT IN s_kunnr.
CLEAR: wa_temp,wa_ekpo.
CONTINUE.
ENDIF.
*<=====End Code added By hansraj on 21.11.08
CLEAR wa_ekko.
READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln = wa_ekpo-ebeln BINARY SEARCH.
IF so_ekgrp IS NOT INITIAL AND wa_ekko-ekgrp NOT IN so_ekgrp.
CLEAR wa_temp.
CONTINUE.
ENDIF.
wa_temp-waers = wa_ekko-waers.
wa_temp-ekgrp = wa_ekko-ekgrp.
wa_temp-vendcd = wa_ekko-lifnr.
****************************************************************************** Start Code is added by ravi _12.02.2011
CLEAR wa_konv_po.
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl ='J3AX' .
wa_temp-j3ax = wa_konv_po-kbetr .
CLEAR wa_konv_po.
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl = 'ZRA0'.
wa_temp-zra0 = ( -1 * ( wa_konv_po-kbetr ) / 10 ).
CLEAR wa_konv_po .
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl = 'ZCLD'.
wa_temp-zclm = ( ( wa_konv_po-kbetr ) / 10 ).
CLEAR wa_konv_po .
READ TABLE it_konv_po INTO wa_konv_po WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp kschl = 'ZPD'.
wa_temp-zpd = wa_konv_po-kbetr.
****************************************************************************** End
* fetching the Purchase grp name
CLEAR wa_t024.
READ TABLE it_t024 INTO wa_t024 WITH KEY ekgrp = wa_ekko-ekgrp.
wa_temp-eknam = wa_t024-eknam.
* end code
CLEAR wa_lfa1.
READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_ekko-lifnr BINARY SEARCH.
* code by danish :: 16/11/09
IF so_land1 IS NOT INITIAL AND wa_lfa1-land1 NOT IN so_land1 .
CLEAR wa_temp.
CONTINUE.
ENDIF.
* end code
wa_temp-lname1 = wa_lfa1-name1.
wa_temp-land1 = wa_lfa1-land1. " added by danish - 16/11/09
CLEAR wa_mvke.
READ TABLE it_mvke INTO wa_mvke WITH KEY matnr = wa_ekpo-matnr.
IF sy-subrc EQ 0.
wa_temp-bezei_pt = wa_mvke-bezei.
ENDIF.
"Source office code
CLEAR wa_konv.
READ TABLE it_konv INTO wa_konv WITH KEY knumv = wa_ekko-knumv kposn = wa_ekpo-ebelp BINARY SEARCH.
IF sy-subrc EQ 0.
wa_temp-lifnr = wa_konv-lifnr.
ENDIF.
APPEND wa_temp TO it_temp.
vmflg = 'N'.
CLEAR : vmqty.
LOOP AT it_rsegm INTO wa_rsegm WHERE ebeln = wa_ekpo-ebeln AND ebelp = wa_ekpo-ebelp.
DELETE it_rsegd WHERE ebeln = wa_ekpo-ebeln AND ebelp = wa_ekpo-ebelp. " deleting records to check for remaining miro
CLEAR wa_rbkp.
READ TABLE it_rbkp INTO wa_rbkp WITH KEY belnr = wa_rsegm-belnr stblg = ''.
IF sy-subrc EQ 0.
CLEAR wa_lfa1.
READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_rbkp-lifnr BINARY SEARCH. " added by danish - 09/06/2010
wa_temp-lname2 = wa_lfa1-name1.
* wa_temp-menge = wa_rsegm-menge.
wa_temp-belnr = wa_rbkp-belnr.
wa_temp-bldat = wa_rbkp-bldat.
wa_temp-budat = wa_rbkp-budat.
wa_temp-mwaers = wa_rbkp-waers.
wa_temp-xblnr = wa_rbkp-xblnr.
wa_temp-cpudt = wa_rbkp-cpudt. " added by danish - 06/01/09
CONCATENATE wa_rbkp-budat+0(4) '/' wa_rbkp-budat+4(2) INTO wa_temp-vmonth SEPARATED BY space. " added by danish on 01/12/09
ELSE.
* if its revesal has been made
CONTINUE.
ENDIF.
CLEAR : wa_temp-menge , wa_temp-wrbtr,wa_temp-uwrbtr.
* code by danish :: 11/11/09
* converting MIRO value to USD
*************************************************************************** Start Commet by ravi _14.02.2011
* IF wa_temp-mwaers NE 'USD'.
* CLEAR vexrt.
* LOOP AT it_tcurr INTO wa_tcurr WHERE fcurr = wa_temp-mwaers AND tcurr = 'USD'.
*
* IF wa_tcurr-gdatu GT wa_rbkp-bldat .
* CONTINUE.
* ELSEIF wa_tcurr-gdatu LE wa_rbkp-bldat.
* vexrt = wa_tcurr-ukurs. " Exchange Rate
* EXIT.
* ENDIF.
*
* ENDLOOP.
**break hopflabap1.
* IF vexrt LT 0 .
*
* vexrt = ( -1 ) * vexrt .
* wa_temp-uwrbtr = ( wa_temp-wrbtr / vexrt ).
*
* ELSEIF vexrt GT 0 .
* wa_temp-uwrbtr = ( wa_temp-wrbtr * vexrt ).
*
* ENDIF.
* ELSE.
* wa_temp-uwrbtr = wa_temp-wrbtr.
* ENDIF.
* end code :: 11/11/09
************************************************************************** end
************************************************************************* Start Code is commented by ravi _14.02.2011
CLEAR : vawkey." ,wa_mbkpf
CONCATENATE wa_rsegm-belnr wa_rsegm-gjahr INTO vawkey.
CLEAR wa_bkpf.
READ TABLE it_bkpfm INTO wa_bkpf WITH KEY awkey = vawkey.
wa_temp-belnr_m = wa_bkpf-belnr.
************************************************************************* End
*--------------------------------------------------------------------*
* code by danish - 05/06/2010
CLEAR wa_mtot.
READ TABLE it_mtot INTO wa_mtot WITH KEY belnr = wa_rsegm-belnr ebeln = wa_ekpo-ebeln ebelp = wa_ekpo-ebelp BINARY SEARCH.
wa_temp-menge = wa_mtot-menge.
IF wa_bkpf-budat IS NOT INITIAL. " if miro accounting is posted then only show the miro value
wa_temp-wrbtr = wa_mtot-wrbtr.
ENDIF.
IF wa_temp-menge IS NOT INITIAL.
wa_temp-ntbtr = wa_temp-wrbtr / wa_temp-menge .
ENDIF.
* end code by danish - 05/06/2010
*--------------------------------------------------------------------*
vmflg = 'Y'.
******************************************************************************************* add by ravi_09.03.2011
LOOP AT it_lips INTO wa_lips WHERE vgbel = wa_ekpo-ebeln AND vgpos = wa_ekpo-ebelp.
wa_temp-delnm = wa_lips-vbeln .
wa_temp-deldt = wa_lips-lfdat.
wa_temp-delqy = wa_lips-kcmeng.
CLEAR wa_vttp.
READ TABLE it_vttp INTO wa_vttp WITH KEY vbeln = wa_lips-vbeln.
wa_temp-shnum = wa_vttp-tknum .
CLEAR wa_t173t.
READ TABLE it_t173t INTO wa_t173t WITH KEY vsart = wa_lips-vsart .
wa_temp-vsart = wa_t173t-bezei.
*
* CLEAR wa_temp-mwaers .
* CLEAR wa_temp-divsn.
* CLEAR wa_temp-spart.
* CLEAR wa_temp-merchant.
* CLEAR wa_temp-sales_emp.
APPEND wa_temp TO it_temp.
ENDLOOP.
************************************************************************************** End
APPEND wa_temp TO it_temp.
CLEAR wa_temp-lfimg_s.
CLEAR wa_temp-menge_d.
CLEAR : wa_temp-soqty , wa_temp-soqtyc .
CLEAR : wa_temp-belnr,wa_temp-bldat,wa_temp-budat,wa_temp-waers,wa_temp-menge,wa_temp-wrbtr,wa_temp-belnr_m,wa_temp-lname1,wa_temp-vmonth .
CLEAR : wa_temp-menge_d,wa_temp-xblnr,wa_temp-cpudt.
CLEAR : wa_temp-soqty , wa_temp-soqtyc ,wa_temp-uwrbtr.
CLEAR : wa_temp-j3ax ,wa_temp-zra0 ,wa_temp-zclm , wa_temp-zpd , wa_temp-netpr_pc,wa_temp-zfob,wa_temp-zds,wa_temp-ntfob .
CLEAR : wa_temp-mwaers,wa_temp-lname2,wa_temp-ntbtr,wa_temp-vendcd.
CLEAR : wa_temp-lifnr. "Sourcing off
CLEAR : wa_temp-kbetr . " so offce comm %
CLEAR : wa_temp-bezei_pt. "'Product Type'
CLEAR : wa_temp-land1. " 'Country Code'
CLEAR : wa_temp-prctr. "'Profit Centre'
CLEAR : wa_temp-ltext. "'Profit Centre Text'
CLEAR : wa_temp-spart. " 'Division'
CLEAR : wa_temp-divsn . " 'Division Desc.'
CLEAR : wa_temp-sales_emp.
CLEAR : wa_temp-merchant." 'Merchant Name'
CLEAR : wa_temp-vkgrp. "'Sales Group'
CLEAR : wa_temp-grpnm. "'Sales Grp. Name'
CLEAR : wa_temp-maktx. "'Style description'
CLEAR : wa_temp-bstkd. "'Buyer Po Number'
CLEAR : wa_temp-season. " Season
ENDLOOP.
******************************************************************************************** Start Code is added by ravi _12.02.2011
" read for inbound delivery,date and qty.
LOOP AT it_lips INTO wa_lips WHERE vgbel = wa_ekpo-ebeln AND vgpos = wa_ekpo-ebelp.
wa_temp-delnm = wa_lips-vbeln .
wa_temp-deldt = wa_lips-lfdat.
wa_temp-delqy = wa_lips-kcmeng.
CLEAR wa_vttp.
READ TABLE it_vttp INTO wa_vttp WITH KEY vbeln = wa_lips-vbeln.
wa_temp-shnum = wa_vttp-tknum .
CLEAR wa_t173t.
READ TABLE it_t173t INTO wa_t173t WITH KEY vsart = wa_lips-vsart .
wa_temp-vsart = wa_t173t-bezei.
*
* CLEAR wa_temp-mwaers .
* CLEAR wa_temp-divsn.
* CLEAR wa_temp-spart.
* CLEAR wa_temp-merchant.
* CLEAR wa_temp-sales_emp.
APPEND wa_temp TO it_temp.
ENDLOOP.
" read for inbound shipment no and type .
********************************************************************************************* End
IF vmflg EQ 'Y'.
DELETE it_temp WHERE ponum = wa_ekpo-ebeln AND poitm = wa_ekpo-ebelp AND belnr = '' AND delnm = ''. .
ENDIF.
CLEAR : wa_temp-belnr,wa_temp-bldat,wa_temp-budat,wa_temp-vmonth,wa_temp-waers,wa_temp-menge,wa_temp-wrbtr,wa_temp-belnr_m,wa_temp-lname1 .
CLEAR : wa_temp-menge_d,wa_temp-xblnr,wa_temp-cpudt.
CLEAR : wa_temp-soqty , wa_temp-soqtyc,wa_temp-uwrbtr .
DELETE it_ekknd[] WHERE ebeln = wa_ekpo-ebeln AND ebelp = wa_ekpo-ebelp.
CLEAR wa_temp.
ENDLOOP.
CLEAR : wa_temp , wa_vbkd, wa_vbap, wa_ekkn, wa_makt,
wa_vbak , wa_kna1, wa_ekko.
it_final[] = it_temp[].
BREAK hopflabap1.
delete it_final[] WHERE soqty is INITIAL AND menge_d is INITIAL. " added by narendra_12.01.2012
delete ADJACENT DUPLICATES FROM it_final COMPARING ALL FIELDS. " added by narendra_13.01.2012
*****************************************************************************************
ENDFORM. " MAKE_FINALTAB
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form DISPLAY_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_report .
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_pf_status_set = 'SET_STATUS'
i_callback_top_of_page = 'TOP-OF-PAGES'
is_layout = gd_layout
is_print = gd_slis_print_alv
it_fieldcat = it_fcat[]
it_sort = it_sort[]
TABLES
t_outtab = it_final[].
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM top-of-pages.
ENDFORM. " DISPLAY_REPORT
*&---------------------------------------------------------------------*
*& Form TOP-OF-PAGES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM top-of-pages .
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c.
SELECT werks name1 " code added by prashant 25.11.2008
FROM t001w
INTO TABLE it_t001w.
READ TABLE it_t001w " code added by prashant 25.11.2008
INTO wa_t001w
WITH KEY werks = p_plant .
vplant = wa_t001w-name1. " code added by prashant 25.11.2008
"----> Title
wa_header-info = 'SOURCING REGISTER ' . "'EXPORT REGISTER FOB ' changed to 'EXPORT REGISTER' by Hansraj on 21.11.08
wa_header-typ = 'H'.
APPEND wa_header TO t_header.
CLEAR wa_header.
CONCATENATE 'FOR PLANT ' '' vplant INTO wa_header-info SEPARATED BY space. " code added by prashant 25.11.2008
wa_header-typ = 'H '.
APPEND wa_header TO t_header.
CLEAR wa_header.
IF s_date IS NOT INITIAL.
CONCATENATE ' FOR PERIOD: ' s_date-low+6(2) '/' s_date-low+4(2) '/' s_date-low+0(4) 'TO' s_date-high+6(2) '/' s_date-high+4(2) '/' s_date-high+0(4) INTO wa_header-info SEPARATED BY space.
wa_header-typ = 'H'.
APPEND wa_header TO t_header.
CLEAR wa_header.
ENDIF.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM. " TOP-OF-PAGES
Comments
Post a Comment