TYPE-POOLS: slis.
TYPES: BEGIN OF TY_CUSTOM,
WRBTR TYPE RSEG-WRBTR,
KSCHL TYPE RSEG-KSCHL,
EBELN TYPE RSEG-EBELN,
EBELP TYPE RSEG-EBELP,
END OF TY_CUSTOM.
TYPES: BEGIN OF ty_itab,
lfbnr LIKE rseg-lfbnr, " GR NO
belnr LIKE rbkp-belnr, " MIRO doc.no.
buzei LIKE rseg-buzei, " MIRO line item number
fidoc LIKE bkpf-belnr, " accounting doc.no.
matnr LIKE rseg-matnr, " Material number
maktx LIKE makt-maktx, " material description
xblnr LIKE rbkp-xblnr, " Reference Document Number
budat LIKE rbkp-budat, " Posting Date in Document
mwskz LIKE rseg-mwskz, " Tax Code
bklas LIKE rseg-bklas, " Valuation Class
menge LIKE rseg-menge, " Quantity
gjahr LIKE rseg-gjahr, " Fiscal Year
bldat LIKE rbkp-bldat, " Document Date
lifnr TYPE rbkp-lifnr, "Vendor Code
stcd1 TYPE lfa1-stcd1, "Tin number
matkl TYPE mara-matkl, "Mat Desc
name1 TYPE lfa1-name1, "Vendor Name
awkey TYPE bkpf-awkey, "Reference Key
str_suppl1 TYPE adrc-str_suppl1, "Street
post_code1 TYPE adrc-post_code1, "Pincode
city1 TYPE adrc-city1, "City
region TYPE adrc-region, "Region
adrnr TYPE lfa1-adrnr, "Address Number
dms(3) TYPE c, "DMS
werks TYPE rseg-werks, "PLANT
bukrs TYPE rseg-bukrs, "COMPANY CODE
stblg TYPE rbkp-stblg, "DOCUMENT REVERSAL INDICATOR
mtart TYPE mara-mtart, "MATERIAL TYPE
wrbtr TYPE rseg-wrbtr, "Base Amount
tax_amount TYPE konv-kwert, "Tax amount for summary
vgart TYPE rbkp-vgart, "Transaction Type
ivtyp TYPE rbkp-ivtyp, "Invoice Category
reverse(2), "Invoice Reversed
land1 TYPE lfa1-land1, "Country Key
*Fields added for customs
BED TYPE RSEG-WRBTR, "BASIC ED FOR CUSTOMS
CVD TYPE RSEG-WRBTR, "CVD FOR CUSTOMS
ECVD TYPE RSEG-WRBTR, "CESS ON VD FOR CUSTOMS
ECED TYPE RSEG-wrbtr, "CESS ON DUTIES
lfgja type rseg-lfgja, "Mat Doc Year
frbnr type mkpf-frbnr, "Bill of Lading No
waers type rbkp-waers,
txz01 TYPE ekpo-txz01, "Short Text for Material
ebeln TYPE rseg-ebeln, "Purchasing Doc
bsart type ekko-bsart, "Pur.Doc Type
batxt type t161t-batxt, "Desc for Pur Doc.Type
ebelp TYPE ekpo-ebelp, "Purchase Ord Ln Item
NCVD TYPE RSEG-WRBTR, "CESS ON VD FOR CUSTOMS
SBED TYPE RSEG-wrbtr, "CESS ON DUTIES
TEXT(30),
qtr_yr(4),
qtr_mth(10),
*Fields added for Inr Value for exchange rate
kursf type rbkp-kursf,
inrval type rseg-wrbtr,
BELNR1 TYPE RBKP-BELNR,
remarks(15),
END OF ty_itab.
TYPES: BEGIN OF ty_header,
belnr LIKE rbkp-belnr, " MIRO doc.no.
fidoc LIKE bkpf-belnr, " accounting doc.no.
xblnr LIKE rbkp-xblnr, " Reference Document Number
budat LIKE rbkp-budat, " Posting Date in Document
mwskz LIKE rseg-mwskz, " Tax Code
bklas LIKE rseg-bklas, " Valuation Class
gjahr LIKE rseg-gjahr, " Fiscal Year
bldat LIKE rbkp-bldat, " Document Date
lifnr TYPE rbkp-lifnr, "Vendor Code
stcd1 TYPE lfa1-stcd1, "Tin number
name1 TYPE lfa1-name1, "Vendor Name
awkey TYPE bkpf-awkey, "Reference Key
str_suppl1 TYPE adrc-str_suppl1, "Street
post_code1 TYPE adrc-post_code1, "Pincode
city1 TYPE adrc-city1, "City
region TYPE adrc-region, "Region
adrnr TYPE lfa1-adrnr, "Address Number
dms(3) TYPE c, "DMS
werks TYPE rseg-werks, "PLANT
bukrs TYPE rseg-bukrs, "COMPANY CODE
stblg TYPE rbkp-stblg, "DOCUMENT REVERSAL INDICATOR
mtart TYPE mara-mtart, "MATERIAL TYPE
wrbtr TYPE rseg-wrbtr, "Base Amount
tax_amount TYPE konv-kwert, "Tax amount for summary
vgart TYPE rbkp-vgart, "Transaction Type
ivtyp TYPE rbkp-ivtyp, "Invoice Category
reverse(2), "Invoice Reversed
land1 TYPE lfa1-land1, "Country Key
BED TYPE RSEG-WRBTR, "BASIC ED FOR CUSTOMS
CVD TYPE RSEG-WRBTR, "CVD FOR CUSTOMS
ECVD TYPE RSEG-WRBTR, "CESS ON VD FOR CUSTOMS
ECED TYPE RSEG-wrbtr, "CESS ON DUTIES
lfgja type rseg-lfgja, "Mat Doc Year
frbnr type mkpf-frbnr, "Bill of Lading No
waers type rbkp-waers,
txz01 TYPE ekpo-txz01, "Short Text for Material
NCVD TYPE RSEG-WRBTR, "CESS ON VD FOR CUSTOMS
SBED TYPE RSEG-wrbtr, "CESS ON DUTIES
TEXT(30),
qtr_yr(4),
qtr_mth(10),
*Fields added for Inr Value for exchange rate
kursf type rbkp-kursf,
inrval type rseg-wrbtr,
BELNR1 TYPE RBKP-BELNR,
remarks(15),
END OF ty_header.
types: begin of ty_pohistory,
xblnr type ekbe-xblnr,
bewtp type ekbe-bewtp,
belnr type ekbe-belnr,
gjahr type ekbe-gjahr,
end of ty_pohistory.
TYPES: BEGIN OF ty_temp,
fidoc TYPE bkpf-belnr, "FIDOC No
awkey TYPE bkpf-belnr, "Reference Key
gjahr TYPE bkpf-gjahr, "Fiscal Year
budat TYPE bkpf-budat, "Posting Date
belnr TYPE rbkp-belnr, "Doc No
blart TYPE bkpf-blart, "Document Type
END OF ty_temp.
*Internal Table
DATA: itab TYPE ty_itab OCCURS 0 WITH HEADER LINE.
DATA: itab_temp TYPE ty_temp OCCURS 0 WITH HEADER LINE.
DATA : IT_CUSTOM TYPE TY_CUSTOM OCCURS 0 WITH HEADER LINE.
data: it_pohistory type ty_pohistory occurs 0 with header line.
data : it_header type ty_header occurs 0 with header line.
data : it_temp14 type ty_header occurs 0 with header line.
*Data Declaration
DATA: BKTXT TYPE MKPF-BKTXT.
DATA: FRBNR TYPE MKPF-FRBNR.
data: budat type mkpf-budat.
DATA: BELNR TYPE RSEG-BELNR.
data: gjahr type rseg-gjahr.
data: date1(10).
data: date2(10).
data: title(70).
DATA : adrnr1 LIKE t001w-adrnr.
DATA: plant_name1 LIKE adrc-name1.
DATA: plant_name2 type adrc-name2.
data: plant_name(70).
DATA: comp_name1 LIKE adrc-name1.
DATA: comp_name2 type adrc-name2.
data: comp_name(70).
DATA: month(2).
* For ALV display
DATA: itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_layout TYPE slis_layout_alv,
itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA: gd_prntparams TYPE slis_print_alv.
DATA : it_data TYPE slis_t_listheader,
wa_data LIKE LINE OF it_data.
**ALV Declaration
DATA: it_alv1 LIKE TABLE OF itab WITH HEADER LINE.
DATA : i TYPE n.
DATA : col_name(10) TYPE c.
data: text(70).
*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
PARAMETERS:p_bukrs LIKE rbkp-bukrs OBLIGATORY.
SELECT-OPTIONS: s_werks FOR rseg-werks NO INTERVALS OBLIGATORY.
SELECT-OPTIONS: s_regio FOR lfa1-regio NO INTERVALS.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr NO INTERVALS.
select-options: s_bsart for ekko-bsart no intervals.
SELECT-OPTIONS:s_bldat FOR rbkp-bldat.
SELECT-OPTIONS:s_budat FOR rbkp-budat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-002.
PARAMETERS : R1 RADIOBUTTON GROUP G1.
PARAMETERS : R2 RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF BLOCK block2.
SELECT-OPTIONS: s_mwskz FOR rseg-mwskz NO-DISPLAY.
SELECT-OPTIONS: s_land1 FOR lfa1-land1 NO-DISPLAY.
START-OF-SELECTION.
PERFORM get_data.
**Filtering the Data based on the Document Type and Document Status in the Internal Table
LOOP AT itab_temp.
IF itab_temp-blart = 'RE'.
itab_temp-belnr = itab_temp-awkey+0(10).
MODIFY itab_temp.
ELSE.
DELETE itab_temp.
ENDIF.
ENDLOOP.
WRITE : s_budat-low TO date1,
s_budat-high TO date2.
CONCATENATE 'Import Purchase Register From :' date1 ' To : ' date2 INTO text.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .
SELECT belnr AS fidoc
awkey
budat
gjahr
blart
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE itab_temp
WHERE bukrs = p_bukrs
AND budat IN s_budat
AND bstat = space.
IF sy-subrc NE 0.
MESSAGE 'No Values exist for the Selection.' TYPE 'S'.
STOP.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form taxvalues
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM taxvalues .
LOOP AT itab_temp.
MOVE-CORRESPONDING itab_temp TO itab.
SELECT SINGLE
lifnr
xblnr
belnr
gjahr
stblg
bldat
vgart
ivtyp
waers
kursf
FROM rbkp INTO CORRESPONDING FIELDS OF itab
WHERE belnr = itab_temp-belnr
AND gjahr = itab_temp-gjahr.
SELECT menge
bklas
matnr
lfbnr
werks
mwskz
buzei
wrbtr
pstyp
kschl
ebeln
ebelp
lfgja
shkzg FROM rseg INTO CORRESPONDING FIELDS OF itab
WHERE belnr = itab_temp-belnr
AND gjahr = itab_temp-gjahr.
*Purchase Order Document Type.
select single bsart from ekko into corresponding fields of itab
where ebeln = itab-ebeln.
select single batxt from t161t into corresponding fields of itab
where spras = 'EN' AND
bsart = itab-bsart.
*Material Details
SELECT SINGLE matkl mtart FROM mara
INTO CORRESPONDING FIELDS OF itab
WHERE mara~matnr = itab-matnr.
SELECT SINGLE name1 adrnr land1 FROM lfa1 INTO
(itab-name1,itab-adrnr,itab-land1) WHERE lifnr = itab-lifnr.
*Short Text
SELECT SINGLE txz01 INTO itab-maktx FROM ekpo
WHERE ebeln = itab-ebeln
and ebelp = itab-ebelp.
**Vendor Address
SELECT SINGLE str_suppl1
post_code1
city1
region
FROM adrc INTO CORRESPONDING FIELDS OF itab
WHERE addrnumber = itab-adrnr.
itab-qtr_yr = itab-bldat+0(4).
month = itab-bldat+4(2).
CASE month.
WHEN '01'.
itab-qtr_mth = 'JAN'.
WHEN '02'.
itab-qtr_mth = 'FEB'.
WHEN '03'.
itab-qtr_mth = 'MAR'.
WHEN '04'.
itab-qtr_mth = 'APR'.
WHEN '05'.
itab-qtr_mth = 'MAY'.
WHEN '06'.
itab-qtr_mth = 'JUN'.
WHEN '07'.
itab-qtr_mth = 'JUL'.
WHEN '08'.
itab-qtr_mth = 'AUG'.
WHEN '09'.
itab-qtr_mth = 'SEP'.
WHEN '10'.
itab-qtr_mth = 'OCT'.
WHEN '11'.
itab-qtr_mth = 'NOV'.
WHEN '12'.
itab-qtr_mth = 'DEC'.
ENDCASE.
*INR VALUE CALCULATION
itab-inrval = itab-wrbtr * itab-kursf.MODIFY itab.
ENDLOOP.
ENDFORM. " taxvalues
*&---------------------------------------------------------------------*
*& Form build_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_layout .
CLEAR itab.
gd_layout-zebra = 'X'.
gd_layout-colwidth_optimize = 'X'.
ENDFORM. " build_layout
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_fieldcat .
IF itab[] IS INITIAL.
MESSAGE 'No Values exist for the Selection.' TYPE 'S'.
STOP.
ENDIF.
*&--------------------------------------------------------------------*
*& Form list1
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELDtext
*---------------------------------------------------------------------*
FORM list1 USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'LFBNR'.
* AND rs_selfield-fieldname = 'GJAHR'.
* Read data table, using index of row user clicked on
READ TABLE itab
* INTO wa_ekko
INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'MBN' FIELD itab-lfbnr.
SET PARAMETER ID 'GJR' FIELD itab-gjahr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-fieldname = 'FIDOC'.
* AND rs_selfield-fieldname = 'GJAHR'.
* Read data table, using index of row user clicked on
READ TABLE itab
* INTO wa_ekko
INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BLN' FIELD itab-fidoc.
SET PARAMETER ID 'BUK' FIELD p_bukrs.
SET PARAMETER ID 'GJR' FIELD itab-gjahr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-fieldname = 'BELNR'.
* AND rs_selfield-fieldname = 'GJAHR'.
* Read data table, using index of row user clicked on
READ TABLE itab
* INTO wa_ekko
INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'RBN' FIELD itab-BELNR.
SET PARAMETER ID 'GJR' FIELD itab-gjahr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-fieldname = 'BELNR1'.
* AND rs_selfield-fieldname = 'GJAHR'.
* Read data table, using index of row user clicked on
READ TABLE itab
* INTO wa_ekko
INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'RBN' FIELD itab-BELNR1.
SET PARAMETER ID 'GJR' FIELD itab-gjahr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form alv_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_display .
IF sy-batch = space.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gd_layout
i_callback_user_command = 'LIST1'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
it_fieldcat = itfieldcat[]
i_save = 'A'
is_print = gd_prntparams
it_sort = itsort[]
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSEIF sy-batch = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = itfieldcat[]
it_sort = itsort[]
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
*& Form FILTERING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM filtering .
** Material type should be of ROH or HALB or FERT
*CLEAR s_mtart.
*REFRESH s_mtart.
*
*s_mtart-sign = 'I'.
*s_mtart-option = 'EQ'.
*s_mtart-low = 'ROH'.
*APPEND s_mtart.
*s_mtart-low = 'HALB'.
*APPEND s_mtart.
*s_mtart-low = 'FERT'.
*APPEND s_mtart.
*CLEAR s_mtart.
IF itab-mwskz NOT IN s_mwskz
* AND itab-shkzg EQ 'S'
AND itab-bldat IN s_bldat
AND itab-region IN s_regio
AND itab-lifnr IN s_lifnr
AND itab-land1 IN s_land1
AND itab-werks IN s_werks
AND itab-bsart IN s_bsart.
ELSE.
DELETE itab.
CONTINUE.
ENDIF.
IF itab-vgart EQ 'RS'
AND itab-ivtyp EQ '5'
AND itab-stblg NE ' '.
itab-reverse = 'RS'.
ELSEIF itab-vgart EQ 'RD'
AND itab-ivtyp EQ ' '
AND itab-stblg NE ' '.
itab-reverse = 'RD'.
ENDIF.
MODIFY itab.
ENDLOOP.
ENDFORM. " FILTERING
*&---------------------------------------------------------------------*
*& Form CUSTOMS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form CUSTOMS .
LOOP AT ITAB.
IF ITAB-LFBNR IS NOT INITIAL.
SELECT SINGLE BKTXT
FRBNR
budat
FROM MKPF INTO (BKTXT,FRBNR,budat)
WHERE MBLNR = ITAB-LFBNR
and mjahr = itab-lfgja.
move frbnr to itab-frbnr.
perform get_custom_invoice.
else.
select xblnr
bewtp
belnr
gjahr
from ekbe into table it_pohistory
where ebeln = itab-ebeln
and ebelp = itab-ebelp.
sort it_pohistory by xblnr.
read table it_pohistory with key xblnr = itab-xblnr bewtp = 'E' binary search.
if sy-subrc = 0.
SELECT SINGLE BKTXT
FRBNR
budat
FROM MKPF INTO (BKTXT,FRBNR,budat)
WHERE MBLNR = it_pohistory-belnr
and mjahr = it_pohistory-gjahr.
move it_pohistory-belnr to itab-lfbnr.
move frbnr to itab-frbnr.
perform get_custom_invoice.
endif.
ENDIF.
MODIFY ITAB.
clear: bktxt,frbnr,budat.
ENDLOOP.
SORT itab BY lfbnr belnr. " Sorting by GR no.
endform. " CUSTOMS
*&---------------------------------------------------------------------*
*& Form get_custom_invoice
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_custom_invoice .
CALL FUNCTION 'GET_CURRENT_YEAR'
EXPORTING
BUKRS = p_bukrs
DATE = budat
IMPORTING
CURRY = gjahr
.
ITAB-BELNR1 = BELNR.
*For getting the Customs MIRO doc, it is assumed that the Fiscal Year of Customs Miro is same as Fiscal Year of Migo Posting Date
clear it_custom.
refresh it_custom.
SELECT WRBTR
KSCHL
EBELN
EBELP
FROM RSEG INTO CORRESPONDING FIELDS OF IT_CUSTOM
WHERE BELNR = BELNR
and gjahr = gjahr.
if sy-subrc = 0.
APPEND IT_CUSTOM.
endif.
ENDSELECT.
LOOP AT IT_CUSTOM.
IF IT_CUSTOM-EBELN = ITAB-EBELN AND IT_CUSTOM-EBELP = ITAB-EBELP.
CASE IT_CUSTOM-KSCHL.
WHEN 'JCDB'.
MOVE IT_CUSTOM-WRBTR TO ITAB-BED.
WHEN 'JCV1'.
MOVE IT_CUSTOM-WRBTR TO ITAB-CVD.
WHEN 'JECV'.
MOVE IT_CUSTOM-WRBTR TO ITAB-ECVD.
WHEN 'JEDB'.
MOVE IT_CUSTOM-WRBTR TO ITAB-ECED.
WHEN 'JCDS'.
MOVE IT_CUSTOM-WRBTR TO ITAB-SBED.
WHEN 'JCV2'.
MOVE IT_CUSTOM-WRBTR TO ITAB-NCVD.
ENDCASE.
ENDIF.
ENDLOOP.
endform. " get_custom_invoice
*&---------------------------------------------------------------------*
*& Form filtering2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form filtering2 .
loop at itab.
if itab-lfbnr is initial.
delete itab.
endif.
endloop.
endform. " filtering2
*Company Details
SELECT adrnr FROM t001 INTO adrnr1 WHERE bukrs = p_bukrs.
ENDSELECT.
SELECT name1 name2 FROM adrc INTO (comp_name1,comp_name2) WHERE addrnumber = adrnr1.
ENDSELECT.
concatenate comp_name1 comp_name2 into comp_name.
wa_data-typ = 'H'.
wa_data-info = comp_name.
APPEND wa_data TO it_data.
*Plant Details for Display
loop at s_werks.
SELECT single adrnr FROM t001w INTO adrnr1 WHERE werks = s_werks-low.
SELECT single name1 name2 FROM adrc INTO (plant_name1,plant_name2) WHERE addrnumber = adrnr1.
concatenate s_werks-low ' - ' plant_name1 ',' plant_name2 into plant_name.
wa_data-info = plant_name.
APPEND wa_data TO it_data.
endloop.
WRITE : s_budat-low TO date1,
s_budat-high TO date2.
if r1 = 'X'.
CONCATENATE 'Import Purchase Register From :' date1 ' To : ' date2 INTO title.
elseif r2 = 'X'.
CONCATENATE 'Imp.Pur.Reg- Inv.Header From :' date1 ' To : ' date2 INTO title.
endif.
wa_data-info = title.
APPEND wa_data TO it_data.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_data
* I_LOGO =
* I_END_OF_LIST_GRID =
.
CLEAR WA_DATA.
CLEAR IT_DATA.
ENDFORM. "top_of_page
*&---------------------------------------------------------------------*
*& Form importheader
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form importheader .
LOOP AT itab.
MOVE-CORRESPONDING itab TO it_header.
APPEND it_header.
ENDLOOP.
SORT it_header BY belnr.
LOOP AT it_header.
AT END OF belnr.
READ TABLE it_header INDEX sy-tabix.
SUM. " Summing the Amount for each Vendor Invoice No.
MOVE-CORRESPONDING it_header TO it_temp14.
APPEND it_temp14.
CLEAR it_temp14.
ENDAT.
ENDLOOP.
SORT it_temp14 BY belnr ASCENDING. " SORTING BY MIRO NUMBER
endform. " importheader
*&---------------------------------------------------------------------*
*& Form build_fieldcat1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_fieldcat1 .
IF itab[] IS INITIAL.
MESSAGE 'No Values exist for the Selection.' TYPE 'S'.
STOP.
ENDIF.
*&---------------------------------------------------------------------*
*& Form alv_display_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form alv_display_header .
IF sy-batch = space.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gd_layout
i_callback_user_command = 'LIST2'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
it_fieldcat = itfieldcat[]
i_save = 'A'
is_print = gd_prntparams
it_sort = itsort[]
TABLES
t_outtab = it_temp14
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.
ELSEIF sy-batch = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = itfieldcat[]
it_sort = itsort[]
TABLES
t_outtab = it_temp14
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.
ENDIF.
endform. " alv_display_header
*&--------------------------------------------------------------------*
*& Form list1
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELDtext
*---------------------------------------------------------------------*
FORM list2 USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'FIDOC'.
* AND rs_selfield-fieldname = 'GJAHR'.
* Read data table, using index of row user clicked on
READ TABLE it_temp14
* INTO wa_ekko
INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BLN' FIELD it_temp14-fidoc.
SET PARAMETER ID 'BUK' FIELD p_bukrs.
SET PARAMETER ID 'GJR' FIELD it_temp14-gjahr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-fieldname = 'BELNR'.
* AND rs_selfield-fieldname = 'GJAHR'.
* Read data table, using index of row user clicked on
READ TABLE it_temp14
* INTO wa_ekko
INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'RBN' FIELD it_temp14-BELNR.
SET PARAMETER ID 'GJR' FIELD it_temp14-gjahr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-fieldname = 'BELNR1'.
* AND rs_selfield-fieldname = 'GJAHR'.
* Read data table, using index of row user clicked on
READ TABLE it_temp14
* INTO wa_ekko
INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'RBN' FIELD it_temp14-BELNR1.
SET PARAMETER ID 'GJR' FIELD it_temp14-gjahr.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.